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
738c028e
Commit
738c028e
authored
Jun 29, 2020
by
Piotr Gawron
Browse files
fix export/import notes (export notes for all bionetities and escape xml)
parent
f6c99d46
Pipeline
#29084
passed with stage
in 10 minutes and 49 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
738c028e
...
...
@@ -2,6 +2,8 @@ minerva (15.0.2) stable; urgency=medium
*
Bug
fix
:
annotations
using
identifiers
.
org
urls
sometimes
required
http
and
sometimes
required
https
url
(#
1297
)
*
Bug
fix
:
map
notes
were
not
exported
to
GPML
*
Bug
fix
:
reaction
notes
were
not
imported
from
GPML
*
Bug
fix
:
export
of
notes
could
create
invalid
GPML
file
(#
1299
)
--
Piotr
Gawron
<
piotr
.
gawron
@
uni
.
lu
>
Mon
,
29
Jun
2020
11
:
00
:
00
+
0200
...
...
pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java
View file @
738c028e
...
...
@@ -131,12 +131,16 @@ public class ModelContructor {
species
.
setHypothetical
(
true
);
}
species
.
setName
(
dataNode
.
getName
());
StringBuilder
notes
=
new
StringBuilder
();
species
.
setNotes
(
getComments
(
dataNode
));
return
species
;
}
private
String
getComments
(
PathwayElement
dataNode
)
{
StringBuilder
notes
=
new
StringBuilder
(
""
);
for
(
String
comment
:
dataNode
.
getComments
())
{
notes
.
append
(
comment
+
"\n\n"
);
}
species
.
setNotes
(
notes
.
toString
());
return
species
;
return
notes
.
toString
();
}
/**
...
...
@@ -197,7 +201,7 @@ public class ModelContructor {
protected
void
addElement
(
Model
model
,
Graph
graph
,
Data
data
)
{
for
(
DataNode
dataNode
:
graph
.
getDataNodes
())
{
Species
species
=
createSpecies
(
dataNode
);
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
dataNode
.
getBiopaxReference
()));
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
dataNode
.
getBiopaxReference
s
()));
Element
alias
=
updateAlias
(
dataNode
,
species
);
...
...
@@ -207,7 +211,7 @@ public class ModelContructor {
for
(
Label
label
:
graph
.
getLabels
())
{
if
(
label
.
isTreatAsNode
())
{
Species
species
=
createSpecies
(
label
);
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
label
.
getBiopaxReference
()));
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
label
.
getBiopaxReference
s
()));
Element
alias
=
updateAlias
(
label
,
species
);
...
...
@@ -221,7 +225,7 @@ public class ModelContructor {
for
(
Shape
shape
:
graph
.
getShapes
())
{
if
(
shape
.
isTreatAsNode
())
{
Species
species
=
createSpecies
(
shape
);
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
shape
.
getBiopaxReference
()));
species
.
addMiriamData
(
biopaxFactory
.
getMiriamData
(
graph
.
getBiopaxData
(),
shape
.
getBiopaxReference
s
()));
Element
alias
=
updateAlias
(
shape
,
species
);
...
...
@@ -671,6 +675,8 @@ public class ModelContructor {
reaction
.
setReversible
(
true
);
}
}
reaction
.
setNotes
(
getComments
(
interaction
));
reaction
.
addMiriamData
(
interaction
.
getReferences
());
reaction
.
setZ
(
interaction
.
getzOrder
());
...
...
pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelToGPML.java
View file @
738c028e
...
...
@@ -7,6 +7,7 @@ import java.awt.geom.*;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.apache.commons.text.StringEscapeUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -338,7 +339,7 @@ public class ModelToGPML {
String
shape
=
ShapeMapping
.
getShape
(
ca
.
getClass
()).
getStringRepresentation
();
comparments
.
append
(
" <Shape TextLabel=\""
+
ca
.
getName
()
+
"\" GraphId=\""
+
ca
.
getElementId
()
+
"\">\n"
);
comparments
.
append
(
" <Comment>"
+
getAllNames
(
ca
)
+
"</Comment>\n"
);
comparments
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
getAllNames
(
ca
)
)
+
"</Comment>\n"
);
comparments
.
append
(
" <Attribute Key=\"org.pathvisio.CellularComponentProperty\" Value=\"Cell\" />\n"
);
comparments
.
append
(
" <Attribute Key=\"org.pathvisio.DoubleLineProperty\" Value=\"Double\" />\n"
);
comparments
.
append
(
...
...
@@ -531,7 +532,7 @@ public class ModelToGPML {
}
result
.
append
(
">\n"
);
result
.
append
(
" <Comment>"
+
species
.
getNotes
().
trim
()
+
"</Comment>\n"
);
result
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
species
.
getNotes
().
trim
()
)
+
"</Comment>\n"
);
result
.
append
(
biopaxParser
.
toReferenceXml
(
species
.
getMiriamData
()));
Rectangle2D
rec
=
species
.
getBorder
();
...
...
@@ -564,7 +565,7 @@ public class ModelToGPML {
}
result
.
append
(
">\n"
);
result
.
append
(
" <Comment>"
+
species
.
getNotes
().
trim
()
+
"</Comment>\n"
);
result
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
species
.
getNotes
().
trim
()
)
+
"</Comment>\n"
);
Rectangle2D
rec
=
species
.
getBorder
();
...
...
@@ -607,7 +608,7 @@ public class ModelToGPML {
}
result
.
append
(
">\n"
);
result
.
append
(
" <Comment>"
+
species
.
getNotes
()
+
"</Comment>\n"
);
result
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
species
.
getNotes
()
.
trim
())
+
"</Comment>\n"
);
result
.
append
(
biopaxParser
.
toReferenceXml
(
species
.
getMiriamData
()));
Rectangle2D
rec
=
species
.
getBorder
();
...
...
@@ -721,6 +722,9 @@ public class ModelToGPML {
interactions
.
append
(
" <Interaction GraphId=\""
+
reaction
.
getIdReaction
()
+
"\">\n"
);
interactions
.
append
(
biopaxParser
.
toReferenceXml
(
reaction
.
getMiriamData
()));
if
(
reaction
.
getNotes
()
!=
null
)
{
interactions
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
reaction
.
getNotes
().
trim
())
+
"</Comment>\n"
);
}
interactions
.
append
(
" <Graphics "
+
"ConnectorType=\"Segmented\" "
+
"ZOrder=\""
+
reaction
.
getZ
()
+
"\" "
...
...
@@ -730,6 +734,8 @@ public class ModelToGPML {
}
interactions
.
append
(
"LineThickness=\""
+
reaction
.
getLine
().
getWidth
()
+
"\">\n"
);
/** Start and End **/
Reactant
start
=
reaction
.
getReactants
().
get
(
0
);
Product
end
=
reaction
.
getProducts
().
get
(
0
);
...
...
@@ -806,7 +812,7 @@ public class ModelToGPML {
gpml
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
);
gpml
.
append
(
"<Pathway xmlns=\"http://pathvisio.org/GPML/2013a\" Name=\"Generated\">\n"
);
if
(
model
.
getNotes
()
!=
null
)
{
gpml
.
append
(
" <Comment>"
+
model
.
getNotes
().
trim
()
+
"</Comment>\n"
);
gpml
.
append
(
" <Comment>"
+
StringEscapeUtils
.
escapeXml11
(
model
.
getNotes
().
trim
()
)
+
"</Comment>\n"
);
}
gpml
.
append
(
" <Graphics BoardWidth=\""
+
model
.
getWidth
()
+
"\" BoardHeight=\""
+
model
.
getHeight
()
+
"\"/>\n"
);
...
...
pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/Interaction.java
View file @
738c028e
package
lcsb.mapviewer.wikipathway.model
;
import
java.awt.Color
;
import
java.awt.geom.Rectangle2D
;
import
java.io.Serializable
;
import
java.util.*
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
lcsb.mapviewer.common.exception.NotImplementedException
;
import
lcsb.mapviewer.model.graphics.PolylineData
;
import
lcsb.mapviewer.model.map.MiriamData
;
...
...
@@ -16,7 +18,7 @@ import lcsb.mapviewer.model.map.MiriamData;
* @author Jan Badura
*
*/
public
class
Interaction
implements
Serializable
{
public
class
Interaction
extends
PathwayElement
implements
Serializable
{
static
Logger
logger
=
LogManager
.
getLogger
();
/**
...
...
@@ -24,11 +26,6 @@ public class Interaction implements Serializable {
*/
private
static
final
long
serialVersionUID
=
1L
;
/**
* Identifier in GPML model.
*/
private
String
graphId
;
/**
* Where this {@link Interaction} starts (in which {@link Edge}/
* {@link Interaction}).
...
...
@@ -46,11 +43,6 @@ public class Interaction implements Serializable {
*/
private
PolylineData
line
;
/**
* Z order of the {@link Interaction} (how far it should be located in the z
* coordinate).
*/
private
Integer
zOrder
;
/**
* Gpml interaction type (arrow).
...
...
@@ -62,10 +54,6 @@ public class Interaction implements Serializable {
*/
private
Set
<
String
>
anchors
;
/**
* Comments.
*/
private
List
<
String
>
comments
=
new
ArrayList
<>();
/**
* List of edges representing reactants in interaction.
...
...
@@ -82,11 +70,6 @@ public class Interaction implements Serializable {
*/
private
Set
<
Edge
>
modifiers
=
new
HashSet
<>();
/**
* Identifiers of BioPax references.
*/
private
Set
<
String
>
biopaxReferences
=
new
HashSet
<>();
/**
* References for given edge.
*/
...
...
@@ -101,7 +84,7 @@ public class Interaction implements Serializable {
* object will be created from this {@link Edge}
*/
public
Interaction
(
Edge
edge
)
{
graphId
=
edge
.
getGraphId
();
super
(
edge
.
getGraphId
()
,
null
)
;
setStart
(
edge
.
getStart
());
setEnd
(
edge
.
getEnd
());
setLine
(
edge
.
getLine
());
...
...
@@ -111,8 +94,8 @@ public class Interaction implements Serializable {
addReference
(
new
MiriamData
(
md
));
}
setColor
(
edge
.
getColor
());
this
.
c
omments
.
addAll
(
edge
.
getComments
());
b
iopaxReferences
.
addAll
(
edge
.
getBiopaxReferences
());
addC
omments
(
edge
.
getComments
());
addB
iopaxReferences
(
edge
.
getBiopaxReferences
());
reversible
=
edge
.
isReversibleReaction
();
}
...
...
@@ -133,23 +116,6 @@ public class Interaction implements Serializable {
references
.
add
(
reference
);
}
/**
* @return the graphId
* @see #graphId
*/
public
String
getGraphId
()
{
return
graphId
;
}
/**
* @param graphId
* the graphId to set
* @see #graphId
*/
public
void
setGraphId
(
String
graphId
)
{
this
.
graphId
=
graphId
;
}
/**
* @return the start
* @see #start
...
...
@@ -218,23 +184,6 @@ public class Interaction implements Serializable {
this
.
anchors
=
anchors
;
}
/**
* @return the comment
* @see #comment
*/
public
List
<
String
>
getComments
()
{
return
comments
;
}
/**
* @param comment
* the comment to set
* @see #comment
*/
public
void
addComment
(
String
comment
)
{
this
.
comments
.
add
(
comment
);
}
/**
* @return the reactants
* @see #reactants
...
...
@@ -267,7 +216,7 @@ public class Interaction implements Serializable {
*/
public
void
addProduct
(
Edge
interaction
)
{
this
.
products
.
add
(
interaction
);
b
iopaxReferences
.
addAll
(
interaction
.
getBiopaxReferences
());
addB
iopaxReferences
(
interaction
.
getBiopaxReferences
());
}
/**
...
...
@@ -278,7 +227,7 @@ public class Interaction implements Serializable {
*/
public
void
addModifier
(
Edge
interaction
)
{
this
.
modifiers
.
add
(
interaction
);
b
iopaxReferences
.
addAll
(
interaction
.
getBiopaxReferences
());
addB
iopaxReferences
(
interaction
.
getBiopaxReferences
());
}
/**
...
...
@@ -289,24 +238,7 @@ public class Interaction implements Serializable {
*/
public
void
addReactant
(
Edge
interaction
)
{
this
.
reactants
.
add
(
interaction
);
biopaxReferences
.
addAll
(
interaction
.
getBiopaxReferences
());
}
/**
* @return the biopaxReferences
* @see #biopaxReferences
*/
public
Set
<
String
>
getBiopaxReferences
()
{
return
biopaxReferences
;
}
/**
* @param biopaxReferences
* the biopaxReferences to set
* @see #biopaxReferences
*/
public
void
setBiopaxReferences
(
Set
<
String
>
biopaxReferences
)
{
this
.
biopaxReferences
=
biopaxReferences
;
addBiopaxReferences
(
interaction
.
getBiopaxReferences
());
}
/**
...
...
@@ -371,23 +303,6 @@ public class Interaction implements Serializable {
}
}
/**
* @return the zOrder
* @see #zOrder
*/
public
Integer
getzOrder
()
{
return
zOrder
;
}
/**
* @param zOrder
* the zOrder to set
* @see #zOrder
*/
public
void
setzOrder
(
Integer
zOrder
)
{
this
.
zOrder
=
zOrder
;
}
public
boolean
isReversible
()
{
return
reversible
;
}
...
...
@@ -396,4 +311,14 @@ public class Interaction implements Serializable {
this
.
reversible
=
reversible
;
}
@Override
String
getName
()
{
throw
new
NotImplementedException
();
}
@Override
Rectangle2D
getRectangle
()
{
throw
new
NotImplementedException
();
}
}
pathvisio/src/main/java/lcsb/mapviewer/wikipathway/model/PathwayElement.java
View file @
738c028e
...
...
@@ -2,8 +2,7 @@ package lcsb.mapviewer.wikipathway.model;
import
java.awt.geom.Rectangle2D
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.*
;
import
lcsb.mapviewer.model.LogMarker
;
import
lcsb.mapviewer.model.ProjectLogEntryType
;
...
...
@@ -104,7 +103,7 @@ public abstract class PathwayElement implements Serializable {
* @return the biopaxReference
* @see #biopaxReference
*/
public
List
<
String
>
getBiopaxReference
()
{
public
List
<
String
>
getBiopaxReference
s
()
{
return
biopaxReferences
;
}
...
...
@@ -113,7 +112,7 @@ public abstract class PathwayElement implements Serializable {
* the biopaxReference to set
* @see #biopaxReference
*/
public
void
setBiopaxReference
(
List
<
String
>
biopaxReferences
)
{
public
void
setBiopaxReference
s
(
List
<
String
>
biopaxReferences
)
{
this
.
biopaxReferences
=
biopaxReferences
;
}
...
...
@@ -143,6 +142,10 @@ public abstract class PathwayElement implements Serializable {
public
void
addBiopaxReference
(
String
biopaxString
)
{
biopaxReferences
.
add
(
biopaxString
);
}
public
void
addBiopaxReferences
(
Collection
<
String
>
biopaxStrings
)
{
biopaxReferences
.
addAll
(
biopaxStrings
);
}
/**
* @return the comments
...
...
@@ -161,6 +164,10 @@ public abstract class PathwayElement implements Serializable {
this
.
comments
.
add
(
comment
);
}
public
void
addComments
(
Collection
<
String
>
comments
)
{
this
.
comments
.
addAll
(
comments
);
}
public
String
getMapName
()
{
return
mapName
;
}
...
...
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/DataNodeParserTest.java
View file @
738c028e
...
...
@@ -33,8 +33,8 @@ public class DataNodeParserTest extends WikipathwaysTestFunctions {
assertNotNull
(
dataNode
);
assertEquals
(
"GeneProduct"
,
dataNode
.
getTextLabel
());
assertEquals
(
"ab30b"
,
dataNode
.
getGraphId
());
assertEquals
(
1
,
dataNode
.
getBiopaxReference
().
size
());
assertEquals
(
"aea"
,
dataNode
.
getBiopaxReference
().
get
(
0
));
assertEquals
(
1
,
dataNode
.
getBiopaxReference
s
().
size
());
assertEquals
(
"aea"
,
dataNode
.
getBiopaxReference
s
().
get
(
0
));
assertEquals
(
1
,
dataNode
.
getReferences
().
size
());
assertEquals
(
new
MiriamData
(
MiriamType
.
HGNC_SYMBOL
,
"SNCA"
),
dataNode
.
getReferences
().
get
(
0
));
...
...
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/LabelParserTest.java
View file @
738c028e
...
...
@@ -29,8 +29,8 @@ public class LabelParserTest extends WikipathwaysTestFunctions {
assertEquals
(
"Label 2"
,
label
.
getTextLabel
());
assertEquals
(
"edf06"
,
label
.
getGraphId
());
assertEquals
(
2
,
label
.
getBiopaxReference
().
size
());
assertEquals
(
"b38"
,
label
.
getBiopaxReference
().
get
(
1
));
assertEquals
(
2
,
label
.
getBiopaxReference
s
().
size
());
assertEquals
(
"b38"
,
label
.
getBiopaxReference
s
().
get
(
1
));
assertEquals
((
Integer
)
28672
,
label
.
getzOrder
());
assertEquals
((
Double
)
10.0
,
label
.
getFontSize
());
...
...
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java
View file @
738c028e
...
...
@@ -22,6 +22,7 @@ import lcsb.mapviewer.model.map.compartment.Compartment;
import
lcsb.mapviewer.model.map.compartment.SquareCompartment
;
import
lcsb.mapviewer.model.map.model.*
;
import
lcsb.mapviewer.model.map.reaction.*
;
import
lcsb.mapviewer.model.map.reaction.type.StateTransitionReaction
;
import
lcsb.mapviewer.model.map.reaction.type.TransportReaction
;
import
lcsb.mapviewer.model.map.species.*
;
import
lcsb.mapviewer.model.map.species.field.ModificationState
;
...
...
@@ -201,7 +202,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
}
private
Reaction
createReaction
(
Species
p1
,
Species
p2
)
{
Reaction
reaction
=
new
Transport
Reaction
(
"re"
+
(
speciesCounter
++));
Reaction
reaction
=
new
StateTransition
Reaction
(
"re"
+
(
speciesCounter
++));
Reactant
reactant
=
new
Reactant
(
p1
);
Product
product
=
new
Product
(
p2
);
reaction
.
addReactant
(
reactant
);
...
...
@@ -410,4 +411,33 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions {
assertEquals
(
0
,
new
ModelComparator
().
compare
(
model
,
model2
));
}
@Test
public
void
testHtmlTagInNotes
()
throws
Exception
{
Model
model
=
new
ModelFullIndexed
(
null
);
model
.
setWidth
(
1000
);
model
.
setHeight
(
1000
);
model
.
setNotes
(
"a < b"
);
Species
p1
=
createProtein
();
p1
.
setNotes
(
"<a href='https://google.lu/'>link</a>"
);
model
.
addElement
(
p1
);
Species
p2
=
createProtein
();
model
.
addElement
(
p2
);
Reaction
r
=
createReaction
(
p1
,
p2
);
r
.
setNotes
(
"<xml>tag</xml>"
);
model
.
addReaction
(
r
);
lcsb
.
mapviewer
.
wikipathway
.
GpmlParser
parser
=
new
lcsb
.
mapviewer
.
wikipathway
.
GpmlParser
();
String
xml
=
parser
.
model2String
(
model
);
Model
model2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
new
ByteArrayInputStream
(
xml
.
getBytes
())));
assertEquals
(
0
,
new
ModelComparator
().
compare
(
model
,
model2
));
}
}
pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ShapeParserTest.java
View file @
738c028e
...
...
@@ -47,8 +47,8 @@ public class ShapeParserTest extends WikipathwaysTestFunctions {
assertEquals
(
"dfdfs fds "
,
shape
.
getTextLabel
());
assertEquals
(
"eb55e"
,
shape
.
getGraphId
());
assertEquals
(
1
,
shape
.
getBiopaxReference
().
size
());
assertEquals
(
"d04"
,
shape
.
getBiopaxReference
().
get
(
0
));
assertEquals
(
1
,
shape
.
getBiopaxReference
s
().
size
());
assertEquals
(
"d04"
,
shape
.
getBiopaxReference
s
().
get
(
0
));
assertEquals
((
Integer
)
16384
,
shape
.
getzOrder
());
assertEquals
((
Double
)
10.0
,
shape
.
getFontSize
());
...
...
@@ -69,8 +69,8 @@ public class ShapeParserTest extends WikipathwaysTestFunctions {
assertEquals
(
"compartment title"
,
shape
.
getTextLabel
());
assertEquals
(
"c5869"
,
shape
.
getGraphId
());
assertEquals
(
1
,
shape
.
getBiopaxReference
().
size
());
assertEquals
(
"b80"
,
shape
.
getBiopaxReference
().
get
(
0
));
assertEquals
(
1
,
shape
.
getBiopaxReference
s
().
size
());
assertEquals
(
"b80"
,
shape
.
getBiopaxReference
s
().
get
(
0
));
assertEquals
((
Integer
)
16384
,
shape
.
getzOrder
());
assertEquals
((
Double
)
10.0
,
shape
.
getFontSize
());
...
...
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