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
dd9bc16f
Commit
dd9bc16f
authored
Mar 21, 2018
by
David Hoksza
Browse files
Merge branch 'master' into structure-viewer
# Conflicts: # frontend-js/src/main/css/global.css
parents
dae9c901
40f1b78b
Pipeline
#4273
failed with stage
in 42 seconds
Changes
103
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
LICENSE
0 → 100644
View file @
dd9bc16f
This diff is collapsed.
Click to expand it.
commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
View file @
dd9bc16f
...
...
@@ -14,61 +14,64 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException;
*/
public
class
ColorParser
{
/**
* Base of the hex representation.
*/
private
static
final
int
HEX_BASE
=
16
;
/**
* Base of the hex representation.
*/
private
static
final
int
HEX_BASE
=
16
;
/**
* Length of the string describing color in
rgb
: "#RRGGBB".
*/
private
static
final
int
COLOR_STRING_LENGTH
=
7
;
/**
* Length of the string describing color in
RGB
: "#RRGGBB".
*/
private
static
final
int
COLOR_STRING_LENGTH
=
7
;
/**
* Where starts description of red color in st
i
rng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_RED
=
1
;
/**
* Where starts description of red color in str
i
ng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_RED
=
1
;
/**
* Where starts description of green color in st
i
rng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_GREEN
=
3
;
/**
* Where starts description of green color in str
i
ng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_GREEN
=
3
;
/**
* Where starts description of blue color in st
i
rng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_BLUE
=
5
;
/**
* Where starts description of blue color in str
i
ng representing color.
*/
private
static
final
int
COLOR_SUBSTRING_START_BLUE
=
5
;
/**
* Extracts {@link Color} from input {@link String}.
*
* @param string
* text to process
* @return {@link Color} obtained from input text
*/
public
Color
parse
(
String
string
)
{
if
(
string
.
charAt
(
0
)
!=
'#'
)
{
string
=
"#"
+
string
;
}
if
(
string
.
length
()
!=
COLOR_STRING_LENGTH
)
{
throw
new
InvalidArgumentException
(
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx (where x is a hex value)"
);
}
else
{
return
new
Color
(
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_RED
,
COLOR_SUBSTRING_START_GREEN
),
HEX_BASE
),
//
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_GREEN
,
COLOR_SUBSTRING_START_BLUE
),
HEX_BASE
),
//
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_BLUE
,
COLOR_STRING_LENGTH
),
HEX_BASE
));
}
}
/**
* Extracts {@link Color} from input {@link String}.
*
* @param string
* text to process
* @return {@link Color} obtained from input text
*/
public
Color
parse
(
String
string
)
{
if
(
string
.
charAt
(
0
)
!=
'#'
)
{
string
=
"#"
+
string
;
}
if
(
string
.
length
()
!=
COLOR_STRING_LENGTH
)
{
throw
new
InvalidArgumentException
(
"Invalid color value: "
+
string
+
". Correct format: #xxxxxx (where x is a hex value)"
);
}
else
{
return
new
Color
(
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_RED
,
COLOR_SUBSTRING_START_GREEN
),
HEX_BASE
),
//
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_GREEN
,
COLOR_SUBSTRING_START_BLUE
),
HEX_BASE
),
//
Integer
.
valueOf
(
string
.
substring
(
COLOR_SUBSTRING_START_BLUE
,
COLOR_STRING_LENGTH
),
HEX_BASE
));
}
}
/**
* Converts color into list of atributes.
*
* @param color color to convert
* @return map with list of color attributes
*/
public
Map
<
String
,
Object
>
colorToMap
(
Color
color
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"alpha"
,
color
.
getAlpha
());
result
.
put
(
"rgb"
,
color
.
getRGB
());
return
result
;
}
/**
* Converts color into list of attributes.
*
* @param color
* color to convert
* @return map with list of color attributes
*/
public
Map
<
String
,
Object
>
colorToMap
(
Color
color
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"alpha"
,
color
.
getAlpha
());
result
.
put
(
"rgb"
,
color
.
getRGB
());
return
result
;
}
}
converter-sbml/.gitignore
View file @
dd9bc16f
.settings/org.eclipse.wst.validation.prefs
/bin/
tmp.png
tmp.xml
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/SbmlBioEntityParser.java
View file @
dd9bc16f
...
...
@@ -15,8 +15,10 @@ import lcsb.mapviewer.common.XmlParser;
import
lcsb.mapviewer.common.exception.InvalidXmlSchemaException
;
import
lcsb.mapviewer.converter.InvalidInputDataExecption
;
import
lcsb.mapviewer.converter.annotation.XmlAnnotationParser
;
import
lcsb.mapviewer.converter.model.sbml.species.ElementColorEnum
;
import
lcsb.mapviewer.model.map.BioEntity
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.species.Element
;
public
class
SbmlBioEntityParser
extends
XmlParser
{
Logger
logger
=
Logger
.
getLogger
(
SbmlBioEntityParser
.
class
);
...
...
@@ -55,6 +57,11 @@ public class SbmlBioEntityParser extends XmlParser {
}
String
notes
=
extractNotes
(
sbmlElement
);
result
.
setNotes
(
notes
);
if
(
result
instanceof
Element
)
{
Element
element
=
(
Element
)
result
;
element
.
setColor
(
ElementColorEnum
.
getColorByClass
(
element
.
getClass
()));
}
}
private
String
extractNotes
(
AbstractNamedSBase
sbmlElement
)
throws
InvalidInputDataExecption
{
...
...
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SBOTermModifierType.java
View file @
dd9bc16f
...
...
@@ -7,6 +7,9 @@ import org.apache.log4j.Logger;
import
lcsb.mapviewer.model.map.modifier.Catalysis
;
import
lcsb.mapviewer.model.map.modifier.Inhibition
;
import
lcsb.mapviewer.model.map.modifier.Modulation
;
import
lcsb.mapviewer.model.map.modifier.PhysicalStimulation
;
import
lcsb.mapviewer.model.map.modifier.Trigger
;
import
lcsb.mapviewer.model.map.modifier.UnknownCatalysis
;
import
lcsb.mapviewer.model.map.modifier.UnknownInhibition
;
import
lcsb.mapviewer.model.map.reaction.Modifier
;
...
...
@@ -14,6 +17,9 @@ import lcsb.mapviewer.model.map.reaction.Modifier;
public
enum
SBOTermModifierType
{
CATALYSIS
(
Catalysis
.
class
,
new
String
[]
{
"SBO:0000013"
}),
//
INHIBITION
(
Inhibition
.
class
,
new
String
[]
{
"SBO:0000537"
}),
//
MODULATION
(
Modulation
.
class
,
new
String
[]
{
"SBO:0000594"
}),
//
PHYSICAL_STIMULATION
(
PhysicalStimulation
.
class
,
new
String
[]
{
"SBO:0000459"
}),
//
TRIGGER
(
Trigger
.
class
,
new
String
[]
{
"SBO:0000461"
}),
//
UNKNOWN_CATALYSIS
(
UnknownCatalysis
.
class
,
new
String
[]
{
"SBO:0000462"
}),
//
UNKNOWN_INHIBITION
(
UnknownInhibition
.
class
,
new
String
[]
{
"SBO:0000536"
}),
//
;
...
...
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SBOTermReactionType.java
View file @
dd9bc16f
...
...
@@ -11,6 +11,9 @@ import lcsb.mapviewer.model.map.reaction.type.HeterodimerAssociationReaction;
import
lcsb.mapviewer.model.map.reaction.type.KnownTransitionOmittedReaction
;
import
lcsb.mapviewer.model.map.reaction.type.NegativeInfluenceReaction
;
import
lcsb.mapviewer.model.map.reaction.type.PositiveInfluenceReaction
;
import
lcsb.mapviewer.model.map.reaction.type.ReducedModulationReaction
;
import
lcsb.mapviewer.model.map.reaction.type.ReducedPhysicalStimulationReaction
;
import
lcsb.mapviewer.model.map.reaction.type.ReducedTriggerReaction
;
import
lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction
;
import
lcsb.mapviewer.model.map.reaction.type.TranscriptionReaction
;
import
lcsb.mapviewer.model.map.reaction.type.TranslationReaction
;
...
...
@@ -18,22 +21,31 @@ import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import
lcsb.mapviewer.model.map.reaction.type.TruncationReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownNegativeInfluenceReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownPositiveInfluenceReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownReducedModulationReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownReducedPhysicalStimulationReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownReducedTriggerReaction
;
import
lcsb.mapviewer.model.map.reaction.type.UnknownTransitionReaction
;
public
enum
SBOTermReactionType
{
DISSOCIATION
(
DissociationReaction
.
class
,
new
String
[]
{
"SBO:0000180"
}),
//
HETERODIMER_ASSOCIATION
(
HeterodimerAssociationReaction
.
class
,
new
String
[]
{
"SBO:0000177"
}),
//
KNOWN_TRANSITION_OMITTED
(
KnownTransitionOmittedReaction
.
class
,
new
String
[]
{
"SBO:0000205"
}),
//
NEGATIVE_INFLUENCE
(
NegativeInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000407"
}),
//
POSITIVE_INFLUENCE
(
PositiveInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000171"
}),
//
REDUCED_MODULATION
(
ReducedModulationReaction
.
class
,
new
String
[]
{
"SBO:0000632"
}),
//
REDUCED_PHYSICAL_STIMULATION
(
ReducedPhysicalStimulationReaction
.
class
,
new
String
[]
{
"SBO:0000411"
}),
//
REDUCED_TRIGGER
(
ReducedTriggerReaction
.
class
,
new
String
[]
{
"SBO:0000461"
}),
//
STATE_TRANSITION
(
StateTransitionReaction
.
class
,
new
String
[]
{
"SBO:0000176"
}),
//
TRANSCRIPTION
(
TranscriptionReaction
.
class
,
new
String
[]
{
"SBO:0000183"
}),
//
TRANSLATION
(
TranslationReaction
.
class
,
new
String
[]
{
"SBO:0000184"
}),
//
TRANSPORT
(
TransportReaction
.
class
,
new
String
[]
{
"SBO:0000185"
}),
//
KNOWN_TRANSITION_OMITTED
(
KnownTransitionOmittedReaction
.
class
,
new
String
[]
{
"SBO:0000205"
}),
//
UNKNOWN_TRANSITION
(
UnknownTransitionReaction
.
class
,
new
String
[]
{
"SBO:0000396"
}),
//
HETERODIMER_ASSOCIATION
(
HeterodimerAssociationReaction
.
class
,
new
String
[]
{
"SBO:0000177"
}),
//
DISSOCIATION
(
DissociationReaction
.
class
,
new
String
[]
{
"SBO:0000180"
}),
//
TRUNCATION
(
TruncationReaction
.
class
,
new
String
[]
{
"SBO:0000178"
}),
//
POSITIVE_INFLUENCE
(
PositiveInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000171"
}),
//
UNKNOWN_POSITIVE_INFLUENCE
(
UnknownPositiveInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000170"
}),
//
NEGATIVE_INFLUENCE
(
NegativeInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000407"
}),
//
UNKNOWN_NEGATIVE_INFLUENCE
(
UnknownNegativeInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000169"
}),
//
UNKNOWN_POSITIVE_INFLUENCE
(
UnknownPositiveInfluenceReaction
.
class
,
new
String
[]
{
"SBO:0000172"
}),
//
UNKNOWN_REDUCED_MODULATION
(
UnknownReducedModulationReaction
.
class
,
new
String
[]
{
"SBO:0000631"
}),
//
UNKNOWN_REDUCED_PHYSICAL_STIMULATION
(
UnknownReducedPhysicalStimulationReaction
.
class
,
new
String
[]
{
"SBO:0000170"
}),
//
UNKNOWN_REDUCED_TRIGGER
(
UnknownReducedTriggerReaction
.
class
,
new
String
[]
{
"SBO:0000533"
}),
//
UNKNOWN_TRANSITION
(
UnknownTransitionReaction
.
class
,
new
String
[]
{
"SBO:0000396"
}),
//
;
private
static
Logger
logger
=
Logger
.
getLogger
(
SBOTermReactionType
.
class
);
...
...
@@ -60,7 +72,7 @@ public enum SBOTermReactionType {
}
}
if
(
result
==
null
)
{
logger
.
warn
(
"Don't know how to handle SBOTerm "
+
sboTerm
+
" for
modifier
"
);
logger
.
warn
(
"Don't know how to handle SBOTerm "
+
sboTerm
+
" for
reaction
"
);
result
=
StateTransitionReaction
.
class
;
}
return
result
;
...
...
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionExporter.java
View file @
dd9bc16f
...
...
@@ -10,6 +10,7 @@ import org.apache.log4j.Logger;
import
org.sbml.jsbml.ASTNode
;
import
org.sbml.jsbml.KineticLaw
;
import
org.sbml.jsbml.LocalParameter
;
import
org.sbml.jsbml.Model
;
import
org.sbml.jsbml.SimpleSpeciesReference
;
import
org.sbml.jsbml.Species
;
import
org.sbml.jsbml.SpeciesReference
;
...
...
@@ -63,7 +64,10 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
}
result
=
getSbmlModel
().
createReaction
(
reactionId
);
result
.
setReversible
(
reaction
.
isReversible
());
result
.
setSBOTerm
(
SBOTermReactionType
.
getTermByType
(
reaction
.
getClass
()));
String
sboTerm
=
SBOTermReactionType
.
getTermByType
(
reaction
.
getClass
());
if
(
sboTerm
!=
null
)
{
result
.
setSBOTerm
(
sboTerm
);
}
for
(
Product
product
:
reaction
.
getProducts
())
{
Species
sbmlSymbol
=
speciesExporter
.
getSbmlElementByElementId
(
product
.
getElement
().
getElementId
());
SpeciesReference
speciesReference
=
result
.
createProduct
(
sbmlSymbol
);
...
...
@@ -222,4 +226,9 @@ public class SbmlReactionExporter extends SbmlBioEntityExporter<Reaction, org.sb
return
curve
;
}
@Override
protected
void
setSbmlModel
(
Model
sbmlModel
)
{
super
.
setSbmlModel
(
sbmlModel
);
}
}
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/ElementColorEnum.java
0 → 100644
View file @
dd9bc16f
package
lcsb.mapviewer.converter.model.sbml.species
;
import
java.awt.Color
;
import
lcsb.mapviewer.common.geometry.ColorParser
;
import
lcsb.mapviewer.model.map.compartment.OvalCompartment
;
import
lcsb.mapviewer.model.map.compartment.SquareCompartment
;
import
lcsb.mapviewer.model.map.species.AntisenseRna
;
import
lcsb.mapviewer.model.map.species.Complex
;
import
lcsb.mapviewer.model.map.species.Degraded
;
import
lcsb.mapviewer.model.map.species.Drug
;
import
lcsb.mapviewer.model.map.species.Element
;
import
lcsb.mapviewer.model.map.species.Gene
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
import
lcsb.mapviewer.model.map.species.Ion
;
import
lcsb.mapviewer.model.map.species.IonChannelProtein
;
import
lcsb.mapviewer.model.map.species.Phenotype
;
import
lcsb.mapviewer.model.map.species.ReceptorProtein
;
import
lcsb.mapviewer.model.map.species.Rna
;
import
lcsb.mapviewer.model.map.species.SimpleMolecule
;
import
lcsb.mapviewer.model.map.species.TruncatedProtein
;
import
lcsb.mapviewer.model.map.species.Unknown
;
public
enum
ElementColorEnum
{
ANTISENSE_RNA
(
AntisenseRna
.
class
,
"#ff6666"
),
//
COMPLEX
(
Complex
.
class
,
"#f7f7f7"
),
//
DEGRADED
(
Degraded
.
class
,
"#ffcccc"
),
//
DRUG
(
Drug
.
class
,
"#ff00ff"
),
//
ELEMENT
(
Element
.
class
,
"#000000"
),
//
GENE
(
Gene
.
class
,
"#ffff66"
),
//
GENERIC_PROTEIN
(
GenericProtein
.
class
,
"ccffcc"
),
//
TRUNCATED_PROTEIN
(
TruncatedProtein
.
class
,
"#ffcccc"
),
//
ION
(
Ion
.
class
,
"#9999ff"
),
//
ION_CHANNEL
(
IonChannelProtein
.
class
,
"#ccffff"
),
//
OVAL_COMPARTMENT
(
OvalCompartment
.
class
,
"#cccc00"
),
//
PHENOTYPE
(
Phenotype
.
class
,
"#cc99ff"
),
//
RECEPTOR
(
ReceptorProtein
.
class
,
"#ffffcc"
),
//
RNA
(
Rna
.
class
,
"#66ff66"
),
//
SIMPLE_MOLECULE
(
SimpleMolecule
.
class
,
"#ccff66"
),
//
SQUARE_COMPARTMENT
(
SquareCompartment
.
class
,
"#cccc00"
),
//
UNKNOWN
(
Unknown
.
class
,
"#cccccc"
),
//
;
private
Class
<?
extends
Element
>
clazz
;
private
Color
color
;
ColorParser
colorParser
=
new
ColorParser
();
private
ElementColorEnum
(
Class
<?
extends
Element
>
clazz
,
String
color
)
{
this
.
clazz
=
clazz
;
if
(
color
!=
null
)
{
this
.
color
=
colorParser
.
parse
(
color
);
}
}
public
static
Color
getColorByClass
(
Class
<?
extends
Element
>
clazz
)
{
Color
result
=
null
;
for
(
ElementColorEnum
type
:
ElementColorEnum
.
values
())
{
if
(
type
.
getClazz
().
equals
(
clazz
))
{
result
=
type
.
getColor
();
}
}
if
(
result
==
null
)
{
for
(
ElementColorEnum
type
:
ElementColorEnum
.
values
())
{
if
(
type
.
getClazz
().
isAssignableFrom
(
clazz
))
{
result
=
type
.
getColor
();
}
}
}
return
result
;
}
public
Class
<?
extends
Element
>
getClazz
()
{
return
clazz
;
}
public
Color
getColor
()
{
return
color
;
}
}
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/AllSbmlConverterTests.java
View file @
dd9bc16f
...
...
@@ -4,16 +4,16 @@ import org.junit.runner.RunWith;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
lcsb.mapviewer.converter.model.sbml.reaction.SbmlReactionParserTest
;
import
lcsb.mapviewer.converter.model.sbml.reaction.
All
SbmlReactionParserTest
s
;
import
lcsb.mapviewer.converter.model.sbml.species.SbmlSpeciesParserTest
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
GenericSbmlParserTest
.
class
,
//
@SuiteClasses
({
AllSbmlReactionParserTests
.
class
,
//
GenericSbmlParserTest
.
class
,
//
GenericSbmlToXmlParserTest
.
class
,
//
SbmlExporterTest
.
class
,
//
SbmlPareserForInvalidReactionTest
.
class
,
//
SbmlParserTest
.
class
,
//
SbmlReactionParserTest
.
class
,
//
SbmlSpeciesParserTest
.
class
,
//
})
public
class
AllSbmlConverterTests
{
...
...
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/reaction/AllSbmlReactionParserTests.java
0 → 100644
View file @
dd9bc16f
package
lcsb.mapviewer.converter.model.sbml.reaction
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
SbmlReactionExporterTest
.
class
,
//
SbmlReactionParserTest
.
class
//
})
public
class
AllSbmlReactionParserTests
{
}
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionExporterTest.java
0 → 100644
View file @
dd9bc16f
package
lcsb.mapviewer.converter.model.sbml.reaction
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
org.junit.Test
;
import
org.sbml.jsbml.Model
;
import
org.sbml.jsbml.SBMLDocument
;
import
org.sbml.jsbml.ext.layout.Dimensions
;
import
org.sbml.jsbml.ext.layout.Layout
;
import
org.sbml.jsbml.ext.layout.LayoutModelPlugin
;
import
lcsb.mapviewer.converter.model.sbml.SbmlBioEntityExporter
;
import
lcsb.mapviewer.converter.model.sbml.SbmlCompartmentExporter
;
import
lcsb.mapviewer.converter.model.sbml.species.SbmlSpeciesExporter
;
import
lcsb.mapviewer.model.map.InconsistentModelException
;
import
lcsb.mapviewer.model.map.model.ModelFullIndexed
;
import
lcsb.mapviewer.model.map.reaction.type.TriggerReaction
;
import
lcsb.mapviewer.model.map.species.Species
;
public
class
SbmlReactionExporterTest
{
@Test
public
void
testTriggerReactionToSbml
()
throws
InconsistentModelException
{
ModelFullIndexed
model
=
new
ModelFullIndexed
(
null
);
SbmlReactionExporter
exporter
=
createExporter
(
model
);
org
.
sbml
.
jsbml
.
Reaction
result
=
exporter
.
createSbmlElement
(
new
TriggerReaction
());
assertNotNull
(
result
);
}
private
SbmlReactionExporter
createExporter
(
ModelFullIndexed
model
)
{
SBMLDocument
doc
=
new
SBMLDocument
(
3
,
1
);
Model
result
=
doc
.
createModel
(
model
.
getIdModel
());
result
.
setName
(
model
.
getName
());
LayoutModelPlugin
plugin
=
new
LayoutModelPlugin
(
result
);
Layout
layout
=
new
Layout
();
Dimensions
dimensions
=
new
Dimensions
();
if
(
model
.
getHeight
()
!=
null
)
{
dimensions
.
setHeight
(
model
.
getHeight
());
}
else
{
dimensions
.
setHeight
(
640
);
}
if
(
model
.
getWidth
()
!=
null
)
{
dimensions
.
setWidth
(
model
.
getWidth
());
}
else
{
dimensions
.
setWidth
(
480
);
}
layout
.
setDimensions
(
dimensions
);
plugin
.
add
(
layout
);
result
.
addExtension
(
"layout"
,
plugin
);
SbmlCompartmentExporter
compartmentExporter
=
new
SbmlCompartmentExporter
(
layout
,
model
);
SbmlBioEntityExporter
<
Species
,
org
.
sbml
.
jsbml
.
Species
>
speciesExporter
=
new
SbmlSpeciesExporter
(
layout
,
model
,
compartmentExporter
);
SbmlReactionExporter
exporter
=
new
SbmlReactionExporter
(
layout
,
model
,
speciesExporter
,
compartmentExporter
);
exporter
.
setSbmlModel
(
result
);
return
exporter
;
}
}
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/reaction/SbmlReactionParserTest.java
View file @
dd9bc16f
...
...
@@ -151,10 +151,11 @@ public class SbmlReactionParserTest {
@Test
public
void
testParseUnknownPositiveInfluence
()
throws
FileNotFoundException
,
InvalidInputDataExecption
{
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/reaction/unknown_positive_influence.xml"
));
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/reaction/unknown_positive_influence.xml"
));
Reaction
reaction
=
model
.
getReactions
().
iterator
().
next
();
assertNotNull
(
reaction
);
assertTrue
(
reaction
instanceof
UnknownPositiveInfluenceReaction
);
assertTrue
(
"Invalid class type: "
+
reaction
.
getClass
(),
reaction
instanceof
UnknownPositiveInfluenceReaction
);
}
@Test
...
...
@@ -167,7 +168,8 @@ public class SbmlReactionParserTest {
@Test
public
void
testParseUnknownNegativeInfluence
()
throws
FileNotFoundException
,
InvalidInputDataExecption
{
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/reaction/unknown_negative_influence.xml"
));
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/reaction/unknown_negative_influence.xml"
));
Reaction
reaction
=
model
.
getReactions
().
iterator
().
next
();
assertNotNull
(
reaction
);
assertTrue
(
reaction
instanceof
UnknownNegativeInfluenceReaction
);
...
...
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/species/SbmlSpeciesParserTest.java
View file @
dd9bc16f
package
lcsb.mapviewer.converter.model.sbml.species
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.io.FileNotFoundException
;
...
...
@@ -7,6 +8,7 @@ import java.io.FileNotFoundException;
import
org.apache.log4j.Logger
;
import
org.junit.Test
;
import
lcsb.mapviewer.common.geometry.ColorParser
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.InvalidInputDataExecption
;
import
lcsb.mapviewer.converter.model.sbml.SbmlParser
;
...
...
@@ -30,11 +32,14 @@ public class SbmlSpeciesParserTest {
Logger
logger
=
Logger
.
getLogger
(
SbmlSpeciesParserTest
.
class
);
SbmlParser
parser
=
new
SbmlParser
();
ColorParser
colorParser
=
new
ColorParser
();
@Test
public
void
testParseAntisenseRna
()
throws
FileNotFoundException
,
InvalidInputDataExecption
{
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/antisense_rna.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
AntisenseRna
);
assertEquals
(
ElementColorEnum
.
ANTISENSE_RNA
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -42,6 +47,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/complex.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Complex
);
assertEquals
(
ElementColorEnum
.
COMPLEX
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -49,6 +55,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/degraded.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Degraded
);
assertEquals
(
ElementColorEnum
.
DEGRADED
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -56,6 +63,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/drug.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Drug
);
assertEquals
(
ElementColorEnum
.
DRUG
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -63,6 +71,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/gene.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Gene
);
assertEquals
(
ElementColorEnum
.
GENE
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -70,6 +79,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/generic_protein.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
GenericProtein
);
assertEquals
(
ElementColorEnum
.
GENERIC_PROTEIN
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -77,6 +87,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/ion_channel.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
IonChannelProtein
);
assertEquals
(
ElementColorEnum
.
ION_CHANNEL
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -84,6 +95,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/ion.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Ion
);
assertEquals
(
ElementColorEnum
.
ION
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -91,6 +103,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/phenotype.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
Phenotype
);
assertEquals
(
ElementColorEnum
.
PHENOTYPE
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -98,6 +111,7 @@ public class SbmlSpeciesParserTest {
Model
model
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
"testFiles/small/receptor.xml"
));
Element
element
=
model
.
getElementByElementId
(
"s1"
);
assertTrue
(
element
instanceof
ReceptorProtein
);
assertEquals
(
ElementColorEnum
.
RECEPTOR
.
getColor
(),
element
.
getColor
());
}
@Test
...
...
@@ -105,6 +119,7 @@ public class SbmlSpeciesParserTest {