Skip to content

Commit 2ef2a3a

Browse files
committed
(hopefully final commit for KEGGtranslator version 2.2.0)
- 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
1 parent 727b58c commit 2ef2a3a

12 files changed

+1015
-114
lines changed

src/de/zbit/kegg/Translator.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,5 +536,22 @@ protected boolean addCopyrightToSplashScreen() {
536536
public Window initGUI(AppConf appConf) {
537537
return new TranslatorUI(appConf);
538538
}
539+
540+
/**
541+
* Decide whether to show the gui or not.
542+
*/
543+
@Override
544+
public boolean showsGUI() {
545+
SBProperties props = getCommandLineArgs();
546+
boolean showGUI = (props.size() < 1) || props.getBooleanProperty(GUIOptions.GUI);
547+
if (!showGUI) {
548+
// Check if an input file is given. This is required for and will trigger the command-line mode.
549+
String inputFile = props.getProperty(KEGGtranslatorIOOptions.INPUT);
550+
if (inputFile==null || inputFile.length()<1) {
551+
showGUI = true;
552+
}
553+
}
554+
return showGUI;
555+
}
539556

540557
}

src/de/zbit/kegg/gui/TranslatorPanelTools.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static TranslatorPanel<?> createPanel(final File inputFile, final Format
5050
TranslatorPanel<?> panel = null;
5151

5252
switch (outputFormat) {
53-
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: /*case LaTeX: */
53+
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: case SBML_L2V4: case SBML_L3V1: /*case LaTeX: */
5454
panel = new TranslatorSBMLPanel(inputFile, outputFormat, translationResult);
5555
break;
5656

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

8282
switch (outputFormat) {
83-
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: /*case LaTeX: */
83+
case SBML: case SBML_QUAL: case SBML_CORE_AND_QUAL: case SBML_L2V4: case SBML_L3V1: /*case LaTeX: */
8484
panel = new TranslatorSBMLPanel(pathwayID, outputFormat, translationResult);
8585
break;
8686

src/de/zbit/kegg/gui/TranslatorUI.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import de.zbit.gui.prefs.FileSelector;
6767
import de.zbit.gui.prefs.PreferencesPanel;
6868
import de.zbit.io.filefilter.SBFileFilter;
69+
import de.zbit.kegg.KEGGtranslatorOptions;
6970
import de.zbit.kegg.Translator;
7071
import de.zbit.kegg.ext.KEGGTranslatorPanelOptions;
7172
import de.zbit.kegg.io.KEGG2jSBML;
@@ -275,6 +276,11 @@ public void actionPerformed(ActionEvent e) {
275276
// Get selected file and format
276277
File inFile = getInputFile(r);
277278
String format = getOutputFileFormat(r);
279+
280+
// Check if it is conform with current settings
281+
if (!checkSettingsAndIssueWarning(format)) {
282+
return;
283+
}
278284

279285
// Translate
280286
createNewTab(inFile, format);
@@ -290,8 +296,38 @@ public void actionPerformed(ActionEvent e) {
290296
}
291297

292298
/**
299+
* Checks if the current application preferences are conform
300+
* with the currently selected format and eventually
301+
* issues a warning.
302+
* @param format
303+
* @return <code>FALSE</code> if the translation should be
304+
* stopped.
305+
*/
306+
protected boolean checkSettingsAndIssueWarning(String format) {
307+
308+
Format f = Format.valueOf(format);
309+
if (f==null) {
310+
GUITools.showErrorMessage(this, "Unknown output format: " + format);
311+
return false;
312+
} else if (f == Format.SBML_L2V4) {
313+
// Check if Level 2 and extensions are selected.
314+
SBPreferences prefs = SBPreferences.getPreferencesFor(KEGGtranslatorOptions.class);
315+
if (KEGGtranslatorOptions.ADD_LAYOUT_EXTENSION.getValue(prefs) ||
316+
KEGGtranslatorOptions.USE_GROUPS_EXTENSION.getValue(prefs)) {
317+
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?";
318+
int ret = GUITools.showQuestionMessage(this, message, "Conflict between selected Level and extension support", JOptionPane.OK_CANCEL_OPTION);
319+
if (ret == JOptionPane.CANCEL_OPTION) {
320+
return false;
321+
}
322+
}
323+
}
324+
325+
return true;
326+
}
327+
328+
/**
293329
* Searches for any JComponent with
294-
* "TranslatorOptions.FORMAT.getOptionName()" on it and returns the selected
330+
* {@link KEGGtranslatorIOOptions#FORMAT}.getOptionName() on it and returns the selected
295331
* format. Use it e.g. with {@link #translateToolBar}.
296332
*
297333
* @param r
@@ -774,7 +810,6 @@ public URL getURLOnlineHelp() {
774810
/* (non-Javadoc)
775811
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
776812
*/
777-
@Override
778813
public void propertyChange(PropertyChangeEvent evt) {
779814
logger.fine(evt.toString());
780815
}

src/de/zbit/kegg/io/AbstractKEGGtranslator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ protected static String firstName(String name) {
802802
*/
803803
protected String NameToSId(String name) {
804804
/*
805-
* letter ::= �a�..�z�,�A�..�Z� digit ::= �0�..�9� idChar ::= letter |
806-
* digit | �_� SId ::= ( letter | �_� ) idChar*
805+
* letter = a-z,A-Z; digit = 0-9; idChar = (letter | digit | _ );
806+
* SId = ( letter | _ ) idChar*
807807
*/
808808
String ret;
809809
if (name == null || name.trim().length() == 0) {
@@ -848,7 +848,7 @@ protected String NameToSId(String name) {
848848
* @return
849849
*/
850850
private static boolean isLetter(char c) {
851-
// Unfortunately Character.isLetter also acceps ß, but SBML doesn't.
851+
// Unfortunately Character.isLetter also accepts ß, but SBML doesn't.
852852
// a-z or A-Z
853853
return (c>=97 && c<=122) || (c>=65 && c<=90);
854854
}

src/de/zbit/kegg/io/BatchKEGGtranslator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ private boolean writeAsJPG(Object translatedDoc, Pathway originalPW, String outF
294294
break;
295295

296296
case SBML:
297+
case SBML_L2V4:
298+
case SBML_L3V1:
297299
myGraph = new SBML2GraphML().createGraph((org.sbml.jsbml.SBMLDocument) translatedDoc);
298300
break;
299301

@@ -331,6 +333,12 @@ public static KEGGtranslator<?> getTranslator(Format outFormat, KeggInfoManageme
331333
case SBML:
332334
translator = new KEGG2jSBML(manager);
333335
break;
336+
case SBML_L2V4:
337+
translator = new KEGG2jSBML(manager, 2, 4);
338+
break;
339+
case SBML_L3V1:
340+
translator = new KEGG2jSBML(manager, 3, 1);
341+
break;
334342
case SBML_QUAL:
335343
translator = new KEGG2SBMLqual(manager);
336344
break;

0 commit comments

Comments
 (0)