Commit ee9b37d7 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

antisense rna region has width with absolute values instead of CellDesigner relative values

parent f96f720b
......@@ -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())
......
......@@ -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);
......
......@@ -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;
}
}
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment