diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java index ee2c84aa360c92075ed2a6e38d971dc7297e2925..bacf3f3ae250f0104e7177931c87f6d0dd73953a 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/AntisenseRnaXmlParser.java @@ -125,8 +125,8 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<CellDesigner if (!region.getName().equals("")) { attributes += " name=\"" + escapeXml(region.getName()) + "\""; } - if (region.getSize() != 0) { - attributes += " size=\"" + region.getSize() + "\""; + if (region.getWidth() != 0) { + attributes += " size=\"" + region.getWidth() / region.getSpecies().getWidth() + "\""; } if (region.getPosition() != null) { double pos = (region.getPosition().getX() - region.getSpecies().getWidth()) diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java index ec607f2dfe74a03e05ba368aca803372a4b84339..09c29bb9546474451a2b8953280e24af00468a99 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerAntisenseRnaRegion.java @@ -329,7 +329,7 @@ public class CellDesignerAntisenseRnaRegion implements Serializable { AntisenseRnaRegion result = new AntisenseRnaRegion(); result.setIdAntisenseRnaRegion(idAntisenseRnaRegion); result.setName(name); - result.setSize(size); + result.setWidth(element.getWidth()*size); result.setPosition(new Point2D.Double(element.getX() + element.getWidth() * 3.0 / 4.0 * pos, element.getY())); result.setType(type); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java index 2691644b16bae71ee8d8199806aba72658d4c4eb..c75979518d4f214af23bd09c105eeb6247d0f77c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegion.java @@ -44,7 +44,7 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { /** * Default size of the object (in graphical representation). */ - private static final double DEFAULT_SIZE = 0.1; + private static final double DEFAULT_SIZE = 10; /** * Default class logger. @@ -85,10 +85,10 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { private AntisenseRnaRegionType type; /** - * Size of the region in the graphic representation. + * Width of the region in the graphic representation. */ - @Column(name = "size") - private double size = DEFAULT_SIZE; + @Column(name = "width") + private double width = DEFAULT_SIZE; /** * Position on the species in graphic representation. @@ -121,9 +121,11 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { public AntisenseRnaRegion(AntisenseRnaRegion original) { this.idAntisenseRnaRegion = original.idAntisenseRnaRegion; this.name = original.name; - this.size = original.size; this.type = original.type; - this.setPosition(original.getPosition()); + Point2D position = new Point2D.Double(); + position.setLocation(original.getPosition()); + this.setPosition(position); + this.setWidth(original.getWidth()); } /** @@ -140,21 +142,6 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { } - /** - * Sets size from the string. - * - * @param text - * size to parse and set - * @see #size - */ - public void setSize(String text) { - try { - size = Double.parseDouble(text); - } catch (NumberFormatException e) { - throw new InvalidArgumentException("Invalid angle: " + text, e); - } - } - /** * Update data in this object from parameter (only if values in parameter object * are valid). @@ -167,7 +154,7 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { && !this.idAntisenseRnaRegion.equals(mr.getIdAntisenseRnaRegion())) { throw new InvalidArgumentException("Cannot update from mr with different id"); } - this.size = mr.getSize(); + this.setWidth(mr.getWidth()); if (mr.getName() != null) { this.name = mr.getName(); } @@ -180,7 +167,7 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { @Override public String toString() { String result = getIdAntisenseRnaRegion() + "," + getName() + "," + getType() + "," + getPosition() + "," - + getSize() + ","; + + getWidth() + ","; return result; } @@ -243,23 +230,6 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { this.type = type; } - /** - * @return the size - * @see #size - */ - public double getSize() { - return size; - } - - /** - * @param size - * the size to set - * @see #size - */ - public void setSize(double size) { - this.size = size; - } - /** * @return the species * @see #species @@ -301,4 +271,12 @@ public class AntisenseRnaRegion implements Serializable, ElementModification { public void setPosition(Point2D position) { this.position = position; } + + public double getWidth() { + return width; + } + + public void setWidth(double width) { + this.width = width; + } } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java index 3f8a0ab1488b511949afc0cc9b7cddc8212d8fd9..8ee9493bb1cfbe9b4136f873561ba9d2ed1cef7c 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java @@ -84,7 +84,7 @@ public class AntisenseRnaComparatorTest { region1.setIdAntisenseRnaRegion("a"); region1.setName("name"); region1.setPosition(new Point2D.Double(0, 1)); - region1.setSize("2"); + region1.setWidth(2); region1.setType(AntisenseRnaRegionType.CODING_REGION); return result; } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java index cb1e7efa20ea920c5f98ce014918d331a412f294..7bc36464908e7eff9a90943d8a0de4c399a4a724 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/field/AntisenseRnaRegionTest.java @@ -89,7 +89,7 @@ public class AntisenseRnaRegionTest { int id = 91; AntisenseRna species = new AntisenseRna("id"); Point2D position = new Point2D.Double(10, 20); - double size = 5.3; + double width = 5.3; AntisenseRnaRegionType type = AntisenseRnaRegionType.CODING_REGION; String name = "nam"; String idAntisenseRnaRegion = "iddd"; @@ -97,7 +97,7 @@ public class AntisenseRnaRegionTest { region.setId(id); region.setSpecies(species); region.setPosition(position); - region.setSize(size); + region.setWidth(width); region.setType(type); region.setName(name); region.setIdAntisenseRnaRegion(idAntisenseRnaRegion); @@ -105,19 +105,11 @@ public class AntisenseRnaRegionTest { assertEquals(id, region.getId()); assertEquals(species, region.getSpecies()); assertEquals(position.distance(region.getPosition()), 0, Configuration.EPSILON); - assertEquals(size, region.getSize(), Configuration.EPSILON); + assertEquals(width, region.getWidth(), Configuration.EPSILON); assertEquals(type, region.getType()); assertEquals(name, region.getName()); assertEquals(idAntisenseRnaRegion, region.getIdAntisenseRnaRegion()); - try { - region.setSize("text"); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - } - - region.setSize("1.0"); - assertEquals(1.0, region.getSize(), Configuration.EPSILON); } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/persist/src/db/12.1.0~alpha.0/fix_db_20180709.sql b/persist/src/db/12.1.0~alpha.0/fix_db_20180709.sql index ec463fbdab69b92f4604456ac985f50c9320e1ec..5c5283269f4da32d6b166facf5bb348e7af38f59 100644 --- a/persist/src/db/12.1.0~alpha.0/fix_db_20180709.sql +++ b/persist/src/db/12.1.0~alpha.0/fix_db_20180709.sql @@ -6,3 +6,11 @@ update antisense_rna_region_table set type_string ='CODING_REGION' where type =1 update antisense_rna_region_table set type_string ='PROTEIN_BINDING_DOMAIN' where type =2; alter table antisense_rna_region_table drop column type; alter table antisense_rna_region_table rename COLUMN type_string to type; + +-- antisense region doesn't have state +alter table antisense_rna_region_table drop column state; + +--size is changed to width for antisense rna region +alter table antisense_rna_region_table add column width numeric(6,2); +update antisense_rna_region_table set width=element_table.width*antisense_rna_region_table.size from element_table where element_table.iddb = antisense_rna_region_table.idspeciesdb and not size is null; +alter table antisense_rna_region_table drop column size; diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java index c1831f210e8a19549393d4e8dd6a6d9fc35d16e4..58d106086b1307919bccc4fab4a604c69a1257ec 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest2.java @@ -181,7 +181,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { AntisenseRna sp = new AntisenseRna(testIdAlias); AntisenseRnaRegion mr = new AntisenseRnaRegion(); mr.setName("name"); - mr.setSize(3.0); + mr.setWidth(3.0); mr.setType(AntisenseRnaRegionType.MODIFICATION_SITE); sp.addRegion(mr); @@ -197,7 +197,7 @@ public class AliasDaoTest2 extends PersistTestFunctions { assertEquals(sp2.getRegions().get(0).getIdAntisenseRnaRegion(), mr.getIdAntisenseRnaRegion()); assertEquals(sp2.getRegions().get(0).getName(), mr.getName()); - assertEquals(sp2.getRegions().get(0).getSize(), mr.getSize(), EPSILON); + assertEquals(sp2.getRegions().get(0).getWidth(), mr.getWidth(), EPSILON); assertEquals(sp2.getRegions().get(0).getType(), mr.getType()); aliasDao.delete(sp2);