Commit 61cc3462 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1063-import-sbgn-file' into 'devel_14.0.x'

Resolve "import of sbgn files"

See merge request minerva/core!1075
parents 88282e74 81e925a8
Pipeline #22670 failed with stage
in 19 minutes and 34 seconds
minerva (14.0.10) stable; urgency=medium
* Bug fix: reaction without ports in SBGN crashed upload (#1065)
-- Piotr Gawron <piotr.gawron@uni.lu> Tue, 27 Feb 2020 10:00:00 +0200
minerva (14.0.9) stable; urgency=medium
* Bug fix: simultanous export to SBML of more than one file could result in
500 Internal Server Error (#1110)
......
......@@ -456,16 +456,34 @@ public class SbgnmlXmlParser {
* @throws InvalidInputDataExecption
*/
private void parseArc(Arc a, Model model) throws InvalidInputDataExecption {
boolean processFound;
switch (ArcClazz.fromClazz(a.getClazz())) {
case CONSUMPTION:
Port arcTargetPort;
processFound = false;
Port arcTargetPort = null;
if (a.getTarget() instanceof Port) {
arcTargetPort = (Port) a.getTarget();
} else if (a.getSource() instanceof Port) {
logger.warn(getTag(a) + "Consumption is going from process");
arcTargetPort = (Port) a.getSource();
} else {
throw new InvalidInputDataExecption("[" + a.getId() + "]\tConsumption must be connected to a Port");
for (Process p : processes) {
if (p.getCentralPoint().equals(a.getTarget())) {
p.addReagentArc(a);
logger.warn(getTag(a) + "Invalid target port");
processFound = true;
break;
}
if (p.getCentralPoint().equals(a.getSource())) {
p.addProductArc(a);
logger.warn(getTag(a) + "Invalid source port");
processFound = true;
break;
}
}
if (!processFound) {
throw new InvalidInputDataExecption(getTag(a) + "Consumption must be connected to a Port");
}
}
for (Process p : processes) {
if (p.getCentralPoint().getPort().contains(arcTargetPort)) {
......@@ -475,7 +493,7 @@ public class SbgnmlXmlParser {
}
break;
case PRODUCTION:
boolean processFound = false;
processFound = false;
Port arcSourcePort = null;
if (a.getSource() instanceof Port) {
arcSourcePort = (Port) a.getSource();
......@@ -1316,7 +1334,7 @@ public class SbgnmlXmlParser {
return;
}
p.setProductsPort((Port) p.getProductArcs().get(0).getSource());
p.setProductsPort(getSourcePort(p.getProductArcs().get(0)));
if (p.getProductArcs().size() >= 2 && p.getReagentArcs().size() == 0) {
p.setReversible(true);
......@@ -1329,7 +1347,7 @@ public class SbgnmlXmlParser {
ports.add(getSourcePort(a));
}
if (ports.size() < 2) {
logger.warn("There is only one port used in process: " + p.getProductsPort().getId());
logger.warn("Ports are not used in process: " + p.getCentralPoint().getId());
}
if (p.getReagentsPort() == null && !p.getReagentArcs().isEmpty()) {
......@@ -1376,7 +1394,8 @@ public class SbgnmlXmlParser {
}
for (Arc a : p.getProductArcs()) {
if (getSourcePort(a).equals(p.getProductsPort()) && ports.size() == 2 || reaction.getProducts().size() == 0) {
if (Objects.equals(getSourcePort(a), p.getProductsPort()) && ports.size() == 2
|| reaction.getProducts().size() == 0) {
Product product = new Product();
product.setReaction(reaction);
Glyph target = getTargetGlyph(a);
......@@ -1462,12 +1481,12 @@ public class SbgnmlXmlParser {
return (Port) a.getTarget();
} else if (a.getSource() instanceof Port) {
return (Port) a.getSource();
} else if (a.getTarget() instanceof Glyph && ((Glyph) a.getTarget()).getPort().size()>0) {
} else if (a.getTarget() instanceof Glyph && ((Glyph) a.getTarget()).getPort().size() > 0) {
return ((Glyph) a.getTarget()).getPort().get(0);
} else if (a.getSource() instanceof Glyph && ((Glyph) a.getSource()).getPort().size()>0) {
} else if (a.getSource() instanceof Glyph && ((Glyph) a.getSource()).getPort().size() > 0) {
return ((Glyph) a.getSource()).getPort().get(0);
} else {
throw new InvalidArgumentException("Arc is not connected to port: " + a.getId());
return null;
}
}
......@@ -1476,12 +1495,12 @@ public class SbgnmlXmlParser {
return (Port) a.getSource();
} else if (a.getTarget() instanceof Port) {
return (Port) a.getTarget();
} else if (a.getSource() instanceof Glyph && ((Glyph) a.getSource()).getPort().size()>0) {
} else if (a.getSource() instanceof Glyph && ((Glyph) a.getSource()).getPort().size() > 0) {
return ((Glyph) a.getSource()).getPort().get(0);
} else if (a.getTarget() instanceof Glyph && ((Glyph) a.getTarget()).getPort().size()>0) {
} else if (a.getTarget() instanceof Glyph && ((Glyph) a.getTarget()).getPort().size() > 0) {
return ((Glyph) a.getTarget()).getPort().get(0);
} else {
throw new InvalidArgumentException("Arc is not connected to port: " + a.getId());
return null;
}
}
......
......@@ -187,5 +187,17 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
}
@Test
public void testReactionWithoutPort() throws Exception {
Converter converter = new SbgnmlXmlConverter();
Model model = converter.createModel(
new ConverterParams().filename("testFiles/sbgnmlParserTestFiles/sbgnmlFiles/reaction_without_port.sbgn"));
assertEquals(1, model.getReactions().size());
Reaction r = model.getReactions().iterator().next();
assertEquals(2, r.getReactants().size());
assertEquals(1, r.getProducts().size());
}
}
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<sbgn xmlns="http://sbgn.org/libsbgn/0.2">
<map language="process description">
<extension>
<renderInformation
xmlns="http://www.sbml.org/sbml/level3/version1/render/version1" id="renderInformation" program-name="sbgnviz" program-version="5.0.0" background-color="#00000000">
<listOfColorDefinitions>
<colorDefinition id="color_1" value="#f7f7f77f"/>
<colorDefinition id="color_2" value="#555555"/>
<colorDefinition id="color_3" value="#92c5deff"/>
<colorDefinition id="color_4" value="#d1e5f07f"/>
<colorDefinition id="color_5" value="#ffffffff"/>
</listOfColorDefinitions>
<listOfBackgroundImages/>
<listOfStyles>
<style id="nodef7f7f70.55555553.2514normalnormalHelvetica000none5050100100" id-list="nucleoplasm">
<g font-size="14" font-family="Helvetica" font-weight="normal" font-style="normal" font-color="#000" stroke="color_2" stroke-width="3.25" fill="color_1" background-fit="none" background-pos-x="50%" background-pos-y="50%" background-width="100%" background-height="100%"/>
</style>
<style id="node92c5de15555551.2511normalnormalHelvetica000none5050100100" id-list="http___www.reactome.org_biopax_48887Protein1270 http___www.reactome.org_biopax_48887Protein1269 http___www.reactome.org_biopax_48887Protein1270_http___www.reactome.org_biopax_48887Complex2699 http___www.reactome.org_biopax_48887Protein1269_http___www.reactome.org_biopax_48887Complex2699">
<g font-size="11" font-family="Helvetica" font-weight="normal" font-style="normal" font-color="#000" stroke="color_2" stroke-width="1.25" fill="color_3" background-fit="none" background-pos-x="50%" background-pos-y="50%" background-width="100%" background-height="100%"/>
</style>
<style id="noded1e5f00.55555551.259boldnormalHelvetica000none5050100100" id-list="http___www.reactome.org_biopax_48887Complex2699">
<g font-size="9" font-family="Helvetica" font-weight="bold" font-style="normal" font-color="#000" stroke="color_2" stroke-width="1.25" fill="color_4" background-fit="none" background-pos-x="50%" background-pos-y="50%" background-width="100%" background-height="100%"/>
</style>
<style id="nodeffffff15555551.25none5050100100" id-list="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT">
<g stroke="color_2" stroke-width="1.25" fill="color_5" background-fit="none" background-pos-x="50%" background-pos-y="50%" background-width="100%" background-height="100%"/>
</style>
<style id="edge5555551.25" id-list="http___www.reactome.org_biopax_48887Protein1269-http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT http___www.reactome.org_biopax_48887Protein1270-http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT-http___www.reactome.org_biopax_48887Complex2699">
<g stroke="color_2" stroke-width="1.25"/>
</style>
</listOfStyles>
</renderInformation>
<mapProperties>
<compoundPadding>10</compoundPadding>
<extraCompartmentPadding>14</extraCompartmentPadding>
<extraComplexPadding>10</extraComplexPadding>
<arrowScale>1.25</arrowScale>
<showComplexName>true</showComplexName>
<dynamicLabelSize>regular</dynamicLabelSize>
<inferNestingOnLoad>false</inferNestingOnLoad>
<fitLabelsToNodes>false</fitLabelsToNodes>
<fitLabelsToInfoboxes>false</fitLabelsToInfoboxes>
<recalculateLayoutOnComplexityManagement>true</recalculateLayoutOnComplexityManagement>
<rearrangeOnComplexityManagement>true</rearrangeOnComplexityManagement>
<animateOnDrawingChanges>true</animateOnDrawingChanges>
<adjustNodeLabelFontSizeAutomatically>false</adjustNodeLabelFontSizeAutomatically>
<enablePorts>true</enablePorts>
<enableSIFTopologyGrouping>false</enableSIFTopologyGrouping>
<allowCompoundNodeResize>false</allowCompoundNodeResize>
<mapColorScheme>opposed_red_blue</mapColorScheme>
<mapColorSchemeStyle>solid</mapColorSchemeStyle>
<mapName>ATM mediated phosphorylation of repair proteins</mapName>
<mapDescription>Following the detection of DSBs, ATM mediates the phosphorylation of proteins involved in DNA repair (Thompson and Schild, 2002)</mapDescription>
<defaultInfoboxHeight>12</defaultInfoboxHeight>
<defaultInfoboxWidth>30</defaultInfoboxWidth>
<rearrangeAfterExpandCollapse>true</rearrangeAfterExpandCollapse>
</mapProperties>
</extension>
<glyph id="nucleoplasm" class="compartment">
<label text="nucleoplasm"/>
<bbox x="226.68870256893706" y="35.66109966758765" w="238.40088182291336" h="170.71861079657222"/>
</glyph>
<glyph id="http___www.reactome.org_biopax_48887Protein1269" class="macromolecule" compartmentRef="nucleoplasm">
<label text="RAD50"/>
<bbox x="295.06520988210997" y="37.28609966758765" w="48" h="35"/>
</glyph>
<glyph id="http___www.reactome.org_biopax_48887Protein1270" class="macromolecule" compartmentRef="nucleoplasm">
<label text="MRE11A"/>
<bbox x="228.31370256893703" y="106.28106840878256" w="48" h="35"/>
</glyph>
<glyph id="http___www.reactome.org_biopax_48887Complex2699" class="complex" compartmentRef="nucleoplasm">
<label text="RAD50:MRE11 complex"/>
<bbox x="345.16458439185044" y="156.50471046415987" w="108.30000000000001" h="38.25"/>
<glyph id="http___www.reactome.org_biopax_48887Protein1269_http___www.reactome.org_biopax_48887Complex2699" class="macromolecule">
<label text="RAD50"/>
<bbox x="346.7895843918504" y="158.12971046415987" w="48" h="35"/>
</glyph>
<glyph id="http___www.reactome.org_biopax_48887Protein1270_http___www.reactome.org_biopax_48887Complex2699" class="macromolecule">
<label text="MRE11A"/>
<bbox x="403.8395843918504" y="158.12971046415987" w="48" h="35"/>
</glyph>
</glyph>
<glyph id="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT" class="process" compartmentRef="nucleoplasm">
<bbox x="314.34209793937094" y="109.65758942422164" w="15" h="15"/>
</glyph>
<arc id="http___www.reactome.org_biopax_48887Protein1269-http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT" class="consumption" source="http___www.reactome.org_biopax_48887Protein1269" target="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT">
<start x="319.8721666540941" y="72.91109966758765"/>
<end x="321.4803586967574" y="109.03258942422164"/>
</arc>
<arc id="http___www.reactome.org_biopax_48887Protein1270-http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT" class="consumption" source="http___www.reactome.org_biopax_48887Protein1270" target="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT">
<start x="276.93870256893706" y="121.43521864300226"/>
<end x="313.71709793937094" y="117.93160076826082"/>
</arc>
<arc id="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT-http___www.reactome.org_biopax_48887Complex2699" class="production" source="http___www.reactome.org_biopax_48887BiochemicalReaction2203LEFT_TO_RIGHT" target="http___www.reactome.org_biopax_48887Complex2699">
<start x="329.96709793937094" y="123.28990820220366"/>
<end x="357.40309319338877" y="143.9971412962147"/>
</arc>
</map>
</sbgn>
\ No newline at end of file
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