Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
76ea198f
Commit
76ea198f
authored
Nov 13, 2019
by
Piotr Gawron
Browse files
parsing of CellDesigner 2.5 should work
parent
706980fa
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
76ea198f
...
@@ -10,6 +10,7 @@ minerva (15.0.0~alpha.1) stable; urgency=medium
...
@@ -10,6 +10,7 @@ minerva (15.0.0~alpha.1) stable; urgency=medium
*
Small
improvement
:
list
of
genomes
is
automatically
refreshed
during
genome
*
Small
improvement
:
list
of
genomes
is
automatically
refreshed
during
genome
upload
(#
820
)
upload
(#
820
)
*
Small
improvement
:
items
in
context
menu
are
reorganized
(#
787
)
*
Small
improvement
:
items
in
context
menu
are
reorganized
(#
787
)
*
Small
improvement
:
CellDesigner
files
from
version
2.5
should
be
parseable
*
Bug
fix
:
compartments
limited
by
corner
(
left
-
top
corner
compartment
,
etc
)
*
Bug
fix
:
compartments
limited
by
corner
(
left
-
top
corner
compartment
,
etc
)
are
parsed
properly
from
CellDesigner
files
are
parsed
properly
from
CellDesigner
files
*
Bug
fix
:
structural
states
of
proteins
are
imported
properly
from
SBGNML
PD
*
Bug
fix
:
structural
states
of
proteins
are
imported
properly
from
SBGNML
PD
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java
View file @
76ea198f
...
@@ -62,7 +62,7 @@ public class CellDesignerXmlParser extends Converter {
...
@@ -62,7 +62,7 @@ public class CellDesignerXmlParser extends Converter {
/**
/**
* Default class logger.
* Default class logger.
*/
*/
private
static
Logger
logger
=
LogManager
.
getLogger
(
CellDesignerXmlParser
.
class
.
getName
()
);
private
static
Logger
logger
=
LogManager
.
getLogger
();
/**
/**
* CellDesigner parser for layers.
* CellDesigner parser for layers.
...
@@ -89,8 +89,11 @@ public class CellDesignerXmlParser extends Converter {
...
@@ -89,8 +89,11 @@ public class CellDesignerXmlParser extends Converter {
*/
*/
private
RestAnnotationParser
rap
=
new
RestAnnotationParser
();
private
RestAnnotationParser
rap
=
new
RestAnnotationParser
();
private
boolean
oldCellDesignerVersion
;
@Override
@Override
public
Model
createModel
(
ConverterParams
params
)
throws
InvalidInputDataExecption
{
public
Model
createModel
(
ConverterParams
params
)
throws
InvalidInputDataExecption
{
oldCellDesignerVersion
=
false
;
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
FunctionCollectionXmlParser
functionParser
=
new
FunctionCollectionXmlParser
();
FunctionCollectionXmlParser
functionParser
=
new
FunctionCollectionXmlParser
();
UnitCollectionXmlParser
unitParser
=
new
UnitCollectionXmlParser
();
UnitCollectionXmlParser
unitParser
=
new
UnitCollectionXmlParser
();
...
@@ -213,7 +216,7 @@ public class CellDesignerXmlParser extends Converter {
...
@@ -213,7 +216,7 @@ public class CellDesignerXmlParser extends Converter {
if
(
reactionsNode
!=
null
)
{
if
(
reactionsNode
!=
null
)
{
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
params
.
isSbgnFormat
());
params
.
isSbgnFormat
()
,
oldCellDesignerVersion
);
List
<
Reaction
>
reactions
=
reactionCollectionXmlParser
.
parseXmlReactionCollection
(
reactionsNode
);
List
<
Reaction
>
reactions
=
reactionCollectionXmlParser
.
parseXmlReactionCollection
(
reactionsNode
);
model
.
addReactions
(
reactions
);
model
.
addReactions
(
reactions
);
}
}
...
@@ -376,7 +379,11 @@ public class CellDesignerXmlParser extends Converter {
...
@@ -376,7 +379,11 @@ public class CellDesignerXmlParser extends Converter {
model
.
addAuthors
(
xmlAnnotationParser
.
getAuthorsFromRdf
(
node
));
model
.
addAuthors
(
xmlAnnotationParser
.
getAuthorsFromRdf
(
node
));
model
.
setCreationDate
(
xmlAnnotationParser
.
getCreateDateFromRdf
(
node
));
model
.
setCreationDate
(
xmlAnnotationParser
.
getCreateDateFromRdf
(
node
));
model
.
addModificationDates
(
xmlAnnotationParser
.
getModificationDatesFromRdf
(
node
));
model
.
addModificationDates
(
xmlAnnotationParser
.
getModificationDatesFromRdf
(
node
));
}
else
{
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"celldesigner:modelVersion"
))
{
logger
.
warn
(
"Old version of cell designer found: "
+
XmlParser
.
getNodeValue
(
node
));
oldCellDesignerVersion
=
true
;
extensionNode
=
annotationNode
;
}
else
if
(!
oldCellDesignerVersion
)
{
throw
new
InvalidXmlSchemaException
(
"Unknown element of annotation: "
+
node
.
getNodeName
());
throw
new
InvalidXmlSchemaException
(
"Unknown element of annotation: "
+
node
.
getNodeName
());
}
}
}
}
...
@@ -601,8 +608,9 @@ public class CellDesignerXmlParser extends Converter {
...
@@ -601,8 +608,9 @@ public class CellDesignerXmlParser extends Converter {
try
{
try
{
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
SpeciesCollectionXmlParser
speciesCollectionXmlParser
=
new
SpeciesCollectionXmlParser
(
elements
,
model
.
getUnits
());
SpeciesCollectionXmlParser
speciesCollectionXmlParser
=
new
SpeciesCollectionXmlParser
(
elements
,
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
);
model
.
getUnits
());
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
,
oldCellDesignerVersion
);
UnitCollectionXmlParser
unitCollectionXmlParser
=
new
UnitCollectionXmlParser
();
UnitCollectionXmlParser
unitCollectionXmlParser
=
new
UnitCollectionXmlParser
();
FunctionCollectionXmlParser
functionCollectionXmlParser
=
new
FunctionCollectionXmlParser
();
FunctionCollectionXmlParser
functionCollectionXmlParser
=
new
FunctionCollectionXmlParser
();
ParameterCollectionXmlParser
parameterCollectionXmlParser
=
new
ParameterCollectionXmlParser
(
model
);
ParameterCollectionXmlParser
parameterCollectionXmlParser
=
new
ParameterCollectionXmlParser
(
model
);
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParser.java
View file @
76ea198f
...
@@ -53,9 +53,10 @@ public class ReactionCollectionXmlParser {
...
@@ -53,9 +53,10 @@ public class ReactionCollectionXmlParser {
* @param model
* @param model
* model that is parsed/transformed into xml
* model that is parsed/transformed into xml
*/
*/
public
ReactionCollectionXmlParser
(
Model
model
,
CellDesignerElementCollection
elements
,
boolean
sbgn
)
{
public
ReactionCollectionXmlParser
(
Model
model
,
CellDesignerElementCollection
elements
,
boolean
sbgn
,
boolean
oldCellDesignerVersion
)
{
this
.
model
=
model
;
this
.
model
=
model
;
xmlStructureFactory
=
new
ReactionXmlParser
(
elements
,
sbgn
);
xmlStructureFactory
=
new
ReactionXmlParser
(
elements
,
sbgn
,
oldCellDesignerVersion
);
}
}
/**
/**
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXml.java
View file @
76ea198f
...
@@ -96,15 +96,18 @@ public class ReactionFromXml {
...
@@ -96,15 +96,18 @@ public class ReactionFromXml {
*/
*/
private
boolean
sbgn
;
private
boolean
sbgn
;
private
boolean
oldCellDesignerVersion
;
/**
/**
* Default constructor.
* Default constructor.
*
*
* @param sbgn
* @param sbgn
* Should the converter use SBGN standard
* Should the converter use SBGN standard
*/
*/
public
ReactionFromXml
(
CellDesignerElementCollection
elements
,
boolean
sbgn
)
{
public
ReactionFromXml
(
CellDesignerElementCollection
elements
,
boolean
sbgn
,
boolean
oldCellDesignerVersion
)
{
this
.
elements
=
elements
;
this
.
elements
=
elements
;
this
.
sbgn
=
sbgn
;
this
.
sbgn
=
sbgn
;
this
.
oldCellDesignerVersion
=
oldCellDesignerVersion
;
}
}
/**
/**
...
@@ -276,6 +279,9 @@ public class ReactionFromXml {
...
@@ -276,6 +279,9 @@ public class ReactionFromXml {
private
Reaction
parseReactionAnnotation
(
Node
annotationNode
,
Reaction
result
,
Model
model
)
private
Reaction
parseReactionAnnotation
(
Node
annotationNode
,
Reaction
result
,
Model
model
)
throws
ReactionParserException
{
throws
ReactionParserException
{
NodeList
nodes
=
annotationNode
.
getChildNodes
();
NodeList
nodes
=
annotationNode
.
getChildNodes
();
if
(
oldCellDesignerVersion
)
{
result
=
parseReactionExtension
(
result
,
annotationNode
,
model
);
}
for
(
int
x
=
0
;
x
<
nodes
.
getLength
();
x
++)
{
for
(
int
x
=
0
;
x
<
nodes
.
getLength
();
x
++)
{
Node
node
=
nodes
.
item
(
x
);
Node
node
=
nodes
.
item
(
x
);
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
...
@@ -288,11 +294,12 @@ public class ReactionFromXml {
...
@@ -288,11 +294,12 @@ public class ReactionFromXml {
}
catch
(
InvalidXmlSchemaException
e
)
{
}
catch
(
InvalidXmlSchemaException
e
)
{
throw
new
ReactionParserException
(
"Problem with parsing RDF"
,
result
,
e
);
throw
new
ReactionParserException
(
"Problem with parsing RDF"
,
result
,
e
);
}
}
}
else
{
}
else
if
(!
oldCellDesignerVersion
)
{
throw
new
ReactionParserException
(
"Unknown element of reaction/annotation: "
+
node
.
getNodeName
(),
result
);
throw
new
ReactionParserException
(
"Unknown element of reaction/annotation: "
+
node
.
getNodeName
(),
result
);
}
}
}
}
}
}
return
result
;
return
result
;
}
}
...
@@ -409,7 +416,7 @@ public class ReactionFromXml {
...
@@ -409,7 +416,7 @@ public class ReactionFromXml {
}
}
applyStylingToLine
(
line
,
result
.
getLine
());
applyStylingToLine
(
line
,
result
.
getLine
());
if
(
booleanLogicGateType
!=
null
)
{
if
(
booleanLogicGateType
!=
null
)
{
assignColorFromGateMembers
(
result
,
gateMembers
);
assignColorFromGateMembers
(
result
,
gateMembers
);
}
}
if
(
reactantsLinkNode
!=
null
)
{
if
(
reactantsLinkNode
!=
null
)
{
...
@@ -954,7 +961,7 @@ public class ReactionFromXml {
...
@@ -954,7 +961,7 @@ public class ReactionFromXml {
polylines
.
add
(
result
.
getReactants
().
get
(
elementIndex
-
1
).
getLine
());
polylines
.
add
(
result
.
getReactants
().
get
(
elementIndex
-
1
).
getLine
());
}
}
}
}
for
(
PolylineData
polyline:
polylines
)
{
for
(
PolylineData
polyline
:
polylines
)
{
polyline
.
setColor
(
line
.
getColor
());
polyline
.
setColor
(
line
.
getColor
());
polyline
.
setWidth
(
line
.
getWidth
());
polyline
.
setWidth
(
line
.
getWidth
());
}
}
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionXmlParser.java
View file @
76ea198f
...
@@ -39,9 +39,9 @@ public class ReactionXmlParser {
...
@@ -39,9 +39,9 @@ public class ReactionXmlParser {
* collection of {@link CellDesignerElement cell designer elements}
* collection of {@link CellDesignerElement cell designer elements}
* parsed from xml
* parsed from xml
*/
*/
public
ReactionXmlParser
(
CellDesignerElementCollection
elements
,
boolean
sbgn
)
{
public
ReactionXmlParser
(
CellDesignerElementCollection
elements
,
boolean
sbgn
,
boolean
oldCellDesignerVersion
)
{
reactionToXml
=
new
ReactionToXml
(
elements
,
sbgn
);
reactionToXml
=
new
ReactionToXml
(
elements
,
sbgn
);
reactionFromXml
=
new
ReactionFromXml
(
elements
,
sbgn
);
reactionFromXml
=
new
ReactionFromXml
(
elements
,
sbgn
,
oldCellDesignerVersion
);
}
}
/**
/**
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesSbmlParser.java
View file @
76ea198f
...
@@ -88,6 +88,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
...
@@ -88,6 +88,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
list
=
annotationNode
.
getChildNodes
();
list
=
annotationNode
.
getChildNodes
();
Node
extensionNode
=
null
;
Node
extensionNode
=
null
;
Node
rdfNode
=
null
;
Node
rdfNode
=
null
;
Node
speciesIdentity
=
null
;
Node
positionToCompartment
=
null
;
for
(
int
i
=
0
;
i
<
list
.
getLength
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
getLength
();
i
++)
{
Node
node
=
list
.
item
(
i
);
Node
node
=
list
.
item
(
i
);
...
@@ -96,36 +98,45 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
...
@@ -96,36 +98,45 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
extensionNode
=
node
;
extensionNode
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"rdf:RDF"
))
{
}
else
if
(
node
.
getNodeName
().
equals
(
"rdf:RDF"
))
{
rdfNode
=
node
;
rdfNode
=
node
;
}
else
{
throw
new
InvalidXmlSchemaException
(
"Unknown element of annotation "
+
node
.
getNodeName
());
}
}
}
if
(
extensionNode
==
null
)
{
throw
new
InvalidXmlSchemaException
(
"No celldesigner:extension node in SBML/model/listOfSpecies/species/annotation"
);
}
list
=
extensionNode
.
getChildNodes
();
Node
speciesIdentity
=
null
;
Node
positionToCompartment
=
null
;
for
(
int
i
=
0
;
i
<
list
.
getLength
();
i
++)
{
Node
node
=
list
.
item
(
i
);
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
node
.
getNodeName
().
equals
(
"celldesigner:speciesIdentity"
))
{
speciesIdentity
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:positionToCompartment"
))
{
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:positionToCompartment"
))
{
positionToCompartment
=
node
;
positionToCompartment
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:speciesIdentity"
))
{
speciesIdentity
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:listOfCatalyzedReactions"
))
{
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:listOfCatalyzedReactions"
))
{
// we can ignore it - every node on the map contains information about
// we can ignore it - every node on the map contains information about
// itself
// itself
continue
;
continue
;
}
else
{
}
else
{
throw
new
InvalidXmlSchemaException
(
"["
+
XmlParser
.
getNodeAttr
(
"id"
,
spieciesNode
)
logger
.
debug
(
XmlParser
.
nodeToString
(
spieciesNode
,
true
));
+
"]\tUnknown element of celldesigner:extension "
+
node
.
getNodeName
());
throw
new
InvalidXmlSchemaException
(
"Unknown element of annotation "
+
node
.
getNodeName
());
}
}
}
if
(
extensionNode
!=
null
)
{
list
=
extensionNode
.
getChildNodes
();
for
(
int
i
=
0
;
i
<
list
.
getLength
();
i
++)
{
Node
node
=
list
.
item
(
i
);
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
node
.
getNodeName
().
equals
(
"celldesigner:speciesIdentity"
))
{
speciesIdentity
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:positionToCompartment"
))
{
positionToCompartment
=
node
;
}
else
if
(
node
.
getNodeName
().
equals
(
"celldesigner:listOfCatalyzedReactions"
))
{
// we can ignore it - every node on the map contains information about
// itself
continue
;
}
else
{
throw
new
InvalidXmlSchemaException
(
"["
+
XmlParser
.
getNodeAttr
(
"id"
,
spieciesNode
)
+
"]\tUnknown element of celldesigner:extension "
+
node
.
getNodeName
());
}
}
}
}
}
}
else
{
if
(
speciesIdentity
==
null
)
{
// speciesIdentity was placed in the parent node in CD 2.5
throw
new
InvalidXmlSchemaException
(
"No celldesigner:extension node in SBML/model/listOfSpecies/species/annotation"
);
}
}
}
if
(
speciesIdentity
==
null
)
{
if
(
speciesIdentity
==
null
)
{
...
@@ -213,7 +224,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
...
@@ -213,7 +224,8 @@ public class SpeciesSbmlParser extends AbstractElementXmlParser<CellDesignerSpec
}
}
if
(
species
.
getSubstanceUnits
()
!=
null
)
{
if
(
species
.
getSubstanceUnits
()
!=
null
)
{
if
(
species
.
getSubstanceUnits
()
instanceof
SbmlUnit
)
{
if
(
species
.
getSubstanceUnits
()
instanceof
SbmlUnit
)
{
attributesBuilder
.
append
(
" substanceUnits=\""
+
((
SbmlUnit
)
species
.
getSubstanceUnits
()).
getUnitId
().
toLowerCase
()
+
"\""
);
attributesBuilder
.
append
(
" substanceUnits=\""
+
((
SbmlUnit
)
species
.
getSubstanceUnits
()).
getUnitId
().
toLowerCase
()
+
"\""
);
}
else
{
}
else
{
attributesBuilder
.
append
(
" substanceUnits=\""
+
species
.
getSubstanceUnits
().
toString
().
toLowerCase
()
+
"\""
);
attributesBuilder
.
append
(
" substanceUnits=\""
+
species
.
getSubstanceUnits
().
toString
().
toLowerCase
()
+
"\""
);
}
}
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierType.java
View file @
76ea198f
...
@@ -48,7 +48,20 @@ public enum ModifierType {
...
@@ -48,7 +48,20 @@ public enum ModifierType {
/**
/**
* Trigger.
* Trigger.
*/
*/
TRIGGER_STRING
(
"TRIGGER"
,
Trigger
.
class
,
ArrowType
.
BLANK_CROSSBAR
);
TRIGGER_STRING
(
"TRIGGER"
,
Trigger
.
class
,
ArrowType
.
BLANK_CROSSBAR
),
/**
* CellDesigner 2.5 modification type.
*/
TRANSCRIPTIONAL_ACTIVATION
(
"TRANSCRIPTIONAL_ACTIVATION"
,
Trigger
.
class
,
ArrowType
.
BLANK_CROSSBAR
),
/**
* CellDesigner 2.5 modification type.
*/
TRANSCRIPTIONAL_INHIBITION
(
"TRANSCRIPTIONAL_INHIBITION"
,
Inhibition
.
class
,
ArrowType
.
CROSSBAR
,
8.0
,
ReactionCellDesignerConverter
.
RECT_SIZE
/
2
-
1
),
;
/**
/**
* CellDesigner string describing this type.
* CellDesigner string describing this type.
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java
View file @
76ea198f
...
@@ -78,6 +78,16 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
...
@@ -78,6 +78,16 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
super
.
testXmlSerialization
(
model
);
super
.
testXmlSerialization
(
model
);
}
}
@Test
public
void
testCellDesigner2_5
()
throws
Exception
{
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/problematic/MYO_signaling_pathway.xml"
)
.
sizeAutoAdjust
(
false
));
assertNotNull
(
model
);
super
.
testXmlSerialization
(
model
);
}
@Test
@Test
public
void
testUnknownCatalysisWithGate
()
throws
Exception
{
public
void
testUnknownCatalysisWithGate
()
throws
Exception
{
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java
View file @
76ea198f
...
@@ -36,7 +36,7 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions {
...
@@ -36,7 +36,7 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions {
Model
model
=
getModelFilledWithSpecies
();
Model
model
=
getModelFilledWithSpecies
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
ReactionCollectionXmlParser
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
);
ReactionCollectionXmlParser
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
,
false
);
String
xmlString
=
readFile
(
"testFiles/reactions/listOfReactions.xml"
);
String
xmlString
=
readFile
(
"testFiles/reactions/listOfReactions.xml"
);
Node
node
=
getNodeFromXmlString
(
xmlString
);
Node
node
=
getNodeFromXmlString
(
xmlString
);
...
@@ -56,19 +56,19 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions {
...
@@ -56,19 +56,19 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions {
Model
model
=
getModelFilledWithSpecies
();
Model
model
=
getModelFilledWithSpecies
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
ReactionCollectionXmlParser
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
);
ReactionCollectionXmlParser
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
,
false
);
String
xmlString
=
readFile
(
"testFiles/reactions/listOfReactions.xml"
);
String
xmlString
=
readFile
(
"testFiles/reactions/listOfReactions.xml"
);
Node
node
=
getNodeFromXmlString
(
xmlString
);
Node
node
=
getNodeFromXmlString
(
xmlString
);
List
<
Reaction
>
reactions
=
parser
.
parseXmlReactionCollection
(
node
);
List
<
Reaction
>
reactions
=
parser
.
parseXmlReactionCollection
(
node
);
elements
=
new
CellDesignerElementCollection
();
elements
=
new
CellDesignerElementCollection
();
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
);
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
,
false
);
String
xmlString2
=
parser
.
reactionCollectionToXmlString
(
reactions
);
String
xmlString2
=
parser
.
reactionCollectionToXmlString
(
reactions
);
assertNotNull
(
xmlString2
);
assertNotNull
(
xmlString2
);
elements
=
new
CellDesignerElementCollection
();
elements
=
new
CellDesignerElementCollection
();
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
);
parser
=
new
ReactionCollectionXmlParser
(
model
,
elements
,
false
,
false
);
node
=
getNodeFromXmlString
(
xmlString2
);
node
=
getNodeFromXmlString
(
xmlString2
);
List
<
Reaction
>
reactions2
=
parser
.
parseXmlReactionCollection
(
node
);
List
<
Reaction
>
reactions2
=
parser
.
parseXmlReactionCollection
(
node
);
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java
View file @
76ea198f
...
@@ -27,7 +27,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -27,7 +27,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
@Before
@Before
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
elements
=
new
CellDesignerElementCollection
();
elements
=
new
CellDesignerElementCollection
();
parser
=
new
ReactionXmlParser
(
elements
,
false
);
parser
=
new
ReactionXmlParser
(
elements
,
false
,
false
);
Species
alias
=
new
GenericProtein
(
"sa1"
);
Species
alias
=
new
GenericProtein
(
"sa1"
);
model
.
addElement
(
alias
);
model
.
addElement
(
alias
);
...
@@ -195,7 +195,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -195,7 +195,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
public
void
testInvalidReaction
()
throws
Exception
{
public
void
testInvalidReaction
()
throws
Exception
{
// test situation when createProperTypeReaction returns reaction of
// test situation when createProperTypeReaction returns reaction of
// unknown type
// unknown type
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
)
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
{
return
result
;
return
result
;
}
}
...
@@ -209,7 +209,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -209,7 +209,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
// test situation when createProperTypeReaction returns reaction of
// test situation when createProperTypeReaction returns reaction of
// unknown type that implements TwoProductReactionInterface
// unknown type that implements TwoProductReactionInterface
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
)
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
reaction
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
reaction
)
{
Reaction
result
=
Mockito
.
mock
(
Reaction
.
class
,
Reaction
result
=
Mockito
.
mock
(
Reaction
.
class
,
Mockito
.
withSettings
().
extraInterfaces
(
TwoProductReactionInterface
.
class
));
Mockito
.
withSettings
().
extraInterfaces
(
TwoProductReactionInterface
.
class
));
...
@@ -229,7 +229,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -229,7 +229,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
// test situation when createOperatorsForTwoProductReaction encounter
// test situation when createOperatorsForTwoProductReaction encounter
// reaction with two many base reactants
// reaction with two many base reactants
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
)
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
r
.
addReactant
(
new
Reactant
());
r
.
addReactant
(
new
Reactant
());
...
@@ -246,7 +246,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -246,7 +246,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
// test situation when createOperatorsForTwoProductReaction encounter
// test situation when createOperatorsForTwoProductReaction encounter
// reaction with two many base products
// reaction with two many base products
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
)
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
r
.
addProduct
(
new
Product
());
r
.
addProduct
(
new
Product
());
...
@@ -263,7 +263,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -263,7 +263,7 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
// test situation when createOperatorsForTwoReactantReaction encounter
// test situation when createOperatorsForTwoReactantReaction encounter
// reaction with two many base products
// reaction with two many base products
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
)
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
)
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
createProperTypeReaction
(
String
type
,
Reaction
result
)
throws
ReactionParserException
{
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
Reaction
r
=
super
.
createProperTypeReaction
(
type
,
result
);
r
.
addProduct
(
new
Product
());
r
.
addProduct
(
new
Product
());
...
@@ -276,14 +276,14 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
...
@@ -276,14 +276,14 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions {
@Test
(
expected
=
InvalidArgumentException
.
class
)
@Test
(
expected
=
InvalidArgumentException
.
class
)
public
void
testParseInvalidEditPointsString
()
throws
Exception
{
public
void
testParseInvalidEditPointsString
()
throws
Exception
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
);
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
);
parser
.
parseEditPointsString
(
"1"
);
parser
.
parseEditPointsString
(
"1"
);
}
}
@Test
(
expected
=
InvalidArgumentException
.
class
)
@Test
(
expected
=
InvalidArgumentException
.
class
)
public
void
testParseInvalidEditPointsString2
()
throws
Exception
{
public
void
testParseInvalidEditPointsString2
()
throws
Exception
{
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
);
ReactionFromXml
parser
=
new
ReactionFromXml
(
null
,
false
,
false
);
parser
.
parseEditPointsString
(
"1,Infinity"
);
parser
.
parseEditPointsString
(
"1,Infinity"
);
}