Commit 47ed2363 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

import of reaction with products/reactants that have no lines doesn't crash...

import of reaction with products/reactants that have no lines doesn't crash the system (autolayout for such reactions will be triggered)
parent 4a474119
......@@ -238,6 +238,7 @@ public class SbmlParser implements IConverter {
}
}
}
return true;
}
......
......@@ -30,7 +30,6 @@ import org.sbml.jsbml.ext.render.LocalStyle;
import org.sbml.jsbml.ext.render.RenderGroup;
import org.w3c.dom.Node;
import lcsb.mapviewer.common.XmlParser;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.InvalidStateException;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
......@@ -154,8 +153,8 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
}
PolylineData line = getLineFromReferenceGlyph(speciesRefernceGlyph);
if (line == null) {
throw new InvalidArgumentException("Line undefined for element " + minervaElement.getElementId()
if (line.length() == 0) {
logger.warn("Line undefined for element " + minervaElement.getElementId()
+ " in reaction " + reactionWithLayout.getElementId());
}
if (minervaNode instanceof Reactant) {
......@@ -450,6 +449,9 @@ public class SbmlReactionParser extends SbmlBioEntityParser {
line.addPoint(end);
}
}
if (line == null) {
return new PolylineData();
}
return line;
}
......
......@@ -248,4 +248,32 @@ public class SbmlReactionParserTest {
}
}
@Test
public void testParseReactionWithProductWithoutLayout() throws Exception {
try {
Model model = parser
.createModel(new ConverterParams().filename("testFiles/small/reaction/product_without_layout.xml"));
Reaction reaction = model.getReactions().iterator().next();
assertNotNull(reaction);
assertTrue(reaction instanceof Reaction);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testParseReactionWithReactantWithoutLayout() throws Exception {
try {
Model model = parser
.createModel(new ConverterParams().filename("testFiles/small/reaction/reactant_without_layout.xml"));
Reaction reaction = model.getReactions().iterator().next();
assertNotNull(reaction);
assertTrue(reaction instanceof Reaction);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created by minerva version Unknown on 2019-04-25 at 08:13:40 CEST with
JSBML version 1.4. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core"
layout:required="false" level="3" multi:required="true"
render:required="false" version="2"
xmlns:layout="http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
xmlns:render="http://www.sbml.org/sbml/level3/version1/render/version1">
<model id="A_comprehensive_Parkinsons_disease_map"
name="iron_metabolism_reaction">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<layout:listOfLayouts
xmlns:layout="http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<layout:layout layout:id="minerva_layout">
<render:listOfRenderInformation
xmlns:render="http://www.sbml.org/sbml/level3/version1/render/version1">
<render:renderInformation
render:id="minerva_definitions">
<render:listOfColorDefinitions>
<render:colorDefinition
render:id="color_FFF7F7F7" render:value="#F7F7F7FF" />
<render:colorDefinition
render:id="color_FF000000" render:value="#000000FF" />
<render:colorDefinition
render:id="color_FF9999FF" render:value="#9999FFFF" />
</render:listOfColorDefinitions>
<render:listOfLineEndings>
<render:lineEnding render:id="line_ending_NONE">
<render:g />
</render:lineEnding>
<render:lineEnding render:id="line_ending_OPEN">
<layout:boundingBox>
<layout:position layout:x="-12" layout:y="-6" />
<layout:dimensions layout:height="12"
layout:width="12" />
</layout:boundingBox>
<render:g>
<render:polygon>
<render:listOfElements>
<render:element render:x="0%" render:y="0%"
xsi:type="RenderPoint" />
<render:element render:x="100%" render:y="50%"
xsi:type="RenderPoint" />
<render:element render:x="0%" render:y="100%"
xsi:type="RenderPoint" />
<render:element render:x="100%" render:y="50%"
xsi:type="RenderPoint" />
</render:listOfElements>
</render:polygon>
</render:g>
</render:lineEnding>
</render:listOfLineEndings>
<render:listOfStyles>
<render:style render:idList="csa106">
<render:g render:fill="color_FFF7F7F7"
render:font-size="12" render:stroke-width="2.0">
<render:rectangle render:height="100%"
render:rx="0%" render:ry="0%" render:stroke="color_FF000000"
render:width="100%" render:x="0%" render:y="0%" />
</render:g>
</render:style>
<render:style render:idList="text_csa106">
<render:g render:text-anchor="middle"
render:vtext-anchor="middle" />
</render:style>
<render:style render:idList="sa10326">
<render:g render:fill="color_FF9999FF"
render:font-size="12" render:stroke-width="1.0">
<render:ellipse render:cx="50%" render:cy="50%"
render:rx="50%" render:ry="50%" render:stroke="color_FF000000" />
</render:g>
</render:style>
<render:style render:idList="text_sa10326">
<render:g render:text-anchor="middle"
render:vtext-anchor="middle" />
</render:style>
<render:style render:idList="node_1">
<render:g render:endHead="line_ending_NONE"
render:fill="color_FF000000" render:stroke="color_FF000000"
render:stroke-width="1.0" />
</render:style>
<render:style render:idList="node_2">
<render:g render:endHead="line_ending_OPEN"
render:fill="color_FF000000" render:stroke="color_FF000000"
render:stroke-width="1.0" />
</render:style>
<render:style render:idList="re4888_0">
<render:g render:fill="color_FF000000"
render:stroke="color_FF000000" render:stroke-width="1.0" />
</render:style>
</render:listOfStyles>
</render:renderInformation>
</render:listOfRenderInformation>
<layout:dimensions layout:height="4185"
layout:width="4665.500000000001" />
<layout:listOfCompartmentGlyphs>
<layout:compartmentGlyph
layout:compartment="default" layout:id="default_compartment">
<layout:boundingBox>
<layout:position layout:x="0" layout:y="0" />
<layout:dimensions layout:height="4185"
layout:width="4665.500000000001" />
</layout:boundingBox>
</layout:compartmentGlyph>
</layout:listOfCompartmentGlyphs>
<layout:listOfSpeciesGlyphs>
<layout:speciesGlyph layout:id="csa106"
layout:species="species_0">
<layout:boundingBox>
<layout:position layout:x="2247.5"
layout:y="2007" />
<layout:dimensions layout:height="171"
layout:width="103" />
</layout:boundingBox>
</layout:speciesGlyph>
<layout:speciesGlyph layout:id="sa10326"
layout:species="species_1">
<layout:boundingBox>
<layout:position layout:x="2378.000000000001"
layout:y="2072.166666666668" />
<layout:dimensions layout:height="40"
layout:width="40" />
</layout:boundingBox>
</layout:speciesGlyph>
</layout:listOfSpeciesGlyphs>
<layout:listOfReactionGlyphs>
<layout:reactionGlyph layout:id="re4888_0"
layout:reaction="re4888">
<layout:curve>
<layout:listOfCurveSegments>
<layout:curveSegment xsi:type="LineSegment">
<layout:start layout:x="2373.5803457559946"
layout:y="2092.167623163763" />
<layout:end layout:x="2398.000000000001"
layout:y="2092.166666666668" />
</layout:curveSegment>
</layout:listOfCurveSegments>
</layout:curve>
<layout:listOfSpeciesReferenceGlyphs>
<layout:speciesReferenceGlyph
layout:id="node_1" layout:role="substrate"
layout:speciesGlyph="csa106">
<layout:curve>
<layout:listOfCurveSegments>
<layout:curveSegment
xsi:type="LineSegment">
<layout:start layout:x="2373.5803457559946"
layout:y="2092.167623163763" />
<layout:end layout:x="2373.5804166076578"
layout:y="2092.4950049596146" />
</layout:curveSegment>
<layout:curveSegment
xsi:type="LineSegment">
<layout:start layout:x="2373.5804166076578"
layout:y="2092.4950049596146" />
<layout:end layout:x="2350.5" layout:y="2092.5" />
</layout:curveSegment>
</layout:listOfCurveSegments>
</layout:curve>
</layout:speciesReferenceGlyph>
<layout:speciesReferenceGlyph
layout:id="node_2" layout:role="product"
layout:speciesGlyph="sa10326">
<layout:curve />
</layout:speciesReferenceGlyph>
</layout:listOfSpeciesReferenceGlyphs>
</layout:reactionGlyph>
</layout:listOfReactionGlyphs>
<layout:listOfTextGlyphs>
<layout:textGlyph layout:id="text_csa106"
layout:originOfText="csa106" layout:text="labile iron pool">
<layout:boundingBox>
<layout:position layout:x="2247.5"
layout:y="2007" />
<layout:dimensions layout:height="171"
layout:width="103" />
</layout:boundingBox>
</layout:textGlyph>
<layout:textGlyph layout:id="text_sa10326"
layout:originOfText="sa10326" layout:text="Fe2+">
<layout:boundingBox>
<layout:position layout:x="2378.000000000001"
layout:y="2072.166666666668" />
<layout:dimensions layout:height="40"
layout:width="40" />
</layout:boundingBox>
</layout:textGlyph>
</layout:listOfTextGlyphs>
</layout:layout>
</layout:listOfLayouts>
<multi:listOfSpeciesTypes
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1">
<multi:speciesType
multi:id="minerva_species_type_Complex" multi:name="Complex"
sboTerm="SBO:0000297">
<multi:listOfSpeciesFeatureTypes>
<multi:speciesFeatureType
multi:id="minerva_position_to_compartment_Complex"
multi:name="Position to compartment" multi:occur="1">
<multi:listOfPossibleSpeciesFeatureValues>
<multi:possibleSpeciesFeatureValue
multi:id="minerva_position_to_compartment_Complex_0"
multi:name="NULL" />
<multi:possibleSpeciesFeatureValue
multi:id="minerva_position_to_compartment_Complex_1"
multi:name="inside" />
</multi:listOfPossibleSpeciesFeatureValues>
</multi:speciesFeatureType>
<multi:speciesFeatureType
multi:id="minerva_hypothetical_Complex" multi:name="Hypothetical"
multi:occur="1">
<multi:listOfPossibleSpeciesFeatureValues>
<multi:possibleSpeciesFeatureValue
multi:id="minerva_hypothetical_Complex_2" multi:name="true" />
</multi:listOfPossibleSpeciesFeatureValues>
</multi:speciesFeatureType>
<multi:speciesFeatureType
multi:id="minerva_activity_Complex" multi:name="Activity"
multi:occur="1">
<multi:listOfPossibleSpeciesFeatureValues>
<multi:possibleSpeciesFeatureValue
multi:id="minerva_activity_Complex_3" multi:name="false" />
</multi:listOfPossibleSpeciesFeatureValues>
</multi:speciesFeatureType>
</multi:listOfSpeciesFeatureTypes>
</multi:speciesType>
<multi:speciesType
multi:id="minerva_species_type_Ion" multi:name="Ion"
sboTerm="SBO:0000327">
<multi:listOfSpeciesFeatureTypes>
<multi:speciesFeatureType
multi:id="minerva_position_to_compartment_Ion"
multi:name="Position to compartment" multi:occur="1">
<multi:listOfPossibleSpeciesFeatureValues>
<multi:possibleSpeciesFeatureValue
multi:id="minerva_position_to_compartment_Ion_4"
multi:name="NULL" />
<multi:possibleSpeciesFeatureValue
multi:id="minerva_position_to_compartment_Ion_5"
multi:name="inside" />
</multi:listOfPossibleSpeciesFeatureValues>
</multi:speciesFeatureType>
<multi:speciesFeatureType
multi:id="minerva_activity_Ion" multi:name="Activity"
multi:occur="1">
<multi:listOfPossibleSpeciesFeatureValues>
<multi:possibleSpeciesFeatureValue
multi:id="minerva_activity_Ion_6" multi:name="false" />
</multi:listOfPossibleSpeciesFeatureValues>
</multi:speciesFeatureType>
</multi:listOfSpeciesFeatureTypes>
</multi:speciesType>
</multi:listOfSpeciesTypes>
<listOfUnitDefinitions>
<unitDefinition id="length" name="length">
<listOfUnits>
<unit exponent="1" kind="metre" multiplier="1" scale="0" />
</listOfUnits>
</unitDefinition>
<unitDefinition id="substance" name="substance">
<listOfUnits>
<unit exponent="1" kind="mole" multiplier="1" scale="0" />
</listOfUnits>
</unitDefinition>
<unitDefinition id="volume" name="volume">
<listOfUnits>
<unit exponent="1" kind="litre" multiplier="1" scale="0" />
</listOfUnits>
</unitDefinition>
<unitDefinition id="time" name="time">
<listOfUnits>
<unit exponent="1" kind="second" multiplier="1" scale="0" />
</listOfUnits>
</unitDefinition>
<unitDefinition id="area" name="area">
<listOfUnits>
<unit exponent="2" kind="metre" multiplier="1" scale="0" />
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment constant="false" id="default"
multi:isType="false" size="1" spatialDimensions="3">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<annotation>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:bqbiol="http://biomodels.net/biology-qualifiers/"
xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#">
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
</listOfCompartments>
<listOfSpecies>
<species boundaryCondition="false" compartment="default"
constant="false" hasOnlySubstanceUnits="false" id="species_0"
initialAmount="0" multi:speciesType="minerva_species_type_Complex"
name="labile iron pool" sboTerm="SBO:0000297">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<annotation>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:bqbiol="http://biomodels.net/biology-qualifiers/"
xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#">
<bqbiol:isDescribedBy>
<rdf:Bag>
<rdf:li rdf:resource="urn:miriam:pubmed:27293957" />
</rdf:Bag>
</bqbiol:isDescribedBy>
</rdf:Description>
</rdf:RDF>
</annotation>
<multi:listOfSpeciesFeatures>
<multi:speciesFeature
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
multi:occur="1"
multi:speciesFeatureType="minerva_position_to_compartment_Complex">
<multi:listOfSpeciesFeatureValues>
<multi:speciesFeatureValue
multi:value="minerva_position_to_compartment_Complex_1" />
</multi:listOfSpeciesFeatureValues>
</multi:speciesFeature>
<multi:speciesFeature
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
multi:occur="1"
multi:speciesFeatureType="minerva_hypothetical_Complex">
<multi:listOfSpeciesFeatureValues>
<multi:speciesFeatureValue
multi:value="minerva_hypothetical_Complex_2" />
</multi:listOfSpeciesFeatureValues>
</multi:speciesFeature>
<multi:speciesFeature
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
multi:occur="1"
multi:speciesFeatureType="minerva_activity_Complex">
<multi:listOfSpeciesFeatureValues>
<multi:speciesFeatureValue
multi:value="minerva_activity_Complex_3" />
</multi:listOfSpeciesFeatureValues>
</multi:speciesFeature>
</multi:listOfSpeciesFeatures>
</species>
<species boundaryCondition="false" compartment="default"
constant="false" hasOnlySubstanceUnits="false" id="species_1"
initialAmount="0" multi:speciesType="minerva_species_type_Ion"
name="Fe2+" sboTerm="SBO:0000327">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<annotation>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:bqbiol="http://biomodels.net/biology-qualifiers/"
xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#">
</rdf:Description>
</rdf:RDF>
</annotation>
<multi:listOfSpeciesFeatures>
<multi:speciesFeature
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
multi:occur="1"
multi:speciesFeatureType="minerva_position_to_compartment_Ion">
<multi:listOfSpeciesFeatureValues>
<multi:speciesFeatureValue
multi:value="minerva_position_to_compartment_Ion_5" />
</multi:listOfSpeciesFeatureValues>
</multi:speciesFeature>
<multi:speciesFeature
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
multi:occur="1" multi:speciesFeatureType="minerva_activity_Ion">
<multi:listOfSpeciesFeatureValues>
<multi:speciesFeatureValue
multi:value="minerva_activity_Ion_6" />
</multi:listOfSpeciesFeatureValues>
</multi:speciesFeature>
</multi:listOfSpeciesFeatures>
</species>
</listOfSpecies>
<listOfReactions>
<reaction id="re4888" reversible="false"
sboTerm="SBO:0000171">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<annotation>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#"
xmlns:bqbiol="http://biomodels.net/biology-qualifiers/"
xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#">
<bqbiol:isDescribedBy>
<rdf:Bag>
<rdf:li rdf:resource="urn:miriam:pubmed:26106291" />
</rdf:Bag>
</bqbiol:isDescribedBy>
<bqbiol:isDescribedBy>
<rdf:Bag>
<rdf:li rdf:resource="urn:miriam:pubmed:25231526" />
</rdf:Bag>
</bqbiol:isDescribedBy>
</rdf:Description>
</rdf:RDF>
</annotation>
<listOfReactants>
<speciesReference constant="false"
species="species_0" />
</listOfReactants>
<listOfProducts>
<speciesReference constant="false"
species="species_1" />
</listOfProducts>
</reaction>
</listOfReactions>
</model>
</sbml>
\ No newline at end of file
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<!-- Created by minerva version Unknown on 2019-04-25 at 08:13:40 CEST with
JSBML version 1.4. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core"
layout:required="false" level="3" multi:required="true"
render:required="false" version="2"
xmlns:layout="http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:multi="http://www.sbml.org/sbml/level3/version1/multi/version1"
xmlns:render="http://www.sbml.org/sbml/level3/version1/render/version1">
<model id="A_comprehensive_Parkinsons_disease_map"
name="iron_metabolism_reaction">
<notes>
<body xmlns="http://www.w3.org/1999/xhtml">
<p />
</body>
</notes>
<layout:listOfLayouts
xmlns:layout="http://www.sbml.org/sbml/level3/version1/layout/version1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<layout:layout layout:id="minerva_layout">
<render:listOfRenderInformation
xmlns:render="http://www.sbml.org/sbml/level3/version1/render/version1">
<render:renderInformation
render:id="minerva_definitions">
<render:listOfColorDefinitions>
<render:colorDefinition
render:id="color_FFF7F7F7" render:value="#F7F7F7FF" />
<render:colorDefinition
render:id="color_FF000000" render:value="#000000FF" />
<render:colorDefinition
render:id="color_FF9999FF" render:value="#9999FFFF" />
</render:listOfColorDefinitions>
<render:listOfLineEndings>
<render:lineEnding render:id="line_ending_NONE">
<render:g />
</render:lineEnding>
<render:lineEnding render:id="line_ending_OPEN">
<layout:boundingBox>
<layout:position layout:x="-12" layout:y="-6" />
<layout:dimensions layout:height="12"
layout:width="12" />
</layout:boundingBox>
<render:g>
<render:polygon>
<render:listOfElements>
<render:element render:x="0%" render:y="0%"
xsi:type="RenderPoint" />
<render:element render:x="100%" render:y="50%"
xsi:type="RenderPoint" />
<render:element render:x="0%" render:y="100%"
xsi:type="RenderPoint" />
<render:element render:x="100%" render:y="50%"
xsi:type="RenderPoint" />
</render:listOfElements>
</render:polygon>
</render:g>
</render:lineEnding>
</render:listOfLineEndings>
<render:listOfStyles>
<render:style render:idList="csa106">
<render:g render:fill="color_FFF7F7F7"
render:font-size="12" render:stroke-width="2.0">
<render:rectangle render:height="100%"
render:rx="0%" render:ry="0%" render:stroke="color_FF000000"
render:width="100%" render:x="0%" render:y="0%" />
</render:g>
</render:style>
<render:style render:idList="text_csa106">
<render:g render:text-anchor="middle"
render:vtext-anchor="middle" />