Commit 3e11e490 authored by Piotr Gawron's avatar Piotr Gawron

structural states are rendered in SBML

parent 894d6e1a
Pipeline #37538 passed with stage
in 18 minutes and 51 seconds
......@@ -20,6 +20,8 @@ minerva (16.0.0~alpha.1) stable; urgency=medium
(#1055)
* Small improvement: SBML render contains information about modification
residues (#1456)
* Small improvement: SBML render contains information about structural states
(#1456)
* Bug fix: refreshing page after removing last project on the page redirect to
proper page (#1051)
* Bug fix: removing plugin that does not exist anymore does not raise an error
......
......@@ -7,8 +7,7 @@ import org.sbml.jsbml.ext.layout.*;
import org.sbml.jsbml.ext.render.*;
import lcsb.mapviewer.converter.model.sbml.SbmlModelUtils;
import lcsb.mapviewer.model.map.species.field.AbstractRegionModification;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
import lcsb.mapviewer.model.map.species.field.*;
public class ModificationResidueExporter {
......@@ -18,7 +17,14 @@ public class ModificationResidueExporter {
this.sbmlModelUtils = new SbmlModelUtils(sbmlModel);
}
protected LocalStyle createStyle(ModificationResidue element) {
public LocalStyle createStyle(ModificationResidue element) {
return createStyle();
}
public LocalStyle createStyle(StructuralState structuralState) {
return createStyle();
}
private LocalStyle createStyle() {
LocalStyle style = sbmlModelUtils.createStyle();
ColorDefinition color = sbmlModelUtils.getColorDefinition(Color.BLACK);
ColorDefinition background = sbmlModelUtils.getColorDefinition(Color.WHITE);
......@@ -39,6 +45,10 @@ public class ModificationResidueExporter {
}
public LocalStyle createTextStyle(ModificationResidue mr) {
return createTextStyle();
}
private LocalStyle createTextStyle() {
LocalStyle style = sbmlModelUtils.createStyle();
ColorDefinition color = sbmlModelUtils.getColorDefinition(Color.BLACK);
ColorDefinition background = sbmlModelUtils.getColorDefinition(Color.WHITE);
......@@ -52,6 +62,10 @@ public class ModificationResidueExporter {
return style;
}
public LocalStyle createTextStyle(StructuralState structuralState) {
return createTextStyle();
}
public BoundingBox createBoundingBoxForModification(ModificationResidue mr) {
double width, height;
if (mr instanceof AbstractRegionModification) {
......@@ -78,4 +92,27 @@ public class ModificationResidueExporter {
return result;
}
public BoundingBox createBoundingBoxForStructuralState(StructuralState structuralState) {
double width = structuralState.getWidth();
double height = structuralState.getHeight();
double x = structuralState.getPosition().getX();
double y = structuralState.getPosition().getY();
BoundingBox boundingBox = new BoundingBox();
boundingBox.setPosition(new Point(x, y, structuralState.getSpecies().getZ() + 1));
Dimensions dimensions = new Dimensions();
dimensions.setWidth(width);
dimensions.setHeight(height);
boundingBox.setDimensions(dimensions);
return boundingBox;
}
public BoundingBox createBoundingBoxForStructuralStateText(StructuralState structuralState) {
BoundingBox result = createBoundingBoxForStructuralState(structuralState);
result.getPosition().setZ(result.getPosition().getZ() + 1);
return result;
}
}
......@@ -779,6 +779,7 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
}
private void createStructuralStateGlyph(Species element, AbstractReferenceGlyph speciesGlyph) {
StructuralState structuralState = element.getStructuralState();
org.sbml.jsbml.Species sbmlSpecies = getSbmlModel().getSpecies(speciesGlyph.getReference());
MultiSpeciesPlugin speciesExtension = (MultiSpeciesPlugin) sbmlSpecies.getExtension("multi");
......@@ -787,7 +788,7 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
BioEntityFeature.STRUCTURAL_STATE);
PossibleSpeciesFeatureValue possibleSpeciesFeatureValue = getPosibleFeatureIdByName(
element.getStructuralState().getValue(), structuralStateFeature);
structuralState.getValue(), structuralStateFeature);
SpeciesFeature feature = null;
for (SpeciesFeature existingFeature : speciesExtension.getListOfSpeciesFeatures()) {
......@@ -803,16 +804,30 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
}
}
modificationFeatureValue.setId(getStructuralStateUniqueId(element.getStructuralState()));
modificationFeatureValue.setId(getStructuralStateUniqueId(structuralState));
GeneralGlyph modificationGlyph = getLayout().createGeneralGlyph("structural_state_" + (idCounter++),
GeneralGlyph structuralStateGlyph = getLayout().createGeneralGlyph("structural_state_" + (idCounter++),
modificationFeatureValue.getId());
ReferenceGlyph referenceGlyph = new ReferenceGlyph("structural_state_reference_" + (idCounter++));
referenceGlyph.setGlyph(speciesGlyph.getId());
referenceGlyph.setBoundingBox(createBoundingBoxForStructuralState(element.getStructuralState()));
referenceGlyph.setBoundingBox(modificationResidueExporter.createBoundingBoxForStructuralState(structuralState));
modificationGlyph.addReferenceGlyph(referenceGlyph);
modificationGlyph.setBoundingBox(createBoundingBoxForStructuralState(element.getStructuralState()));
structuralStateGlyph.addReferenceGlyph(referenceGlyph);
structuralStateGlyph
.setBoundingBox(modificationResidueExporter.createBoundingBoxForStructuralState(structuralState));
String str = structuralState.getValue();
TextGlyph textGlyph = getLayout().createTextGlyph("modification_text_" + (idCounter++), str);
textGlyph.setGraphicalObject(structuralStateGlyph.getId());
textGlyph.setBoundingBox(modificationResidueExporter.createBoundingBoxForStructuralStateText(structuralState));
if (isExtensionEnabled(SbmlExtension.RENDER)) {
LocalStyle structuralStateStyle = modificationResidueExporter.createStyle(structuralState);
assignStyleToGlyph(structuralStateGlyph, structuralStateStyle);
LocalStyle structuralStateTextStyle = modificationResidueExporter.createTextStyle(structuralState);
assignStyleToGlyph(textGlyph, structuralStateTextStyle);
}
}
......@@ -914,20 +929,6 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j
}
private BoundingBox createBoundingBoxForStructuralState(StructuralState structuralState) {
double width = structuralState.getWidth();
double height = structuralState.getHeight();
double x = structuralState.getPosition().getX();
double y = structuralState.getPosition().getY();
BoundingBox boundingBox = new BoundingBox();
boundingBox.setPosition(new Point(x, y, structuralState.getSpecies().getZ() + 1));
Dimensions dimensions = new Dimensions();
dimensions.setWidth(width);
dimensions.setHeight(height);
boundingBox.setDimensions(dimensions);
return boundingBox;
}
private String getModificationResidueUniqueId(ModificationResidue mr) {
SpeciesWithModificationResidue species = (SpeciesWithModificationResidue) mr.getSpecies();
String modificationId = "mod" + species.getModificationResidues().indexOf(mr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment