Commit 6932c247 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

cell designer structures for storing modification data simplified

parent ca4d2258
......@@ -11,7 +11,7 @@ import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.field.CodingRegion;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
......@@ -166,9 +166,9 @@ public class AntisenseRnaXmlParser extends AbstractElementXmlParser<CellDesigner
* @throws InvalidXmlSchemaException
* thrown when input xml node doesn't follow defined schema
*/
private CellDesignerAntisenseRnaRegion getAntisenseRnaRegion(Node regionNode) throws InvalidXmlSchemaException {
CellDesignerAntisenseRnaRegion residue = new CellDesignerAntisenseRnaRegion();
residue.setIdAntisenseRnaRegion(getNodeAttr("id", regionNode));
private CellDesignerModificationResidue getAntisenseRnaRegion(Node regionNode) throws InvalidXmlSchemaException {
CellDesignerModificationResidue residue = new CellDesignerModificationResidue();
residue.setIdModificationResidue(getNodeAttr("id", regionNode));
residue.setName(getNodeAttr("name", regionNode));
residue.setSize(getNodeAttr("size", regionNode));
residue.setPos(getNodeAttr("pos", regionNode));
......
......@@ -12,7 +12,6 @@ import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationPars
import lcsb.mapviewer.converter.model.celldesigner.geometry.CellDesignerAliasConverter;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerGene;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerGeneRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
......@@ -92,8 +91,8 @@ public class GeneXmlParser extends AbstractElementXmlParser<CellDesignerGene, Ge
* @throws InvalidXmlSchemaException
* thrown when input xml node doesn't follow defined schema
*/
CellDesignerGeneRegion getModificationResidue(Node residueNode) throws InvalidXmlSchemaException {
CellDesignerGeneRegion residue = new CellDesignerGeneRegion();
CellDesignerModificationResidue getModificationResidue(Node residueNode) throws InvalidXmlSchemaException {
CellDesignerModificationResidue residue = new CellDesignerModificationResidue();
residue.setIdModificationResidue(getNodeAttr("id", residueNode));
residue.setName(getNodeAttr("name", residueNode));
residue.setSide(getNodeAttr("side", residueNode));
......
......@@ -10,7 +10,7 @@ import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection
import lcsb.mapviewer.converter.model.celldesigner.annotation.RestAnnotationParser;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.Rna;
/**
......@@ -88,9 +88,9 @@ public class RnaXmlParser extends AbstractElementXmlParser<CellDesignerRna, Rna>
* @throws InvalidXmlSchemaException
* thrown when input xml node doesn't follow defined schema
*/
private CellDesignerRnaRegion getRnaRegion(Node residueNode) throws InvalidXmlSchemaException {
CellDesignerRnaRegion residue = new CellDesignerRnaRegion();
residue.setIdRnaRegion(getNodeAttr("id", residueNode));
private CellDesignerModificationResidue getRnaRegion(Node residueNode) throws InvalidXmlSchemaException {
CellDesignerModificationResidue residue = new CellDesignerModificationResidue();
residue.setIdModificationResidue(getNodeAttr("id", residueNode));
residue.setSize(getNodeAttr("size", residueNode));
residue.setPos(getNodeAttr("pos", residueNode));
String typeString = getNodeAttr("type", residueNode);
......
......@@ -20,10 +20,7 @@ import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerProtein
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerRna;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSimpleMolecule;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerSpecies;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerGeneRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.SpeciesState;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
......@@ -446,7 +443,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
throw new NotImplementedException("StructuralState not supported in Gene");
}
for (CellDesignerModificationResidue mr : state.getModifications()) {
gene.addModificationResidue(createGeneRegion(mr));
gene.addModificationResidue(mr);
}
} else if (species instanceof CellDesignerProtein) {
CellDesignerProtein<?> protein = (CellDesignerProtein<?>) species;
......@@ -461,7 +458,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
}
for (CellDesignerModificationResidue mr : state.getModifications()) {
rna.addRegion(createRnaRegion(mr));
rna.addRegion(mr);
}
} else if (species instanceof CellDesignerSimpleMolecule) {
if (state.getStructuralState() != null && !state.getStructuralState().isEmpty()) {
......@@ -478,8 +475,7 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
}
for (CellDesignerModificationResidue mr : state.getModifications()) {
CellDesignerAntisenseRnaRegion region = createAntisenseRnaRegion(mr);
antisenseRna.addRegion(region);
antisenseRna.addRegion(mr);
}
} else {
if (state.getStructuralState() != null && !state.getStructuralState().isEmpty()) {
......@@ -492,23 +488,6 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
}
private CellDesignerGeneRegion createGeneRegion(CellDesignerModificationResidue mr) {
CellDesignerGeneRegion region = new CellDesignerGeneRegion();
region.setIdModificationResidue(mr.getIdModificationResidue());
if (mr.getSize() != null) {
region.setSize(mr.getSize());
}
region.setState(mr.getState());
region.setName(mr.getName());
if (mr.getAngle() != null) {
region.setAngle(mr.getAngle());
}
if (mr.getModificationType() != null) {
region.setModificationType(mr.getModificationType());
}
return region;
}
/**
* Creates {@link SpeciesState} from xml node.
*
......@@ -623,49 +602,4 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
return "<celldesigner:modification residue=\"" + mr.getIdModificationResidue() + "\" state=\"" + state
+ "\"> </celldesigner:modification>\n";
}
/**
* Creates {@link CellDesignerAntisenseRnaRegion} from
* {@link CellDesignerModificationResidue} description.
*
* @param mr
* object from which we create {@link CellDesignerAntisenseRnaRegion}
* @return {@link CellDesignerAntisenseRnaRegion} object created from param
*/
CellDesignerAntisenseRnaRegion createAntisenseRnaRegion(CellDesignerModificationResidue mr) {
CellDesignerAntisenseRnaRegion region = new CellDesignerAntisenseRnaRegion();
region.setIdAntisenseRnaRegion(mr.getIdModificationResidue());
if (mr.getSize() != null) {
region.setSize(mr.getSize());
}
region.setState(mr.getState());
region.setName(mr.getName());
if (mr.getAngle() != null) {
region.setPos(mr.getAngle());
}
return region;
}
/**
* Creates {@link CellDesignerRnaRegion} from
* {@link CellDesignerModificationResidue} description.
*
* @param mr
* object from which we create {@link CellDesignerRnaRegion}
* @return {@link CellDesignerRnaRegion} object created from parameter
*/
public CellDesignerRnaRegion createRnaRegion(CellDesignerModificationResidue mr) {
CellDesignerRnaRegion result = new CellDesignerRnaRegion();
result.setIdRnaRegion(mr.getIdModificationResidue());
if (mr.getSize() != null) {
result.setSize(mr.getSize());
}
result.setState(mr.getState());
result.setName(mr.getName());
if (mr.getAngle() != null) {
result.setPos(mr.getAngle());
}
return result;
}
}
......@@ -6,7 +6,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerAntisenseRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.Species;
......@@ -32,7 +32,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
/**
* List of antisense rna regions (some rna sequences) in this object.
*/
private List<CellDesignerAntisenseRnaRegion> regions = new ArrayList<>();
private List<CellDesignerModificationResidue> regions = new ArrayList<>();
/**
* Constructor that copies the data from species given in the argument.
......@@ -44,8 +44,8 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
super(species);
if (species instanceof CellDesignerAntisenseRna) {
CellDesignerAntisenseRna asRna = (CellDesignerAntisenseRna) species;
for (CellDesignerAntisenseRnaRegion region : asRna.getRegions()) {
addRegion(new CellDesignerAntisenseRnaRegion(region));
for (CellDesignerModificationResidue region : asRna.getRegions()) {
addRegion(new CellDesignerModificationResidue(region));
}
}
}
......@@ -75,14 +75,13 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
* @param region
* region to add
*/
public void addRegion(CellDesignerAntisenseRnaRegion region) {
for (CellDesignerAntisenseRnaRegion region2 : regions) {
if (region2.getIdAntisenseRnaRegion().equals(region.getIdAntisenseRnaRegion())) {
public void addRegion(CellDesignerModificationResidue region) {
for (CellDesignerModificationResidue region2 : regions) {
if (region2.getIdModificationResidue().equals(region.getIdModificationResidue())) {
region2.update(region);
return;
}
}
regions.add(region);
region.setSpecies(this);
}
......@@ -92,11 +91,11 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
super.update(sp);
if (sp instanceof CellDesignerAntisenseRna) {
CellDesignerAntisenseRna rna = (CellDesignerAntisenseRna) sp;
for (CellDesignerAntisenseRnaRegion mr : getRegions()) {
for (CellDesignerModificationResidue mr : getRegions()) {
mr.setState(null);
}
for (CellDesignerAntisenseRnaRegion region : rna.getRegions()) {
for (CellDesignerModificationResidue region : rna.getRegions()) {
updateRegion(region);
}
}
......@@ -110,9 +109,9 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
* @param param
* - object with new data from where update should be performed
*/
private void updateRegion(CellDesignerAntisenseRnaRegion param) {
for (CellDesignerAntisenseRnaRegion region : regions) {
if (region.getIdAntisenseRnaRegion().equals(param.getIdAntisenseRnaRegion())) {
private void updateRegion(CellDesignerModificationResidue param) {
for (CellDesignerModificationResidue region : regions) {
if (region.getIdModificationResidue().equals(param.getIdModificationResidue())) {
region.update(param);
return;
}
......@@ -124,7 +123,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
* @return the regions
* @see #regions
*/
public List<CellDesignerAntisenseRnaRegion> getRegions() {
public List<CellDesignerModificationResidue> getRegions() {
return regions;
}
......@@ -133,7 +132,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
* the regions to set
* @see #regions
*/
public void setRegions(List<CellDesignerAntisenseRnaRegion> regions) {
public void setRegions(List<CellDesignerModificationResidue> regions) {
this.regions = regions;
}
......@@ -146,7 +145,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
@Override
public void updateModelElementAfterLayoutAdded(Species element) {
for (CellDesignerAntisenseRnaRegion region : regions) {
for (CellDesignerModificationResidue region : regions) {
((AntisenseRna) element).addRegion(region.createAntisenseRegionAlias(element));
}
}
......
......@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerGeneRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.Species;
......@@ -25,7 +24,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
/**
* List of modifications for the Gene.
*/
private List<CellDesignerGeneRegion> modificationResidues = new ArrayList<>();
private List<CellDesignerModificationResidue> modificationResidues = new ArrayList<>();
/**
* Constructor that initializes gene with the data passed in the argument.
......@@ -37,8 +36,8 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
super(species);
if (species instanceof CellDesignerGene) {
CellDesignerGene gene = (CellDesignerGene) species;
for (CellDesignerGeneRegion mr : gene.getModificationResidues()) {
addModificationResidue(new CellDesignerGeneRegion(mr));
for (CellDesignerModificationResidue mr : gene.getModificationResidues()) {
addModificationResidue(new CellDesignerModificationResidue(mr));
}
}
}
......@@ -49,7 +48,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
if (species instanceof CellDesignerGene) {
CellDesignerGene gene = (CellDesignerGene) species;
for (CellDesignerGeneRegion mr : gene.getModificationResidues()) {
for (CellDesignerModificationResidue mr : gene.getModificationResidues()) {
addModificationResidue(mr);
}
}
......@@ -77,8 +76,8 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
* @param modificationResidue
* modification to add
*/
public void addModificationResidue(CellDesignerGeneRegion modificationResidue) {
for (CellDesignerGeneRegion mr : modificationResidues) {
public void addModificationResidue(CellDesignerModificationResidue modificationResidue) {
for (CellDesignerModificationResidue mr : modificationResidues) {
if (mr.getIdModificationResidue().equals(modificationResidue.getIdModificationResidue())) {
mr.update(modificationResidue);
return;
......@@ -93,7 +92,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
* @return the modificationResidues
* @see #modificationResidues
*/
public List<CellDesignerGeneRegion> getModificationResidues() {
public List<CellDesignerModificationResidue> getModificationResidues() {
return modificationResidues;
}
......@@ -102,7 +101,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
* the modificationResidues to set
* @see #modificationResidues
*/
public void setModificationResidues(List<CellDesignerGeneRegion> modificationResidues) {
public void setModificationResidues(List<CellDesignerModificationResidue> modificationResidues) {
this.modificationResidues = modificationResidues;
}
......@@ -115,7 +114,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
@Override
public void updateModelElementAfterLayoutAdded(Species element) {
for (CellDesignerGeneRegion region : modificationResidues) {
for (CellDesignerModificationResidue region : modificationResidues) {
((Gene) element).addModificationResidue(region.createGeneModification(element));
}
}
......
......@@ -6,7 +6,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerRnaRegion;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.map.species.Species;
......@@ -32,7 +32,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
/**
* List of rna regions (some rna sequences) in this object.
*/
private List<CellDesignerRnaRegion> regions = new ArrayList<>();
private List<CellDesignerModificationResidue> regions = new ArrayList<>();
/**
* Constructor that initializes rna with the data passed in the argument.
......@@ -44,8 +44,8 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
super(species);
if (species instanceof CellDesignerRna) {
CellDesignerRna rna = (CellDesignerRna) species;
for (CellDesignerRnaRegion region : rna.getRegions()) {
addRegion(new CellDesignerRnaRegion(region));
for (CellDesignerModificationResidue region : rna.getRegions()) {
addRegion(new CellDesignerModificationResidue(region));
}
}
}
......@@ -71,11 +71,11 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
super.update(species);
if (species instanceof CellDesignerRna) {
CellDesignerRna rna = (CellDesignerRna) species;
for (CellDesignerRnaRegion mr : getRegions()) {
for (CellDesignerModificationResidue mr : getRegions()) {
mr.setState(null);
}
for (CellDesignerRnaRegion region : rna.getRegions()) {
for (CellDesignerModificationResidue region : rna.getRegions()) {
updateRegion(region);
}
}
......@@ -87,14 +87,14 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
* @param param
* region that with the data to update
*/
private void updateRegion(CellDesignerRnaRegion param) {
for (CellDesignerRnaRegion region : regions) {
if (region.getIdRnaRegion().equals(param.getIdRnaRegion())) {
private void updateRegion(CellDesignerModificationResidue param) {
for (CellDesignerModificationResidue region : regions) {
if (region.getIdModificationResidue().equals(param.getIdModificationResidue())) {
region.update(param);
return;
}
}
addRegion(new CellDesignerRnaRegion(param));
addRegion(new CellDesignerModificationResidue(param));
}
/**
......@@ -104,9 +104,9 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
* @param rnaRegion
* region to add
*/
public void addRegion(CellDesignerRnaRegion rnaRegion) {
for (CellDesignerRnaRegion region2 : regions) {
if (region2.getIdRnaRegion().equals(rnaRegion.getIdRnaRegion())) {
public void addRegion(CellDesignerModificationResidue rnaRegion) {
for (CellDesignerModificationResidue region2 : regions) {
if (region2.getIdModificationResidue().equals(rnaRegion.getIdModificationResidue())) {
region2.update(rnaRegion);
return;
}
......@@ -121,7 +121,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
* @return the regions
* @see #regions
*/
public List<CellDesignerRnaRegion> getRegions() {
public List<CellDesignerModificationResidue> getRegions() {
return regions;
}
......@@ -130,7 +130,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
* the regions to set
* @see #regions
*/
public void setRegions(List<CellDesignerRnaRegion> regions) {
public void setRegions(List<CellDesignerModificationResidue> regions) {
this.regions = regions;
}
......@@ -143,7 +143,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
@Override
public void updateModelElementAfterLayoutAdded(Species element) {
for (CellDesignerRnaRegion region : regions) {
for (CellDesignerModificationResidue region : regions) {
Rna rna = (Rna) element;
rna.addRegion(region.createRnaRegionAlias(rna));
}
......
package lcsb.mapviewer.converter.model.celldesigner.structure.fields;
import java.awt.geom.Point2D;
import java.io.Serializable;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna;
import lcsb.mapviewer.model.map.species.Element;
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;
/**
* This structure contains information about antisense rna region (rna fragment
* of interest) for a specific
* {@link lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerAntisenseRna
* AntisenseRna}.
*
* @author Piotr Gawron
*
*/
public class CellDesignerAntisenseRnaRegion implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default size of the object (in graphical representation).
*/
private static final double DEFAULT_SIZE = 0.1;
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(CellDesignerAntisenseRnaRegion.class.getName());
/**
* Unique identifier in the database.
*/
private int id;
/**
* String identifier of the element. Unique in the model.
*/
private String idAntisenseRnaRegion = "";
/**
* Name of the region.
*/
private String name = "";
/**
* Defines a state of the region (for instance ubiquitinated etc).
*
* @see ModificationState
*/
private ModificationState state = null;
private String modificationType;
/**
* Size of the region in the graphic representation.
*/
private double size = DEFAULT_SIZE;
/**
* Position on the species in graphic representation.
*/
private Double pos;
/**
* Defines a species where the region belongs to.
*/
private CellDesignerAntisenseRna species;
/**
* Default constructor.
*/
public CellDesignerAntisenseRnaRegion() {
}
/**
* Constructor that initialize object with the data from the parameter.
*
* @param original
* object from which we initialize data
*/
public CellDesignerAntisenseRnaRegion(CellDesignerAntisenseRnaRegion original) {
this.idAntisenseRnaRegion = original.idAntisenseRnaRegion;
this.name = original.name;
this.size = original.size;
this.pos = original.pos;
this.modificationType = original.modificationType;
}
/**
* Creates a copy of current object.
*
* @return copy of the object
*/