Skip to content

Commit

Permalink
Merge pull request #53 from draeger-lab/bugfixes
Browse files Browse the repository at this point in the history
When compartment boundaries should be inferred and no x and y coordin…
  • Loading branch information
draeger authored Jul 29, 2019
2 parents 1357467 + 1d15dcb commit b291a0e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/main/java/edu/ucsd/sbrg/escher/converter/Escher2SBML.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public SBMLDocument convert(EscherMap map) {
Canvas canvas = map.getCanvas();
double xOffset = canvas.isSetX() ? canvas.getX().doubleValue() : 0d;
double yOffset = canvas.isSetY() ? canvas.getY().doubleValue() : 0d;
double canvasWidth = canvas.getWidth();
double canvasHeight = canvas.getWidth();
Map<String, String> node2glyph = new HashMap<String, String>();
Map<String, Node> multimarkers = new HashMap<String, Node>();
Layout layout = initLayout(map, xOffset, yOffset);
Expand All @@ -119,7 +121,7 @@ public SBMLDocument convert(EscherMap map) {
String id = entry.getKey();
if (!(id.equalsIgnoreCase("n") || id.equalsIgnoreCase(getDefaultCompartmentId())
|| id.equalsIgnoreCase("e"))) {
createCompartmentGlyph(entry.getValue(), layout, xOffset, yOffset);
createCompartmentGlyph(entry.getValue(), layout, xOffset, yOffset, canvasWidth, canvasHeight);
}
}
}
Expand All @@ -137,11 +139,44 @@ public SBMLDocument convert(EscherMap map) {
* @param yOffset y-offset.
*/
private void createCompartmentGlyph(EscherCompartment ec, Layout layout,
double xOffset, double yOffset) {
double xOffset, double yOffset, double canvasWidth, double canvasHeight) {
//TODO
//for now, if no x and y coordinates are available, the compartment is set around all nodes
CompartmentGlyph cg = layout.createCompartmentGlyph(ec.getId() + "_glyph");
double x = ec.getX() - xOffset - getPrimaryNodeWidth();
double y = ec.getY() - yOffset - getPrimaryNodeHeight();
cg.createBoundingBox(ec.getWidth(), ec.getHeight(), getNodeDepth(), x, y, getZ());
double x;
double y;
double width;
double height;
if(ec.getX()==null){
x = xOffset;
logger.severe(format(bundle.getString("Escher2SBML.inferredCompartment"),
ec.getName(), "x-offset", "x-offset of the canvas: "+ xOffset));
}else{
x= ec.getX() - xOffset - getPrimaryNodeWidth();

}
if(ec.getY()==null){
y = yOffset;
logger.severe(format(bundle.getString("Escher2SBML.inferredCompartment"),
ec.getName(), "y-offset", "y-offset of the canvas: "+yOffset));
}else{
y= ec.getY() - yOffset - getPrimaryNodeWidth();
}
if(ec.getWidth()==null ){
width = canvasWidth;
logger.severe(format(bundle.getString("Escher2SBML.inferredCompartment"),
ec.getName(), "the width", "the width of the canvas: "+canvasWidth));
}else{
width = ec.getWidth();
}
if(ec.getHeight()==null ){
height = canvasHeight;
logger.severe(format(bundle.getString("Escher2SBML.inferredCompartment"),
ec.getName(), "the height", "the height of the canvas: "+canvasHeight));
}else{
height = ec.getHeight();
}
cg.createBoundingBox(width, height, getNodeDepth(), x, y, getZ());
cg.setCompartment(SBMLtools.toSId(ec.getId()));
NamedSBase compartment = cg.getCompartmentInstance();
if ((compartment != null) && compartment.isSetName()) {
Expand All @@ -150,6 +185,7 @@ private void createCompartmentGlyph(EscherCompartment ec, Layout layout,
text.createBoundingBox(compartment.getName().length() * 5d,
getNodeLabelHeight(), getNodeDepth(), x, y, getZ());
}

}


Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/edu/ucsd/sbrg/escher/Messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
<entry key="Escher2SBML.textLabelIdNotUnique">Found text label with id=''{0}'' that is identical to the id of a {1}</entry>
<entry key="Escher2SBML.reactionCompartmentUnknown">Could not identify compartment of reaction {0}</entry>
<entry key="Escher2SBML.layoutIDnotunique">Layout identifier {0} changed to {1} as it is the same as model's id {2}.</entry>
<entry key="Escher2SBML.metaboliteId_missing">{0} is not a valid id for a metabolite in reaction {1}.</entry>
<entry key="Escher2SBML.inferredCompartment">In Compartment ''{0}'' {1} was not available and was therefore set to {2}.</entry>

<entry key="Escher2Standard.reversed_segment">Reversed direction of segment {0}: {1} -> {2}.</entry>
<entry key="Escher2Standard.node_lacking_metabolite">Node ''{0}'' in reaction ''{1}'' lacks a corresponding metabolite.</entry>
Expand Down

0 comments on commit b291a0e

Please sign in to comment.