Commit 48e20687 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

TranscriptionSite data model supported

parent d6fad8c4
......@@ -19,6 +19,7 @@ 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.RegulatoryRegion;
import lcsb.mapviewer.model.map.species.field.TranscriptionSite;
/**
* Class that performs parsing of the CellDesigner xml for
......@@ -174,6 +175,15 @@ public class GeneXmlParser extends AbstractElementXmlParser<CellDesignerGene, Ge
} else if (mr instanceof CodingRegion) {
type = ModificationType.CODING_REGION.getCellDesignerName();
attributes += " size=\"" + ((RegulatoryRegion) mr).getWidth() / mr.getSpecies().getWidth() + "\"";
} else if (mr instanceof TranscriptionSite) {
TranscriptionSite transcriptionSite = (TranscriptionSite) mr;
if (transcriptionSite.getDirection().equals("RIGHT")) {
type = ModificationType.TRANSCRIPTION_SITE_RIGHT.getCellDesignerName();
} else {
type = ModificationType.TRANSCRIPTION_SITE_LEFT.getCellDesignerName();
}
attributes += " size=\"" + transcriptionSite.getWidth() / mr.getSpecies().getWidth() + "\"";
attributes += " active=\"" + transcriptionSite.getActive() + "\"";
} else {
throw new InvalidArgumentException("Don't know how to handle: " + mr.getClass());
}
......
......@@ -18,6 +18,7 @@ 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;
import lcsb.mapviewer.model.map.species.field.TranscriptionSite;
/**
* This class represent modification residue in a Species.
......@@ -97,6 +98,7 @@ public class CellDesignerModificationResidue implements Serializable {
this.idModificationResidue = mr.idModificationResidue;
this.name = mr.name;
this.angle = mr.angle;
this.active= mr.active;
this.size = mr.size;
this.side = mr.side;
this.pos = mr.pos;
......@@ -131,6 +133,15 @@ public class CellDesignerModificationResidue implements Serializable {
} else if (mr instanceof RegulatoryRegion) {
this.size = ((RegulatoryRegion) mr).getWidth() / mr.getSpecies().getWidth();
this.modificationType = ModificationType.REGULATORY_REGION;
} else if (mr instanceof TranscriptionSite) {
TranscriptionSite transcriptionSite = (TranscriptionSite)mr;
this.size = transcriptionSite.getWidth() / mr.getSpecies().getWidth();
this.active = transcriptionSite.getActive();
if (transcriptionSite.getDirection().equals("LEFT")) {
this.modificationType = ModificationType.TRANSCRIPTION_SITE_LEFT;
} else {
this.modificationType = ModificationType.TRANSCRIPTION_SITE_RIGHT;
}
} else if (mr instanceof BindingRegion) {
this.modificationType = ModificationType.BINDING_REGION;
if (Math.abs(mr.getPosition().getX() - mr.getSpecies().getX()) < Configuration.EPSILON) {
......@@ -171,6 +182,9 @@ public class CellDesignerModificationResidue implements Serializable {
if (mr.getAngle() != null) {
this.angle = mr.angle;
}
if (mr.getActive() != null) {
this.active = mr.active;
}
if (mr.getSize() != null) {
this.size = mr.size;
}
......@@ -386,6 +400,8 @@ public class CellDesignerModificationResidue implements Serializable {
return createProteinBindingDomain(element, converter);
} else if (modificationType.equals(ModificationType.REGULATORY_REGION)) {
return createRegulatoryRegion(element, converter);
} else if (modificationType.equals(ModificationType.TRANSCRIPTION_SITE_LEFT) || modificationType.equals(ModificationType.TRANSCRIPTION_SITE_RIGHT)) {
return createTranscriptionSite(element, converter);
} else {
throw new InvalidArgumentException("Unknown modification type: " + modificationType);
}
......@@ -434,6 +450,21 @@ public class CellDesignerModificationResidue implements Serializable {
return result;
}
private TranscriptionSite createTranscriptionSite(Element element, CellDesignerAliasConverter converter) {
TranscriptionSite result = new TranscriptionSite();
result.setWidth(element.getWidth() * size);
result.setIdModificationResidue(idModificationResidue);
result.setName(name);
result.setActive(active);
result.setPosition(converter.getResidueCoordinates(element, angle));
if (modificationType.equals(ModificationType.TRANSCRIPTION_SITE_LEFT)) {
result.setDirection("LEFT");
} else {
result.setDirection("RIGHT");
}
return result;
}
private ModificationSite createModificationSite(Element element, CellDesignerAliasConverter converter) {
ModificationSite result = new ModificationSite();
result.setState(this.getState());
......
......@@ -8,6 +8,8 @@ public enum ModificationType {
PROTEIN_BINDING_DOMAIN("proteinBindingDomain"), //
RESIDUE(null), //
REGULATORY_REGION("RegulatoryRegion"), //
TRANSCRIPTION_SITE_RIGHT("transcriptionStartingSiteR"), //
TRANSCRIPTION_SITE_LEFT("transcriptionStartingSiteL"), //
MODIFICATION_SITE("Modification Site");//
private String cellDesignerName;
......
......@@ -53,6 +53,7 @@ import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.field.BindingRegion;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.RegulatoryRegion;
import lcsb.mapviewer.model.map.species.field.TranscriptionSite;
public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
Logger logger = Logger.getLogger(CellDesignerXmlParserTest.class);
......@@ -1056,4 +1057,58 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
}
}
@Test
public void testRegulatoryTranscriptionSiteRight() throws Exception {
try {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/gene_with_transcription_site_right.xml"));
Gene gene = model.getElementByElementId("sa1");
assertEquals(1, gene.getModificationResidues().size());
ModificationResidue residue = gene.getModificationResidues().get(0);
assertTrue(residue instanceof TranscriptionSite);
TranscriptionSite transcriptionSite = (TranscriptionSite) residue;
assertEquals(transcriptionSite.getPosition().getY(), gene.getY(), Configuration.EPSILON);
assertEquals("RIGHT", transcriptionSite.getDirection());
assertTrue(transcriptionSite.getActive());
String xml = parser.toXml(model);
InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is));
model.setName(null);
ModelComparator comparator = new ModelComparator();
assertEquals(0, comparator.compare(model, model2));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testRegulatoryTranscriptionSiteLeft() throws Exception {
try {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/gene_with_transcription_site_left.xml"));
Gene gene = model.getElementByElementId("sa1");
assertEquals(1, gene.getModificationResidues().size());
ModificationResidue residue = gene.getModificationResidues().get(0);
assertTrue(residue instanceof TranscriptionSite);
TranscriptionSite transcriptionSite = (TranscriptionSite) residue;
assertEquals(transcriptionSite.getPosition().getY(), gene.getY(), Configuration.EPSILON);
assertEquals("LEFT", transcriptionSite.getDirection());
assertFalse(transcriptionSite.getActive());
String xml = parser.toXml(model);
InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is));
model.setName(null);
ModelComparator comparator = new ModelComparator();
assertEquals(0, comparator.compare(model, model2));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="untitled" id="untitled">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="600" sizeY="400"/>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases/>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa1" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="197.0" y="177.5" w="70.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="70.0" height="25.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffffff66" 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="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins/>
<celldesigner:listOfGenes>
<celldesigner:gene id="gn1" name="s1" type="GENE">
<celldesigner:listOfRegions>
<celldesigner:region id="tr1" size="0.38" pos="0.2" type="transcriptionStartingSiteL" active="false"/>
</celldesigner:listOfRegions>
</celldesigner:gene>
</celldesigner:listOfGenes>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers/>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition metaid="substance" id="substance" name="substance">
<listOfUnits>
<unit metaid="CDMT00001" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00002" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00003" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00004" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00005" kind="second"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="default" id="default" size="1" units="volume"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="s1" id="s1" name="s1" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>GENE</celldesigner:class>
<celldesigner:geneReference>gn1</celldesigner:geneReference>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
</model>
</sbml>
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="untitled" id="untitled">
<annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="600" sizeY="400"/>
<celldesigner:listOfCompartmentAliases/>
<celldesigner:listOfComplexSpeciesAliases/>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa1" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="278.0" y="218.5" w="70.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="70.0" height="25.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffffff66" 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="0.0"/>
<celldesigner:paint color="3fff0000" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:speciesAlias>
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfGroups/>
<celldesigner:listOfProteins/>
<celldesigner:listOfGenes>
<celldesigner:gene id="gn1" name="s1" type="GENE">
<celldesigner:listOfRegions>
<celldesigner:region id="tr1" name="qwe" size="0.1" pos="0.25" type="transcriptionStartingSiteR" active="true"/>
</celldesigner:listOfRegions>
</celldesigner:gene>
</celldesigner:listOfGenes>
<celldesigner:listOfRNAs/>
<celldesigner:listOfAntisenseRNAs/>
<celldesigner:listOfLayers/>
<celldesigner:listOfBlockDiagrams/>
</celldesigner:extension>
</annotation>
<listOfUnitDefinitions>
<unitDefinition metaid="substance" id="substance" name="substance">
<listOfUnits>
<unit metaid="CDMT00001" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00002" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00003" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00004" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00005" kind="second"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment metaid="default" id="default" size="1" units="volume"/>
</listOfCompartments>
<listOfSpecies>
<species metaid="s1" id="s1" name="s1" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>GENE</celldesigner:class>
<celldesigner:geneReference>gn1</celldesigner:geneReference>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
</model>
</sbml>
package lcsb.mapviewer.model.map.species.field;
import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import org.apache.log4j.Logger;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.Species;
/**
* This structure contains information about Transcription Site for one of the
* following {@link Species}:
* <ul>
* <li>{@link Gene}</li>
* </ul>
*
* @author Piotr Gawron
*
*/
@Entity
@DiscriminatorValue("TRANSCRIPTION_SITE")
public class TranscriptionSite extends AbstractRegionModification implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(TranscriptionSite.class);
private String direction = null;
private Boolean active = false;
/**
* Default constructor.
*/
public TranscriptionSite() {
}
/**
* Constructor that initialize object with the data from the parameter.
*
* @param original
* object from which we initialize data
*/
public TranscriptionSite(TranscriptionSite original) {
super(original);
this.direction = original.getDirection();
this.active = original.getActive();
}
@Override
public void update(AbstractRegionModification mr) {
TranscriptionSite original = (TranscriptionSite) mr;
if (original.getDirection() != null) {
this.direction = original.getDirection();
}
if (original.getActive() != null) {
this.active = original.getActive();
}
}
/**
* Creates a copy of current object.
*
* @return copy of the object
*/
public TranscriptionSite copy() {
if (this.getClass() == TranscriptionSite.class) {
return new TranscriptionSite(this);
} else {
throw new NotImplementedException("Method copy() should be overriden in class " + this.getClass());
}
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
@Override
public String toString() {
return super.toString() + "," + getActive() + "," + getDirection();
}
}
-- modification residue should have height
alter table modification_residue_table add column height numeric(6,2);
update modification_residue_table set height = 10.0;
-- transcription site activity and direction
alter table modification_residue_table add column direction varchar(255);
......@@ -181,6 +181,7 @@
<value>lcsb.mapviewer.model.map.species.field.ModificationSite</value>
<value>lcsb.mapviewer.model.map.species.field.ProteinBindingDomain</value>
<value>lcsb.mapviewer.model.map.species.field.Residue</value>
<value>lcsb.mapviewer.model.map.species.field.TranscriptionSite</value>
<value>lcsb.mapviewer.model.map.species.field.UniprotRecord</value>
<value>lcsb.mapviewer.model.map.species.field.Structure</value>
......
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