Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Devrim Gunyel
core
Commits
67255046
Commit
67255046
authored
Sep 18, 2019
by
Piotr Gawron
Browse files
export of reaction properly align lines that are not attached to elements
parent
aa464c39
Changes
5
Hide whitespace changes
Inline
Side-by-side
CHANGELOG
View file @
67255046
...
@@ -19,6 +19,8 @@ minerva (14.0.0~beta.2) unstable; urgency=low
...
@@ -19,6 +19,8 @@ minerva (14.0.0~beta.2) unstable; urgency=low
*
Bug
fix
:
hide
glyphs
tab
when
necessary
(#
949
)
*
Bug
fix
:
hide
glyphs
tab
when
necessary
(#
949
)
*
Bug
fix
:
user
with
write
access
but
without
can_create_privileges
cannot
*
Bug
fix
:
user
with
write
access
but
without
can_create_privileges
cannot
create
data
overlay
(#
939
)
create
data
overlay
(#
939
)
*
Bug
fix
:
export
to
CD
could
misalign
reaction
lines
that
were
imported
from
format
that
didn
't require reaction line to be attached to the species (#933)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 16 Sep 2019 21:00:00 +0200
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 16 Sep 2019 21:00:00 +0200
...
...
converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXml.java
View file @
67255046
...
@@ -963,6 +963,7 @@ public class ReactionToXml {
...
@@ -963,6 +963,7 @@ public class ReactionToXml {
String
getEditPointsXmlStringForSimpleReaction
(
Reaction
reaction
)
{
String
getEditPointsXmlStringForSimpleReaction
(
Reaction
reaction
)
{
Product
product
=
reaction
.
getProducts
().
get
(
0
);
Product
product
=
reaction
.
getProducts
().
get
(
0
);
Reactant
reactant
=
reaction
.
getReactants
().
get
(
0
);
Reactant
reactant
=
reaction
.
getReactants
().
get
(
0
);
List
<
Point2D
>
points
=
new
ArrayList
<>();
List
<
Point2D
>
points
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
reactant
.
getLine
().
getPoints
().
size
()
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
reactant
.
getLine
().
getPoints
().
size
()
-
1
;
i
++)
{
points
.
add
(
reactant
.
getLine
().
getPoints
().
get
(
i
));
points
.
add
(
reactant
.
getLine
().
getPoints
().
get
(
i
));
...
@@ -986,9 +987,18 @@ public class ReactionToXml {
...
@@ -986,9 +987,18 @@ public class ReactionToXml {
}
}
PolylineData
pd
=
new
PolylineData
(
points
);
PolylineData
pd
=
new
PolylineData
(
points
);
pd
.
setPoint
(
0
,
getAnchorPoint
(
reactant
.
getElement
(),
reactant
.
getLine
().
getBeginPoint
()));
pd
.
setPoint
(
pd
.
getPoints
().
size
()
-
1
,
getAnchorPoint
(
product
.
getElement
(),
productLine
.
getEndPoint
()));
return
getEditPointsXmlStringForLine
(
new
PolylineData
[]
{
pd
},
centerPosition
);
return
getEditPointsXmlStringForLine
(
new
PolylineData
[]
{
pd
},
centerPosition
);
}
}
private
Point2D
getAnchorPoint
(
Element
element
,
Point2D
originalPoint
)
{
CellDesignerAliasConverter
converter
=
new
CellDesignerAliasConverter
(
element
,
sbgn
);
CellDesignerAnchor
anchor
=
converter
.
getAnchorForCoordinates
(
element
,
originalPoint
);
return
converter
.
getPointCoordinates
(
element
,
anchor
);
}
/**
/**
* Creates valid xml node with connectScheme for the reaction.
* Creates valid xml node with connectScheme for the reaction.
*
*
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerTestFunctions.java
View file @
67255046
...
@@ -230,7 +230,7 @@ public abstract class CellDesignerTestFunctions {
...
@@ -230,7 +230,7 @@ public abstract class CellDesignerTestFunctions {
throws
InconsistentModelException
,
UnsupportedEncodingException
,
InvalidInputDataExecption
{
throws
InconsistentModelException
,
UnsupportedEncodingException
,
InvalidInputDataExecption
{
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xmlString
=
parser
.
model2String
(
model
);
String
xmlString
=
parser
.
model2String
(
model
);
logger
.
debug
(
xmlString
);
//
logger.debug(xmlString);
InputStream
is
=
new
ByteArrayInputStream
(
xmlString
.
getBytes
(
"UTF-8"
));
InputStream
is
=
new
ByteArrayInputStream
(
xmlString
.
getBytes
(
"UTF-8"
));
Model
model2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
is
).
sizeAutoAdjust
(
false
));
Model
model2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
is
).
sizeAutoAdjust
(
false
));
...
...
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java
View file @
67255046
...
@@ -799,5 +799,56 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
...
@@ -799,5 +799,56 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
assertEquals
(
"Whole reaction should use the same reaction type"
,
1
,
reactionTypes
.
size
());
assertEquals
(
"Whole reaction should use the same reaction type"
,
1
,
reactionTypes
.
size
());
}
}
@Test
public
void
testExportReactoinWithLinesNotAttachedToSpecies
()
throws
Exception
{
Model
model
=
new
ModelFullIndexed
(
null
);
model
.
setIdModel
(
"as"
);
model
.
setWidth
(
1000
);
model
.
setHeight
(
1000
);
Species
protein
=
new
SimpleMolecule
(
"id1"
);
protein
.
setX
(
383
);
protein
.
setY
(
584
);
protein
.
setWidth
(
140
);
protein
.
setHeight
(
60
);
model
.
addElement
(
protein
);
Species
protein2
=
new
SimpleMolecule
(
"id2"
);
protein2
.
setX
(
351
);
protein2
.
setY
(
697
);
protein2
.
setWidth
(
100
);
protein2
.
setHeight
(
60
);
model
.
addElement
(
protein2
);
Reaction
reaction
=
new
StateTransitionReaction
();
reaction
.
setIdReaction
(
"re1"
);
reaction
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
401.0
,
673.0
),
new
Point2D
.
Double
(
401.0
,
673.0
)));
Reactant
reactant
=
new
Reactant
(
protein
);
reactant
.
setLine
(
new
PolylineData
(
Arrays
.
asList
(
new
Point2D
.
Double
(
420.0
,
644.0
),
new
Point2D
.
Double
(
420.0
,
654.0
),
new
Point2D
.
Double
(
401.0
,
654.0
),
new
Point2D
.
Double
(
401.0
,
665.0
))));
reaction
.
addReactant
(
reactant
);
model
.
addReaction
(
reaction
);
Product
product
=
new
Product
(
protein2
);
product
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(
401.0
,
673.0
),
new
Point2D
.
Double
(
401.0
,
697.0
)));
reaction
.
addProduct
(
product
);
Model
model2
=
serializeModel
(
model
);
Reaction
reaction2
=
model2
.
getReactionByReactionId
(
"re1"
);
Reactant
newReactant
=
reaction2
.
getReactants
().
get
(
0
);
// center part of the line shouldn't change - edges should be aligned to touch
// species
assertEquals
(
0
,
newReactant
.
getLine
().
getPoints
().
get
(
1
).
distance
(
reactant
.
getLine
().
getPoints
().
get
(
1
)),
Configuration
.
EPSILON
);
assertEquals
(
0
,
newReactant
.
getLine
().
getPoints
().
get
(
2
).
distance
(
reactant
.
getLine
().
getPoints
().
get
(
2
)),
Configuration
.
EPSILON
);
}
}
}
converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java
View file @
67255046
...
@@ -47,6 +47,9 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
...
@@ -47,6 +47,9 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
Model
model
=
new
ModelFullIndexed
(
null
);
Model
model
=
new
ModelFullIndexed
(
null
);
Species
protein1
=
new
GenericProtein
(
"2"
);
Species
protein1
=
new
GenericProtein
(
"2"
);
Species
protein2
=
new
GenericProtein
(
"3"
);
Species
protein2
=
new
GenericProtein
(
"3"
);
protein2
.
setX
(
100
);
protein2
.
setY
(
100
);
Species
protein3
=
new
GenericProtein
(
"4"
);
model
.
addElement
(
protein1
);
model
.
addElement
(
protein1
);
model
.
addElement
(
protein2
);
model
.
addElement
(
protein2
);
...
@@ -61,10 +64,10 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
...
@@ -61,10 +64,10 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
reaction
.
addReactant
(
reactant
);
reaction
.
addReactant
(
reactant
);
reaction
.
addProduct
(
product
);
reaction
.
addProduct
(
product
);
Modifier
modifier
=
new
Catalysis
(
protein
1
);
Modifier
modifier
=
new
Catalysis
(
protein
3
);
modifier
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(),
new
Point2D
.
Double
(
30
,
0
)));
modifier
.
setLine
(
new
PolylineData
(
new
Point2D
.
Double
(),
new
Point2D
.
Double
(
30
,
0
)));
Modifier
modifier2
=
new
Catalysis
(
protein
1
);
Modifier
modifier2
=
new
Catalysis
(
protein
3
);
List
<
Point2D
>
points
=
new
ArrayList
<>();
List
<
Point2D
>
points
=
new
ArrayList
<>();
points
.
add
(
new
Point2D
.
Double
(
0
,
0
));
points
.
add
(
new
Point2D
.
Double
(
0
,
0
));
points
.
add
(
new
Point2D
.
Double
(
30
,
30
));
points
.
add
(
new
Point2D
.
Double
(
30
,
30
));
...
@@ -101,6 +104,7 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
...
@@ -101,6 +104,7 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
Model
model
=
new
ModelFullIndexed
(
null
);
Model
model
=
new
ModelFullIndexed
(
null
);
Species
protein1
=
new
GenericProtein
(
"2"
);
Species
protein1
=
new
GenericProtein
(
"2"
);
protein1
.
setX
(
100
);
Species
protein2
=
new
GenericProtein
(
"3"
);
Species
protein2
=
new
GenericProtein
(
"3"
);
model
.
addElement
(
protein1
);
model
.
addElement
(
protein1
);
...
@@ -249,10 +253,18 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
...
@@ -249,10 +253,18 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
@Test
@Test
public
void
testGetEditPointsXmlStringForSimpleReaction
()
{
public
void
testGetEditPointsXmlStringForSimpleReaction
()
{
Reaction
r
=
new
TriggerReaction
();
Reaction
r
=
new
TriggerReaction
();
Product
product
=
new
Product
();
Species
productSpecies
=
new
GenericProtein
(
"id1"
);
productSpecies
.
setX
(
20
);
productSpecies
.
setY
(
20
);
productSpecies
.
setWidth
(
20
);
productSpecies
.
setHeight
(
20
);
Product
product
=
new
Product
(
productSpecies
);
PolylineData
productLine
=
new
PolylineData
(
new
Point2D
.
Double
(
10
,
10
),
new
Point2D
.
Double
(
20
,
20
));
PolylineData
productLine
=
new
PolylineData
(
new
Point2D
.
Double
(
10
,
10
),
new
Point2D
.
Double
(
20
,
20
));
product
.
setLine
(
productLine
);
product
.
setLine
(
productLine
);
Reactant
reactant
=
new
Reactant
();
Species
reactantSpecies
=
new
GenericProtein
(
"id1"
);
reactantSpecies
.
setWidth
(
10
);
reactantSpecies
.
setHeight
(
10
);
Reactant
reactant
=
new
Reactant
(
reactantSpecies
);
PolylineData
reactantLine
=
new
PolylineData
(
new
Point2D
.
Double
(
0
,
0
),
new
Point2D
.
Double
(
10
,
10
));
PolylineData
reactantLine
=
new
PolylineData
(
new
Point2D
.
Double
(
0
,
0
),
new
Point2D
.
Double
(
10
,
10
));
reactant
.
setLine
(
reactantLine
);
reactant
.
setLine
(
reactantLine
);
r
.
addProduct
(
product
);
r
.
addProduct
(
product
);
...
@@ -264,10 +276,18 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
...
@@ -264,10 +276,18 @@ public class ReactionToXmlTest extends CellDesignerTestFunctions {
@Test
@Test
public
void
testGetEditPointsXmlStringForSimpleReactionWhenNotImportedFromCD
()
{
public
void
testGetEditPointsXmlStringForSimpleReactionWhenNotImportedFromCD
()
{
Reaction
r
=
new
TriggerReaction
();
Reaction
r
=
new
TriggerReaction
();
Product
product
=
new
Product
();
Species
productSpecies
=
new
GenericProtein
(
"id1"
);
productSpecies
.
setX
(
20
);
productSpecies
.
setY
(
20
);
productSpecies
.
setWidth
(
20
);
productSpecies
.
setHeight
(
20
);
Product
product
=
new
Product
(
productSpecies
);
PolylineData
productLine
=
new
PolylineData
(
new
Point2D
.
Double
(
10
,
10
),
new
Point2D
.
Double
(
20
,
10
));
PolylineData
productLine
=
new
PolylineData
(
new
Point2D
.
Double
(
10
,
10
),
new
Point2D
.
Double
(
20
,
10
));
product
.
setLine
(
productLine
);
product
.
setLine
(
productLine
);
Reactant
reactant
=
new
Reactant
();
Species
reactantSpecies
=
new
GenericProtein
(
"id1"
);
reactantSpecies
.
setWidth
(
10
);
reactantSpecies
.
setHeight
(
10
);
Reactant
reactant
=
new
Reactant
(
reactantSpecies
);
PolylineData
reactantLine
=
new
PolylineData
(
new
Point2D
.
Double
(
0
,
0
),
new
Point2D
.
Double
(
10
,
10
));
PolylineData
reactantLine
=
new
PolylineData
(
new
Point2D
.
Double
(
0
,
0
),
new
Point2D
.
Double
(
10
,
10
));
reactant
.
setLine
(
reactantLine
);
reactant
.
setLine
(
reactantLine
);
r
.
addProduct
(
product
);
r
.
addProduct
(
product
);
...
...
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