Commit 0c8dafc8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1320-modifier-reaction-to-phenotype-are-following-the-sbgn-notation' into 'master'

Resolve "Modifier reaction to Phenotype are following the SBGN notation"

Closes #1320

See merge request !1222
parents 94a0142c 424fcc68
Pipeline #29729 passed with stage
in 11 minutes and 36 seconds
......@@ -25,6 +25,8 @@ minerva (15.1.0) unstable; urgency=medium
index
* Small improvement: pathways with glyphs and z index below 0 are not
clickable (#1314)
* Small improvement: Modifier Reaction from CellDesigner are exported properly
to SBGN-ML PD (#1320)
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
......
......@@ -139,18 +139,21 @@ public class SbgnmlXmlExporter {
for (Reaction reaction : model.getReactions()) {
try {
map.getGlyph().add(getProcessGlyphFromReaction(reaction));
} catch (InvalidArgumentException ex) {
// Reduced notation
try {
map.getArc().add(getArcFromReducedReaction(reaction));
} catch (InvalidArgumentException e) {
logger.warn(new LogMarker(ProjectLogEntryType.EXPORT_ISSUE, reaction), "Invalid arc type."
+ " Reduced notation reaction found of type that is not compliant with SBGN-ML format.");
Glyph glyph = getProcessGlyphFromReaction(reaction);
if (glyph != null) {
map.getGlyph().add(glyph);
map.getArc().addAll(getArcsFromReaction(reaction, map.getGlyph()));
} else {
Arc arc = getArcFromReducedReaction(reaction);
if (arc != null) {
map.getArc().add(arc);
}
}
continue;
} catch (Exception ex) {
ex.printStackTrace();
logger.warn(new LogMarker(ProjectLogEntryType.EXPORT_ISSUE, reaction),
"Unexpected problem with exporting reaction.");
}
map.getArc().addAll(getArcsFromReaction(reaction, map.getGlyph()));
}
try {
RenderUtil.setRenderInformation(map, renderInformation);
......@@ -599,7 +602,11 @@ public class SbgnmlXmlExporter {
private Glyph getProcessGlyphFromReaction(Reaction reaction) {
Glyph processGlyph = new Glyph();
processGlyph.setId(reaction.getIdReaction());
processGlyph.setClazz(getGlyphClazzFromReaction(reaction).getClazz());
GlyphClazz clazz = getGlyphClazzFromReaction(reaction);
if (clazz == null) {
return null;
}
processGlyph.setClazz(clazz.getClazz());
Bbox bbox = new Bbox();
PolylineData line = reaction.getLine();
......@@ -708,12 +715,6 @@ public class SbgnmlXmlExporter {
* @return {@link GlyphClazz} appropriate to given reaction
*/
private GlyphClazz getGlyphClazzFromReaction(Reaction reaction) {
if (reaction instanceof StateTransitionReaction ||
reaction instanceof TransportReaction ||
reaction instanceof TranslationReaction ||
reaction instanceof TranscriptionReaction) {
return GlyphClazz.PROCESS;
}
if (reaction instanceof HeterodimerAssociationReaction) {
return GlyphClazz.ASSOCIATION;
}
......@@ -726,7 +727,10 @@ public class SbgnmlXmlExporter {
if (reaction instanceof UnknownTransitionReaction) {
return GlyphClazz.UNCERTAIN_PROCESS;
}
throw new InvalidArgumentException();
if (reaction instanceof ReducedNotation) {
return null;
}
return GlyphClazz.PROCESS;
}
/**
......@@ -738,7 +742,9 @@ public class SbgnmlXmlExporter {
*/
private Arc getArcFromReducedReaction(Reaction reaction) {
if ((reaction.getReactants().size() != 1) || (reaction.getProducts().size() != 1)) {
throw new InvalidArgumentException();
logger.warn(new LogMarker(ProjectLogEntryType.PARSING_ISSUE, reaction),
"Reduced notation does not allow to have multiple reactants/products. Reaction skipped");
return null;
}
Arc arc = new Arc();
arc.setId(reaction.getIdReaction());
......@@ -752,7 +758,9 @@ public class SbgnmlXmlExporter {
} else if (reaction instanceof ReducedPhysicalStimulationReaction) {
arc.setClazz(ArcClazz.STIMULATION.getClazz());
} else {
throw new InvalidArgumentException();
logger.warn(new LogMarker(ProjectLogEntryType.EXPORT_ISSUE, reaction), "Invalid arc type."
+ " Reduced notation reaction found of type that is not compliant with SBGN-ML format.");
return null;
}
if (reaction.getProducts().get(0).getElement() instanceof Phenotype) {
......@@ -941,7 +949,8 @@ public class SbgnmlXmlExporter {
}
}
} else if (node instanceof NodeOperator) {
if ((node instanceof DissociationOperator) || (node instanceof AssociationOperator)) {
if ((node instanceof DissociationOperator) || (node instanceof AssociationOperator)
|| (node instanceof TruncationOperator)) {
throw new InvalidArgumentException();
}
arc.setSource(sourceTargetMap.get(operatorIds.get(node).concat(".2")));
......
......@@ -4,7 +4,7 @@ package lcsb.mapviewer.model.map.reaction.type;
*
* Interface used for marking {@link lcsb.mapviewer.model.map.reaction.Reaction
* Reaction} extensions that implements reduced notation in CellDesigner. These
* classes should have more than one reactant and product and cannot have any
* classes should have no more than one reactant and product and cannot have any
* modifiers.
*
* @author Piotr Gawron
......
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