diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java index f558c3d7f1ead56135c366f2a461978a2fa981ae..f94f91807ddf8c5db8f002e394d9182c32079fa3 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java @@ -19,97 +19,104 @@ import lcsb.mapviewer.model.map.species.Species; */ public class AntisenseRnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { - /** - * Default constructor. - * - * @param sbgn - * Should the converter use sbgn standard - */ - protected AntisenseRnaCellDesignerAliasConverter(boolean sbgn) { - super(sbgn); - } + /** + * Default constructor. + * + * @param sbgn + * Should the converter use sbgn standard + */ + protected AntisenseRnaCellDesignerAliasConverter(boolean sbgn) { + super(sbgn); + } - /** - * How big should be the arc in rectangle for nucleic acid feature - * representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 5; + /** + * How big should be the arc in rectangle for nucleic acid feature + * representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 5; - @Override - public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - if (isSbgn()) { - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor); - } - ArrayList<Point2D> points = getPoints(alias); - return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); - } + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + if (isSbgn()) { + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), + alias.getHeight(), anchor); + } + ArrayList<Point2D> points = getPoints(alias); + return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); + } - @Override - protected PathIterator getBoundPathIterator(Species alias) { - return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform()); - } + @Override + protected PathIterator getBoundPathIterator(Species alias) { + return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform()); + } - /** - * Returns shape of the AntisenseRna as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - private ArrayList<Point2D> getPoints(Element alias) { - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - ArrayList<Point2D> points = new ArrayList<Point2D>(); + /** + * Returns shape of the AntisenseRna as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + private ArrayList<Point2D> getPoints(Element alias) { + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + ArrayList<Point2D> points = new ArrayList<Point2D>(); - // CHECKSTYLE:OFF - points.add(new Point2D.Double(x + width / 8, y + height / 2)); - points.add(new Point2D.Double(x, y)); - points.add(new Point2D.Double(x + width * 3 / 8, y)); - points.add(new Point2D.Double(x + width * 3 / 4, y)); - points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); - points.add(new Point2D.Double(x + width, y + height)); - points.add(new Point2D.Double(x + width * 5 / 8, y + height)); - points.add(new Point2D.Double(x + width / 4, y + height)); - // CHECKSTYLE:ON - return points; - } + // CHECKSTYLE:OFF + points.add(new Point2D.Double(x + width / 8, y + height / 2)); + points.add(new Point2D.Double(x, y)); + points.add(new Point2D.Double(x + width * 3 / 8, y)); + points.add(new Point2D.Double(x + width * 3 / 4, y)); + points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); + points.add(new Point2D.Double(x + width, y + height)); + points.add(new Point2D.Double(x + width * 5 / 8, y + height)); + points.add(new Point2D.Double(x + width / 4, y + height)); + // CHECKSTYLE:ON + return points; + } - /** - * Returns shape of the AntisenseRna as a GeneralPath object. - * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias - */ - private GeneralPath getAntisebseRnaPath(Element alias) { - // CHECKSTYLE:OFF - GeneralPath path; - if (!isSbgn()) { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); - path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight()); - path.closePath(); - } else { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + /** + * Returns shape of the AntisenseRna as a GeneralPath object. + * + * @param alias + * alias for which we are looking for a border + * @return GeneralPath object defining border of the given alias + */ + private GeneralPath getAntisebseRnaPath(Element alias) { + // CHECKSTYLE:OFF + GeneralPath path; + if (!isSbgn()) { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); + path.moveTo(alias.getX(), alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight()); + path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight()); + path.closePath(); + } else { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); + double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); - path.moveTo(x, y); - path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height); - path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); - path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.lineTo(x + width, y); - path.closePath(); - } - // CHECKSTYLE:ON - return path; - } + path.moveTo(x, y); + path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height); + path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); + path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width, + y + height - RECTANGLE_CORNER_ARC_SIZE); + path.lineTo(x + width, y); + path.closePath(); + } + // CHECKSTYLE:ON + return path; + } + + @Override + public Point2D getResidueCoordinates(Species element, double angle) { + return new Point2D.Double(element.getX() + element.getWidth() * 3.0 / 4.0 * angle, element.getY()); + } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java index 0cee48a0e63f19509fc0dc46c7ea5b004cea319d..7116bb1f8a3b17aadf41e8d1b13cdcd39a2b1b90 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java @@ -1,118 +1,122 @@ -package lcsb.mapviewer.converter.model.celldesigner.geometry; - -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; -import java.util.ArrayList; - -import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; -import lcsb.mapviewer.model.map.species.Element; -import lcsb.mapviewer.model.map.species.Species; - -/** - * Class that provides CellDesigner specific graphical information for Rna. - * It's used for conversion from xml to normal x,y coordinates. - * - * @author Piotr Gawron - * - */ -public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { - - /** - * Default constructor. - * - * @param sbgn - * Should the converter use sbgn standard - */ - protected RnaCellDesignerAliasConverter(boolean sbgn) { - super(sbgn); - } - - /** - * How big should be the arc in rectangle for nucleic acid feature representation. - */ - private static final int RECTANGLE_CORNER_ARC_SIZE = 5; - - @Override - public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { - if (invalidAnchorPosition(alias, anchor)) { - return alias.getCenter(); - } - if (isSbgn()) { - return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), - alias.getWidth(), alias.getHeight(), anchor); - } - ArrayList<Point2D> points = getPoints(alias); - return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); - } - - @Override - public PathIterator getBoundPathIterator(Species alias) { - return getRnaPath(alias).getPathIterator(new AffineTransform()); - } - - /** - * Returns shape of the Rna as a list of points. - * - * @param alias - * alias for which we are looking for a border - * @return list of points defining border of the given alias - */ - private ArrayList<Point2D> getPoints(Element alias) { - double x = alias.getX(); - double y = alias.getY(); - double width = alias.getWidth(); - double height = alias.getHeight(); - ArrayList<Point2D> points = new ArrayList<Point2D>(); - // CHECKSTYLE:OFF - points.add(new Point2D.Double(x + width / 8, y + height / 2)); - points.add(new Point2D.Double(x + width / 4, y)); - points.add(new Point2D.Double(x + width * 5 / 8, y)); - points.add(new Point2D.Double(x + width, y)); - points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); - points.add(new Point2D.Double(x + width * 3 / 4, y + height)); - points.add(new Point2D.Double(x + width * 3 / 8, y + height)); - // CHECKSTYLE:ON - points.add(new Point2D.Double(x, y + height)); - return points; - } - - /** - * Returns shape of the Rna as a GeneralPath object. - * - * @param alias - * alias for which we are looking for a border - * @return GeneralPath object defining border of the given alias - */ - private GeneralPath getRnaPath(Element alias) { - // CHECKSTYLE:OFF - GeneralPath path; - if (!isSbgn()) { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); - path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); - path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); - path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight()); - path.lineTo(alias.getX(), alias.getY() + alias.getHeight()); - path.closePath(); - } else { - path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); - double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); - - path.moveTo(x, y); - path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.curveTo(x, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height, - x + RECTANGLE_CORNER_ARC_SIZE, y + height); - path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); - path.curveTo(x + width, y + height, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, - x + width, y + height - RECTANGLE_CORNER_ARC_SIZE); - path.lineTo(x + width, y); - path.closePath(); - } - // CHECKSTYLE:ON - return path; - } - -} +package lcsb.mapviewer.converter.model.celldesigner.geometry; + +import java.awt.geom.AffineTransform; +import java.awt.geom.GeneralPath; +import java.awt.geom.PathIterator; +import java.awt.geom.Point2D; +import java.util.ArrayList; + +import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor; +import lcsb.mapviewer.model.map.species.Element; +import lcsb.mapviewer.model.map.species.Species; + +/** + * Class that provides CellDesigner specific graphical information for Rna. It's + * used for conversion from xml to normal x,y coordinates. + * + * @author Piotr Gawron + * + */ +public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> { + + /** + * Default constructor. + * + * @param sbgn + * Should the converter use sbgn standard + */ + protected RnaCellDesignerAliasConverter(boolean sbgn) { + super(sbgn); + } + + /** + * How big should be the arc in rectangle for nucleic acid feature + * representation. + */ + private static final int RECTANGLE_CORNER_ARC_SIZE = 5; + + @Override + public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) { + if (invalidAnchorPosition(alias, anchor)) { + return alias.getCenter(); + } + if (isSbgn()) { + return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), + alias.getHeight(), anchor); + } + ArrayList<Point2D> points = getPoints(alias); + return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor); + } + + @Override + public PathIterator getBoundPathIterator(Species alias) { + return getRnaPath(alias).getPathIterator(new AffineTransform()); + } + + /** + * Returns shape of the Rna as a list of points. + * + * @param alias + * alias for which we are looking for a border + * @return list of points defining border of the given alias + */ + private ArrayList<Point2D> getPoints(Element alias) { + double x = alias.getX(); + double y = alias.getY(); + double width = alias.getWidth(); + double height = alias.getHeight(); + ArrayList<Point2D> points = new ArrayList<Point2D>(); + // CHECKSTYLE:OFF + points.add(new Point2D.Double(x + width / 8, y + height / 2)); + points.add(new Point2D.Double(x + width / 4, y)); + points.add(new Point2D.Double(x + width * 5 / 8, y)); + points.add(new Point2D.Double(x + width, y)); + points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2)); + points.add(new Point2D.Double(x + width * 3 / 4, y + height)); + points.add(new Point2D.Double(x + width * 3 / 8, y + height)); + // CHECKSTYLE:ON + points.add(new Point2D.Double(x, y + height)); + return points; + } + + /** + * Returns shape of the Rna as a GeneralPath object. + * + * @param alias + * alias for which we are looking for a border + * @return GeneralPath object defining border of the given alias + */ + private GeneralPath getRnaPath(Element alias) { + // CHECKSTYLE:OFF + GeneralPath path; + if (!isSbgn()) { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4); + path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY()); + path.lineTo(alias.getX() + alias.getWidth(), alias.getY()); + path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight()); + path.lineTo(alias.getX(), alias.getY() + alias.getHeight()); + path.closePath(); + } else { + path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6); + double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight(); + + path.moveTo(x, y); + path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE); + path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height); + path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height); + path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width, + y + height - RECTANGLE_CORNER_ARC_SIZE); + path.lineTo(x + width, y); + path.closePath(); + } + // CHECKSTYLE:ON + return path; + } + + @Override + public Point2D getResidueCoordinates(Species element, double angle) { + return new Point2D.Double(element.getX() + element.getWidth() / 4.0 + element.getWidth() * 3.0 / 4.0 * angle, + element.getY()); + } + +} diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java index be71b282d64dee36a9dde2b5bbb91832cd130e9f..dd6373dc2985071908e814fc55a3e17d50581a51 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java @@ -146,7 +146,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna> @Override public void updateModelElementAfterLayoutAdded(Species element) { for (CellDesignerModificationResidue region : regions) { - ((AntisenseRna) element).addRegion(region.createAntisenseRegionAlias(element)); + ((AntisenseRna) element).addRegion(region.createModificationResidue(element)); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java index db286beee208268c42f18a0d3dba3c6130b81b5a..7e485de81648c9a341e7c26f21983230751d4d40 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java @@ -115,7 +115,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> { @Override public void updateModelElementAfterLayoutAdded(Species element) { for (CellDesignerModificationResidue region : modificationResidues) { - ((Gene) element).addModificationResidue(region.createGeneModification(element)); + ((Gene) element).addModificationResidue(region.createModificationResidue(element)); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java index 12892adc56594de9cd3c6082b03480833004090c..9fa15ca0dff3c18c82d4db90de02094f23bda405 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java @@ -152,7 +152,7 @@ public class CellDesignerProtein<T extends Protein> extends CellDesignerSpecies< @Override public void updateModelElementAfterLayoutAdded(Species element) { for (CellDesignerModificationResidue mr : modificationResidues) { - ((Protein) element).addModificationResidue(mr.createProteinModification(element)); + ((Protein) element).addModificationResidue(mr.createModificationResidue(element)); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java index 2c0bc90eea43b79ea1f4b477b870d75f2a354f39..745cc58d1b03b876e25bfafafdaa57c364a66248 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java @@ -145,7 +145,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> { public void updateModelElementAfterLayoutAdded(Species element) { for (CellDesignerModificationResidue region : regions) { Rna rna = (Rna) element; - rna.addRegion(region.createRnaRegionAlias(rna)); + rna.addRegion(region.createModificationResidue(rna)); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java index 20eeb4f4276348a6596c1476dbdd805c84c0a12f..49a4e24703a9d937a74ff7abf251da2d5f5e6d68 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java @@ -1,6 +1,5 @@ package lcsb.mapviewer.converter.model.celldesigner.structure.fields; -import java.awt.geom.Point2D; import java.io.Serializable; import org.apache.log4j.Logger; @@ -348,19 +347,46 @@ public class CellDesignerModificationResidue implements Serializable { * * @return {@link ModificationResidue} representing this object in a model */ - public ModificationResidue createProteinModification(Element element) { + public ModificationResidue createModificationResidue(Element element) { CellDesignerAliasConverter converter = new CellDesignerAliasConverter(element, false); - ModificationResidue result = null; if (modificationType == null) { throw new InvalidArgumentException("No type information for modification: " + idModificationResidue); } else if (modificationType.equals("RESIDUE")) { - result = new Residue(); - ((Residue) result).setState(this.getState()); + return createResidue(element, converter); + } else if (modificationType.equals("MODIFICATION_SITE")) { + return createModificationSite(element, converter); + } else if (modificationType.equals("CODING_REGION")) { + return createCodingRegion(element, converter); + } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) { + return createProteinBindingDomain(element, converter); } else { - throw new InvalidArgumentException("Unknown protein modification type: " + modificationType); + throw new InvalidArgumentException("Unknown modification type: " + modificationType); } + } + + private ProteinBindingDomain createProteinBindingDomain(Element element, CellDesignerAliasConverter converter) { + ProteinBindingDomain result = new ProteinBindingDomain(); + result.setWidth(element.getWidth() * size); + result.setIdModificationResidue(idModificationResidue); + result.setName(name); + result.setPosition(converter.getResidueCoordinates(element, angle)); + return result; + } + + private CodingRegion createCodingRegion(Element element, CellDesignerAliasConverter converter) { + CodingRegion result = new CodingRegion(); + result.setWidth(element.getWidth() * size); + result.setIdModificationResidue(idModificationResidue); + result.setName(name); + result.setPosition(converter.getResidueCoordinates(element, angle)); + return result; + } + + private ModificationSite createModificationSite(Element element, CellDesignerAliasConverter converter) { + ModificationSite result = new ModificationSite(); + result.setState(this.getState()); result.setIdModificationResidue(this.getIdModificationResidue()); result.setName(this.getName()); if (angle == null) { @@ -371,26 +397,9 @@ public class CellDesignerModificationResidue implements Serializable { return result; } - /** - * Creates model representation of {@link ModificationResidue}. - * - * @return {@link ModificationResidue} representing this object in a model - */ - public ModificationResidue createGeneModification(Element element) { - CellDesignerAliasConverter converter = new CellDesignerAliasConverter(element, false); - ModificationResidue result; - - if (modificationType == null) { - logger.debug(this); - throw new InvalidArgumentException("Unknown gene modification type"); - } else if (modificationType.equals("MODIFICATION_SITE")) { - result = new ModificationSite(); - ((ModificationSite) result).setState(this.getState()); - } else { - logger.debug(this); - throw new InvalidArgumentException("Unknown gene modification type: " + modificationType); - } - + private Residue createResidue(Element element, CellDesignerAliasConverter converter) { + Residue result = new Residue(); + result.setState(this.getState()); result.setIdModificationResidue(this.getIdModificationResidue()); result.setName(this.getName()); if (angle == null) { @@ -401,61 +410,6 @@ public class CellDesignerModificationResidue implements Serializable { return result; } - /** - * Creates model representation of {@link AntisenseRnaRegion}. - * - * @return {@link AntisenseRnaRegion} representing this object in a model - */ - public ModificationResidue createAntisenseRegionAlias(Element element) { - ModificationResidue result; - if (modificationType.equals("MODIFICATION_SITE")) { - result = new ModificationSite(); - } else if (modificationType.equals("CODING_REGION")) { - result = new CodingRegion(); - ((CodingRegion) result).setWidth(element.getWidth() * size); - } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) { - result = new ProteinBindingDomain(); - ((ProteinBindingDomain) result).setWidth(element.getWidth() * size); - } else { - throw new InvalidArgumentException("Unknown antisense rna modification type: " + modificationType); - - } - result.setIdModificationResidue(idModificationResidue); - result.setName(name); - - result.setPosition(new Point2D.Double(element.getX() + element.getWidth() * 3.0 / 4.0 * pos, element.getY())); - return result; - } - - /** - * Creates model representation of {@link RnaRegion}. - * - * @return {@link RnaRegion} representing this object in a model - */ - public ModificationResidue createRnaRegionAlias(Element element) { - ModificationResidue result; - if (modificationType == null) { - throw new InvalidArgumentException("No type information for modification: " + idModificationResidue); - } else if (modificationType.equals("MODIFICATION_SITE")) { - result = new ModificationSite(); - ((ModificationSite) result).setState(this.state); - } else if (modificationType.equals("CODING_REGION")) { - result = new CodingRegion(); - ((CodingRegion) result).setWidth(element.getWidth() * size); - } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) { - result = new ProteinBindingDomain(); - ((ProteinBindingDomain) result).setWidth(element.getWidth() * size); - } else { - throw new InvalidArgumentException("Unknown antisense rna modification type: " + modificationType); - - } - result.setIdModificationResidue(this.idModificationResidue); - result.setPosition(new Point2D.Double( - element.getX() + element.getWidth() / 4.0 + element.getWidth() * 3.0 / 4.0 * pos, element.getY())); - result.setName(this.name); - return result; - } - public String getModificationType() { return modificationType; }