From b833152e3c62f25508eea85ce9ab28c0eabffc69 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 13 Jul 2018 10:45:07 +0200
Subject: [PATCH] processing modification site for rna/antisense rna uses
 proper modification type

---
 .../alias/SpeciesAliasXmlParser.java          | 508 +++++++++---------
 .../structure/CellDesignerAntisenseRna.java   |   4 -
 .../structure/CellDesignerRna.java            |   3 -
 .../CellDesignerModificationResidue.java      |   1 -
 .../structure/fields/SpeciesState.java        |   7 +
 .../model/celldesigner/ModificationTest.java  |   8 +
 .../antisense_rna_with_region.xml             |  43 +-
 7 files changed, 309 insertions(+), 265 deletions(-)

diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java
index a194db9c50..30ab817536 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java
@@ -1,253 +1,255 @@
-package lcsb.mapviewer.converter.model.celldesigner.alias;
-
-import org.apache.log4j.Logger;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
-import lcsb.mapviewer.common.exception.NotImplementedException;
-import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
-import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies;
-import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
-import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies;
-import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View;
-import lcsb.mapviewer.model.map.compartment.Compartment;
-import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
-import lcsb.mapviewer.model.map.model.Model;
-import lcsb.mapviewer.model.map.model.ModelData;
-import lcsb.mapviewer.model.map.species.Complex;
-import lcsb.mapviewer.model.map.species.Species;
-
-/**
- * Parser of CellDesigner xml used for parsing SpeciesAlias.
- * 
- * @author Piotr Gawron
- * 
- * @see Complex
- */
-public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
-  /**
-   * Default class logger.
-   */
-  private Logger logger = Logger.getLogger(SpeciesAliasXmlParser.class.getName());
-
-  /**
-   * Collection of {@link CellDesignerElement cell designer elements} parsed from
-   * xml.
-   */
-  private CellDesignerElementCollection elements;
-
-  /**
-   * Model for which we parse elements.
-   */
-  private Model model;
-
-  /**
-   * Default constructor with model object for which we parse data.
-   * 
-   * @param model
-   *          model for which we parse elements
-   * @param elements
-   *          collection of {@link CellDesignerElement cell designer elements}
-   *          parsed from xml
-   */
-  public SpeciesAliasXmlParser(CellDesignerElementCollection elements, Model model) {
-    this.elements = elements;
-    this.model = model;
-  }
-
-  @Override
-  Species parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException {
-
-    String speciesId = getNodeAttr("species", aliasNode);
-    String aliasId = getNodeAttr("id", aliasNode);
-    CellDesignerSpecies<?> species = elements.getElementByElementId(speciesId);
-    if (species == null) {
-      throw new InvalidXmlSchemaException("Unknown species for alias (speciesId: " + speciesId + ")");
-    }
-    if (species instanceof CellDesignerComplexSpecies) {
-      logger.warn("[" + speciesId + "," + aliasId
-          + "]\tSpecies is defined as a complex, but alias is not a complex. Changing alias to complex.");
-    }
-
-    elements.addElement(species, aliasId);
-    Species result = species.createModelElement(aliasId);
-
-    String state = "usual";
-    NodeList nodes = aliasNode.getChildNodes();
-    View usualView = null;
-    View briefView = null;
-    for (int x = 0; x < nodes.getLength(); x++) {
-      Node node = nodes.item(x);
-      if (node.getNodeType() == Node.ELEMENT_NODE) {
-        if (node.getNodeName().equalsIgnoreCase("celldesigner:activity")) {
-          result.setActivity(getNodeValue(node).equalsIgnoreCase("active"));
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:bounds")) {
-          result.setX(getNodeAttr("X", node));
-          result.setY(getNodeAttr("Y", node));
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:font")) {
-          result.setFontSize(getNodeAttr("size", node));
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:view")) {
-          state = getNodeAttr("state", node);
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:usualView")) {
-          usualView = getCommonParser().getView(node);
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:briefView")) {
-          briefView = getCommonParser().getView(node);
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:info")) {
-          processAliasState(node, result);
-        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:structuralState")) {
-          // not handled
-          continue;
-        } else {
-          throw new InvalidXmlSchemaException("Unknown element of celldesigner:speciesAlias: " + node.getNodeName());
-        }
-      }
-    }
-
-    View view = null;
-    if (state.equalsIgnoreCase("usual")) {
-      view = usualView;
-    } else if (state.equalsIgnoreCase("brief")) {
-      view = briefView;
-    }
-
-    if (view != null) {
-      // inner position defines the position in compartment
-      // result.moveBy(view.innerPosition);
-      result.setWidth(view.getBoxSize().width);
-      result.setHeight(view.getBoxSize().height);
-      result.setLineWidth(view.getSingleLine().getWidth());
-      result.setColor(view.getColor());
-    } else {
-      throw new InvalidXmlSchemaException("No view in Alias");
-    }
-    result.setState(state);
-    String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode);
-    if (!compartmentAliasId.isEmpty()) {
-      Compartment compartment = model.getElementByElementId(compartmentAliasId);
-      if (compartment == null) {
-        throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId);
-      } else {
-        result.setCompartment(compartment);
-        compartment.addElement(result);
-      }
-    }
-    String complexAliasId = getNodeAttr("complexSpeciesAlias", aliasNode);
-    if (!complexAliasId.isEmpty()) {
-      Complex complex = model.getElementByElementId(complexAliasId);
-      if (complex == null) {
-        throw new InvalidXmlSchemaException(
-            "ComplexAlias does not exist: " + complexAliasId + ", current: " + result.getElementId());
-      } else {
-        result.setComplex(complex);
-        complex.addSpecies(result);
-      }
-    }
-    species.updateModelElementAfterLayoutAdded(result);
-    return result;
-  }
-
-  /**
-   * Process node with information about alias state and puts data into alias.
-   * 
-   * @param node
-   *          node where information about alias state is stored
-   * @param alias
-   *          alias object to be modified if necessary
-   */
-  private void processAliasState(Node node, Species alias) {
-    String state = getNodeAttr("state", node);
-    if ("open".equalsIgnoreCase(state)) {
-      String prefix = getNodeAttr("prefix", node);
-      String label = getNodeAttr("label", node);
-      alias.setStatePrefix(prefix);
-      alias.setStateLabel(label);
-    } else if ("empty".equalsIgnoreCase(state)) {
-      return;
-    } else if (state == null || state.isEmpty()) {
-      return;
-    } else {
-      throw new NotImplementedException("[Alias: " + alias.getElementId() + "] Unkown alias state: " + state);
-    }
-
-  }
-
-  @Override
-  public String toXml(Species species) {
-    Compartment ca = null;
-    // artificial compartment aliases should be excluded
-    if (species.getCompartment() != null && !(species.getCompartment() instanceof PathwayCompartment)) {
-      ca = (Compartment) species.getCompartment();
-    } else if (species.getComplex() == null) {
-      ModelData model = species.getModelData();
-      if (model != null) {
-        for (Compartment cAlias : model.getModel().getCompartments()) {
-          if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(species)) {
-            if (ca == null) {
-              ca = cAlias;
-            } else if (ca.getSize() > cAlias.getSize()) {
-              ca = cAlias;
-            }
-          }
-        }
-      }
-    }
-
-    Complex complex = species.getComplex();
-
-    String compartmentAliasId = null;
-    if (ca != null) {
-      compartmentAliasId = ca.getElementId();
-    }
-    StringBuilder sb = new StringBuilder("");
-    sb.append("<celldesigner:speciesAlias ");
-    sb.append("id=\"" + species.getElementId() + "\" ");
-    sb.append("species=\"" + elements.getElementId(species) + "\" ");
-    if (compartmentAliasId != null) {
-      sb.append("compartmentAlias=\"" + compartmentAliasId + "\" ");
-    }
-
-    if (complex != null) {
-      sb.append("complexSpeciesAlias=\"" + complex.getElementId() + "\" ");
-    }
-    sb.append(">\n");
-
-    if (species.getActivity() != null) {
-      if (species.getActivity()) {
-        sb.append("<celldesigner:activity>active</celldesigner:activity>\n");
-      } else {
-        sb.append("<celldesigner:activity>inactive</celldesigner:activity>\n");
-      }
-    }
-
-    sb.append("<celldesigner:bounds ");
-    sb.append("x=\"" + species.getX() + "\" ");
-    sb.append("y=\"" + species.getY() + "\" ");
-    sb.append("w=\"" + species.getWidth() + "\" ");
-    sb.append("h=\"" + species.getHeight() + "\" ");
-    sb.append("/>\n");
-
-    sb.append("<celldesigner:font size=\"" + species.getFontSize() + "\"/>\n");
-
-    // TODO to be improved
-    sb.append("<celldesigner:view state=\"usual\"/>\n");
-    sb.append("<celldesigner:usualView>");
-    sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
-    sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
-    sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
-    sb.append("<celldesigner:paint color=\"" + colorToString(species.getColor()) + "\" scheme=\"Color\"/>");
-    sb.append("</celldesigner:usualView>\n");
-    sb.append("<celldesigner:briefView>");
-    sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
-    sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
-    sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
-    sb.append("<celldesigner:paint color=\"" + colorToString(species.getColor()) + "\" scheme=\"Color\"/>");
-    sb.append("</celldesigner:briefView>\n");
-    if (species.getStateLabel() != null || species.getStatePrefix() != null) {
-      sb.append("<celldesigner:info state=\"open\" prefix=\"" + species.getStatePrefix() + "\" label=\""
-          + species.getStateLabel() + "\"/>\n");
-    }
-    sb.append("</celldesigner:speciesAlias>\n");
-    return sb.toString();
-  }
-}
+package lcsb.mapviewer.converter.model.celldesigner.alias;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
+import lcsb.mapviewer.common.exception.NotImplementedException;
+import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
+import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerComplexSpecies;
+import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
+import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies;
+import lcsb.mapviewer.converter.model.celldesigner.structure.fields.View;
+import lcsb.mapviewer.model.map.compartment.Compartment;
+import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
+import lcsb.mapviewer.model.map.model.Model;
+import lcsb.mapviewer.model.map.model.ModelData;
+import lcsb.mapviewer.model.map.species.Complex;
+import lcsb.mapviewer.model.map.species.Species;
+
+/**
+ * Parser of CellDesigner xml used for parsing SpeciesAlias.
+ * 
+ * @author Piotr Gawron
+ * 
+ * @see Complex
+ */
+public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> {
+  /**
+   * Default class logger.
+   */
+  private Logger logger = Logger.getLogger(SpeciesAliasXmlParser.class.getName());
+
+  /**
+   * Collection of {@link CellDesignerElement cell designer elements} parsed from
+   * xml.
+   */
+  private CellDesignerElementCollection elements;
+
+  /**
+   * Model for which we parse elements.
+   */
+  private Model model;
+
+  /**
+   * Default constructor with model object for which we parse data.
+   * 
+   * @param model
+   *          model for which we parse elements
+   * @param elements
+   *          collection of {@link CellDesignerElement cell designer elements}
+   *          parsed from xml
+   */
+  public SpeciesAliasXmlParser(CellDesignerElementCollection elements, Model model) {
+    this.elements = elements;
+    this.model = model;
+  }
+
+  @Override
+  Species parseXmlAlias(Node aliasNode) throws InvalidXmlSchemaException {
+
+    String speciesId = getNodeAttr("species", aliasNode);
+    String aliasId = getNodeAttr("id", aliasNode);
+    CellDesignerSpecies<?> species = elements.getElementByElementId(speciesId);
+    if (species == null) {
+      throw new InvalidXmlSchemaException("Unknown species for alias (speciesId: " + speciesId + ")");
+    }
+    if (species instanceof CellDesignerComplexSpecies) {
+      logger.warn("[" + speciesId + "," + aliasId
+          + "]\tSpecies is defined as a complex, but alias is not a complex. Changing alias to complex.");
+    }
+
+    elements.addElement(species, aliasId);
+    Species result = species.createModelElement(aliasId);
+
+    String state = "usual";
+    NodeList nodes = aliasNode.getChildNodes();
+    View usualView = null;
+    View briefView = null;
+    for (int x = 0; x < nodes.getLength(); x++) {
+      Node node = nodes.item(x);
+      if (node.getNodeType() == Node.ELEMENT_NODE) {
+        if (node.getNodeName().equalsIgnoreCase("celldesigner:activity")) {
+          result.setActivity(getNodeValue(node).equalsIgnoreCase("active"));
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:bounds")) {
+          result.setX(getNodeAttr("X", node));
+          result.setY(getNodeAttr("Y", node));
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:font")) {
+          result.setFontSize(getNodeAttr("size", node));
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:view")) {
+          state = getNodeAttr("state", node);
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:usualView")) {
+          usualView = getCommonParser().getView(node);
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:briefView")) {
+          briefView = getCommonParser().getView(node);
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:info")) {
+          processAliasState(node, result);
+        } else if (node.getNodeName().equalsIgnoreCase("celldesigner:structuralState")) {
+          // not handled
+          continue;
+        } else {
+          throw new InvalidXmlSchemaException("Unknown element of celldesigner:speciesAlias: " + node.getNodeName());
+        }
+      }
+    }
+
+    View view = null;
+    if (state.equalsIgnoreCase("usual")) {
+      view = usualView;
+    } else if (state.equalsIgnoreCase("brief")) {
+      view = briefView;
+    }
+
+    if (view != null) {
+      // inner position defines the position in compartment
+      // result.moveBy(view.innerPosition);
+      result.setWidth(view.getBoxSize().width);
+      result.setHeight(view.getBoxSize().height);
+      result.setLineWidth(view.getSingleLine().getWidth());
+      result.setColor(view.getColor());
+    } else {
+      throw new InvalidXmlSchemaException("No view in Alias");
+    }
+    result.setState(state);
+    String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode);
+    if (!compartmentAliasId.isEmpty()) {
+      Compartment compartment = model.getElementByElementId(compartmentAliasId);
+      if (compartment == null) {
+        throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId);
+      } else {
+        result.setCompartment(compartment);
+        compartment.addElement(result);
+      }
+    }
+    String complexAliasId = getNodeAttr("complexSpeciesAlias", aliasNode);
+    if (!complexAliasId.isEmpty()) {
+      Complex complex = model.getElementByElementId(complexAliasId);
+      if (complex == null) {
+        throw new InvalidXmlSchemaException(
+            "ComplexAlias does not exist: " + complexAliasId + ", current: " + result.getElementId());
+      } else {
+        result.setComplex(complex);
+        complex.addSpecies(result);
+      }
+    }
+    
+
+    species.updateModelElementAfterLayoutAdded(result);
+    return result;
+  }
+
+  /**
+   * Process node with information about alias state and puts data into alias.
+   * 
+   * @param node
+   *          node where information about alias state is stored
+   * @param alias
+   *          alias object to be modified if necessary
+   */
+  private void processAliasState(Node node, Species alias) {
+    String state = getNodeAttr("state", node);
+    if ("open".equalsIgnoreCase(state)) {
+      String prefix = getNodeAttr("prefix", node);
+      String label = getNodeAttr("label", node);
+      alias.setStatePrefix(prefix);
+      alias.setStateLabel(label);
+    } else if ("empty".equalsIgnoreCase(state)) {
+      return;
+    } else if (state == null || state.isEmpty()) {
+      return;
+    } else {
+      throw new NotImplementedException("[Alias: " + alias.getElementId() + "] Unkown alias state: " + state);
+    }
+
+  }
+
+  @Override
+  public String toXml(Species species) {
+    Compartment ca = null;
+    // artificial compartment aliases should be excluded
+    if (species.getCompartment() != null && !(species.getCompartment() instanceof PathwayCompartment)) {
+      ca = (Compartment) species.getCompartment();
+    } else if (species.getComplex() == null) {
+      ModelData model = species.getModelData();
+      if (model != null) {
+        for (Compartment cAlias : model.getModel().getCompartments()) {
+          if (!(cAlias instanceof PathwayCompartment) && cAlias.cross(species)) {
+            if (ca == null) {
+              ca = cAlias;
+            } else if (ca.getSize() > cAlias.getSize()) {
+              ca = cAlias;
+            }
+          }
+        }
+      }
+    }
+
+    Complex complex = species.getComplex();
+
+    String compartmentAliasId = null;
+    if (ca != null) {
+      compartmentAliasId = ca.getElementId();
+    }
+    StringBuilder sb = new StringBuilder("");
+    sb.append("<celldesigner:speciesAlias ");
+    sb.append("id=\"" + species.getElementId() + "\" ");
+    sb.append("species=\"" + elements.getElementId(species) + "\" ");
+    if (compartmentAliasId != null) {
+      sb.append("compartmentAlias=\"" + compartmentAliasId + "\" ");
+    }
+
+    if (complex != null) {
+      sb.append("complexSpeciesAlias=\"" + complex.getElementId() + "\" ");
+    }
+    sb.append(">\n");
+
+    if (species.getActivity() != null) {
+      if (species.getActivity()) {
+        sb.append("<celldesigner:activity>active</celldesigner:activity>\n");
+      } else {
+        sb.append("<celldesigner:activity>inactive</celldesigner:activity>\n");
+      }
+    }
+
+    sb.append("<celldesigner:bounds ");
+    sb.append("x=\"" + species.getX() + "\" ");
+    sb.append("y=\"" + species.getY() + "\" ");
+    sb.append("w=\"" + species.getWidth() + "\" ");
+    sb.append("h=\"" + species.getHeight() + "\" ");
+    sb.append("/>\n");
+
+    sb.append("<celldesigner:font size=\"" + species.getFontSize() + "\"/>\n");
+
+    // TODO to be improved
+    sb.append("<celldesigner:view state=\"usual\"/>\n");
+    sb.append("<celldesigner:usualView>");
+    sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
+    sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
+    sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
+    sb.append("<celldesigner:paint color=\"" + colorToString(species.getColor()) + "\" scheme=\"Color\"/>");
+    sb.append("</celldesigner:usualView>\n");
+    sb.append("<celldesigner:briefView>");
+    sb.append("<celldesigner:innerPosition x=\"" + species.getX() + "\" y=\"" + species.getY() + "\"/>");
+    sb.append("<celldesigner:boxSize width=\"" + species.getWidth() + "\" height=\"" + species.getHeight() + "\"/>");
+    sb.append("<celldesigner:singleLine width=\"" + species.getLineWidth() + "\"/>");
+    sb.append("<celldesigner:paint color=\"" + colorToString(species.getColor()) + "\" scheme=\"Color\"/>");
+    sb.append("</celldesigner:briefView>\n");
+    if (species.getStateLabel() != null || species.getStatePrefix() != null) {
+      sb.append("<celldesigner:info state=\"open\" prefix=\"" + species.getStatePrefix() + "\" label=\""
+          + species.getStateLabel() + "\"/>\n");
+    }
+    sb.append("</celldesigner:speciesAlias>\n");
+    return sb.toString();
+  }
+}
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 dd6373dc29..9ad77efd72 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
@@ -91,10 +91,6 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
     super.update(sp);
     if (sp instanceof CellDesignerAntisenseRna) {
       CellDesignerAntisenseRna rna = (CellDesignerAntisenseRna) sp;
-      for (CellDesignerModificationResidue mr : getRegions()) {
-        mr.setState(null);
-      }
-
       for (CellDesignerModificationResidue region : rna.getRegions()) {
         updateRegion(region);
       }
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 745cc58d1b..64e121ad9a 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
@@ -71,9 +71,6 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
     super.update(species);
     if (species instanceof CellDesignerRna) {
       CellDesignerRna rna = (CellDesignerRna) species;
-      for (CellDesignerModificationResidue mr : getRegions()) {
-        mr.setState(null);
-      }
 
       for (CellDesignerModificationResidue region : rna.getRegions()) {
         updateRegion(region);
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 8dc7e0c0f9..9ce8b7956f 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
@@ -460,7 +460,6 @@ public class CellDesignerModificationResidue implements Serializable {
     result.setIdModificationResidue(idModificationResidue);
     result.setName(name);
     result.setActive(active);
-    logger.debug(angle);
     result.setPosition(converter.getCoordinatesByPosition(element, angle));
     if (modificationType.equals(ModificationType.TRANSCRIPTION_SITE_LEFT)) {
       result.setDirection("LEFT");
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java
index 8ae901497d..2e9562224a 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/SpeciesState.java
@@ -6,6 +6,7 @@ import java.util.List;
 import org.apache.log4j.Logger;
 
 import lcsb.mapviewer.common.exception.InvalidArgumentException;
+import lcsb.mapviewer.model.map.species.AntisenseRna;
 import lcsb.mapviewer.model.map.species.Complex;
 import lcsb.mapviewer.model.map.species.Gene;
 import lcsb.mapviewer.model.map.species.Protein;
@@ -87,6 +88,12 @@ public class SpeciesState {
         CellDesignerModificationResidue mr = new CellDesignerModificationResidue(region);
         addModificationResidue(mr);
       }
+    } else if (species instanceof AntisenseRna) {
+      AntisenseRna rna = (AntisenseRna) species;
+      for (ModificationResidue region : rna.getRegions()) {
+        CellDesignerModificationResidue mr = new CellDesignerModificationResidue(region);
+        addModificationResidue(mr);
+      }
     } else if (species instanceof Gene) {
       Gene gene = (Gene) species;
       for (ModificationResidue mr : gene.getModificationResidues()) {
diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ModificationTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ModificationTest.java
index 46c1aa2e24..bacc86fe1b 100644
--- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ModificationTest.java
+++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ModificationTest.java
@@ -27,6 +27,7 @@ import lcsb.mapviewer.model.map.species.field.BindingRegion;
 import lcsb.mapviewer.model.map.species.field.CodingRegion;
 import lcsb.mapviewer.model.map.species.field.ModificationResidue;
 import lcsb.mapviewer.model.map.species.field.ModificationSite;
+import lcsb.mapviewer.model.map.species.field.ModificationState;
 import lcsb.mapviewer.model.map.species.field.ProteinBindingDomain;
 import lcsb.mapviewer.model.map.species.field.RegulatoryRegion;
 import lcsb.mapviewer.model.map.species.field.Residue;
@@ -233,6 +234,13 @@ public class ModificationTest extends CellDesignerTestFunctions {
       rna = model.getElementByElementId("sa3");
       assertEquals(1, rna.getRegions().size());
       assertTrue(rna.getRegions().get(0) instanceof ModificationSite);
+
+      rna = model.getElementByElementId("sa4");
+      assertEquals(1, rna.getRegions().size());
+      assertTrue(rna.getRegions().get(0) instanceof ModificationSite);
+      ModificationSite modificationSite = (ModificationSite) rna.getRegions().get(0);
+      assertEquals(ModificationState.PHOSPHORYLATED, modificationSite.getState());
+
       testXmlSerialization(model);
 
     } catch (Exception e) {
diff --git a/converter-CellDesigner/testFiles/modifications/antisense_rna_with_region.xml b/converter-CellDesigner/testFiles/modifications/antisense_rna_with_region.xml
index 91a7ef532f..1fe9f35b36 100644
--- a/converter-CellDesigner/testFiles/modifications/antisense_rna_with_region.xml
+++ b/converter-CellDesigner/testFiles/modifications/antisense_rna_with_region.xml
@@ -22,7 +22,7 @@
 <celldesigner:briefView>
 <celldesigner:innerPosition x="0.0" y="0.0"/>
 <celldesigner:boxSize width="80.0" height="60.0"/>
-<celldesigner:singleLine width="0.0"/>
+<celldesigner:singleLine width="1.0"/>
 <celldesigner:paint color="3fff0000" scheme="Color"/>
 </celldesigner:briefView>
 <celldesigner:info state="empty" angle="-1.5707963267948966"/>
@@ -41,12 +41,12 @@
 <celldesigner:briefView>
 <celldesigner:innerPosition x="0.0" y="0.0"/>
 <celldesigner:boxSize width="80.0" height="60.0"/>
-<celldesigner:singleLine width="0.0"/>
+<celldesigner:singleLine width="1.0"/>
 <celldesigner:paint color="3fff0000" scheme="Color"/>
 </celldesigner:briefView>
 <celldesigner:info state="empty" angle="-1.5707963267948966"/>
 </celldesigner:speciesAlias>
-<celldesigner:speciesAlias id="sa3" species="s3">
+<celldesigner:speciesAlias id="sa3" species="s4">
 <celldesigner:activity>inactive</celldesigner:activity>
 <celldesigner:bounds x="192.0" y="247.5" w="90.0" h="25.0"/>
 <celldesigner:font size="12"/>
@@ -60,7 +60,26 @@
 <celldesigner:briefView>
 <celldesigner:innerPosition x="0.0" y="0.0"/>
 <celldesigner:boxSize width="80.0" height="60.0"/>
-<celldesigner:singleLine width="0.0"/>
+<celldesigner:singleLine width="1.0"/>
+<celldesigner:paint color="3fff0000" scheme="Color"/>
+</celldesigner:briefView>
+<celldesigner:info state="empty" angle="-1.5707963267948966"/>
+</celldesigner:speciesAlias>
+<celldesigner:speciesAlias id="sa4" species="s3">
+<celldesigner:activity>inactive</celldesigner:activity>
+<celldesigner:bounds x="300.0" y="207.0" w="90.0" h="25.0"/>
+<celldesigner:font size="12"/>
+<celldesigner:view state="usual"/>
+<celldesigner:usualView>
+<celldesigner:innerPosition x="0.0" y="0.0"/>
+<celldesigner:boxSize width="90.0" height="25.0"/>
+<celldesigner:singleLine width="1.0"/>
+<celldesigner:paint color="ffff6666" scheme="Color"/>
+</celldesigner:usualView>
+<celldesigner:briefView>
+<celldesigner:innerPosition x="0.0" y="0.0"/>
+<celldesigner:boxSize width="80.0" height="60.0"/>
+<celldesigner:singleLine width="1.0"/>
 <celldesigner:paint color="3fff0000" scheme="Color"/>
 </celldesigner:briefView>
 <celldesigner:info state="empty" angle="-1.5707963267948966"/>
@@ -151,6 +170,22 @@
 <celldesigner:speciesIdentity>
 <celldesigner:class>ANTISENSE_RNA</celldesigner:class>
 <celldesigner:antisensernaReference>arn3</celldesigner:antisensernaReference>
+<celldesigner:state>
+<celldesigner:listOfModifications>
+<celldesigner:modification residue="tr1" state="phosphorylated"/>
+</celldesigner:listOfModifications>
+</celldesigner:state>
+</celldesigner:speciesIdentity>
+</celldesigner:extension>
+</annotation>
+</species>
+<species metaid="s4" id="s4" name="s3" compartment="default" initialAmount="0">
+<annotation>
+<celldesigner:extension>
+<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
+<celldesigner:speciesIdentity>
+<celldesigner:class>ANTISENSE_RNA</celldesigner:class>
+<celldesigner:antisensernaReference>arn3</celldesigner:antisensernaReference>
 </celldesigner:speciesIdentity>
 </celldesigner:extension>
 </annotation>
-- 
GitLab