Skip to content

Commit

Permalink
(hopefully final commit for KEGGtranslator version 2.2.0)
Browse files Browse the repository at this point in the history
- Added separate format options for SBML_L2V4 and SBML_L3V1
- Massively changed how relations are translated to BioPAX, especially in Level 3:
  o Added support for controller/control combinations
  o Added support for modified proteins with a modificaiton feature, that point to the same protein instance
  o Added complexAssembly and biochemicalReaction for some relations
  o ...
- Various other improvements to 2BioPAX translations
- Added PSI-MI and PSI-MOD ontologies
- Improved command-line usage
  • Loading branch information
Clemens82 committed Nov 8, 2012
1 parent 727b58c commit 2ef2a3a
Show file tree
Hide file tree
Showing 12 changed files with 1,015 additions and 114 deletions.
17 changes: 17 additions & 0 deletions src/de/zbit/kegg/Translator.java
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,22 @@ protected boolean addCopyrightToSplashScreen() {
public Window initGUI(AppConf appConf) {
return new TranslatorUI(appConf);
}

/**
* Decide whether to show the gui or not.
*/
@Override
public boolean showsGUI() {
SBProperties props = getCommandLineArgs();
boolean showGUI = (props.size() < 1) || props.getBooleanProperty(GUIOptions.GUI);
if (!showGUI) {
// Check if an input file is given. This is required for and will trigger the command-line mode.
String inputFile = props.getProperty(KEGGtranslatorIOOptions.INPUT);
if (inputFile==null || inputFile.length()<1) {
showGUI = true;
}
}
return showGUI;
}

}
4 changes: 2 additions & 2 deletions src/de/zbit/kegg/gui/TranslatorPanelTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static TranslatorPanel<?> createPanel(final File inputFile, final Format
TranslatorPanel<?> panel = null;

switch (outputFormat) {
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: /*case LaTeX: */
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: case SBML_L2V4: case SBML_L3V1: /*case LaTeX: */
panel = new TranslatorSBMLPanel(inputFile, outputFormat, translationResult);
break;

Expand Down Expand Up @@ -80,7 +80,7 @@ public static TranslatorPanel<?> createPanel(final String pathwayID, final Forma
TranslatorPanel<?> panel = null;

switch (outputFormat) {
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: /*case LaTeX: */
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: case SBML_L2V4: case SBML_L3V1: /*case LaTeX: */
panel = new TranslatorSBMLPanel(pathwayID, outputFormat, translationResult);
break;

Expand Down
39 changes: 37 additions & 2 deletions src/de/zbit/kegg/gui/TranslatorUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import de.zbit.gui.prefs.FileSelector;
import de.zbit.gui.prefs.PreferencesPanel;
import de.zbit.io.filefilter.SBFileFilter;
import de.zbit.kegg.KEGGtranslatorOptions;
import de.zbit.kegg.Translator;
import de.zbit.kegg.ext.KEGGTranslatorPanelOptions;
import de.zbit.kegg.io.KEGG2jSBML;
Expand Down Expand Up @@ -275,6 +276,11 @@ public void actionPerformed(ActionEvent e) {
// Get selected file and format
File inFile = getInputFile(r);
String format = getOutputFileFormat(r);

// Check if it is conform with current settings
if (!checkSettingsAndIssueWarning(format)) {
return;
}

// Translate
createNewTab(inFile, format);
Expand All @@ -290,8 +296,38 @@ public void actionPerformed(ActionEvent e) {
}

/**
* Checks if the current application preferences are conform
* with the currently selected format and eventually
* issues a warning.
* @param format
* @return <code>FALSE</code> if the translation should be
* stopped.
*/
protected boolean checkSettingsAndIssueWarning(String format) {

Format f = Format.valueOf(format);
if (f==null) {
GUITools.showErrorMessage(this, "Unknown output format: " + format);
return false;
} else if (f == Format.SBML_L2V4) {
// Check if Level 2 and extensions are selected.
SBPreferences prefs = SBPreferences.getPreferencesFor(KEGGtranslatorOptions.class);
if (KEGGtranslatorOptions.ADD_LAYOUT_EXTENSION.getValue(prefs) ||
KEGGtranslatorOptions.USE_GROUPS_EXTENSION.getValue(prefs)) {
String message = "SBML supports extensions since Level 3. You've chosen to translate a document to Level 2 including the layout or groups extension, what is not possible.\nDo you want to deactivate the extensions for this translation?";
int ret = GUITools.showQuestionMessage(this, message, "Conflict between selected Level and extension support", JOptionPane.OK_CANCEL_OPTION);
if (ret == JOptionPane.CANCEL_OPTION) {
return false;
}
}
}

return true;
}

/**
* Searches for any JComponent with
* "TranslatorOptions.FORMAT.getOptionName()" on it and returns the selected
* {@link KEGGtranslatorIOOptions#FORMAT}.getOptionName() on it and returns the selected
* format. Use it e.g. with {@link #translateToolBar}.
*
* @param r
Expand Down Expand Up @@ -774,7 +810,6 @@ public URL getURLOnlineHelp() {
/* (non-Javadoc)
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
logger.fine(evt.toString());
}
Expand Down
6 changes: 3 additions & 3 deletions src/de/zbit/kegg/io/AbstractKEGGtranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ protected static String firstName(String name) {
*/
protected String NameToSId(String name) {
/*
* letter ::= �a�..�z�,�A�..�Z� digit ::= �0�..�9� idChar ::= letter |
* digit | �_� SId ::= ( letter | �_� ) idChar*
* letter = a-z,A-Z; digit = 0-9; idChar = (letter | digit | _ );
* SId = ( letter | _ ) idChar*
*/
String ret;
if (name == null || name.trim().length() == 0) {
Expand Down Expand Up @@ -848,7 +848,7 @@ protected String NameToSId(String name) {
* @return
*/
private static boolean isLetter(char c) {
// Unfortunately Character.isLetter also acceps ß, but SBML doesn't.
// Unfortunately Character.isLetter also accepts ß, but SBML doesn't.
// a-z or A-Z
return (c>=97 && c<=122) || (c>=65 && c<=90);
}
Expand Down
8 changes: 8 additions & 0 deletions src/de/zbit/kegg/io/BatchKEGGtranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ private boolean writeAsJPG(Object translatedDoc, Pathway originalPW, String outF
break;

case SBML:
case SBML_L2V4:
case SBML_L3V1:
myGraph = new SBML2GraphML().createGraph((org.sbml.jsbml.SBMLDocument) translatedDoc);
break;

Expand Down Expand Up @@ -331,6 +333,12 @@ public static KEGGtranslator<?> getTranslator(Format outFormat, KeggInfoManageme
case SBML:
translator = new KEGG2jSBML(manager);
break;
case SBML_L2V4:
translator = new KEGG2jSBML(manager, 2, 4);
break;
case SBML_L3V1:
translator = new KEGG2jSBML(manager, 3, 1);
break;
case SBML_QUAL:
translator = new KEGG2SBMLqual(manager);
break;
Expand Down
Loading

0 comments on commit 2ef2a3a

Please sign in to comment.