From 93a2efcda3a5df794acdd94b4b8cd53c09d48fd4 Mon Sep 17 00:00:00 2001 From: Clemens Wrzodek Date: Mon, 4 Jun 2012 12:16:12 +0000 Subject: [PATCH] Various Additions included in KEGGtranslator v2 Release. --- src/de/zbit/kegg/gui/TranslatorBioPAXPanel.java | 10 +++++++++- src/de/zbit/kegg/gui/TranslatorGraphPanel.java | 10 ++++++++-- src/de/zbit/kegg/gui/TranslatorSBGNPanel.java | 9 +++++++++ src/de/zbit/kegg/io/KEGG2BioPAX.java | 6 ++++++ src/de/zbit/kegg/io/KEGG2BioPAX_level2.java | 2 +- src/de/zbit/kegg/io/KEGG2BioPAX_level3.java | 13 +++++++++++-- src/de/zbit/kegg/io/KEGG2SBMLqual.java | 17 ++++++++++++++++- src/de/zbit/kegg/io/KEGG2jSBML.java | 3 ++- 8 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/de/zbit/kegg/gui/TranslatorBioPAXPanel.java b/src/de/zbit/kegg/gui/TranslatorBioPAXPanel.java index 27ec3c4..13a7ca1 100644 --- a/src/de/zbit/kegg/gui/TranslatorBioPAXPanel.java +++ b/src/de/zbit/kegg/gui/TranslatorBioPAXPanel.java @@ -48,7 +48,7 @@ * @author Clemens Wrzodek * @version $Rev$ */ -public class TranslatorBioPAXPanel extends TranslatorGraphLayerPanel{ +public class TranslatorBioPAXPanel extends TranslatorGraphLayerPanel { private static final long serialVersionUID = -6585611929238639630L; @@ -129,6 +129,14 @@ public boolean isAllowedToSaveAsGraphFormats() { return false; } + /* (non-Javadoc) + * @see de.zbit.graph.gui.TranslatorGraphLayerPanel#isDetailPanelAvailable() + */ + @Override + public boolean isDetailPanelAvailable() { + return false; + } + /* (non-Javadoc) * @see de.zbit.kegg.gui.TranslatorGraphLayerPanel#updateDetailPanel(javax.swing.JScrollPane, y.view.HitInfo) */ diff --git a/src/de/zbit/kegg/gui/TranslatorGraphPanel.java b/src/de/zbit/kegg/gui/TranslatorGraphPanel.java index de4e8d4..b51d2a0 100644 --- a/src/de/zbit/kegg/gui/TranslatorGraphPanel.java +++ b/src/de/zbit/kegg/gui/TranslatorGraphPanel.java @@ -108,7 +108,13 @@ protected boolean writeRealDocumentToFileUnchecked(File file, String format) throws Exception { return ((KEGG2yGraph)getTranslator()).writeToFile(document, file.getPath(), format); } - - + + /* (non-Javadoc) + * @see de.zbit.graph.gui.TranslatorGraphLayerPanel#isDetailPanelAvailable() + */ + @Override + public boolean isDetailPanelAvailable() { + return false; + } } diff --git a/src/de/zbit/kegg/gui/TranslatorSBGNPanel.java b/src/de/zbit/kegg/gui/TranslatorSBGNPanel.java index adf8a84..c7046cd 100644 --- a/src/de/zbit/kegg/gui/TranslatorSBGNPanel.java +++ b/src/de/zbit/kegg/gui/TranslatorSBGNPanel.java @@ -118,4 +118,13 @@ protected boolean writeRealDocumentToFileUnchecked(File file, String format) throws Exception { return ((KEGG2SBGN)getTranslator()).writeToFile(document, file.getPath()); } + + /* (non-Javadoc) + * @see de.zbit.graph.gui.TranslatorGraphLayerPanel#isDetailPanelAvailable() + */ + @Override + public boolean isDetailPanelAvailable() { + return false; + } + } diff --git a/src/de/zbit/kegg/io/KEGG2BioPAX.java b/src/de/zbit/kegg/io/KEGG2BioPAX.java index 842bcc9..72a2773 100644 --- a/src/de/zbit/kegg/io/KEGG2BioPAX.java +++ b/src/de/zbit/kegg/io/KEGG2BioPAX.java @@ -277,6 +277,9 @@ public BioPAXElement createXRef(IdentifierDatabases db, String id, int type) { instantiate = relationshipXref.class; } else if (type==3) { instantiate = publicationXref.class; + } else { + // we can NOT instantiate xref.class + instantiate = relationshipXref.class; } xr = model.addNew(instantiate, uri); @@ -293,6 +296,9 @@ public BioPAXElement createXRef(IdentifierDatabases db, String id, int type) { instantiate = RelationshipXref.class; } else if (type==3) { instantiate = PublicationXref.class; + } else { + // we can NOT instantiate Xref.class + instantiate = RelationshipXref.class; } xr = model.addNew(instantiate, uri); diff --git a/src/de/zbit/kegg/io/KEGG2BioPAX_level2.java b/src/de/zbit/kegg/io/KEGG2BioPAX_level2.java index 2578aad..f067d4a 100644 --- a/src/de/zbit/kegg/io/KEGG2BioPAX_level2.java +++ b/src/de/zbit/kegg/io/KEGG2BioPAX_level2.java @@ -113,7 +113,7 @@ protected BioPAXElement createPathwayInstance(Pathway p) { // Parse Kegg Pathway information boolean isKEGGPathway = DatabaseIdentifiers.checkID(DatabaseIdentifiers.IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM()); if (isKEGGPathway) { - xref xr = (xref)createXRef(IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM()); + xref xr = (xref)createXRef(IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM(), 1); if (xr!=null) { pathway.addXREF(xr); } diff --git a/src/de/zbit/kegg/io/KEGG2BioPAX_level3.java b/src/de/zbit/kegg/io/KEGG2BioPAX_level3.java index 1472ab1..1cdd8f8 100644 --- a/src/de/zbit/kegg/io/KEGG2BioPAX_level3.java +++ b/src/de/zbit/kegg/io/KEGG2BioPAX_level3.java @@ -55,7 +55,6 @@ import org.biopax.paxtools.model.level3.SmallMolecule; import org.biopax.paxtools.model.level3.SmallMoleculeReference; import org.biopax.paxtools.model.level3.Stoichiometry; -import org.biopax.paxtools.model.level3.UnificationXref; import org.biopax.paxtools.model.level3.XReferrable; import org.biopax.paxtools.model.level3.Xref; @@ -307,7 +306,7 @@ protected BioPAXElement createPathwayInstance(Pathway p) { // Parse Kegg Pathway information boolean isKEGGPathway = DatabaseIdentifiers.checkID(DatabaseIdentifiers.IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM()); if (isKEGGPathway) { - Xref xr = (Xref)createXRef(IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM()); + Xref xr = (Xref)createXRef(IdentifierDatabases.KEGG_Pathway, p.getNameForMIRIAM(), 1); if (xr!=null) { pathway.addXref(xr); } @@ -474,6 +473,16 @@ public BioPAXElement addKGMLRelation(Relation r, Pathway p) { return null; } +// // Relations should prefarably translated, using the EntityReferences +// if (qOne instanceof SimplePhysicalEntity && +// ((SimplePhysicalEntity)qOne).getEntityReference()!=null ) { +// qOne = ((SimplePhysicalEntity)qOne).getEntityReference(); +// } +// if (qTwo instanceof SimplePhysicalEntity && +// ((SimplePhysicalEntity)qTwo).getEntityReference()!=null ) { +// qTwo = ((SimplePhysicalEntity)qTwo).getEntityReference(); +// } + // Most relations have a left and right side => conversion as default Class instantiate = Conversion.class; diff --git a/src/de/zbit/kegg/io/KEGG2SBMLqual.java b/src/de/zbit/kegg/io/KEGG2SBMLqual.java index c598d2d..fe995c5 100644 --- a/src/de/zbit/kegg/io/KEGG2SBMLqual.java +++ b/src/de/zbit/kegg/io/KEGG2SBMLqual.java @@ -38,6 +38,7 @@ import org.sbml.jsbml.ext.groups.Group; import org.sbml.jsbml.ext.qual.Input; import org.sbml.jsbml.ext.qual.InputTransitionEffect; +import org.sbml.jsbml.ext.qual.Output; import org.sbml.jsbml.ext.qual.OutputTransitionEffect; import org.sbml.jsbml.ext.qual.QualConstant; import org.sbml.jsbml.ext.qual.QualitativeModel; @@ -93,6 +94,13 @@ public class KEGG2SBMLqual extends KEGG2jSBML { */ private boolean considerReactions = false; + /** + * All transitions that are added to the model. + * Identified as "inputQualitativeSpecies ouptutQualitativeSpecies [SBOterm]", + * used to check for duplicates. + */ + private Set containedTransitions = new HashSet(); + /** * @param document @@ -242,7 +250,7 @@ public Transition addKGMLRelation(Relation r, Pathway p, QualitativeModel qualMo in.setMetaId("meta_" + in.getId()); // Output - t.createOutput(NameToSId("out"), qTwo.getId(), OutputTransitionEffect.assignmentLevel); //TODO: is this correct? + Output out = t.createOutput(NameToSId("out"), qTwo.getId(), OutputTransitionEffect.assignmentLevel); //TODO: is this correct? //XXX: "function term" is intentionally not set in KEGG2X (info not provided). @@ -327,6 +335,13 @@ public Transition addKGMLRelation(Relation r, Pathway p, QualitativeModel qualMo t.addCVTerm(cv); } + // Don't att same relations twice + String transitionIdentifier = in.getQualitativeSpecies() + " " + out.getQualitativeSpecies() + " " + (t.isSetSBOTerm() ? t.getSBOTermID():""); + if (!containedTransitions.add(transitionIdentifier)) { + qualModel.getListOfTransitions().remove(t); + t=null; + } + return t; } diff --git a/src/de/zbit/kegg/io/KEGG2jSBML.java b/src/de/zbit/kegg/io/KEGG2jSBML.java index afa676e..ecd2c77 100644 --- a/src/de/zbit/kegg/io/KEGG2jSBML.java +++ b/src/de/zbit/kegg/io/KEGG2jSBML.java @@ -219,7 +219,8 @@ public void setUseGroupsExtension(boolean b) { /** Load the default preferences from the SBPreferences object. */ private void loadPreferences() { - addCellDesignerAnnots = KEGGtranslatorOptions.CELLDESIGNER_ANNOTATIONS.getValue(prefs); + // CellDeisnger annotations are not supported anymore! + //addCellDesignerAnnots = KEGGtranslatorOptions.CELLDESIGNER_ANNOTATIONS.getValue(prefs); addLayoutExtension = KEGGtranslatorOptions.ADD_LAYOUT_EXTENSION.getValue(prefs); useGroupsExtension = KEGGtranslatorOptions.USE_GROUPS_EXTENSION.getValue(prefs); }