Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
24d6947d
Commit
24d6947d
authored
Oct 27, 2016
by
Piotr Gawron
Browse files
model warnings moved to project (issue #9)
parent
d47a3508
Changes
38
Hide whitespace changes
Inline
Side-by-side
annotation/src/main/java/lcsb/mapviewer/annotation/services/ModelAnnotator.java
View file @
24d6947d
...
...
@@ -28,10 +28,12 @@ import lcsb.mapviewer.annotation.services.annotators.UniprotAnnotator;
import
lcsb.mapviewer.common.EventStorageLoggerAppender
;
import
lcsb.mapviewer.common.IProgressUpdater
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.AnnotatedObject
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelData
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Species
;
...
...
@@ -165,13 +167,13 @@ public class ModelAnnotator {
/**
* Performs all possible and automatic annotations on the model.
*
* @param
model
*
model
to update
* @param
project
*
project
to update
* @param progressUpdater
* callback function used for updating progress of the function
*/
public
void
performAnnotations
(
Model
model
,
final
IProgressUpdater
progressUpdater
)
{
performAnnotations
(
model
,
progressUpdater
,
null
);
public
void
performAnnotations
(
Project
project
,
final
IProgressUpdater
progressUpdater
)
{
performAnnotations
(
project
,
progressUpdater
,
null
);
}
/**
...
...
@@ -180,19 +182,21 @@ public class ModelAnnotator {
* @param annotators
* this map contains lists of {@link ElementAnnotator} objects that
* should be used for a given classes
* @param
model
* model to update
* @param
project
*
project with
model
s
to update
* @param progressUpdater
* callback function used for updating progress of the function
*/
public
void
performAnnotations
(
Model
model
,
final
IProgressUpdater
progressUpdater
,
Map
<
Class
<?>,
List
<
ElementAnnotator
>>
annotators
)
{
public
void
performAnnotations
(
Project
project
,
final
IProgressUpdater
progressUpdater
,
Map
<
Class
<?>,
List
<
ElementAnnotator
>>
annotators
)
{
EventStorageLoggerAppender
appender
=
new
EventStorageLoggerAppender
();
try
{
Logger
.
getRootLogger
().
addAppender
(
appender
);
progressUpdater
.
setProgress
(
0
);
List
<
Model
>
models
=
new
ArrayList
<
Model
>();
models
.
add
(
model
);
models
.
addAll
(
model
.
getSubmodels
());
List
<
Model
>
models
=
new
ArrayList
<>();
for
(
ModelData
model:
project
.
getModels
())
{
models
.
add
(
model
.
getModel
());
models
.
addAll
(
model
.
getModel
().
getSubmodels
());
}
final
double
size
=
models
.
size
();
double
counter
=
0
;
for
(
Model
m
:
models
)
{
...
...
@@ -215,7 +219,7 @@ public class ModelAnnotator {
counter
++;
}
Logger
.
getRootLogger
().
removeAppender
(
appender
);
model
.
addLoggingInfo
(
appender
);
project
.
addLoggingInfo
(
appender
);
}
finally
{
Logger
.
getRootLogger
().
removeAppender
(
appender
);
}
...
...
annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java
View file @
24d6947d
...
...
@@ -29,6 +29,7 @@ import lcsb.mapviewer.annotation.services.annotators.AnnotatorException;
import
lcsb.mapviewer.annotation.services.annotators.ElementAnnotator
;
import
lcsb.mapviewer.annotation.services.annotators.ReconAnnotator
;
import
lcsb.mapviewer.common.IProgressUpdater
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.AnnotatedObject
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamRelationType
;
...
...
@@ -311,7 +312,9 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions {
final
MutableDouble
maxProgress
=
new
MutableDouble
(
0.0
);
modelAnnotator
.
performAnnotations
(
model
,
new
IProgressUpdater
()
{
Project
project
=
new
Project
();
project
.
addModel
(
model
);
modelAnnotator
.
performAnnotations
(
project
,
new
IProgressUpdater
()
{
@Override
public
void
setProgress
(
double
progress
)
{
maxProgress
.
setValue
(
Math
.
max
(
progress
,
maxProgress
.
getValue
()));
...
...
console/src/main/java/lcsb/mapviewer/run/BellExport.java
View file @
24d6947d
...
...
@@ -7,6 +7,7 @@ import lcsb.mapviewer.annotation.services.ModelAnnotator;
import
lcsb.mapviewer.common.IProgressUpdater
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.species.Species
;
import
lcsb.mapviewer.persist.ApplicationContextLoader
;
...
...
@@ -26,25 +27,25 @@ public class BellExport {
/**
* Default class logger.
*/
private
static
Logger
logger
=
Logger
.
getLogger
(
BellExport
.
class
.
getName
());
private
static
Logger
logger
=
Logger
.
getLogger
(
BellExport
.
class
.
getName
());
/**
* Object that performs different types of export transformation.
*/
@Autowired
private
IExporterService
exporter
;
private
IExporterService
exporter
;
/**
* Object used to annotate the model.
*/
@Autowired
private
ModelAnnotator
modelAnnotator
;
private
ModelAnnotator
modelAnnotator
;
/**
* Object used to annotate the model.
*/
@Autowired
private
DbUtils
dbUtils
;
private
DbUtils
dbUtils
;
/**
* Static main method used to run this stand alone code.
...
...
@@ -76,23 +77,22 @@ public class BellExport {
try
{
String
filename
=
PdMapAnnotations
.
getLastPdFilename
();
String
version
=
PdMapAnnotations
.
getLastPdVersion
();
//filename = "testFiles/other_full/ASTHMAP18000X8000V1_38.xml";
//version = "1.1.38";
//
filename = "testFiles/other_full/ASTHMAP18000X8000V1_38.xml";
//
version = "1.1.38";
dbUtils
.
createSessionForCurrentThread
();
Model
model
=
p
.
createModel
(
new
ConverterParams
().
filename
(
filename
));
Project
project
=
new
Project
();
project
.
addModel
(
model
);
modelAnnotator
.
performAnnotations
(
model
,
new
IProgressUpdater
()
{
modelAnnotator
.
performAnnotations
(
project
,
new
IProgressUpdater
()
{
@Override
public
void
setProgress
(
double
progress
)
{
// TODO Auto-generated method stub
}
});
ExporterParameters
params
=
new
IExporterService
.
ExporterParameters
().
model
(
model
).
//
fileName
(
"out/bell/"
+
version
+
"-reactions.txt"
).
//
fileName
(
"out/bell/"
+
version
+
"-reactions.txt"
).
//
fileType
(
ExportFileType
.
TAB_SEPARATED
).
//
type
(
Species
.
class
).
//
moleculeEdges
(
false
);
...
...
@@ -100,15 +100,15 @@ public class BellExport {
exporter
.
exportReactions
(
params
);
params
=
new
IExporterService
.
ExporterParameters
().
model
(
model
).
//
fileName
(
"out/bell/"
+
version
+
"-species.txt"
).
//
fileName
(
"out/bell/"
+
version
+
"-species.txt"
).
//
fileType
(
ExportFileType
.
TAB_SEPARATED
).
//
type
(
Species
.
class
).
//
//
column(ExportColumn.FULL).//
//
column(ExportColumn.FULL).//
moleculeEdges
(
false
);
exporter
.
exportSpecies
(
params
);
params
=
new
IExporterService
.
ExporterParameters
().
model
(
model
).
//
fileName
(
"out/bell/"
+
version
+
"-compartments.txt"
).
//
fileName
(
"out/bell/"
+
version
+
"-compartments.txt"
).
//
fileType
(
ExportFileType
.
TAB_SEPARATED
).
//
type
(
Object
.
class
);
//
// column(ExportColumn.FULL);
...
...
console/src/main/java/lcsb/mapviewer/run/Statistics.java
View file @
24d6947d
...
...
@@ -20,13 +20,14 @@ import lcsb.mapviewer.common.Configuration;
import
lcsb.mapviewer.common.IProgressUpdater
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.MiriamType
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Complex
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Species
;
import
lcsb.mapviewer.persist.ApplicationContextLoader
;
import
lcsb.mapviewer.persist.DbUtils
;
...
...
@@ -112,8 +113,11 @@ public class Statistics {
try
{
// String modelName = PdMapAnnotations.getLastPdFilename();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
Project
project
=
new
Project
();
for
(
String
name
:
fileNames
)
{
models
.
add
(
parser
.
createModel
(
new
ConverterParams
().
filename
(
name
)));
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
name
));
models
.
add
(
model
);
project
.
addModel
(
model
);
}
IProgressUpdater
updater
=
new
IProgressUpdater
()
{
...
...
@@ -122,9 +126,7 @@ public class Statistics {
logger
.
debug
(
"Progress: "
+
progress
);
}
};
for
(
Model
model
:
models
)
{
modelAnnotator
.
performAnnotations
(
model
,
updater
);
}
modelAnnotator
.
performAnnotations
(
project
,
updater
);
// modelAnnotator.removeIncorrectAnnotations(model, updater);
printStatistics
(
models
);
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java
View file @
24d6947d
...
...
@@ -18,7 +18,6 @@ import org.w3c.dom.Document;
import
org.w3c.dom.Node
;
import
org.w3c.dom.NodeList
;
import
lcsb.mapviewer.common.EventStorageLoggerAppender
;
import
lcsb.mapviewer.common.MimeType
;
import
lcsb.mapviewer.common.Pair
;
import
lcsb.mapviewer.common.XmlParser
;
...
...
@@ -77,7 +76,6 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter {
/**
* Default class logger.
*/
@SuppressWarnings
(
"unused"
)
private
static
Logger
logger
=
Logger
.
getLogger
(
CellDesignerXmlParser
.
class
.
getName
());
/**
...
...
@@ -107,153 +105,144 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter {
@Override
public
Model
createModel
(
ConverterParams
params
)
throws
InvalidInputDataExecption
{
EventStorageLoggerAppender
appender
=
new
EventStorageLoggerAppender
();
try
{
Logger
.
getRootLogger
().
addAppender
(
appender
);
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
CellDesignerElementCollection
elements
=
new
CellDesignerElementCollection
();
Model
model
=
new
ModelFullIndexed
(
null
);
model
.
setSbgnFormat
(
params
.
isSbgnFormat
());
Model
model
=
new
ModelFullIndexed
(
null
);
model
.
setSbgnFormat
(
params
.
isSbgnFormat
());
if
(
params
.
getFilename
()
!=
null
)
{
model
.
setName
(
FilenameUtils
.
getBaseName
(
params
.
getFilename
()));
}
speciesSbmlParser
=
new
SpeciesCollectionXmlParser
(
elements
);
aliasCollectionParser
=
new
AliasCollectionXmlParser
(
elements
,
model
);
compartmentCollectionXmlParser
=
new
CompartmentCollectionXmlParser
(
elements
);
if
(
params
.
getFilename
()
!=
null
)
{
model
.
setName
(
FilenameUtils
.
getBaseName
(
params
.
getFilename
()));
}
speciesSbmlParser
=
new
SpeciesCollectionXmlParser
(
elements
);
aliasCollectionParser
=
new
AliasCollectionXmlParser
(
elements
,
model
);
compartmentCollectionXmlParser
=
new
CompartmentCollectionXmlParser
(
elements
);
DOMParser
parser
=
new
DOMParser
();
try
{
parser
.
parse
(
params
.
getSource
());
}
catch
(
IOException
e
)
{
throw
new
InvalidInputDataExecption
(
"IO Problem with a file: "
+
params
.
getSource
().
getSystemId
(),
e
);
}
Document
doc
=
parser
.
getDocument
();
try
{
DOMParser
parser
=
new
DOMParser
();
try
{
parser
.
parse
(
params
.
getSource
());
}
catch
(
IOException
e
)
{
throw
new
InvalidInputDataExecption
(
"IO Problem with a file: "
+
params
.
getSource
().
getSystemId
(),
e
);
}
Document
doc
=
parser
.
getDocument
();
try
{
// Get the document's root XML node
NodeList
root
=
doc
.
getChildNodes
();
// Get the document's root XML node
NodeList
root
=
doc
.
getChildNodes
();
// Navigate down the hierarchy to get to the CEO node
Node
sbmlNode
=
getNode
(
"SBML"
,
root
);
if
(
sbmlNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No SBML node"
);
}
// Navigate down the hierarchy to get to the CEO node
Node
sbmlNode
=
getNode
(
"SBML"
,
root
);
if
(
sbmlNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No SBML node"
);
}
Node
modelNode
=
getNode
(
"model"
,
sbmlNode
.
getChildNodes
());
if
(
modelNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No model node in SBML"
);
}
// we ignore metaid - it's useless and obstruct data model
// model.setMetaId(getNodeAttr("metaId", modelNode));
model
.
setIdModel
(
getNodeAttr
(
"id"
,
modelNode
));
Node
compartmentNode
=
getNode
(
"listOfCompartments"
,
modelNode
.
getChildNodes
());
if
(
compartmentNode
!=
null
)
{
List
<
CellDesignerCompartment
>
compartments
=
compartmentCollectionXmlParser
.
parseXmlCompartmentCollection
(
compartmentNode
);
elements
.
addElements
(
compartments
);
}
Node
modelNode
=
getNode
(
"model"
,
sbmlNode
.
getChildNodes
());
if
(
modelNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No model node in SBML"
);
}
// we ignore metaid - it's useless and obstruct data model
// model.setMetaId(getNodeAttr("metaId", modelNode));
model
.
setIdModel
(
getNodeAttr
(
"id"
,
modelNode
));
Node
compartmentNode
=
getNode
(
"listOfCompartments"
,
modelNode
.
getChildNodes
());
if
(
compartmentNode
!=
null
)
{
List
<
CellDesignerCompartment
>
compartments
=
compartmentCollectionXmlParser
.
parseXmlCompartmentCollection
(
compartmentNode
);
elements
.
addElements
(
compartments
);
}
InternalModelSpeciesData
modelData
=
new
InternalModelSpeciesData
();
InternalModelSpeciesData
modelData
=
new
InternalModelSpeciesData
();
Node
speciesNode
=
getNode
(
"listOfSpecies"
,
modelNode
.
getChildNodes
());
if
(
speciesNode
!=
null
)
{
List
<
Pair
<
String
,
?
extends
CellDesignerSpecies
<?>>>
species
=
speciesSbmlParser
.
parseSbmlSpeciesCollection
(
speciesNode
);
modelData
.
updateSpecies
(
species
);
}
Node
reactionsNode
=
null
;
NodeList
nodes
=
modelNode
.
getChildNodes
();
for
(
int
x
=
0
;
x
<
nodes
.
getLength
();
x
++)
{
Node
node
=
nodes
.
item
(
x
);
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"annotation"
))
{
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfSpecies"
))
{
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfReactions"
))
{
reactionsNode
=
node
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfCompartments"
))
{
// we already parsed compartemnts
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"notes"
))
{
String
notes
=
rap
.
getNotes
(
node
);
if
(
notes
!=
null
)
{
notes
=
StringEscapeUtils
.
unescapeHtml4
(
notes
);
}
model
.
setNotes
(
notes
);
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfUnitDefinitions"
))
{
continue
;
// we can ignore unit definitions
}
else
{
throw
new
InvalidInputDataExecption
(
"Unknown element of model: "
+
node
.
getNodeName
());
Node
speciesNode
=
getNode
(
"listOfSpecies"
,
modelNode
.
getChildNodes
());
if
(
speciesNode
!=
null
)
{
List
<
Pair
<
String
,
?
extends
CellDesignerSpecies
<?>>>
species
=
speciesSbmlParser
.
parseSbmlSpeciesCollection
(
speciesNode
);
modelData
.
updateSpecies
(
species
);
}
Node
reactionsNode
=
null
;
NodeList
nodes
=
modelNode
.
getChildNodes
();
for
(
int
x
=
0
;
x
<
nodes
.
getLength
();
x
++)
{
Node
node
=
nodes
.
item
(
x
);
if
(
node
.
getNodeType
()
==
Node
.
ELEMENT_NODE
)
{
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"annotation"
))
{
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfSpecies"
))
{
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfReactions"
))
{
reactionsNode
=
node
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfCompartments"
))
{
// we already parsed compartemnts
continue
;
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"notes"
))
{
String
notes
=
rap
.
getNotes
(
node
);
if
(
notes
!=
null
)
{
notes
=
StringEscapeUtils
.
unescapeHtml4
(
notes
);
}
model
.
setNotes
(
notes
);
}
else
if
(
node
.
getNodeName
().
equalsIgnoreCase
(
"listOfUnitDefinitions"
))
{
continue
;
// we can ignore unit definitions
}
else
{
throw
new
InvalidInputDataExecption
(
"Unknown element of model: "
+
node
.
getNodeName
());
}
}
}
Node
annotationNode
=
getNode
(
"annotation"
,
modelNode
.
getChildNodes
());
if
(
annotationNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No annotation node in SBML/model"
);
}
Node
annotationNode
=
getNode
(
"annotation"
,
modelNode
.
getChildNodes
());
if
(
annotationNode
==
null
)
{
throw
new
InvalidInputDataExecption
(
"No annotation node in SBML/model"
);
}
parseAnnotation
(
model
,
annotationNode
,
modelData
,
elements
);
parseAnnotation
(
model
,
annotationNode
,
modelData
,
elements
);
if
(
speciesNode
!=
null
)
{
List
<
Pair
<
String
,
?
extends
CellDesignerSpecies
<?>>>
species
=
speciesSbmlParser
.
parseSbmlSpeciesCollection
(
speciesNode
);
modelData
.
updateSpecies
(
species
);
}
if
(
speciesNode
!=
null
)
{
List
<
Pair
<
String
,
?
extends
CellDesignerSpecies
<?>>>
species
=
speciesSbmlParser
.
parseSbmlSpeciesCollection
(
speciesNode
);
modelData
.
updateSpecies
(
species
);
}
if
(
reactionsNode
!=
null
)
{
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
);
List
<
Reaction
>
reactions
=
reactionCollectionXmlParser
.
parseXmlReactionCollection
(
reactionsNode
);
model
.
addReactions
(
reactions
);
}
if
(
reactionsNode
!=
null
)
{
ReactionCollectionXmlParser
reactionCollectionXmlParser
=
new
ReactionCollectionXmlParser
(
model
,
elements
);
List
<
Reaction
>
reactions
=
reactionCollectionXmlParser
.
parseXmlReactionCollection
(
reactionsNode
);
model
.
addReactions
(
reactions
);
}
if
(
params
.
isSizeAutoAdjust
())
{
Rectangle2D
bound
=
getModelBound
(
model
);
double
width
=
bound
.
getWidth
()
+
2
*
(
Math
.
max
(
0
,
bound
.
getX
()));
double
height
=
bound
.
getHeight
()
+
2
*
(
Math
.
max
(
0
,
bound
.
getY
()));
if
(
params
.
isSizeAutoAdjust
())
{
Rectangle2D
bound
=
getModelBound
(
model
);
double
width
=
bound
.
getWidth
()
+
2
*
(
Math
.
max
(
0
,
bound
.
getX
()));
double
height
=
bound
.
getHeight
()
+
2
*
(
Math
.
max
(
0
,
bound
.
getY
()));
model
.
setWidth
(
width
);
model
.
setHeight
(
height
);
}
}
catch
(
InvalidXmlSchemaException
e
)
{
throw
new
InvalidInputDataExecption
(
e
);
}
catch
(
UnknownReactionClassException
e
)
{
String
type
=
e
.
getReactionType
();
String
reactionId
=
e
.
getReactionId
();
String
newType
=
null
;
if
(
"CATALYSIS"
.
equalsIgnoreCase
(
type
))
{
newType
=
"positive influence"
;
}
else
if
(
"INHIBITION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"negative influence"
;
}
else
if
(
"UNKNOWN_CATALYSIS"
.
equalsIgnoreCase
(
type
))
{
newType
=
"unknown positive influence"
;
}
else
if
(
"UNKNOWN_INHIBITION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"unknown negative influence"
;
}
else
if
(
"PHYSICAL_STIMULATION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced physical stimulation"
;
}
else
if
(
"MODULATION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced modulation"
;
}
else
if
(
"TRIGGER"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced trigger"
;
}
else
{
throw
new
InvalidInputDataExecption
(
e
);
}
throw
new
InvalidInputDataExecption
(
"Reaction type \""
+
type
+
"\" is inappropriate for reaction "
+
reactionId
+
". Suggested type: "
+
newType
+
" in the \"Reduced\" notation of CellDesigner."
,
e
);
}
catch
(
CellDesignerParserException
e
)
{
model
.
setWidth
(
width
);
model
.
setHeight
(
height
);
}
}
catch
(
InvalidXmlSchemaException
e
)
{
throw
new
InvalidInputDataExecption
(
e
);
}
catch
(
UnknownReactionClassException
e
)
{
String
type
=
e
.
getReactionType
();
String
reactionId
=
e
.
getReactionId
();
String
newType
=
null
;
if
(
"CATALYSIS"
.
equalsIgnoreCase
(
type
))
{
newType
=
"positive influence"
;
}
else
if
(
"INHIBITION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"negative influence"
;
}
else
if
(
"UNKNOWN_CATALYSIS"
.
equalsIgnoreCase
(
type
))
{
newType
=
"unknown positive influence"
;
}
else
if
(
"UNKNOWN_INHIBITION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"unknown negative influence"
;
}
else
if
(
"PHYSICAL_STIMULATION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced physical stimulation"
;
}
else
if
(
"MODULATION"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced modulation"
;
}
else
if
(
"TRIGGER"
.
equalsIgnoreCase
(
type
))
{
newType
=
"reduced trigger"
;
}
else
{
throw
new
InvalidInputDataExecption
(
e
);
}
Logger
.
getRootLogger
().
removeAppender
(
appender
);
model
.
addLoggingInfo
(
appender
);
return
model
;
}
finally
{
Logger
.
getRootLogger
().
removeAppender
(
appender
);
throw
new
InvalidInputDataExecption
(
"Reaction type \""
+
type
+
"\" is inappropriate for reaction "
+
reactionId
+
". Suggested type: "
+
newType
+
" in the \"Reduced\" notation of CellDesigner."
,
e
)
;
}
catch
(
CellDesignerParserException
e
)
{
throw
new
InvalidInputDataExecption
(
e
);
}
return
model
;
}
/**
...
...
@@ -451,7 +440,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter {
if
(!
species
.
getElementId
().
equals
(
""
))
{
elements
.
addElement
(
species
);
}
else
{
model
.
addCreationWarning
(
logger
.
warn
(
"Species (class: "
+
species
.
getClass
().
getName
()
+
", name: "
+
species
.
getName
()
+
") exists in CD file, but is never instantiated. It's CellDesigner file problem."
);
}
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java
View file @
24d6947d
...
...
@@ -24,9 +24,9 @@ import lcsb.mapviewer.model.map.MiriamType;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelComparator
;
import
lcsb.mapviewer.model.map.model.ModelFullIndexed
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.AntisenseRna
;
import
lcsb.mapviewer.model.map.species.Complex
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
import
lcsb.mapviewer.model.map.species.Protein
;
import
lcsb.mapviewer.model.map.species.Rna
;
...
...
@@ -310,8 +310,8 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
@Test
public
void
testWarningInParser
()
throws
Exception
{
try
{
Model
model
=
getModelForFile
(
"testFiles/problematic/invalid_elements_name.xml"
);
assertTrue
(
model
.
getCreation
Warnings
().
size
()
>
0
);
getModelForFile
(
"testFiles/problematic/invalid_elements_name.xml"
);
assertTrue
(
get
Warnings
().
size
()
>
0
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
...
...
converter/src/main/java/lcsb/mapviewer/converter/ComplexZipConverter.java
View file @
24d6947d
...
...
@@ -36,8 +36,8 @@ import lcsb.mapviewer.model.map.model.Model;
import
lcsb.mapviewer.model.map.model.ModelSubmodelConnection
;
import
lcsb.mapviewer.model.map.model.SubmodelType
;
import
lcsb.mapviewer.model.map.reaction.Reaction
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Complex
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Phenotype
;
import
lcsb.mapviewer.model.map.species.Protein
;
import
lcsb.mapviewer.model.map.species.Species
;
...
...
@@ -59,11 +59,12 @@ public class ComplexZipConverter<T extends IConverter> {
* stream.
*/
private
static
final
int
BUFFER_SIZE
=
1024
;
/**
* Default class logger.
*/
@SuppressWarnings
(
"unused"
)
private
static
Logger
logger
=
Logger
.
getLogger
(
ComplexZipConverter
.
class
);
/**
* Class used to create single submap from a file.