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

Merge branch '1454-phenotype-reaction' into 'devel_15.1.x'

Resolve "Orthogonal reactions drawn wrongly when linking to phenotypes and drugs"

See merge request !1306
parents 349f410e 3cdc2b41
Pipeline #42923 failed with stage
in 25 minutes and 16 seconds
minerva (15.1.4) stable; urgency=medium
* Bug fix: structural state information data was not available for complexes
(#1476)
* Bug fix: orthogonal reactions to phenotypes from CellDesigner were drawn
incorrectly (#1454)
* Bug fix: orthogonal reactions to drugs from CellDesigner were drawn
incorrectly (#1454)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 30 Apr 2021 17:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 30 Apr 2021 18:00:00 +0200
minerva (15.1.3) stable; urgency=medium
* Bug fix: modifier reactions to phenotype were incorrectly translated to
......
package lcsb.mapviewer.converter.model.celldesigner.geometry;
import java.awt.*;
import java.awt.Shape;
import java.awt.geom.*;
import java.util.ArrayList;
import java.util.List;
import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor;
import lcsb.mapviewer.model.map.species.Element;
......@@ -37,7 +38,7 @@ public class DrugCellDesignerAliasConverter extends AbstractCellDesignerAliasCon
if (invalidAnchorPosition(alias, anchor)) {
return alias.getCenter();
}
ArrayList<Point2D> list = getDrugPoints(alias);
List<Point2D> list = getDrugPoints(alias);
return getPolygonTransformation().getPointOnPolygonByAnchor(list, anchor);
}
......@@ -54,23 +55,25 @@ public class DrugCellDesignerAliasConverter extends AbstractCellDesignerAliasCon
* alias for which we are looking for a border
* @return list of points defining border of the given alias
*/
protected ArrayList<Point2D> getDrugPoints(Species alias) {
ArrayList<Point2D> list = new ArrayList<Point2D>();
protected List<Point2D> getDrugPoints(Species alias) {
List<Point2D> list = new ArrayList<>();
double x = alias.getX();
double y = alias.getY();
double width = alias.getWidth();
double height = alias.getHeight();
double cutSize = width*1/5;
// CHECKSTYLE:OFF
list.add(new Point2D.Double(x, y + height / 2));
list.add(new Point2D.Double(x + width / 12, y));
list.add(new Point2D.Double(x + cutSize, y));
list.add(new Point2D.Double(x + width / 2, y));
list.add(new Point2D.Double(x + width * 11 / 12, y));
list.add(new Point2D.Double(x + width - cutSize, y));
list.add(new Point2D.Double(x + width, y + height / 2));
list.add(new Point2D.Double(x + width * 11 / 12, y + height));
list.add(new Point2D.Double(x + width - cutSize, y + height));
list.add(new Point2D.Double(x + width / 2, y + height));
list.add(new Point2D.Double(x + width / 12, y + height));
list.add(new Point2D.Double(x + cutSize, y + height));
// CHECKSTYLE:ON
return list;
}
......
......@@ -53,16 +53,18 @@ public class PhenotypeCellDesignerAliasConverter extends AbstractCellDesignerAli
double y = alias.getY();
double width = alias.getWidth();
double height = alias.getHeight();
double cutSize = Math.min(width, height)/2;
// CHECKSTYLE:OFF
list.add(new Point2D.Double(x, y + height / 2));
list.add(new Point2D.Double(x + width / 6, y));
list.add(new Point2D.Double(x + cutSize, y));
list.add(new Point2D.Double(x + width / 2, y));
list.add(new Point2D.Double(x + width * 5 / 6, y));
list.add(new Point2D.Double(x + width - cutSize, y));
list.add(new Point2D.Double(x + width, y + height / 2));
list.add(new Point2D.Double(x + width * 5 / 6, y + height));
list.add(new Point2D.Double(x + width - cutSize, y + height));
list.add(new Point2D.Double(x + width / 2, y + height));
list.add(new Point2D.Double(x + width / 6, y + height));
list.add(new Point2D.Double(x + cutSize, y + height));
// CHECKSTYLE:ON
return list;
}
......
......@@ -928,4 +928,21 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
assertEquals(2, model.getAuthors().size());
}
@Test
public void testOrthogonalReactionToPhenotype() throws Exception {
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().getBeginPoint().getY(), r.getProducts().get(0).getLine().getBeginPoint().getY(), Configuration.EPSILON);
}
@Test
public void testOrthogonalReactionToDrug() throws Exception {
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().getBeginPoint().getY(), r.getProducts().get(0).getLine().getBeginPoint().getY(), Configuration.EPSILON);
}
}
<?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:complexSpeciesAlias id="csa1" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="29.0" y="213.0" w="100.0" h="120.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:backupSize w="0.0" h="0.0"/>
<celldesigner:backupView state="none"/>
<celldesigner:structuralState angle="1.5707963267948966"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="100.0" height="120.0"/>
<celldesigner:singleLine width="2.0"/>
<celldesigner:paint color="fff7f7f7" 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="2.0"/>
<celldesigner:paint color="fff7f7f7" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:complexSpeciesAlias>
</celldesigner:listOfComplexSpeciesAliases>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa2" species="s3">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="219.0" y="46.0" w="375.0" h="74.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="375.0" height="74.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffff00ff" 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: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>COMPLEX</celldesigner:class>
<celldesigner:name>s1</celldesigner:name>
<celldesigner:state>
<celldesigner:listOfStructuralStates>
<celldesigner:structuralState structuralState="open"/>
</celldesigner:listOfStructuralStates>
</celldesigner:state>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
<species metaid="s3" id="s3" name="s3" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>DRUG</celldesigner:class>
<celldesigner:name>s3</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
<listOfReactions>
<reaction metaid="re3" id="re3" reversible="false">
<annotation>
<celldesigner:extension>
<celldesigner:reactionType>STATE_TRANSITION</celldesigner:reactionType>
<celldesigner:baseReactants>
<celldesigner:baseReactant species="s1" alias="csa1">
<celldesigner:linkAnchor position="ESE"/>
</celldesigner:baseReactant>
</celldesigner:baseReactants>
<celldesigner:baseProducts>
<celldesigner:baseProduct species="s3" alias="sa2">
<celldesigner:linkAnchor position="SSW"/>
</celldesigner:baseProduct>
</celldesigner:baseProducts>
<celldesigner:connectScheme connectPolicy="square" rectangleIndex="0">
<celldesigner:listOfLineDirection>
<celldesigner:lineDirection index="0" value="horizontal"/>
<celldesigner:lineDirection index="1" value="vertical"/>
</celldesigner:listOfLineDirection>
</celldesigner:connectScheme>
<celldesigner:editPoints>0.5937800642735791,0.49112656163645174</celldesigner:editPoints>
<celldesigner:line width="1.0" color="ff000000"/>
</celldesigner:extension>
</annotation>
<listOfReactants>
<speciesReference metaid="CDMT00008" species="s1">
<annotation>
<celldesigner:extension>
<celldesigner:alias>csa1</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfReactants>
<listOfProducts>
<speciesReference metaid="CDMT00009" species="s3">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa2</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfProducts>
</reaction>
</listOfReactions>
</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:complexSpeciesAlias id="csa1" species="s1">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="97.0" y="159.0" w="100.0" h="120.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:backupSize w="0.0" h="0.0"/>
<celldesigner:backupView state="none"/>
<celldesigner:structuralState angle="1.5707963267948966"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="100.0" height="120.0"/>
<celldesigner:singleLine width="2.0"/>
<celldesigner:paint color="fff7f7f7" 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="2.0"/>
<celldesigner:paint color="fff7f7f7" scheme="Color"/>
</celldesigner:briefView>
<celldesigner:info state="empty" angle="-1.5707963267948966"/>
</celldesigner:complexSpeciesAlias>
</celldesigner:listOfComplexSpeciesAliases>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="sa1" species="s2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="328.0" y="93.0" w="186.0" h="29.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="186.0" height="29.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffcc99ff" 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: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>COMPLEX</celldesigner:class>
<celldesigner:name>s1</celldesigner:name>
<celldesigner:state>
<celldesigner:listOfStructuralStates>
<celldesigner:structuralState structuralState="open"/>
</celldesigner:listOfStructuralStates>
</celldesigner:state>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
<species metaid="s2" id="s2" name="s2" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>PHENOTYPE</celldesigner:class>
<celldesigner:name>s2</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
<listOfReactions>
<reaction metaid="re2" id="re2" reversible="false">
<annotation>
<celldesigner:extension>
<celldesigner:reactionType>STATE_TRANSITION</celldesigner:reactionType>
<celldesigner:baseReactants>
<celldesigner:baseReactant species="s1" alias="csa1">
<celldesigner:linkAnchor position="ESE"/>
</celldesigner:baseReactant>
</celldesigner:baseReactants>
<celldesigner:baseProducts>
<celldesigner:baseProduct species="s2" alias="sa1">
<celldesigner:linkAnchor position="SSW"/>
</celldesigner:baseProduct>
</celldesigner:baseProducts>
<celldesigner:connectScheme connectPolicy="square" rectangleIndex="0">
<celldesigner:listOfLineDirection>
<celldesigner:lineDirection index="0" value="horizontal"/>
<celldesigner:lineDirection index="1" value="vertical"/>
</celldesigner:listOfLineDirection>
</celldesigner:connectScheme>
<celldesigner:editPoints>0.6790987148479515,0.46682293253418083</celldesigner:editPoints>
<celldesigner:line width="1.0" color="ff000000"/>
</celldesigner:extension>
</annotation>
<listOfReactants>
<speciesReference metaid="CDMT00006" species="s1">
<annotation>
<celldesigner:extension>
<celldesigner:alias>csa1</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfReactants>
<listOfProducts>
<speciesReference metaid="CDMT00007" species="s2">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa1</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfProducts>
</reaction>
</listOfReactions>
</model>
</sbml>
......@@ -64,12 +64,21 @@ public class PhenotypeConverter extends SpeciesConverter<Phenotype> {
private GeneralPath getPhenotypePath(final Phenotype phenotype) {
// CHECKSTYLE:OFF
GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD, 6);
path.moveTo(phenotype.getX() + phenotype.getWidth() / 6, phenotype.getY());
path.lineTo(phenotype.getX() + phenotype.getWidth() * 5 / 6, phenotype.getY());
path.lineTo(phenotype.getX() + phenotype.getWidth(), phenotype.getY() + phenotype.getHeight() / 2);
path.lineTo(phenotype.getX() + phenotype.getWidth() * 5 / 6, phenotype.getY() + phenotype.getHeight());
path.lineTo(phenotype.getX() + phenotype.getWidth() / 6, phenotype.getY() + phenotype.getHeight());
path.lineTo(phenotype.getX(), phenotype.getY() + phenotype.getHeight() / 2);
double x = phenotype.getX();
double y = phenotype.getY();
double width = phenotype.getWidth();
double height = phenotype.getHeight();
double cutSize = Math.min(width, height)/2;
path.moveTo(x, y + height / 2);
path.lineTo(x + cutSize, y);
path.lineTo(x + width - cutSize, y);
path.lineTo(x + width, y + height / 2);
path.lineTo(x + width - cutSize, y + height);
path.lineTo(x + cutSize, y + height);
// CHECKSTYLE:ON
path.closePath();
return path;
......
This diff is collapsed.
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