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

when there are multiple input operators in reaction one operator ends where the next start

parent d37e6e5d
...@@ -749,11 +749,9 @@ public class ReactionFromXml { ...@@ -749,11 +749,9 @@ public class ReactionFromXml {
inputOperator.setLine(ld); inputOperator.setLine(ld);
applyStylingToLine(new LineProperties(nodes.iterator().next().getLine()), ld); applyStylingToLine(new LineProperties(nodes.iterator().next().getLine()), ld);
inputOperator.addInputs(nodes); inputOperator.addInputs(nodes);
for (Reactant reactant : result.getReactants()) { for (AbstractNode node : nodes) {
if (!toExclude.contains(reactant)) { node.getLine().getEndPoint().setLocation(reactantAndOperatorBeginPoint.getX(),
reactant.getLine().getEndPoint().setLocation(reactantAndOperatorBeginPoint.getX(), reactantAndOperatorBeginPoint.getY());
reactantAndOperatorBeginPoint.getY());
}
} }
if (lineType != null) { if (lineType != null) {
inputOperator.getLine().setType(lineType); inputOperator.getLine().setType(lineType);
...@@ -935,26 +933,28 @@ public class ReactionFromXml { ...@@ -935,26 +933,28 @@ public class ReactionFromXml {
operator.addInputs(andOperator.getInputs()); operator.addInputs(andOperator.getInputs());
//operator line // operator line
PolylineData line = new PolylineData(); PolylineData line = new PolylineData();
line.addPoint(pointTransformation.copyPoint(product.getLine().getBeginPoint())); line.addPoint(pointTransformation.copyPoint(product.getLine().getBeginPoint()));
double secondX = (product.getLine().getPoints().get(1).getX() + product.getLine().getPoints().get(0).getX())*0.4; double secondX = (product.getLine().getPoints().get(1).getX() + product.getLine().getPoints().get(0).getX())
double secondY = (product.getLine().getPoints().get(1).getY() + product.getLine().getPoints().get(0).getY())*0.4; * 0.4;
double thirdX = (product.getLine().getPoints().get(1).getX() + product.getLine().getPoints().get(0).getX())*0.6; double secondY = (product.getLine().getPoints().get(1).getY() + product.getLine().getPoints().get(0).getY())
double thirdY = (product.getLine().getPoints().get(1).getY() + product.getLine().getPoints().get(0).getY())*0.6; * 0.4;
double thirdX = (product.getLine().getPoints().get(1).getX() + product.getLine().getPoints().get(0).getX()) * 0.6;
double thirdY = (product.getLine().getPoints().get(1).getY() + product.getLine().getPoints().get(0).getY()) * 0.6;
Point2D secondPoint = new Point2D.Double(secondX, secondY); Point2D secondPoint = new Point2D.Double(secondX, secondY);
Point2D thirdPoint = new Point2D.Double(thirdX, thirdY); Point2D thirdPoint = new Point2D.Double(thirdX, thirdY);
line.addPoint(pointTransformation.copyPoint(secondPoint)); line.addPoint(pointTransformation.copyPoint(secondPoint));
operator.setLine(line); operator.setLine(line);
//center line // center line
PolylineData centerLine = new PolylineData(); PolylineData centerLine = new PolylineData();
centerLine.addPoint(pointTransformation.copyPoint(secondPoint)); centerLine.addPoint(pointTransformation.copyPoint(secondPoint));
centerLine.addPoint(pointTransformation.copyPoint(thirdPoint)); centerLine.addPoint(pointTransformation.copyPoint(thirdPoint));
result.setLine(centerLine); result.setLine(centerLine);
//product line is not trimmed // product line is not trimmed
product.getLine().getPoints().get(0).setLocation(thirdPoint); product.getLine().getPoints().get(0).setLocation(thirdPoint);
result.addNode(operator); result.addNode(operator);
......
...@@ -19,6 +19,7 @@ import org.junit.Before; ...@@ -19,6 +19,7 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.converter.ConverterParams; import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerElementCollection;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions; import lcsb.mapviewer.converter.model.celldesigner.CellDesignerTestFunctions;
...@@ -884,47 +885,41 @@ public class ReactionParserTests extends CellDesignerTestFunctions { ...@@ -884,47 +885,41 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
NodeOperator operator2 = reaction.getOperators().get(1); NodeOperator operator2 = reaction.getOperators().get(1);
NodeOperator operator3 = reaction.getOperators().get(2); NodeOperator operator3 = reaction.getOperators().get(2);
// new NormalImageGenerator(1, 0, 0, 1024, 1024, model, true, false, 0, Product product1 = reaction.getProducts().get(0);
// false).saveToPNG("tmp.png"); Product product2 = reaction.getProducts().get(1);
// Desktop.getDesktop().open(new File("tmp.png"));
assertEquals(operator1.getLine().getPoints().get(0).distance(new Point2D.Double(287.0, 242.00000000000009)), 0, assertEquals(0, operator1.getLine().getPoints().get(0).distance(new Point2D.Double(287.0, 242.00000000000009)),
EPSILON); EPSILON);
assertEquals( assertEquals(0,
operator1.getLine().getPoints().get(1).distance(new Point2D.Double(287.97349260719136, 204.40292958328325)), operator1.getLine().getPoints().get(1).distance(new Point2D.Double(287.97349260719136, 204.40292958328325)),
0, EPSILON);
assertEquals(
operator1.getLine().getPoints().get(2).distance(new Point2D.Double(372.9868291110932, 203.8558964441427)), 0,
EPSILON); EPSILON);
assertEquals(0, operator1.getLine().getEndPoint().distance(operator2.getLine().getBeginPoint()), EPSILON);
assertEquals( assertEquals(0,
operator2.getLine().getPoints().get(0).distance(new Point2D.Double(359.1840955643148, 203.94471254019686)), 0, operator2.getLine().getPoints().get(0).distance(new Point2D.Double(359.1840955643148, 203.94471254019686)),
EPSILON); EPSILON);
assertEquals( assertEquals(0,
operator2.getLine().getPoints().get(1).distance(new Point2D.Double(372.9868291110932, 203.8558964441427)), 0, operator2.getLine().getPoints().get(1).distance(new Point2D.Double(372.9868291110932, 203.8558964441427)),
EPSILON); EPSILON);
assertEquals( assertEquals(0,
operator3.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)), operator3.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)),
0, EPSILON); EPSILON);
assertEquals( assertEquals(0,
operator3.getLine().getPoints().get(1).distance(new Point2D.Double(380.9866634960982, 203.80442011470782)), 0, operator3.getLine().getPoints().get(1).distance(new Point2D.Double(380.9866634960982, 203.80442011470782)),
EPSILON); EPSILON);
Product product1 = reaction.getProducts().get(0); assertEquals(0,
Product product2 = reaction.getProducts().get(1); product1.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)),
assertEquals(
product1.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)), 0,
EPSILON); EPSILON);
assertEquals(product1.getLine().getPoints().get(1).distance(new Point2D.Double(466.0, 203.25738697556727)), 0, assertEquals(0, product1.getLine().getPoints().get(1).distance(new Point2D.Double(466.0, 203.25738697556727)),
EPSILON); EPSILON);
assertEquals( assertEquals(0,
product2.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)), 0, product2.getLine().getPoints().get(0).distance(new Point2D.Double(394.78939704287654, 203.71560401865366)),
EPSILON); EPSILON);
assertEquals( assertEquals(0,
product2.getLine().getPoints().get(1).distance(new Point2D.Double(452.96894321929705, 107.00000000000001)), 0, product2.getLine().getPoints().get(1).distance(new Point2D.Double(452.96894321929705, 107.00000000000001)),
EPSILON); EPSILON);
} catch (Exception e) { } catch (Exception e) {
...@@ -1779,6 +1774,25 @@ public class ReactionParserTests extends CellDesignerTestFunctions { ...@@ -1779,6 +1774,25 @@ public class ReactionParserTests extends CellDesignerTestFunctions {
} }
} }
@Test
public void testHeterodimerWithAdditionalReactant() throws Exception {
Model model;
try {
model = getModelForFile("testFiles/reactions/heterodimer_association_with_additional_reactant.xml");
assertEquals(1, model.getReactions().size());
Reaction reaction = model.getReactions().iterator().next();
NodeOperator o1 = reaction.getOperators().get(0);
NodeOperator o2 = reaction.getOperators().get(1);
assertEquals(0, o1.getLine().getEndPoint().distance(o2.getLine().getBeginPoint()), Configuration.EPSILON);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test @Test
public void testProblematicDrawing() throws Exception { public void testProblematicDrawing() throws Exception {
Model model; Model model;
......
<?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="161.0" y="74.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" 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:speciesAlias id="sa2" species="s2">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="181.0" y="274.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" 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:speciesAlias id="sa3" species="s3">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="444.0" y="176.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" 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:speciesAlias id="sa4" species="s4">
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="271.0" y="13.0" w="80.0" h="40.0"/>
<celldesigner:font size="12"/>
<celldesigner:view state="usual"/>
<celldesigner:usualView>
<celldesigner:innerPosition x="0.0" y="0.0"/>
<celldesigner:boxSize width="80.0" height="40.0"/>
<celldesigner:singleLine width="1.0"/>
<celldesigner:paint color="ffccffcc" 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:protein id="pr1" name="s1" type="GENERIC"/>
<celldesigner:protein id="pr2" name="s2" type="GENERIC"/>
<celldesigner:protein id="pr3" name="s3" type="GENERIC"/>
<celldesigner:protein id="pr4" name="s4" type="GENERIC"/>
</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="CDMT00004" kind="mole"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="volume" id="volume" name="volume">
<listOfUnits>
<unit metaid="CDMT00005" kind="litre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="area" id="area" name="area">
<listOfUnits>
<unit metaid="CDMT00006" kind="metre" exponent="2"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="length" id="length" name="length">
<listOfUnits>
<unit metaid="CDMT00007" kind="metre"/>
</listOfUnits>
</unitDefinition>
<unitDefinition metaid="time" id="time" name="time">
<listOfUnits>
<unit metaid="CDMT00008" 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>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr1</celldesigner:proteinReference>
</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>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr2</celldesigner:proteinReference>
</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>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr3</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
<species metaid="s4" id="s4" name="s4" compartment="default" initialAmount="0">
<annotation>
<celldesigner:extension>
<celldesigner:positionToCompartment>inside</celldesigner:positionToCompartment>
<celldesigner:speciesIdentity>
<celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>pr4</celldesigner:proteinReference>
</celldesigner:speciesIdentity>
</celldesigner:extension>
</annotation>
</species>
</listOfSpecies>
<listOfReactions>
<reaction metaid="re2" id="re2" reversible="false">
<annotation>
<celldesigner:extension>
<celldesigner:reactionType>HETERODIMER_ASSOCIATION</celldesigner:reactionType>
<celldesigner:baseReactants>
<celldesigner:baseReactant species="s1" alias="sa1">
<celldesigner:linkAnchor position="INACTIVE"/>
</celldesigner:baseReactant>
<celldesigner:baseReactant species="s2" alias="sa2">
<celldesigner:linkAnchor position="INACTIVE"/>
</celldesigner:baseReactant>
</celldesigner:baseReactants>
<celldesigner:baseProducts>
<celldesigner:baseProduct species="s3" alias="sa3">
<celldesigner:linkAnchor position="INACTIVE"/>
</celldesigner:baseProduct>
</celldesigner:baseProducts>
<celldesigner:listOfReactantLinks>
<celldesigner:reactantLink reactant="s4" alias="sa4" targetLineIndex="2,0">
<celldesigner:linkAnchor position="INACTIVE"/>
<celldesigner:connectScheme connectPolicy="direct">
<celldesigner:listOfLineDirection>
<celldesigner:lineDirection index="0" value="unknown"/>
</celldesigner:listOfLineDirection>
</celldesigner:connectScheme>
<celldesigner:line width="1.0" color="ff000000" type="Straight"/>
</celldesigner:reactantLink>
</celldesigner:listOfReactantLinks>
<celldesigner:connectScheme connectPolicy="direct">
<celldesigner:listOfLineDirection>
<celldesigner:lineDirection arm="0" index="0" value="unknown"/>
<celldesigner:lineDirection arm="1" index="0" value="unknown"/>
<celldesigner:lineDirection arm="2" index="0" value="unknown"/>
</celldesigner:listOfLineDirection>
</celldesigner:connectScheme>
<celldesigner:editPoints num0="0" num1="0" num2="0" tShapeIndex="0">0.3416972140762462,0.3398093841642229</celldesigner:editPoints>
<celldesigner:line width="1.0" color="ff000000"/>
</celldesigner:extension>
</annotation>
<listOfReactants>
<speciesReference metaid="CDMT00009" species="s1">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa1</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
<speciesReference metaid="CDMT00010" species="s2">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa2</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
<speciesReference metaid="CDMT00011" species="s4">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa4</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfReactants>
<listOfProducts>
<speciesReference metaid="CDMT00012" species="s3">
<annotation>
<celldesigner:extension>
<celldesigner:alias>sa3</celldesigner:alias>
</celldesigner:extension>
</annotation>
</speciesReference>
</listOfProducts>
</reaction>
</listOfReactions>
</model>
</sbml>
Supports Markdown
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