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

ModificationResidue contains Z index

parent 8afa6513
......@@ -337,11 +337,11 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
RestAnnotationParser rap = new RestAnnotationParser();
rap.processNotes(
"Symbol: ROS1\r\nName: c-ros oncogene 1 , receptor tyrosine kinase\r\n"
+ "Description: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; "
+ "AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; "
+ "AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; "
+ "AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\n"
+ "Previous Symbols:\r\nSynonyms: ROS, MCF3",
+ "Description: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; "
+ "AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; "
+ "AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; "
+ "AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\n"
+ "Previous Symbols:\r\nSynonyms: ROS, MCF3",
speciesAlias);
model.addElement(speciesAlias);
......@@ -353,10 +353,10 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
speciesAlias2.setName("PDK1");
rap.processNotes(
"Symbol: ROS1\r\nName: c-ros oncogene 1 , receptor tyrosine kinase\r\n"
+ "Description: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; "
+ "AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; "
+ "AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\n"
+ "Previous Symbols:\r\nSynonyms: ROS, MCF3",
+ "Description: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; "
+ "AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; "
+ "AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\n"
+ "Previous Symbols:\r\nSynonyms: ROS, MCF3",
speciesAlias2);
model.addElement(speciesAlias2);
......@@ -931,7 +931,8 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
Reactant newReactant = reaction2.getReactants().get(0);
// center part of the line shouldn't change - edges should be aligned to touch
// center part of the line shouldn't change - edges should be aligned to
// touch
// species
PointComparator pc = new PointComparator(Configuration.EPSILON);
assertEquals(0,
......@@ -975,7 +976,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/orthogonal_reaction_to_phenotype.xml"));
Reaction r = model.getReactionByReactionId("re2");
assertEquals(r.getReactants().get(0).getLine().getStartPoint().getY(),
assertEquals(r.getReactants().get(0).getLine().getStartPoint().getY(),
r.getProducts().get(0).getLine().getStartPoint().getY(), Configuration.EPSILON);
}
......@@ -984,9 +985,8 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
Model model = parser.createModel(new ConverterParams().filename("testFiles/orthogonal_reaction_to_drug.xml"));
Reaction r = model.getReactionByReactionId("re3");
assertEquals(r.getReactants().get(0).getLine().getStartPoint().getY(),
assertEquals(r.getReactants().get(0).getLine().getStartPoint().getY(),
r.getProducts().get(0).getLine().getStartPoint().getY(), Configuration.EPSILON);
}
}
......@@ -232,8 +232,9 @@ public class ModificationResidueExporter {
double height = getModificationHeight(mr);
double x = mr.getPosition().getX() - width / 2;
double y = mr.getPosition().getY() - height / 2;
double z = mr.getZ();
BoundingBox boundingBox = new BoundingBox();
boundingBox.setPosition(new Point(x, y, mr.getSpecies().getZ() + 1));
boundingBox.setPosition(new Point(x, y, z));
Dimensions dimensions = new Dimensions();
dimensions.setWidth(width);
dimensions.setHeight(height);
......
......@@ -375,7 +375,9 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species>
double height = residueGlyph.getBoundingBox().getDimensions().getHeight();
double x = residueGlyph.getBoundingBox().getPosition().getX();
double y = residueGlyph.getBoundingBox().getPosition().getY();
double z = residueGlyph.getBoundingBox().getPosition().getZ();
mr.setPosition(new Point2D.Double(x + width / 2, y + height / 2));
mr.setZ((int) Math.round(z));
if (mr instanceof AbstractRegionModification) {
((AbstractRegionModification) mr).setWidth(width);
((AbstractRegionModification) mr).setHeight(height);
......@@ -393,10 +395,13 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species>
if (graphicalObject instanceof GeneralGlyph) {
if (((GeneralGlyph) graphicalObject).getReference().equals(mr.getIdModificationResidue())) {
if (((GeneralGlyph) graphicalObject).getListOfReferenceGlyphs().size() > 0) {
// find a reference to the alias in layout, so we know it's the proper value
// find a reference to the alias in layout, so we know it's the
// proper value
ReferenceGlyph referenceGlyph = ((GeneralGlyph) graphicalObject).getListOfReferenceGlyphs().get(0);
if (Objects.equal(referenceGlyph.getGlyph(), mr.getSpecies().getElementId())) {
// if (referenceGlyph.getGlyph().equals(mr.getSpecies().getElementId())) {
// if
// (referenceGlyph.getGlyph().equals(mr.getSpecies().getElementId()))
// {
residueGlyph = (GeneralGlyph) graphicalObject;
}
} else {
......@@ -415,10 +420,13 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species>
if (graphicalObject instanceof GeneralGlyph) {
if (Objects.equal(((GeneralGlyph) graphicalObject).getReference(), structurlaStateId)) {
if (((GeneralGlyph) graphicalObject).getListOfReferenceGlyphs().size() > 0) {
// find a reference to the alias in layout, so we know it's the proper value
// find a reference to the alias in layout, so we know it's the
// proper value
ReferenceGlyph referenceGlyph = ((GeneralGlyph) graphicalObject).getListOfReferenceGlyphs().get(0);
if (Objects.equal(referenceGlyph.getGlyph(), mr.getSpecies().getElementId())) {
// if (referenceGlyph.getGlyph().equals(mr.getSpecies().getElementId())) {
// if
// (referenceGlyph.getGlyph().equals(mr.getSpecies().getElementId()))
// {
residueGlyph = (GeneralGlyph) graphicalObject;
}
} else {
......
......@@ -126,9 +126,9 @@ public class ZIndexPopulator {
}
});
for (final Drawable bioEntity : sortedDrawables) {
if (bioEntity.getZ() == null) {
bioEntity.setZ(++maxZIndex);
for (final Drawable drawable : sortedDrawables) {
if (drawable.getZ() == null) {
drawable.setZ(++maxZIndex);
}
}
}
......
......@@ -51,7 +51,7 @@ public abstract class AbstractRegionModification extends ModificationResidue {
position = "Point2D[" + format.format(getPosition().getX()) + "," + format.format(getPosition().getY()) + "]";
}
String result = "[" + this.getClass().getSimpleName() + "]: " + getName() + "," + getWidth() + "," + getHeight()
+ "," + position;
+ "," + position + "," + getZ();
return result;
}
......@@ -64,8 +64,8 @@ public abstract class AbstractRegionModification extends ModificationResidue {
}
/**
* Update data in this object from parameter (only if values in parameter object
* are valid).
* Update data in this object from parameter (only if values in parameter
* object are valid).
*
* @param mr
* object from which we are updating data
......@@ -96,4 +96,10 @@ public abstract class AbstractRegionModification extends ModificationResidue {
public void setHeight(final double height) {
this.height = height;
}
@Override
public double getSize() {
return width * height;
}
}
\ No newline at end of file
......@@ -51,8 +51,13 @@ public abstract class AbstractSiteModification extends ModificationResidue {
positionString = "Point2D[" + format.format(getPosition().getX()) + "," + format.format(getPosition().getY())
+ "]";
}
String result = getName() + "," + getState() + "," + positionString;
String result = getName() + "," + getState() + "," + positionString + "," + getZ();
return result;
}
@Override
public double getSize() {
return 0;
}
}
\ No newline at end of file
......@@ -67,4 +67,5 @@ public class BindingRegion extends AbstractRegionModification implements Seriali
}
}
}
......@@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger;
import org.hibernate.annotations.Type;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.Drawable;
import lcsb.mapviewer.model.map.species.Species;
/**
......@@ -36,7 +37,7 @@ import lcsb.mapviewer.model.map.species.Species;
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "modification_type", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("GENERIC_MODIFICATION_RESIDUE")
public abstract class ModificationResidue implements Serializable {
public abstract class ModificationResidue implements Serializable, Drawable {
/**
*
......@@ -71,6 +72,9 @@ public abstract class ModificationResidue implements Serializable {
@Type(type = "lcsb.mapviewer.persist.mapper.Point2DMapper")
private Point2D position = null;
@Column(nullable = false)
private Integer z;
/**
* Species to which this modification belong to.
*/
......@@ -94,6 +98,7 @@ public abstract class ModificationResidue implements Serializable {
this.idModificationResidue = mr.idModificationResidue;
this.name = mr.name;
this.position = mr.position;
this.z = mr.z;
}
public ModificationResidue(final String modificationId) {
......@@ -180,4 +185,19 @@ public abstract class ModificationResidue implements Serializable {
throw new NotImplementedException();
}
@Override
public Integer getZ() {
return z;
}
@Override
public void setZ(Integer z) {
this.z = z;
}
@Override
public String getElementId() {
return getIdModificationResidue();
}
}
......@@ -379,6 +379,7 @@ public class ModelContructor {
Double x = state.getRelX() * species.getWidth() / 2 + species.getCenterX();
Double y = state.getRelY() * species.getHeight() / 2 + species.getCenterY();
mr.setPosition(new Point2D.Double(x, y));
mr.setZ(species.getZ());
}
} else if (state.getStructuralState() != null) {
if (species instanceof Protein) {
......
alter table structural_state_table add column z integer;
update structural_state_table set z = (select z from element_table where structural_state_id=structural_state_table.id);
update structural_state_table set z = (select z+1 from element_table where structural_state_id=structural_state_table.id);
update structural_state_table set z = 0 where z is null;
alter table structural_state_table alter column z set not null;
alter table modification_residue_table add column z integer;
update modification_residue_table set z = (select z+1 from element_table where element_table.id=modification_residue_table.id_species_db);
update modification_residue_table set z = 0 where z is null;
alter table modification_residue_table alter column z set not null;
......@@ -17,7 +17,7 @@ public abstract class PersistTestFunctions extends PersistTestFunctionsNoTransac
@Autowired
protected UserDao userDao;
protected User createUser() {
User user = new User();
user.setName("John");
......@@ -29,5 +29,4 @@ public abstract class PersistTestFunctions extends PersistTestFunctionsNoTransac
return user;
}
}
package lcsb.mapviewer.persist;
import java.awt.Color;
import java.awt.geom.Point2D;
import org.junit.Rule;
import org.junit.runner.RunWith;
......@@ -29,6 +30,10 @@ import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Ion;
import lcsb.mapviewer.model.map.species.Phenotype;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.map.species.field.CodingRegion;
import lcsb.mapviewer.model.map.species.field.ModificationSite;
import lcsb.mapviewer.model.map.species.field.ModificationState;
import lcsb.mapviewer.model.map.species.field.Residue;
@ContextConfiguration(classes = SpringPersistTestConfig.class)
@RunWith(SpringJUnit4ClassRunner.class)
......@@ -169,4 +174,28 @@ public class PersistTestFunctionsNoTransaction extends TestUtils {
return text;
}
protected ModificationSite createModificationSite() {
ModificationSite mr = new ModificationSite();
mr.setName("name");
mr.setState(ModificationState.DONT_CARE);
mr.setZ(z++);
return mr;
}
protected Residue createResidue() {
Residue mr = new Residue();
mr.setPosition(new Point2D.Double(10, 20));
mr.setName("name");
mr.setState(ModificationState.GLYCOSYLATED);
mr.setZ(z++);
return mr;
}
protected CodingRegion createCodingRegion() {
CodingRegion region = new CodingRegion();
region.setZ(z++);
return region;
}
}
\ No newline at end of file
......@@ -151,8 +151,7 @@ public class CommentDaoTest extends PersistTestFunctions {
alias = createProtein(264.8333333333335, 517.75, 86.0, 46.0, "pr1");
model.addElement(alias);
Residue mr = new Residue();
mr.setName("mr");
Residue mr = createResidue();
alias.addResidue(mr);
alias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "c"));
......
......@@ -6,8 +6,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.awt.geom.Point2D;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -38,7 +36,6 @@ import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.field.Residue;
import lcsb.mapviewer.persist.PersistTestFunctions;
import lcsb.mapviewer.persist.dao.ProjectDao;
......@@ -354,10 +351,7 @@ public class ModelDaoTest extends PersistTestFunctions {
alias = createProtein(264.8333333333335, 517.75, 86.0, 46.0, "pr1");
model.addElement(alias);
Residue mr = new Residue();
mr.setName("mr");
mr.setPosition(new Point2D.Double(10, 20));
alias.addResidue(mr);
alias.addResidue(createResidue());
alias.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "c"));
return model;
......
......@@ -27,7 +27,6 @@ import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.field.Residue;
import lcsb.mapviewer.persist.PersistTestFunctions;
import lcsb.mapviewer.persist.dao.ProjectDao;
......@@ -89,9 +88,7 @@ public class ProjectBackgroundDaoTest extends PersistTestFunctions {
Protein protein = createProtein(264.8333333333335, 517.75, 86.0, 46.0, "pr1");
model.addElement(protein);
Residue mr = new Residue();
mr.setName("mr");
protein.addResidue(mr);
protein.addResidue(createResidue());
protein.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CHEBI, "c"));
return model;
......
......@@ -69,7 +69,8 @@ public class AntisenseRnaTest extends PersistTestFunctions {
Model model = new ModelFullIndexed(null);
AntisenseRna species = createAntisenseRna("As");
species.addCodingRegion(new CodingRegion());
CodingRegion region = createCodingRegion();
species.addCodingRegion(region);
model.addElement(species);
return model;
......
......@@ -42,7 +42,6 @@ import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.field.ModificationSite;
import lcsb.mapviewer.model.map.species.field.ModificationState;
import lcsb.mapviewer.model.map.species.field.Residue;
import lcsb.mapviewer.model.map.species.field.Structure;
import lcsb.mapviewer.model.map.species.field.UniprotRecord;
......@@ -200,10 +199,7 @@ public class ElementDaoTest extends PersistTestFunctions {
@Test
public void testProtein() throws Exception {
Protein protein = createProtein(testIdAlias);
Residue mr = new Residue();
mr.setPosition(new Point2D.Double(10, 20));
mr.setName("name");
mr.setState(ModificationState.GLYCOSYLATED);
Residue mr = createResidue();
protein.addResidue(mr);
elementDao.add(protein);
......@@ -229,9 +225,7 @@ public class ElementDaoTest extends PersistTestFunctions {
@Test
public void testRna() throws Exception {
Rna sp = createRna(testIdAlias);
ModificationSite mr = new ModificationSite();
mr.setName("name");
mr.setState(ModificationState.DONT_CARE);
ModificationSite mr = createModificationSite();
sp.addModificationSite(mr);
elementDao.add(sp);
......@@ -258,8 +252,7 @@ public class ElementDaoTest extends PersistTestFunctions {
public void testAntisenseRna() throws Exception {
AntisenseRna sp = createAntisenseRna(testIdAlias);
ModificationSite mr = new ModificationSite();
mr.setName("name");
ModificationSite mr = createModificationSite();
sp.addModificationSite(mr);
elementDao.add(sp);
......@@ -387,7 +380,7 @@ public class ElementDaoTest extends PersistTestFunctions {
assertEquals("sa2", elements.get(2).getElementId());
}
@Test
public void testSearchWithInsideMatch() throws Exception {
Model map = new ModelFullIndexed(null);
......@@ -419,7 +412,7 @@ public class ElementDaoTest extends PersistTestFunctions {
public void testSearchClosestWithModifications() throws Exception {
Model map = new ModelFullIndexed(null);
Protein protein = createProtein(645.0, 220.5, 70.0, 25.0, "sa1");
protein.addResidue(new Residue());
protein.addResidue(createResidue());
map.addElement(protein);
modelDao.add(map);
......
......@@ -18,7 +18,6 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Protein;
import lcsb.mapviewer.model.map.species.field.Residue;
import lcsb.mapviewer.persist.DbUtils;
import lcsb.mapviewer.persist.PersistTestFunctionsNoTransaction;
import lcsb.mapviewer.persist.dao.map.ModelDao;
......@@ -49,7 +48,7 @@ public class ElementDaoTestSeparateTransaction extends PersistTestFunctionsNoTra
public void testSearchClosestWithModifications() throws Exception {
Model map = new ModelFullIndexed(null);
Protein protein = createProtein(645.0, 220.5, 70.0, 25.0, "sa1");
protein.addResidue(new Residue());
protein.addResidue(createResidue());
map.addElement(protein);
map.addElement(createProtein(645.0, 120.5, 70.0, 25.0, "sa2"));
......
......@@ -14,7 +14,6 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.map.species.field.CodingRegion;
import lcsb.mapviewer.persist.PersistTestFunctions;
import lcsb.mapviewer.persist.dao.ProjectDao;
......@@ -64,7 +63,7 @@ public class RnaTest extends PersistTestFunctions {
Model model = new ModelFullIndexed(null);
Rna rna = createRna("As");
rna.addCodingRegion(new CodingRegion());
rna.addCodingRegion(createCodingRegion());
model.addElement(rna);
return model;
......
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