diff --git a/build.xml b/build.xml index 01bc386ca..e0e25882a 100644 --- a/build.xml +++ b/build.xml @@ -77,7 +77,7 @@ - + diff --git a/lib/SysBio.jar b/lib/SysBio.jar index 339509853..6446a65fb 100644 Binary files a/lib/SysBio.jar and b/lib/SysBio.jar differ diff --git a/src/org/sbml/squeezer/SBMLsqueezer.java b/src/org/sbml/squeezer/SBMLsqueezer.java index c57647321..3cb07ef33 100644 --- a/src/org/sbml/squeezer/SBMLsqueezer.java +++ b/src/org/sbml/squeezer/SBMLsqueezer.java @@ -42,8 +42,6 @@ import javax.xml.stream.XMLStreamException; -import jp.sbi.garuda.platform.commons.exception.NetworkException; - import org.sbml.jsbml.Model; import org.sbml.jsbml.Reaction; import org.sbml.jsbml.SBMLDocument; @@ -68,9 +66,7 @@ import de.zbit.AppConf; import de.zbit.Launcher; import de.zbit.garuda.GarudaOptions; -import de.zbit.garuda.GarudaSoftwareBackend; import de.zbit.gui.GUIOptions; -import de.zbit.gui.GUITools; import de.zbit.io.FileWalker; import de.zbit.io.filefilter.SBFileFilter; import de.zbit.util.ResourceManager; @@ -94,25 +90,29 @@ @SuppressWarnings("unchecked") public class SBMLsqueezer extends Launcher { + private static Boolean libSBMLAvailable = null; /** - * Localization support. + * The {@link Logger} for this class. */ - public static final transient ResourceBundle MESSAGES = ResourceManager.getBundle(Bundles.MESSAGES); + private static final transient Logger logger = Logger.getLogger(SBMLsqueezer.class.getName()); + /** * Localization support. */ - public static final transient ResourceBundle WARNINGS = ResourceManager.getBundle(Bundles.WARNINGS); + public static final transient ResourceBundle MESSAGES = ResourceManager.getBundle(Bundles.MESSAGES); - /** - * The {@link Logger} for this class. - */ - private static final transient Logger logger = Logger.getLogger(SBMLsqueezer.class.getName()); + private static boolean sabiorkEnabled = true; /** * Generated serial version identifier. */ private static final long serialVersionUID = 8751196023375780898L; + /** + * Localization support. + */ + public static final transient ResourceBundle WARNINGS = ResourceManager.getBundle(Bundles.WARNINGS); + /** * * @return @@ -121,22 +121,6 @@ public static List> getInteractiveConfigOptions() { return Arrays.asList(getInteractiveConfigOptionsArray()); } - private static boolean sabiorkEnabled = true; - - /** - * @return the sabiorkEnabled - */ - public static boolean isSABIORKEnabled() { - return sabiorkEnabled; - } - - /** - * @param sabiorkEnabled the sabiorkEnabled to set - */ - public static void setSABIORKEnabled(boolean sabiorkEnabled) { - SBMLsqueezer.sabiorkEnabled = sabiorkEnabled; - } - /** * * @return @@ -178,42 +162,11 @@ public static String[] getPossibleEnzymeTypes() { return enzymeTypes.toArray(new String[] {}); } - private static Boolean libSBMLAvailable = null; - /** - * Does initialization for creating a SBMLsqueezer Object. - * Checks if libSBML is available and initializes the Reader/Writer. - * @param tryLoadingLibSBML - * @param reader - * @param writer + * @return the sabiorkEnabled */ - private void initializeReaderAndWriter(boolean tryLoadingLibSBML) { - if (tryLoadingLibSBML) { - if (libSBMLAvailable == null) { - try { - // In order to initialize libSBML, check the java.library.path. - System.loadLibrary("sbmlj"); - // Extra check to be sure we have access to libSBML: - Class.forName("org.sbml.libsbml.libsbml"); - logger.info(MESSAGES.getString("LOADING_LIBSBML")); - libSBMLAvailable = Boolean.TRUE; - } catch (Error e) { - libSBMLAvailable = Boolean.FALSE; - } catch (Throwable e) { - libSBMLAvailable = Boolean.FALSE; - } - } - if (libSBMLAvailable.booleanValue()) { - logger.info(MESSAGES.getString("LAUNCHING_LIBSBML")); - sbmlIo = (SBMLio) new SBMLio( - new LibSBMLReader(), new LibSBMLWriter()); - } - } - if (sbmlIo == null) { - logger.info(MESSAGES.getString("LOADING_JSBML")); - sbmlIo = (SBMLio) new SBMLio(new SqSBMLReader(), - new SqSBMLWriter()); - } + public static boolean isSABIORKEnabled() { + return sabiorkEnabled; } /** @@ -225,15 +178,22 @@ public static void main(String[] args) { } /** - * + * @param sabiorkEnabled the sabiorkEnabled to set */ - private SBMLio sbmlIo; + public static void setSABIORKEnabled(boolean sabiorkEnabled) { + SBMLsqueezer.sabiorkEnabled = sabiorkEnabled; + } /** * */ private AppConf appConf; + /** + * + */ + private SBMLio sbmlIo; + /** * */ @@ -262,6 +222,7 @@ public SBMLsqueezer(SBMLInputConverter sbmlReader, */ public SBMLsqueezer(String[] args) { super(args); + System.out.println(getId()); } /* (non-Javadoc) @@ -323,7 +284,6 @@ public List> getCmdLineOptions() { return list; } - /* (non-Javadoc) * @see de.zbit.Launcher#getInteractiveOptions() */ @@ -332,6 +292,7 @@ public List> getInteractiveOptions() { return getInteractiveConfigOptions(); } + /* (non-Javadoc) * @see de.zbit.Launcher#getLogPackages() */ @@ -381,7 +342,7 @@ public URL getURLOnlineUpdate() { */ @Override public String getVersionNumber() { - return "2.0"; + return "2.0.1"; } /* (non-Javadoc) @@ -409,29 +370,51 @@ public java.awt.Window initGUI(AppConf appConf) { if (properties.containsKey(IOOptions.SBML_IN_FILE)) { readSBMLSource(properties.get(IOOptions.SBML_IN_FILE)); } - final SBMLsqueezerUI gui = new SBMLsqueezerUI(getSBMLIO(), appConf); - if (getCmdLineOptions().contains(GarudaOptions.class) - && (!appConf.getCmdArgs().containsKey(GarudaOptions.CONNECT_TO_GARUDA) || - appConf.getCmdArgs().getBoolean(GarudaOptions.CONNECT_TO_GARUDA))) { - new Thread(new Runnable() { - /* (non-Javadoc) - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - try { - GarudaSoftwareBackend garudaBackend = new GarudaSoftwareBackend( - "dd624b40-7bc0-11e2-b92a-0800200c9a66", gui); - garudaBackend.init(); - } catch (NetworkException exc) { - GUITools.showErrorMessage(gui, exc); - } catch (Throwable exc) { - logger.fine(getMessage(exc)); - } + return new SBMLsqueezerUI(getSBMLIO(), appConf); + } + + /** + * Does initialization for creating a SBMLsqueezer Object. + * Checks if libSBML is available and initializes the Reader/Writer. + * @param tryLoadingLibSBML + * @param reader + * @param writer + */ + private void initializeReaderAndWriter(boolean tryLoadingLibSBML) { + if (tryLoadingLibSBML) { + if (libSBMLAvailable == null) { + try { + // In order to initialize libSBML, check the java.library.path. + System.loadLibrary("sbmlj"); + // Extra check to be sure we have access to libSBML: + Class.forName("org.sbml.libsbml.libsbml"); + logger.info(MESSAGES.getString("LOADING_LIBSBML")); + libSBMLAvailable = Boolean.TRUE; + } catch (Error e) { + libSBMLAvailable = Boolean.FALSE; + } catch (Throwable e) { + libSBMLAvailable = Boolean.FALSE; } - }).start(); + } + if (libSBMLAvailable.booleanValue()) { + logger.info(MESSAGES.getString("LAUNCHING_LIBSBML")); + sbmlIo = (SBMLio) new SBMLio( + new LibSBMLReader(), new LibSBMLWriter()); + } + } + if (sbmlIo == null) { + logger.info(MESSAGES.getString("LOADING_JSBML")); + sbmlIo = (SBMLio) new SBMLio(new SqSBMLReader(), + new SqSBMLWriter()); } - return gui; + } + + /* (non-Javadoc) + * @see de.zbit.Launcher#isGarudaEnabled() + */ + @Override + public boolean isGarudaEnabled() { + return true; } /** @@ -594,39 +577,12 @@ public void squeeze(Object sbmlSource, String outfile, boolean searchSABIO) thro } /** - * Convenient method that writes a LaTeX file from the given SBML source. - * - * @param sbmlInfile - * @param latexFile - * @throws IOException - * @throws SBMLException - * @throws XMLStreamException + * @param absolutePath + * @param outputPath + * @throws Throwable */ - public void toLaTeX(Object sbmlSource, String latexFile) throws IOException, SBMLException, XMLStreamException { - readSBMLSource(sbmlSource); - SBPreferences prefsIO = SBPreferences.getPreferencesFor(GUIOptions.class); - String dir = prefsIO.get(GUIOptions.OPEN_DIR).toString(); - if (latexFile != null) { - File out = new File(latexFile); - if (SBFileFilter.createTeXFileFilter().accept(out)) { - String path = out.getParent(); - if (!path.equals(dir)) { - prefsIO.put(GUIOptions.OPEN_DIR, path); - } - if (!out.exists()) { - long time = System.currentTimeMillis(); - logger.info(MESSAGES.getString("WRITING_LATEX_OUTPUT")); - SBML2LaTeX.convert(sbmlIo.getSelectedModel(), out); - logger.info(MessageFormat.format( - MESSAGES.getString("DONE_IN_MS"), (System.currentTimeMillis() - time)) + "\n"); - } - } else { - logger.log(Level.WARNING, MessageFormat.format( - WARNINGS.getString("INVALID_TEX_FILE"), latexFile) +"\n"); - } - } else { - logger.log(Level.WARNING, WARNINGS.getString("NO_TEX_FILE_PROVIDED")); - } + public void squeeze(String absolutePath, String outputPath) throws Throwable { + squeeze(absolutePath, outputPath, false); } /** @@ -777,12 +733,39 @@ public Set squeezeWithKineticsFromSABIORK(SBMLDocument sbmlDocument, b } /** - * @param absolutePath - * @param outputPath - * @throws Throwable + * Convenient method that writes a LaTeX file from the given SBML source. + * + * @param sbmlInfile + * @param latexFile + * @throws IOException + * @throws SBMLException + * @throws XMLStreamException */ - public void squeeze(String absolutePath, String outputPath) throws Throwable { - squeeze(absolutePath, outputPath, false); + public void toLaTeX(Object sbmlSource, String latexFile) throws IOException, SBMLException, XMLStreamException { + readSBMLSource(sbmlSource); + SBPreferences prefsIO = SBPreferences.getPreferencesFor(GUIOptions.class); + String dir = prefsIO.get(GUIOptions.OPEN_DIR).toString(); + if (latexFile != null) { + File out = new File(latexFile); + if (SBFileFilter.createTeXFileFilter().accept(out)) { + String path = out.getParent(); + if (!path.equals(dir)) { + prefsIO.put(GUIOptions.OPEN_DIR, path); + } + if (!out.exists()) { + long time = System.currentTimeMillis(); + logger.info(MESSAGES.getString("WRITING_LATEX_OUTPUT")); + SBML2LaTeX.convert(sbmlIo.getSelectedModel(), out); + logger.info(MessageFormat.format( + MESSAGES.getString("DONE_IN_MS"), (System.currentTimeMillis() - time)) + "\n"); + } + } else { + logger.log(Level.WARNING, MessageFormat.format( + WARNINGS.getString("INVALID_TEX_FILE"), latexFile) +"\n"); + } + } else { + logger.log(Level.WARNING, WARNINGS.getString("NO_TEX_FILE_PROVIDED")); + } } }