Commit af02f2cf authored by Piotr Gawron's avatar Piotr Gawron
Browse files

sbml id cannot contain ":" or "."

parent da1f2b48
minerva (15.1.1) stable; urgency=medium
* Bug fix: export to CD maps with species containing ":" or "." in species id
generated files that could not be opened in CellDesigner (#1363)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 23 Nov 2020 15:00:00 +0200
minerva (15.1.0) stable; urgency=medium
* Small improvement: information if species has activity, hypothetical flag
set is available over REST API for element (#1379)
......
......@@ -8,7 +8,10 @@ import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.converter.model.celldesigner.structure.CellDesignerElement;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.CellDesignerModificationResidue;
import lcsb.mapviewer.model.LogMarker;
import lcsb.mapviewer.model.ProjectLogEntryType;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.AbstractSiteModification;
import lcsb.mapviewer.model.map.species.field.ModificationResidue;
......@@ -23,7 +26,6 @@ public class CellDesignerElementCollection {
/**
* Default class logger
*/
@SuppressWarnings("unused")
private static Logger logger = LogManager.getLogger();
/**
......@@ -66,7 +68,11 @@ public class CellDesignerElementCollection {
} else {
String sbmlId = getSbmlId(modelElement, true);
if (sbmlIdByElement.get(sbmlId) == null) {
String id = "s_id_" + modelElement.getElementId();
String normalizedId = normalizeIdToCellDesigner(modelElement.getElementId());
if (!normalizedId.equals(modelElement.getElementId())) {
logger.warn(new LogMarker(ProjectLogEntryType.EXPORT_ISSUE, modelElement), "Invalid element id");
}
String id = "s_id_" + normalizeIdToCellDesigner(modelElement.getElementId());
if (sbmlIdByElement.values().contains(id)) {
throw new InvalidArgumentException("id duplicates");
}
......@@ -277,9 +283,20 @@ public class CellDesignerElementCollection {
return null;
}
if (ca.getElementId().length() >= 2) {
return ca.getElementId();
return normalizeIdToCellDesigner(ca.getElementId());
}
return "ca_prefix_issue_" + ca.getElementId();
return "ca_prefix_issue_" + normalizeIdToCellDesigner(ca.getElementId());
}
public String getModelId(Model model) {
if (model.getIdModel() == null) {
return null;
}
return normalizeIdToCellDesigner(model.getIdModel());
}
protected String normalizeIdToCellDesigner(String id) {
return id.replaceAll("[:\\.-]", "_");
}
}
......@@ -393,7 +393,8 @@ public class CellDesignerXmlParser extends Converter {
}
private void processModelRdfNode(Model model, Node node) throws InvalidXmlSchemaException {
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(
CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
model.addMiriamData(xmlAnnotationParser.parseRdfNode(node));
model.addAuthors(xmlAnnotationParser.getAuthorsFromRdf(node));
model.setCreationDate(xmlAnnotationParser.getCreateDateFromRdf(node));
......@@ -635,7 +636,11 @@ public class CellDesignerXmlParser extends Converter {
+ "xmlns:celldesigner=\"http://www.sbml.org/2001/ns/celldesigner\" level=\"2\" version=\"4\">\n");
result.append("<model ");
if (model.getIdModel() != null) {
result.append("metaid=\"" + model.getIdModel() + "\" id=\"" + model.getIdModel() + "\"");
String id = elements.getModelId(model);
if (!id.equals(model.getIdModel())) {
logger.warn("Invalid map id: '" + model.getIdModel() + "' changed to '" + id + "'");
}
result.append("metaid=\"" + id + "\" id=\"" + id + "\"");
}
result.append(">\n");
......@@ -729,7 +734,8 @@ public class CellDesignerXmlParser extends Converter {
result.append("</celldesigner:extension>\n");
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
XmlAnnotationParser xmlAnnotationParser = new XmlAnnotationParser(
CommonXmlParser.RELATION_TYPES_SUPPORTED_BY_CELL_DESIGNER);
result.append(xmlAnnotationParser.dataSetToXmlString(model.getMiriamData(), model.getAuthors(),
model.getCreationDate(), model.getModificationDates(), model.getIdModel()));
result.append("</annotation>\n");
......
package lcsb.mapviewer.converter.model.celldesigner;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import org.apache.logging.log4j.LogManager;
......@@ -54,4 +55,11 @@ public class CellDesignerElementCollectionTest extends CellDesignerTestFunctions
assertNotEquals(collection.getElementId(p1), collection.getElementId(p2));
}
@Test
public void testNormalizeToCd() {
CellDesignerElementCollection collection = new CellDesignerElementCollection();
assertFalse(collection.normalizeIdToCellDesigner("a.b").contains("."));
assertFalse(collection.normalizeIdToCellDesigner("a_b").contains("."));
}
}
......@@ -49,6 +49,7 @@ public class SbmlValidationTests extends CellDesignerTestFunctions {
result.add(getTestSetFromFile("testFiles/reactions/modifier_with_operator.xml"));
result.add(getTestSetFromFile("testFiles/problematic/problematic_reaction_name.xml"));
result.add(getTestSetFromFile("testFiles/reactions/kinetics.xml"));
result.add(getTestSetFromFile("testFiles/problematic/invalid_sbml_id.xml"));
result.add(emptyProteinNameTest());
return result;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" xmlns:celldesigner="http://www.sbml.org/2001/ns/celldesigner" level="2" version="4">
<model metaid="F007-inos.sbgn" id="F007-inos.sbgn">
<notes><html xmlns="http://www.w3.org/1999/xhtml"><head><title/></head><body></body></html></notes><annotation>
<celldesigner:extension>
<celldesigner:modelVersion>4.0</celldesigner:modelVersion>
<celldesigner:modelDisplay sizeX="1632" sizeY="1188"/>
<celldesigner:listOfIncludedSpecies>
</celldesigner:listOfIncludedSpecies>
<celldesigner:listOfCompartmentAliases>
<celldesigner:compartmentAlias id="n1" compartment="s_id_n1">
<celldesigner:class>SQUARE</celldesigner:class>
<celldesigner:bounds x="36.73581314086914" y="921.4197998046875" w="1559.26416015625" h="250.22767639160156"/>
<celldesigner:namePoint x="42.73581314086914" y="927.4197998046875"/>
<celldesigner:doubleLine thickness="3.0" outerWidth="2.0" innerWidth="1.0"/>
<celldesigner:paint color="72EDEBE4" scheme="Color"/>
</celldesigner:compartmentAlias>
</celldesigner:listOfCompartmentAliases>
<celldesigner:listOfComplexSpeciesAliases>
</celldesigner:listOfComplexSpeciesAliases>
<celldesigner:listOfSpeciesAliases>
<celldesigner:speciesAlias id="n1__.__n0" species="s_id_n1__.__n0" compartmentAlias="n1" >
<celldesigner:activity>inactive</celldesigner:activity>
<celldesigner:bounds x="65.0" y="966.6474609375" w="86.0" h="46.0" />
<celldesigner:font size="12"/><celldesigner:view state="usual"/>
<celldesigner:usualView><celldesigner:innerPosition x="0" y="0"/><celldesigner:boxSize width="86.0" height="46.0"/><celldesigner:singleLine width="1.0"/><celldesigner:paint color="FFC8D8EB" scheme="Color"/></celldesigner:usualView>
<celldesigner:briefView><celldesigner:innerPosition x="0" y="0"/><celldesigner:boxSize width="86.0" height="46.0"/><celldesigner:singleLine width="1.0"/><celldesigner:paint color="FFC8D8EB" scheme="Color"/></celldesigner:briefView>
</celldesigner:speciesAlias>
</celldesigner:listOfSpeciesAliases>
<celldesigner:listOfProteins><celldesigner:protein id="p_s_id_n1__.__n0" name="STAT1_alpha_" type="GENERIC">
<celldesigner:listOfModificationResidues><celldesigner:modificationResidue id="3" name="Y701" angle="1.5973482732763293"></celldesigner:modificationResidue><celldesigner:modificationResidue id="4" name="S727" angle="5.280262641519494"></celldesigner:modificationResidue></celldesigner:listOfModificationResidues>
</celldesigner:protein>
</celldesigner:listOfProteins>
<celldesigner:listOfGenes></celldesigner:listOfGenes>
<celldesigner:listOfRNAs></celldesigner:listOfRNAs>
<celldesigner:listOfAntisenseRNAs></celldesigner:listOfAntisenseRNAs>
<celldesigner:listOfLayers></celldesigner:listOfLayers>
</celldesigner:extension>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#F007-inos.sbgn">
<dcterms:modified rdf:parseType="Resource"></dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
<listOfCompartments>
<compartment metaid="s_id_n1" id="s_id_n1" name="NUCLEUS" size="1" units="volume" outside="default" >
<notes><html xmlns="http://www.w3.org/1999/xhtml"><head><title/></head><body>
</body></html></notes>
<annotation>
<celldesigner:extension>
<celldesigner:name>NUCLEUS</celldesigner:name>
</celldesigner:extension>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#s_id_n1">
<dcterms:modified rdf:parseType="Resource"></dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
<compartment metaid="default" id="default" name="" size="1" units="volume" >
<notes><html xmlns="http://www.w3.org/1999/xhtml"><head><title/></head><body>
</body></html></notes>
<annotation>
<celldesigner:extension>
</celldesigner:extension>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#default">
<dcterms:modified rdf:parseType="Resource"></dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
</compartment>
</listOfCompartments>
<listOfSpecies><species name="STAT1_alpha_" id="s_id_n1__.__n0" metaid="s_id_n1__.__n0" initialConcentration="0.0" hasOnlySubstanceUnits="false" constant="false" boundaryCondition="false" compartment="s_id_n1"><annotation><celldesigner:extension><celldesigner:speciesIdentity><celldesigner:class>PROTEIN</celldesigner:class>
<celldesigner:proteinReference>p_s_id_n1__.__n0</celldesigner:proteinReference>
<celldesigner:state>
<celldesigner:homodimer>2</celldesigner:homodimer>
<celldesigner:listOfModifications>
<celldesigner:modification residue="3" state="phosphorylated"> </celldesigner:modification>
<celldesigner:modification residue="4" state="phosphorylated"> </celldesigner:modification>
</celldesigner:listOfModifications>
</celldesigner:state>
<celldesigner:name>STAT1_alpha_</celldesigner:name>
</celldesigner:speciesIdentity>
</celldesigner:extension>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
<rdf:Description rdf:about="#s_id_n1__.__n0">
<dcterms:modified rdf:parseType="Resource"></dcterms:modified>
</rdf:Description>
</rdf:RDF>
</annotation>
</species>
</listOfSpecies>
</model></sbml>
Supports Markdown
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