Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
0a6df492
Commit
0a6df492
authored
Feb 25, 2020
by
Piotr Gawron
Browse files
handle af reactions in pd sbgn
parent
8570b8df
Changes
5
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
0a6df492
...
...
@@ -18,6 +18,9 @@ minerva (14.0.9) stable; urgency=medium
crashed
(#
1063
)
*
Bug
fix
:
when
SBGN
file
contained
reaction
where
every
node
started
in
the
same
process
port
minerva
crashed
crashed
(#
1063
)
*
Bug
fix
:
activity
flow
reaction
inside
SBGN
PD
caused
upload
of
map
to
crash
*
Bug
fix
:
reaction
without
product
in
SBGN
crashed
upload
of
map
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Mon
,
3
Feb
2020
15
:
00
:
00
+
0200
...
...
converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java
View file @
0a6df492
...
...
@@ -61,14 +61,22 @@ public class SbgnmlXmlParser {
* Default class logger.
*/
private
Logger
logger
=
LogManager
.
getLogger
(
SbgnmlXmlParser
.
class
.
getName
());
/**
* List of all processes to be parsed.
*/
private
List
<
Process
>
processes
=
new
ArrayList
<
Process
>();
/**
* List of all arcs that should be translated as activity flow reactions.
*/
private
List
<
Arc
>
activityFlowArcs
=
new
ArrayList
<>();
/**
* List of all logic operator glyphs parsed so far.
*/
private
List
<
Glyph
>
logicOperators
=
new
ArrayList
<
Glyph
>();
/**
* List of all logic arcs parsed so far.
*/
...
...
@@ -130,6 +138,15 @@ public class SbgnmlXmlParser {
}
}
for
(
Arc
arc
:
activityFlowArcs
)
{
try
{
Reaction
r
=
createActivityFlowReaction
(
arc
,
model
);
model
.
addReaction
(
r
);
}
catch
(
Exception
e
)
{
throw
new
InvalidInputDataExecption
(
"Unable to parse the reaction: "
+
arc
.
getId
(),
e
);
}
}
for
(
Element
element
:
model
.
getElements
())
{
if
(
element
.
getCompartment
()
==
null
)
{
Compartment
parent
=
null
;
...
...
@@ -149,6 +166,52 @@ public class SbgnmlXmlParser {
return
model
;
}
private
Reaction
createActivityFlowReaction
(
Arc
arc
,
Model
model
)
{
Reaction
result
;
switch
(
ArcClazz
.
fromClazz
(
arc
.
getClazz
()))
{
case
PRODUCTION:
logger
.
warn
(
getTag
(
arc
)
+
"Activity flow arc type is invalid. Changing to "
+
StateTransitionReaction
.
class
.
getSimpleName
());
result
=
new
StateTransitionReaction
(
arc
.
getId
());
break
;
default
:
throw
new
InvalidArgumentException
(
"Don't know how to translate to activity flow reaction"
);
}
List
<
Point2D
>
pointList
=
getLinePoints
(
arc
);
List
<
Point2D
>
reactantPoints
=
new
ArrayList
<>();
List
<
Point2D
>
centerPoints
=
new
ArrayList
<>();
List
<
Point2D
>
productPoints
=
new
ArrayList
<>();
if
(
pointList
.
size
()
>
3
)
{
reactantPoints
.
addAll
(
pointList
.
subList
(
0
,
pointList
.
size
()
/
2
));
centerPoints
.
addAll
(
pointList
.
subList
(
pointList
.
size
()
/
2
-
1
,
pointList
.
size
()
/
2
+
1
));
productPoints
.
addAll
(
pointList
.
subList
(
pointList
.
size
()
/
2
,
pointList
.
size
()
+
1
));
}
else
{
reactantPoints
.
add
(
pointList
.
get
(
0
));
reactantPoints
.
add
(
new
PointTransformation
().
getPointOnLine
(
pointList
.
get
(
0
),
pointList
.
get
(
1
),
0.3
));
centerPoints
.
add
(
new
PointTransformation
().
getPointOnLine
(
pointList
.
get
(
0
),
pointList
.
get
(
1
),
0.3
));
centerPoints
.
add
(
new
PointTransformation
().
getPointOnLine
(
pointList
.
get
(
0
),
pointList
.
get
(
1
),
0.7
));
productPoints
.
add
(
new
PointTransformation
().
getPointOnLine
(
pointList
.
get
(
0
),
pointList
.
get
(
1
),
0.7
));
for
(
int
i
=
1
;
i
<
pointList
.
size
();
i
++)
{
productPoints
.
add
(
pointList
.
get
(
i
));
}
}
Glyph
source
=
getSourceGlyph
(
arc
);
Reactant
reactant
=
new
Reactant
(
model
.
getElementByElementId
(
source
.
getId
()));
reactant
.
setLine
(
new
PolylineData
(
reactantPoints
));
result
.
addReactant
(
reactant
);
Glyph
target
=
getTargetGlyph
(
arc
);
Product
product
=
new
Product
(
model
.
getElementByElementId
(
target
.
getId
()));
product
.
setLine
(
parseLine
(
arc
,
productPoints
));
result
.
addProduct
(
product
);
result
.
setLine
(
new
PolylineData
(
centerPoints
));
return
result
;
}
/**
* Method used to adjust the size of elements that have their size represented
* different in the SBGN-ML file. Adjusted elements: Source and Sink / Degraded
...
...
@@ -399,7 +462,7 @@ public class SbgnmlXmlParser {
if
(
a
.
getTarget
()
instanceof
Port
)
{
arcTargetPort
=
(
Port
)
a
.
getTarget
();
}
else
if
(
a
.
getSource
()
instanceof
Port
)
{
logger
.
warn
(
"["
+
a
.
getId
(
)
+
"
]\t
Consumption is going from process"
);
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"
);
...
...
@@ -412,7 +475,17 @@ public class SbgnmlXmlParser {
}
break
;
case
PRODUCTION:
Port
arcSourcePort
=
(
Port
)
a
.
getSource
();
Port
arcSourcePort
;
if
(
a
.
getSource
()
instanceof
Port
)
{
arcSourcePort
=
(
Port
)
a
.
getSource
();
}
else
if
(
a
.
getTarget
()
instanceof
Port
)
{
logger
.
warn
(
"["
+
a
.
getId
()
+
"]\tProduction is going to process"
);
arcSourcePort
=
(
Port
)
a
.
getTarget
();
}
else
{
logger
.
warn
(
getTag
(
a
)
+
"Activity flow reaction found in PD"
);
activityFlowArcs
.
add
(
a
);
break
;
}
for
(
Process
p
:
processes
)
{
if
(
p
.
getCentralPoint
().
getPort
().
contains
(
arcSourcePort
))
{
p
.
addProductArc
(
a
);
...
...
@@ -490,6 +563,14 @@ public class SbgnmlXmlParser {
}
}
private
String
getTag
(
Arc
arc
)
{
return
"["
+
ArcClazz
.
fromClazz
(
arc
.
getClazz
())
+
"; "
+
arc
.
getId
()
+
"]\t"
;
}
private
String
getTag
(
Process
process
)
{
return
"["
+
process
.
getClass
()
+
"; "
+
process
.
getCentralPoint
().
getId
()
+
"]\t"
;
}
/**
* Method used to parse arc going to or from a phenotype.
*
...
...
@@ -1212,8 +1293,8 @@ public class SbgnmlXmlParser {
*/
private
void
parseProcess
(
Process
p
,
Model
model
)
throws
Exception
{
if
(
p
.
getProductArcs
().
isEmpty
())
{
throw
new
InvalidArgumentException
(
p
.
getCentralPoint
().
getId
()
+
": The process must have at least one outgoing arc."
)
;
logger
.
warn
(
getTag
(
p
)
+
"The process must have at least one outgoing arc."
);
return
;
}
p
.
setProductsPort
((
Port
)
p
.
getProductArcs
().
get
(
0
).
getSource
());
...
...
@@ -1394,6 +1475,16 @@ public class SbgnmlXmlParser {
}
}
private
Glyph
getTargetGlyph
(
Arc
a
)
{
if
(
a
.
getTarget
()
instanceof
Glyph
)
{
return
(
Glyph
)
a
.
getTarget
();
}
else
if
(
a
.
getSource
()
instanceof
Glyph
)
{
return
(
Glyph
)
a
.
getSource
();
}
else
{
throw
new
InvalidArgumentException
(
"Arc is not connected to glyph: "
+
a
.
getId
());
}
}
/**
* Returns {@link ArrowTypeData} based on given {@link ArcClazz}.
*
...
...
converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParserTest2.java
View file @
0a6df492
...
...
@@ -147,4 +147,29 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
}
@Test
public
void
testActivityFlowReactionInPd
()
throws
Exception
{
Converter
converter
=
new
SbgnmlXmlConverter
();
Model
model
=
converter
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/sbgnmlParserTestFiles/sbgnmlFiles/af_in_pd.sbgn"
));
assertEquals
(
1
,
model
.
getReactions
().
size
());
Reaction
r
=
model
.
getReactions
().
iterator
().
next
();
assertEquals
(
1
,
r
.
getReactants
().
size
());
assertEquals
(
1
,
r
.
getProducts
().
size
());
assertNotNull
(
r
.
getLine
());
}
@Test
public
void
testReactionWithoutProduct
()
throws
Exception
{
Converter
converter
=
new
SbgnmlXmlConverter
();
Model
model
=
converter
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/sbgnmlParserTestFiles/sbgnmlFiles/reaction_without_product.sbgn"
));
assertEquals
(
0
,
model
.
getReactions
().
size
());
}
}
converter-SBGNML/testFiles/sbgnmlParserTestFiles/sbgnmlFiles/af_in_pd.sbgn
0 → 100644
View file @
0a6df492
<?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=
"#ffcc99ff"
/>
<colorDefinition
id=
"color_2"
value=
"#000000"
/>
<colorDefinition
id=
"color_3"
value=
"#ffff99ff"
/>
<colorDefinition
id=
"color_4"
value=
"#ff6600"
/>
</listOfColorDefinitions>
<listOfBackgroundImages>
<backgroundImage
id=
"image_1"
value=
"http://newteditor.org/color-scheme-images/pg5_3d.png"
/>
</listOfBackgroundImages>
<listOfStyles>
<style
id=
"nodeFFCC991000000112normalnormalHelvetica000image_1cover5050"
id-list=
"n9"
>
<g
font-size=
"12"
font-family=
"Helvetica"
font-weight=
"normal"
font-style=
"normal"
font-color=
"#000"
stroke=
"color_2"
stroke-width=
"1"
fill=
"color_1"
background-image=
"image_1"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"nodeFFFF991FF6600112normalnormalHelvetica000image_1cover5050"
id-list=
"n12"
>
<g
font-size=
"12"
font-family=
"Helvetica"
font-weight=
"normal"
font-style=
"normal"
font-color=
"#000"
stroke=
"color_4"
stroke-width=
"1"
fill=
"color_3"
background-image=
"image_1"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"edge0000001"
id-list=
"e4"
>
<g
stroke=
"color_2"
stroke-width=
"1"
/>
</style>
</listOfStyles>
</renderInformation>
<mapProperties>
<compoundPadding>
20
</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>
false
</enablePorts>
<enableSIFTopologyGrouping>
false
</enableSIFTopologyGrouping>
<allowCompoundNodeResize>
false
</allowCompoundNodeResize>
<mapColorScheme>
opposed_purple_green
</mapColorScheme>
<mapColorSchemeStyle>
3D
</mapColorSchemeStyle>
<mapName>
Pathway #sbgn-network-container-0
</mapName>
<mapDescription/>
<defaultInfoboxHeight>
12
</defaultInfoboxHeight>
<defaultInfoboxWidth>
8
</defaultInfoboxWidth>
<rearrangeAfterExpandCollapse>
true
</rearrangeAfterExpandCollapse>
</mapProperties>
</extension>
<glyph
id=
"n9"
class=
"macromolecule"
>
<label
text=
"C3a"
/>
<bbox
x=
"1249.1849"
y=
"857.0031"
w=
"80"
h=
"33"
/>
</glyph>
<glyph
id=
"n12"
class=
"macromolecule"
>
<label
text=
"C3AR1"
/>
<bbox
x=
"1249.1849"
y=
"932.5061"
w=
"80"
h=
"40"
/>
</glyph>
<arc
id=
"e4"
class=
"production"
source=
"n9"
target=
"n12"
>
<start
x=
"1289.1849"
y=
"890.5031"
/>
<end
x=
"1289.1849"
y=
"929.5061"
/>
</arc>
</map>
</sbgn>
\ No newline at end of file
converter-SBGNML/testFiles/sbgnmlParserTestFiles/sbgnmlFiles/reaction_without_product.sbgn
0 → 100644
View file @
0a6df492
<?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=
"#ffffffff"
/>
<colorDefinition
id=
"color_2"
value=
"#000000"
/>
<colorDefinition
id=
"color_3"
value=
"#ffcc99ff"
/>
</listOfColorDefinitions>
<listOfBackgroundImages>
<backgroundImage
id=
"image_1"
value=
"http://newteditor.org/color-scheme-images/bw1_3d.png"
/>
<backgroundImage
id=
"image_2"
value=
"http://newteditor.org/color-scheme-images/pg5_3d.png"
/>
<backgroundImage
id=
"image_3"
value=
"http://newteditor.org/color-scheme-images/pg4_3d.png"
/>
</listOfBackgroundImages>
<listOfStyles>
<style
id=
"nodeFFFFFF1000000114image_1cover5050"
id-list=
"n42"
>
<g
font-size=
"14"
stroke=
"color_2"
stroke-width=
"1"
fill=
"color_1"
background-image=
"image_1"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"nodeFFFFFF1000000112normalnormalHelvetica000image_2cover5050"
id-list=
"n43::n0"
>
<g
font-size=
"12"
font-family=
"Helvetica"
font-weight=
"normal"
font-style=
"normal"
font-color=
"#000"
stroke=
"color_2"
stroke-width=
"1"
fill=
"color_1"
background-image=
"image_2"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"nodeFFCC991000000112normalnormalHelvetica000image_2cover5050"
id-list=
"n23 n44 n43::n1"
>
<g
font-size=
"12"
font-family=
"Helvetica"
font-weight=
"normal"
font-style=
"normal"
font-color=
"#000"
stroke=
"color_2"
stroke-width=
"1"
fill=
"color_3"
background-image=
"image_2"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"nodeFFFFFF1000000112normalnormalHelvetica000image_3cover5050"
id-list=
"n43"
>
<g
font-size=
"12"
font-family=
"Helvetica"
font-weight=
"normal"
font-style=
"normal"
font-color=
"#000"
stroke=
"color_2"
stroke-width=
"1"
fill=
"color_1"
background-image=
"image_3"
background-fit=
"cover"
background-pos-x=
"50%"
background-pos-y=
"50%"
/>
</style>
<style
id=
"edge0000001"
id-list=
"e16 e144 e143"
>
<g
stroke=
"color_2"
stroke-width=
"1"
/>
</style>
</listOfStyles>
</renderInformation>
<mapProperties>
<compoundPadding>
20
</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>
false
</enablePorts>
<enableSIFTopologyGrouping>
false
</enableSIFTopologyGrouping>
<allowCompoundNodeResize>
false
</allowCompoundNodeResize>
<mapColorScheme>
opposed_purple_green
</mapColorScheme>
<mapColorSchemeStyle>
3D
</mapColorSchemeStyle>
<mapName>
Pathway #sbgn-network-container-0
</mapName>
<mapDescription/>
<defaultInfoboxHeight>
12
</defaultInfoboxHeight>
<defaultInfoboxWidth>
8
</defaultInfoboxWidth>
<rearrangeAfterExpandCollapse>
true
</rearrangeAfterExpandCollapse>
</mapProperties>
</extension>
<glyph
id=
"n42"
class=
"process"
>
<bbox
x=
"1394.876"
y=
"79.73557"
w=
"9"
h=
"9"
/>
<port
id=
"n42.1"
x=
"1390.376"
y=
"84.23557"
/>
<port
id=
"n42.2"
x=
"1408.376"
y=
"84.23557"
/>
</glyph>
<glyph
id=
"n23"
class=
"macromolecule"
>
<label
text=
"C3(H2O)"
/>
<bbox
x=
"1278.7437"
y=
"67.73558"
w=
"80"
h=
"33"
/>
</glyph>
<glyph
id=
"n43"
class=
"complex"
>
<label
text=
"LABEL"
/>
<bbox
x=
"1357.6849"
y=
"165.34087"
w=
"83"
h=
"83"
/>
<glyph
id=
"n43::n0"
class=
"macromolecule"
>
<label
text=
"C3(H2O)"
/>
<bbox
x=
"1359.1849"
y=
"166.84087"
w=
"80"
h=
"40"
/>
</glyph>
<glyph
id=
"n43::n1"
class=
"macromolecule"
>
<label
text=
"CFB"
/>
<bbox
x=
"1359.1849"
y=
"206.84087"
w=
"80"
h=
"40"
/>
</glyph>
</glyph>
<glyph
id=
"n44"
class=
"macromolecule"
>
<label
text=
"CFB"
/>
<bbox
x=
"1438.376"
y=
"64.23558"
w=
"106"
h=
"40"
/>
</glyph>
<arc
id=
"e16"
class=
"consumption"
source=
"n43"
target=
"n42.1"
>
<start
x=
"1399.0247443657386"
y=
"153.84087"
/>
<next
x=
"1399.0116"
y=
"149.4910299999948"
/>
<next
x=
"1399.3760000000002"
y=
"149.49102999992817"
/>
<end
x=
"1399.376"
y=
"93.73557"
/>
</arc>
<arc
id=
"e144"
class=
"consumption"
source=
"n44"
target=
"n42.1"
>
<start
x=
"1437.876"
y=
"84.2355741847826"
/>
<end
x=
"1408.876"
y=
"84.23557103260869"
/>
</arc>
<arc
id=
"e143"
class=
"consumption"
source=
"n23"
target=
"n42.1"
>
<start
x=
"1359.2437"
y=
"84.23557497719897"
/>
<end
x=
"1389.876"
y=
"84.2355711781879"
/>
</arc>
</map>
</sbgn>
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment