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
minerva
core
Commits
366411ec
Commit
366411ec
authored
Jan 06, 2022
by
Piotr Gawron
Browse files
Merge branch '1622-export-to-sbml' into 'devel_16.0.x'
Resolve "problem with jsbml" See merge request
!1409
parents
7e3dc7cc
48d28b7f
Pipeline
#51106
failed with stage
in 13 minutes and 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
366411ec
...
...
@@ -13,6 +13,8 @@ minerva (16.0.6) stable; urgency=medium
*
Bug
fix
:
when
there
is
problem
with
loading
data
from
minerva
(
"Load failed"
)
suggestion
about
retrying
before
submitting
error
report
is
provided
(#
1623
)
*
Bug
fix
:
export
to
SBML
of
model
that
contained
compartment
with
"default_compartment"
id
was
crashing
(#
1622
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Thu
,
16
Dec
2021
11
:
00
:
00
+
0200
...
...
converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/compartment/SbmlCompartmentExporter.java
View file @
366411ec
package
lcsb.mapviewer.converter.model.sbml.compartment
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.sbml.jsbml.Model
;
import
org.sbml.jsbml.ext.layout.*
;
import
org.sbml.jsbml.ext.layout.AbstractReferenceGlyph
;
import
org.sbml.jsbml.ext.layout.BoundingBox
;
import
org.sbml.jsbml.ext.layout.CompartmentGlyph
;
import
org.sbml.jsbml.ext.layout.Dimensions
;
import
org.sbml.jsbml.ext.layout.Point
;
import
org.sbml.jsbml.ext.multi.MultiCompartmentPlugin
;
import
org.sbml.jsbml.ext.render.*
;
import
org.sbml.jsbml.ext.render.Ellipse
;
import
org.sbml.jsbml.ext.render.LocalStyle
;
import
org.sbml.jsbml.ext.render.Rectangle
;
import
org.sbml.jsbml.ext.render.RelAbsVector
;
import
lcsb.mapviewer.converter.model.sbml.SbmlElementExporter
;
import
lcsb.mapviewer.converter.model.sbml.SbmlExtension
;
...
...
@@ -22,8 +31,8 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
@SuppressWarnings
(
"unused"
)
private
static
Logger
logger
=
LogManager
.
getLogger
();
public
SbmlCompartmentExporter
(
Model
sbmlModel
,
lcsb
.
mapviewer
.
model
.
map
.
model
.
Model
minervaModel
,
Collection
<
SbmlExtension
>
sbmlExtensions
)
{
public
SbmlCompartmentExporter
(
final
Model
sbmlModel
,
final
lcsb
.
mapviewer
.
model
.
map
.
model
.
Model
minervaModel
,
final
Collection
<
SbmlExtension
>
sbmlExtensions
)
{
super
(
sbmlModel
,
minervaModel
,
sbmlExtensions
);
}
...
...
@@ -45,7 +54,7 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
}
@Override
public
org
.
sbml
.
jsbml
.
Compartment
createSbmlElement
(
Compartment
element
)
throws
InconsistentModelException
{
public
org
.
sbml
.
jsbml
.
Compartment
createSbmlElement
(
final
Compartment
element
)
throws
InconsistentModelException
{
org
.
sbml
.
jsbml
.
Compartment
result
;
if
(
element
==
null
||
getElementId
(
element
).
equals
(
"default"
))
{
result
=
getSbmlModel
().
createCompartment
(
"default"
);
...
...
@@ -65,7 +74,7 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
}
@Override
public
org
.
sbml
.
jsbml
.
Compartment
getSbmlElement
(
Compartment
element
)
throws
InconsistentModelException
{
public
org
.
sbml
.
jsbml
.
Compartment
getSbmlElement
(
final
Compartment
element
)
throws
InconsistentModelException
{
String
mapKey
=
getSbmlIdKey
(
element
);
if
(
element
==
null
&&
sbmlElementByElementNameAndCompartmentName
.
get
(
mapKey
)
==
null
)
{
org
.
sbml
.
jsbml
.
Compartment
sbmlElement
=
createSbmlElement
(
element
);
...
...
@@ -75,7 +84,7 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
}
@Override
protected
String
getSbmlIdKey
(
Compartment
compartment
)
{
protected
String
getSbmlIdKey
(
final
Compartment
compartment
)
{
if
(
compartment
==
null
||
getElementId
(
compartment
).
equals
(
"default"
))
{
return
"default"
;
}
...
...
@@ -83,16 +92,20 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
}
@Override
protected
AbstractReferenceGlyph
createElementGlyph
(
String
sbmlCompartmentId
,
String
glyphId
)
{
protected
AbstractReferenceGlyph
createElementGlyph
(
final
String
sbmlCompartmentId
,
String
glyphId
)
{
if
(
sbmlCompartmentId
.
equals
(
"default"
))
{
glyphId
=
"default_compartment"
;
while
(
getMinervaModel
().
getElementByElementId
(
glyphId
)
!=
null
||
getMinervaModel
().
getReactionByReactionId
(
glyphId
)
!=
null
)
{
glyphId
=
"default_compartment_"
+
getNextId
();
}
}
CompartmentGlyph
result
=
getLayout
().
createCompartmentGlyph
(
glyphId
,
sbmlCompartmentId
);
return
result
;
}
@Override
protected
LocalStyle
createStyle
(
Compartment
element
)
{
protected
LocalStyle
createStyle
(
final
Compartment
element
)
{
LocalStyle
style
=
super
.
createStyle
(
element
);
style
.
getGroup
().
setStrokeWidth
(
element
.
getThickness
());
style
.
getGroup
().
setFill
(
getColorDefinition
(
element
.
getFillColor
()).
getId
());
...
...
@@ -119,7 +132,7 @@ public class SbmlCompartmentExporter extends SbmlElementExporter<Compartment, or
}
@Override
protected
void
assignLayoutToGlyph
(
Compartment
element
,
AbstractReferenceGlyph
speciesGlyph
)
{
protected
void
assignLayoutToGlyph
(
final
Compartment
element
,
final
AbstractReferenceGlyph
speciesGlyph
)
{
if
(
getElementId
(
element
).
equals
(
"default"
))
{
BoundingBox
boundingBox
=
new
BoundingBox
();
...
...
converter-sbml/src/test/java/lcsb/mapviewer/converter/model/sbml/SbmlExporterTest.java
View file @
366411ec
...
...
@@ -770,4 +770,16 @@ public class SbmlExporterTest extends SbmlTestFunctions {
}
@Test
public
void
testExportWithCompartmentWithProblematicId
()
throws
Exception
{
Model
model
=
createEmptyModel
();
Compartment
defaultCompartment
=
createCompartment
();
defaultCompartment
.
setElementId
(
"default_compartment"
);
model
.
addElement
(
defaultCompartment
);
exporter
.
toXml
(
model
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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