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
Devrim Gunyel
core
Commits
f7c0f018
Commit
f7c0f018
authored
May 10, 2019
by
Piotr Gawron
Browse files
export to CellDesigner doesn't support z-index, therefore it must be ignored in comparison
parent
c0afff14
Changes
5
Hide whitespace changes
Inline
Side-by-side
model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java
View file @
f7c0f018
package
lcsb.mapviewer.commands
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -8,58 +11,77 @@ import java.util.Map;
import
org.apache.log4j.Logger
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.InvalidInputDataExecption
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.model.map.Drawable
;
import
lcsb.mapviewer.model.map.InconsistentModelException
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelFullIndexed
;
import
lcsb.mapviewer.model.map.species.Complex
;
import
lcsb.mapviewer.model.map.species.GenericProtein
;
public
abstract
class
CommandTestFunctions
{
public
double
EPSILON
=
1
e
-
6
;
Logger
logger
=
Logger
.
getLogger
(
CommandTestFunctions
.
class
);
private
static
Map
<
String
,
Model
>
models
=
new
HashMap
<
String
,
Model
>();
protected
Model
getModelForFile
(
String
fileName
,
boolean
fromCache
)
throws
Exception
{
if
(!
fromCache
)
{
logger
.
debug
(
"File without cache: "
+
fileName
);
Model
result
=
new
CellDesignerXmlParser
().
createModel
(
new
ConverterParams
().
filename
(
fileName
));
result
.
setName
(
null
);
return
result
;
}
Model
result
=
models
.
get
(
fileName
);
if
(
result
==
null
)
{
logger
.
debug
(
"File to cache: "
+
fileName
);
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
result
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
fileName
).
sizeAutoAdjust
(
false
));
result
.
setName
(
null
);
models
.
put
(
fileName
,
result
);
}
return
result
;
}
protected
Model
createSimpleModel
()
{
Model
model
=
new
ModelFullIndexed
(
null
);
GenericProtein
alias
=
new
GenericProtein
(
"alias_id"
);
alias
.
setNotes
(
null
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"synonym"
);
alias
.
addSynonyms
(
list
);
List
<
String
>
list2
=
new
ArrayList
<>();
list2
.
add
(
"f_symbol"
);
alias
.
setFormerSymbols
(
list2
);
Complex
complexAlias
=
new
Complex
(
"complex_alias_id"
);
model
.
addElement
(
complexAlias
);
complexAlias
.
addSpecies
(
alias
);
model
.
addElement
(
alias
);
return
model
;
}
public
double
EPSILON
=
1
e
-
6
;
Logger
logger
=
Logger
.
getLogger
(
CommandTestFunctions
.
class
);
private
static
Map
<
String
,
Model
>
models
=
new
HashMap
<
String
,
Model
>();
protected
Model
getModelForFile
(
String
fileName
,
boolean
fromCache
)
throws
Exception
{
if
(!
fromCache
)
{
logger
.
debug
(
"File without cache: "
+
fileName
);
Model
result
=
new
CellDesignerXmlParser
().
createModel
(
new
ConverterParams
().
filename
(
fileName
));
result
.
setName
(
null
);
return
result
;
}
Model
result
=
models
.
get
(
fileName
);
if
(
result
==
null
)
{
logger
.
debug
(
"File to cache: "
+
fileName
);
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
result
=
parser
.
createModel
(
new
ConverterParams
().
filename
(
fileName
).
sizeAutoAdjust
(
false
));
result
.
setName
(
null
);
models
.
put
(
fileName
,
result
);
}
return
result
;
}
protected
Model
createSimpleModel
()
{
Model
model
=
new
ModelFullIndexed
(
null
);
GenericProtein
alias
=
new
GenericProtein
(
"alias_id"
);
alias
.
setNotes
(
null
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"synonym"
);
alias
.
addSynonyms
(
list
);
List
<
String
>
list2
=
new
ArrayList
<>();
list2
.
add
(
"f_symbol"
);
alias
.
setFormerSymbols
(
list2
);
Complex
complexAlias
=
new
Complex
(
"complex_alias_id"
);
model
.
addElement
(
complexAlias
);
complexAlias
.
addSpecies
(
alias
);
model
.
addElement
(
alias
);
return
model
;
}
protected
Model
serializeViaCellDesigner
(
Model
original
)
throws
InconsistentModelException
,
InvalidInputDataExecption
{
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xmlString
=
parser
.
model2String
(
original
);
InputStream
stream
=
new
ByteArrayInputStream
(
xmlString
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
result
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
for
(
Drawable
bioEntity:
original
.
getDrawables
())
{
bioEntity
.
setZ
(
null
);
}
for
(
Drawable
bioEntity:
result
.
getDrawables
())
{
bioEntity
.
setZ
(
null
);
}
return
result
;
}
}
model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java
View file @
f7c0f018
...
...
@@ -7,9 +7,6 @@ import static org.junit.Assert.assertTrue;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.awt.geom.Point2D
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Calendar
;
import
org.junit.After
;
...
...
@@ -17,8 +14,6 @@ import org.junit.Before;
import
org.junit.Test
;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.model.graphics.PolylineData
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
...
...
@@ -43,6 +38,8 @@ import lcsb.mapviewer.model.map.species.GenericProtein;
public
class
CopyCommandTest
extends
CommandTestFunctions
{
ModelComparator
comparator
=
new
ModelComparator
();
@Before
public
void
setUp
()
throws
Exception
{
}
...
...
@@ -57,8 +54,6 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
model
=
getModelForFile
(
"testFiles/sample.xml"
,
false
);
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -72,8 +67,6 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
model
=
getModelForFile
(
"testFiles/kinetics_with_compartment.xml"
,
false
);
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
for
(
Reaction
reaction
:
copy
.
getReactions
())
{
if
(
reaction
.
getKinetics
()
!=
null
)
{
...
...
@@ -109,8 +102,6 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -138,8 +129,6 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
...
...
@@ -155,12 +144,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xml
=
parser
.
model2String
(
copy
);
InputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
copy2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
ModelComparator
comparator
=
new
ModelComparator
();
Model
copy2
=
serializeViaCellDesigner
(
copy
);
// check if after conversion to xml everything works
assertEquals
(
0
,
comparator
.
compare
(
copy
,
copy2
));
...
...
@@ -178,12 +162,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xml
=
parser
.
model2String
(
copy
);
InputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
copy2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
ModelComparator
comparator
=
new
ModelComparator
();
Model
copy2
=
serializeViaCellDesigner
(
copy
);
// check if after conversion to xml everything works
assertEquals
(
0
,
comparator
.
compare
(
copy
,
copy2
));
...
...
@@ -202,12 +181,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xml
=
parser
.
model2String
(
copy
);
InputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
copy2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
ModelComparator
comparator
=
new
ModelComparator
();
Model
copy2
=
serializeViaCellDesigner
(
copy
);
new
CreateHierarchyCommand
(
copy2
,
2
,
2
).
execute
();
...
...
@@ -229,8 +203,6 @@ public class CopyCommandTest extends CommandTestFunctions {
model
.
addSubmodelConnection
(
new
ModelSubmodelConnection
(
model2
,
SubmodelType
.
DOWNSTREAM_TARGETS
));
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -253,8 +225,6 @@ public class CopyCommandTest extends CommandTestFunctions {
alias
.
setSubmodel
(
new
ElementSubmodelConnection
(
model3
,
SubmodelType
.
DOWNSTREAM_TARGETS
,
"name c"
));
Model
copy
=
new
CopyCommand
(
model2
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model2
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -274,8 +244,6 @@ public class CopyCommandTest extends CommandTestFunctions {
.
setSubmodel
(
new
ElementSubmodelConnection
(
model2
,
SubmodelType
.
DOWNSTREAM_TARGETS
));
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -291,8 +259,6 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
model
,
copy
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -404,10 +370,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
copy
,
model
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
...
...
@@ -422,10 +385,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
copy
,
model
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
...
...
@@ -440,10 +400,7 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
copy
,
model
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
...
...
@@ -458,16 +415,11 @@ public class CopyCommandTest extends CommandTestFunctions {
Model
copy
=
new
CopyCommand
(
model
).
execute
();
ModelComparator
comparator
=
new
ModelComparator
();
assertEquals
(
0
,
comparator
.
compare
(
copy
,
model
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
}
}
}
model-command/src/test/java/lcsb/mapviewer/commands/SubModelCommandTest.java
View file @
f7c0f018
...
...
@@ -4,9 +4,6 @@ import static org.junit.Assert.assertEquals;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
java.awt.geom.Path2D
;
import
java.io.ByteArrayInputStream
;
import
java.io.InputStream
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Arrays
;
import
java.util.HashSet
;
...
...
@@ -14,13 +11,13 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
lcsb.mapviewer.converter.ConverterParams
;
import
lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser
;
import
lcsb.mapviewer.model.map.model.Model
;
import
lcsb.mapviewer.model.map.model.ModelComparator
;
public
class
SubModelCommandTest
extends
CommandTestFunctions
{
ModelComparator
comparator
=
new
ModelComparator
();
@Before
public
void
setUp
()
throws
Exception
{
}
...
...
@@ -104,12 +101,7 @@ public class SubModelCommandTest extends CommandTestFunctions {
assertEquals
(
model
.
getReactionByReactionId
(
"re3"
).
getLines
().
get
(
0
).
getY2
(),
copy
.
getReactionByReactionId
(
"re3"
).
getLines
().
get
(
0
).
getY2
()
-
dy
,
EPSILON
);
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xml
=
parser
.
model2String
(
copy
);
InputStream
stream
=
new
ByteArrayInputStream
(
xml
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
copy2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
ModelComparator
comparator
=
new
ModelComparator
();
Model
copy2
=
serializeViaCellDesigner
(
copy
);
// check if after conversion to xml everything works
assertEquals
(
0
,
comparator
.
compare
(
copy
,
copy2
));
...
...
@@ -156,16 +148,9 @@ public class SubModelCommandTest extends CommandTestFunctions {
Model
copy
=
new
SubModelCommand
(
model
,
polygon
).
execute
();
CellDesignerXmlParser
parser
=
new
CellDesignerXmlParser
();
String
xmlString
=
parser
.
model2String
(
copy
);
InputStream
stream
=
new
ByteArrayInputStream
(
xmlString
.
getBytes
(
StandardCharsets
.
UTF_8
));
Model
model2
=
parser
.
createModel
(
new
ConverterParams
().
inputStream
(
stream
).
sizeAutoAdjust
(
false
));
ModelComparator
mc
=
new
ModelComparator
();
assertEquals
(
0
,
mc
.
compare
(
copy
,
model2
));
Model
model2
=
serializeViaCellDesigner
(
copy
);
assertEquals
(
0
,
comparator
.
compare
(
copy
,
model2
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
e
;
...
...
model/src/main/java/lcsb/mapviewer/model/map/model/Model.java
View file @
f7c0f018
...
...
@@ -8,6 +8,7 @@ import java.util.Set;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.BioEntity
;
import
lcsb.mapviewer.model.map.Drawable
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
import
lcsb.mapviewer.model.map.kinetics.SbmlArgument
;
...
...
@@ -550,5 +551,5 @@ public interface Model {
void
addModificationDates
(
Collection
<
Calendar
>
modificationDatesFromRdf
);
Set
<
Drawable
>
getDrawables
();
}
model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java
View file @
f7c0f018
...
...
@@ -15,6 +15,7 @@ import org.apache.log4j.Logger;
import
lcsb.mapviewer.common.exception.InvalidArgumentException
;
import
lcsb.mapviewer.model.Project
;
import
lcsb.mapviewer.model.map.BioEntity
;
import
lcsb.mapviewer.model.map.Drawable
;
import
lcsb.mapviewer.model.map.MiriamData
;
import
lcsb.mapviewer.model.map.compartment.Compartment
;
import
lcsb.mapviewer.model.map.kinetics.SbmlFunction
;
...
...
@@ -717,4 +718,14 @@ public class ModelFullIndexed implements Model {
addModificationDate
(
calendar
);
}
}
@Override
public
Set
<
Drawable
>
getDrawables
()
{
Set
<
Drawable
>
result
=
new
HashSet
<>();
result
.
addAll
(
getBioEntities
());
for
(
Layer
layer:
getLayers
())
{
result
.
addAll
(
layer
.
getDrawables
());
}
return
result
;
}
}
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