diff --git a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SBOTermSpeciesType.java b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SBOTermSpeciesType.java index dce3f6eabbb4b8ecad6e03d014159e10c6c86f18..b73d4fa9e941c4912427dd2d6fb26ed3eba27f22 100644 --- a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SBOTermSpeciesType.java +++ b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SBOTermSpeciesType.java @@ -1,7 +1,7 @@ package lcsb.mapviewer.converter.model.sbml.species; -import java.util.HashSet; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; import org.apache.log4j.Logger; @@ -18,6 +18,7 @@ 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.TruncatedProtein; import lcsb.mapviewer.model.map.species.Unknown; public enum SBOTermSpeciesType { @@ -27,6 +28,7 @@ public enum SBOTermSpeciesType { DRUG(Drug.class, new String[] { "SBO:0000298" }), // GENE(Gene.class, new String[] { "SBO:0000243" }), // GENERIC_PROTEIN(GenericProtein.class, new String[] { "SBO:0000252" }), // + TRUNCATED_PROTEIN(TruncatedProtein.class, new String[] {}, 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" }), // @@ -37,7 +39,8 @@ public enum SBOTermSpeciesType { ; private static Logger logger = Logger.getLogger(SBOTermSpeciesType.class); - private Set<String> sboTerms = new HashSet<>(); + private List<String> sboTerms = new ArrayList<>(); + private List<String> exportSboTerms = new ArrayList<>(); Class<? extends Species> clazz; private SBOTermSpeciesType(Class<? extends Species> clazz, String[] inputSboTerms) { @@ -47,6 +50,16 @@ public enum SBOTermSpeciesType { } } + private SBOTermSpeciesType(Class<? extends Species> clazz, String[] inputSboTerms, String[] outputSboTerms) { + this.clazz = clazz; + for (String string : inputSboTerms) { + sboTerms.add(string); + } + for (String string : outputSboTerms) { + exportSboTerms.add(string); + } + } + public static Class<? extends Species> getTypeSBOTerm(String sboTerm) { if (sboTerm == null || sboTerm.isEmpty()) { return SimpleMolecule.class; @@ -65,4 +78,25 @@ public enum SBOTermSpeciesType { } return result; } + + public static String getTermByType(Class<? extends Species> clazz) { + for (SBOTermSpeciesType term : values()) { + if (clazz.equals(term.clazz)) { + return term.getSBO(); + } + } + logger.warn("Cannot find SBO term for class: " + clazz); + return null; + } + + private String getSBO() { + if (sboTerms.size() != 0) { + return sboTerms.get(0); + } + if (exportSboTerms.size() != 0) { + return exportSboTerms.get(0); + } + logger.warn("Cannot find SBO term for class: " + clazz); + return null; + } } diff --git a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SbmlSpeciesExporter.java b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SbmlSpeciesExporter.java index 17a1a9e1005029ef69bc20c2eab6c6d9ae1c57a6..4dfabe7aeec8c0ac555ecdcc755c532056dde2c3 100644 --- a/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SbmlSpeciesExporter.java +++ b/converter-sbml/src/main/java/lcsb/mapviewer/converter/model/sbml/species/SbmlSpeciesExporter.java @@ -24,6 +24,7 @@ public class SbmlSpeciesExporter extends SbmlElementExporter<Species, org.sbml.j @Override public org.sbml.jsbml.Species createSbmlElement(Species element) throws InconsistentModelException { org.sbml.jsbml.Species result = getSbmlModel().createSpecies("species_" + (getNextId())); + result.setSBOTerm(SBOTermSpeciesType.getTermByType(element.getClass())); if (element.getCompartment() != null) { result.setCompartment(compartmentExporter.getSbmlElement(element.getCompartment(), null)); }