Commit 8fd36e0a authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '995-some-modifiers-not-transferred-from-sbgn-ml' into 'master'

Resolve "Some modifiers not transferred from SBGN-ML"

Closes #995

See merge request minerva/core!995
parents 7a5f3553 b6c9ea26
minerva (15.0.0~alpha.1) stable; urgency=medium
* Small improvement: sort order of tables in admin panel is preserved among
sessions (#836)
* Bug fix: structural states of proteins are imported properly from SBGNML PD
(#995)
* Bug fix: clear button icon, refresh comments button and show overview
button icons were missing (regression 15.0.0~alpha.0)
minerva (15.0.0~alpha.0) stable; urgency=medium
* Improvement: logs provided for validation data model are structurized (#325)
......
......@@ -585,10 +585,20 @@ public class SbgnmlXmlParser {
for (Glyph child : children) {
if (GlyphClazz.fromClazz(child.getClazz()).equals(GlyphClazz.STATE_VARIABLE)) {
if (child.getState() == null || child.getState().getVariable() != null) {
try {
parseStateVariable(child, newSpecies);
} catch (Exception ex) {
logger.warn(ex.getMessage());
Residue residue = stateVariableToResidue(child);
if (residue != null) {
if (newSpecies instanceof Protein) {
((Protein) newSpecies).addResidue(residue);
} else {
logger.warn("Only macromolecule elements can have state variables.");
}
} else {
StructuralState state = stateVariableToStructuralState(child);
if (newSpecies instanceof Protein) {
((Protein) newSpecies).setStructuralState(state);
} else {
logger.warn("Only macromolecule elements can have state.");
}
}
} else {
if (newSpecies instanceof Protein) {
......@@ -610,6 +620,20 @@ public class SbgnmlXmlParser {
}
private StructuralState stateVariableToStructuralState(Glyph glyph) {
StructuralState state = new StructuralState();
state.setFontSize(10);
state.setPosition(new Point2D.Double(glyph.getBbox().getX(), glyph.getBbox().getY()));
state.setHeight((double) glyph.getBbox().getH());
state.setWidth((double) glyph.getBbox().getW());
if (glyph.getState() != null) {
state.setValue(glyph.getState().getValue());
}
return state;
}
private StructuralState createStructuralState(Glyph glyph) {
StructuralState structuralState = new StructuralState();
......@@ -775,20 +799,19 @@ public class SbgnmlXmlParser {
*
* @param unitOfInformationGlyph
* unit of information glyph from sbgn-ml file
* @param species
* species that the unit of information considers
* @throws Exception
* Exception is thrown if state variable is parsed for species other
* than Protein
*/
private void parseStateVariable(Glyph unitOfInformationGlyph, Species species) {
if (!(species instanceof Protein)) {
throw new InvalidArgumentException("Only macromolecule elements can have state variables.");
private Residue stateVariableToResidue(Glyph unitOfInformationGlyph) {
if (unitOfInformationGlyph.getState() != null && (unitOfInformationGlyph.getState().getVariable() == null
|| unitOfInformationGlyph.getState().getVariable().trim().isEmpty())) {
return null;
}
Protein protein = (Protein) species;
Residue mr = new Residue();
mr.setSpecies(protein);
mr.setIdModificationResidue(unitOfInformationGlyph.getId());
if (unitOfInformationGlyph.getState() != null) {
// If State variable consists of value and variable
......@@ -806,7 +829,7 @@ public class SbgnmlXmlParser {
mr.setPosition(new Point2D.Double(x, y));
protein.addResidue(mr);
return mr;
}
/**
......
......@@ -14,8 +14,7 @@ import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.Residue;
public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
......@@ -105,4 +104,15 @@ public class SbgnmlXmlParserTest2 extends SbgnmlTestFunctions {
assertEquals(p2.getLine().getBeginPoint(), outputOperator.getLine().getBeginPoint());
}
@Test
public void testProteinState() throws Exception {
Converter converter = new SbgnmlXmlConverter();
Model model = converter
.createModel(new ConverterParams().filename("testFiles/sbgnmlCellDesignerInompatible/stateVariable.sbgn"));
Protein protein = model.getElementByElementId("glyph_n20");
assertEquals("inactive", protein.getStructuralState().getValue());
assertEquals(0, protein.getModificationResidues().size());
}
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sbgn xmlns="http://sbgn.org/libsbgn/0.2">
<map language="process description">
<glyph class="macromolecule" id="glyph_n20">
<label text="PKA"/>
<bbox w="80.0" h="40.0" x="662.7319" y="21.57837"/>
<glyph class="state variable" id="glyph_n20_4">
<state value="inactive" variable=""/>
<bbox w="50.0" h="18.0" x="677.7319" y="51.86792"/>
</glyph>
</glyph>
</map>
</sbgn>
\ No newline at end of file
......@@ -95,7 +95,7 @@ TopMenu.prototype._createGui = function () {
var showOverviewButton = Functions.createElement({
type: "button",
className: "minerva-overview-button",
content: "<i class='fa fa-sitemap' style='font-size:18px; font-weight:400; padding-right:10px;'></i><span >SHOW OVERVIEW</span>",
content: "<i class='fa fa-sitemap' style='font-size:18px; padding-right:10px;'></i><span >SHOW OVERVIEW</span>",
style: "display:none",
xss: false
});
......@@ -142,7 +142,7 @@ TopMenu.prototype._createGui = function () {
var refreshCommentButton = Functions.createElement({
type: "button",
className: "minerva-overview-button",
content: "<i class='fa fa-refresh' style='font-size:21px; font-weight:400;'></i>",
content: "<i class='fa fa-refresh'></i>",
style: "display:none",
xss: false
});
......@@ -153,7 +153,7 @@ TopMenu.prototype._createGui = function () {
type: "button",
name: "clearButton",
className: "minerva-overview-button",
content: "<i class='fa fa-times' style='font-size:18px; font-weight:300; padding-right:10px;'></i>CLEAR",
content: "<i class='fa fa-times' style='padding-right:10px;'></i>CLEAR",
xss: false
});
rightHeaderMenuDiv.appendChild(clearButton);
......
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