Skip to content
Snippets Groups Projects
Commit c9d686ee authored by Piotr Gawron's avatar Piotr Gawron
Browse files

species types are assigned based on sbo terms

parent 6f47fe03
No related branches found
No related tags found
1 merge request!186Resolve "upload of sbml"
package lcsb.mapviewer.converter.model.sbml.species;
import java.util.HashSet;
import java.util.Set;
import org.apache.log4j.Logger;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Degraded;
import lcsb.mapviewer.model.map.species.Drug;
import lcsb.mapviewer.model.map.species.Gene;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Ion;
import lcsb.mapviewer.model.map.species.IonChannelProtein;
import lcsb.mapviewer.model.map.species.Phenotype;
import lcsb.mapviewer.model.map.species.ReceptorProtein;
import lcsb.mapviewer.model.map.species.Rna;
import lcsb.mapviewer.model.map.species.SimpleMolecule;
import lcsb.mapviewer.model.map.species.Species;
import lcsb.mapviewer.model.map.species.Unknown;
public enum SBOTermSpeciesType {
ANTISENSE_RNA(AntisenseRna.class, new String[] { "SBO:0000334" }), //
COMPLEX(Complex.class, new String[] { "SBO:0000297" }), //
DEGRADED(Degraded.class, new String[] { "SBO:0000291" }), //
DRUG(Drug.class, new String[] { "SBO:0000298" }), //
GENE(Gene.class, new String[] { "SBO:0000243" }), //
GENERIC_PROTEIN(GenericProtein.class, new String[] { "SBO:0000252" }), //
ION(Ion.class, new String[] { "SBO:0000327" }), //
ION_CHANNEL(IonChannelProtein.class, new String[] { "SBO:0000284" }), //
PHENOTYPE(Phenotype.class, new String[] { "SBO:0000358" }), //
RECEPTOR(ReceptorProtein.class, new String[] { "SBO:0000244" }), //
RNA(Rna.class, new String[] { "SBO:0000278" }), //
SIMPLE_MOLECULE(SimpleMolecule.class, new String[] { "SBO:0000247", "SBO:0000299" }), //
UNKNOWN(Unknown.class, new String[] { "SBO:0000285" }), //
;
private static Logger logger = Logger.getLogger(SBOTermSpeciesType.class);
private Set<String> sboTerms = new HashSet<>();
Class<? extends Species> clazz;
private SBOTermSpeciesType(Class<? extends Species> clazz, String[] inputSboTerms) {
this.clazz = clazz;
for (String string : inputSboTerms) {
sboTerms.add(string);
}
}
public static Class<? extends Species> getTypeSBOTerm(String sboTerm) {
if (sboTerm == null || sboTerm.isEmpty()) {
return SimpleMolecule.class;
}
Class<? extends Species> result = null;
for (SBOTermSpeciesType term : values()) {
for (String string : term.sboTerms) {
if (string.equalsIgnoreCase(sboTerm)) {
result = term.clazz;
}
}
}
if (result == null) {
logger.warn("Don't know how to handle SBOTerm " + sboTerm + " for species");
result = SimpleMolecule.class;
}
return result;
}
}
...@@ -18,7 +18,6 @@ import lcsb.mapviewer.converter.InvalidInputDataExecption; ...@@ -18,7 +18,6 @@ import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.converter.model.sbml.SbmlElementParser; import lcsb.mapviewer.converter.model.sbml.SbmlElementParser;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.SimpleMolecule;
import lcsb.mapviewer.model.map.species.Species; import lcsb.mapviewer.model.map.species.Species;
public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species> { public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species> {
...@@ -30,14 +29,8 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species> ...@@ -30,14 +29,8 @@ public class SbmlSpeciesParser extends SbmlElementParser<org.sbml.jsbml.Species>
@Override @Override
protected Species parse(org.sbml.jsbml.Species species, Model sbmlModel) throws InvalidInputDataExecption { protected Species parse(org.sbml.jsbml.Species species, Model sbmlModel) throws InvalidInputDataExecption {
String type = species.getSpeciesType(); String sboTerm = species.getSBOTermID();
Class<? extends Species> clazz = null; Class<? extends Species> clazz = SBOTermSpeciesType.getTypeSBOTerm(sboTerm);
if (type == null || type.isEmpty()) {
clazz = SimpleMolecule.class;
}
if (clazz == null) {
throw new InvalidInputDataExecption("Unknown species type: " + type);
}
try { try {
Species result = clazz.getConstructor(String.class).newInstance(species.getId()); Species result = clazz.getConstructor(String.class).newInstance(species.getId());
assignBioEntityData(species, result); assignBioEntityData(species, result);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</compartment> </compartment>
</listOfCompartments> </listOfCompartments>
<listOfSpecies> <listOfSpecies>
<species boundaryCondition="false" compartment="cell" initialConcentration="1" id="s1" name="nm1" sboTerm="SBO:0000462"> <species boundaryCondition="false" compartment="cell" initialConcentration="1" id="s1" name="nm1" sboTerm="SBO:0000285">
<annotation/> <annotation/>
</species> </species>
</listOfSpecies> </listOfSpecies>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment