diff --git a/.gitignore b/.gitignore index 655d22746..902fd564f 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,6 @@ hs_err_pid* IAP CONSOLE/bin/de/ipk/ag_ba/Console.class /.DS_Store + +make/zip/*.zip +make/zip/IAP_* diff --git a/Graffiti_Core/.classpath b/Graffiti_Core/.classpath index d7a652125..16d8f6f56 100644 --- a/Graffiti_Core/.classpath +++ b/Graffiti_Core/.classpath @@ -1,18 +1,19 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Graffiti_Core/org/SystemAnalysis.java b/Graffiti_Core/org/SystemAnalysis.java index a8429333e..964591f07 100644 --- a/Graffiti_Core/org/SystemAnalysis.java +++ b/Graffiti_Core/org/SystemAnalysis.java @@ -510,6 +510,7 @@ public static String getFileSeparator() { public static boolean isRetina() { if (isHeadless()) return false; + if (false) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice device = env.getDefaultScreenDevice(); @@ -526,6 +527,7 @@ public static boolean isRetina() { } } catch (Exception ignore) { } + } return false; } diff --git a/Graffiti_lib/.classpath b/Graffiti_lib/.classpath index b495b262a..cc45c217c 100644 --- a/Graffiti_lib/.classpath +++ b/Graffiti_lib/.classpath @@ -1,58 +1,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IAP CONSOLE/bin/de/ipk/ag_ba/CommandLineStatusProvider.class b/IAP CONSOLE/bin/de/ipk/ag_ba/CommandLineStatusProvider.class index 19b97633b..259750d5e 100644 Binary files a/IAP CONSOLE/bin/de/ipk/ag_ba/CommandLineStatusProvider.class and b/IAP CONSOLE/bin/de/ipk/ag_ba/CommandLineStatusProvider.class differ diff --git a/IAP CONSOLE/bin/de/ipk/ag_ba/SplashScreenDontPrintProgress.class b/IAP CONSOLE/bin/de/ipk/ag_ba/SplashScreenDontPrintProgress.class index 45ba6b3bc..6355cb88b 100644 Binary files a/IAP CONSOLE/bin/de/ipk/ag_ba/SplashScreenDontPrintProgress.class and b/IAP CONSOLE/bin/de/ipk/ag_ba/SplashScreenDontPrintProgress.class differ diff --git a/IAP/.classpath b/IAP/.classpath index ff2de5fb5..920098948 100644 --- a/IAP/.classpath +++ b/IAP/.classpath @@ -1,62 +1,57 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IAP/ant-scripts/createIAPquick.xml b/IAP/ant-scripts/createIAPquick.xml index aff37609c..1f021d1b6 100755 --- a/IAP/ant-scripts/createIAPquick.xml +++ b/IAP/ant-scripts/createIAPquick.xml @@ -3,9 +3,9 @@ - + - + @@ -53,7 +53,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -121,7 +121,7 @@ - + diff --git a/IAP/src/de/ipk/ag_ba/commands/about/ActionAbout.java b/IAP/src/de/ipk/ag_ba/commands/about/ActionAbout.java index 647d4e9a9..cebf8d65c 100644 --- a/IAP/src/de/ipk/ag_ba/commands/about/ActionAbout.java +++ b/IAP/src/de/ipk/ag_ba/commands/about/ActionAbout.java @@ -142,8 +142,8 @@ public ArrayList getResultNewActionSet() { rr.add(new NavigationButton(new ActionAboutLicense("List of external library licenses"), guiSetting)); rr.add(new NavigationButton(new ActionFeedback("Send feedback mail"), guiSetting)); - rr.add(new NavigationButton(new ActionJavaFX("JavaFX Test"), guiSetting)); - rr.add(new NavigationButton(new ActionPLYVIS("PLY Visualization Tool"), guiSetting)); + // rr.add(new NavigationButton(new ActionJavaFX("JavaFX Test"), guiSetting)); + // rr.add(new NavigationButton(new ActionPLYVIS("PLY Visualization Tool"), guiSetting)); return rr; } diff --git a/IAP/src/de/ipk/ag_ba/gui/picture_gui/DataSetFileButton.java b/IAP/src/de/ipk/ag_ba/gui/picture_gui/DataSetFileButton.java index 43d678f7c..af868e539 100644 --- a/IAP/src/de/ipk/ag_ba/gui/picture_gui/DataSetFileButton.java +++ b/IAP/src/de/ipk/ag_ba/gui/picture_gui/DataSetFileButton.java @@ -1,6 +1,6 @@ package de.ipk.ag_ba.gui.picture_gui; -import iap.blocks.debug.BlShowThreeDColorHistogram; +//import iap.blocks.debug.BlShowThreeDColorHistogram; import iap.pipelines.ImageProcessorOptionsAndResults; // import ij.io.FileInfoXYZ; import ij.io.Opener; @@ -591,6 +591,7 @@ public void actionPerformed(ActionEvent e) { sn.add(debugShowSnapshot); jp.add(sn); + /* JMenu fxCube = new JMenu("Color Analysis"); fxCube.setIcon(IAPimages.getIcon("img/cube.png", 16, 16)); { @@ -639,6 +640,7 @@ public void actionPerformed(ActionEvent e) { } jp.add(fxCube); + */ if (targetTreeNode.getExperiment().getIniIoProvider() != null) { try { @@ -1209,6 +1211,7 @@ void addDefaultCommands(final JPopupMenu myPopup) { // myPopup.add(removeOneFromDatabaseCmd); // myPopup.add(removeAllFromDatabaseCmd); } + /* myPopup.add(new JSeparator()); JMenuItem shcube = new JMenuItem("Show 3-D Histogram Cube"); shcube.setIcon(new ImageIcon(IAPimages.getImage("img/cube.png").getScaledInstance(16, 16, @@ -1226,7 +1229,7 @@ void addDefaultCommands(final JPopupMenu myPopup) { ErrorMsg.addErrorMessage(e1); } }); - myPopup.add(shcube); + myPopup.add(shcube);*/ // myPopup.add(debugPipelineTest); @@ -1452,9 +1455,9 @@ public void actionPerformed(ActionEvent e) { id.getURL()); if (addClockToImages) fi = fi.io().canvas().drawClock(clockR, clockB, id, cbc, chc, ctc).getImage(); - if (viewMode == ImageViewMode.HISTOGRAM) - BlShowThreeDColorHistogram.showHistogram(fi, null, id); - else + //if (viewMode == ImageViewMode.HISTOGRAM) + // BlShowThreeDColorHistogram.showHistogram(fi, null, id); + //else fi.show(id.getSubstanceName() + " // " + pre); } } @@ -1476,9 +1479,9 @@ public void actionPerformed(ActionEvent e) { id.getLabelURL()); if (addClockToImages) fi = fi.io().canvas().drawClock(clockR, clockB, id, cbc, chc, ctc).getImage(); - if (viewMode == ImageViewMode.HISTOGRAM) - BlShowThreeDColorHistogram.showHistogram(fi, null, id); - else + //if (viewMode == ImageViewMode.HISTOGRAM) + // BlShowThreeDColorHistogram.showHistogram(fi, null, id); + //else fi.show("Ref " + id.getSubstanceName() + " // " + pre); } } @@ -1503,9 +1506,9 @@ public void actionPerformed(ActionEvent e) { is.addImage(id.getQualityAnnotation() + " / " + id.getSubstanceName() + " / " + id.getParentSample().getTimeUnit() + " " + id.getParentSample().getTime(), fi); else { - if (viewMode == ImageViewMode.HISTOGRAM) - BlShowThreeDColorHistogram.showHistogram(fi, null, id); - else + //if (viewMode == ImageViewMode.HISTOGRAM) + // BlShowThreeDColorHistogram.showHistogram(fi, null, id); + //else fi.show("Annotation " + id.getSubstanceName() + " // " + pre); } } diff --git a/IAP/src/de/ipk/ag_ba/gui/picture_gui/ImageViewMode.java b/IAP/src/de/ipk/ag_ba/gui/picture_gui/ImageViewMode.java index 85127b697..094ac6566 100644 --- a/IAP/src/de/ipk/ag_ba/gui/picture_gui/ImageViewMode.java +++ b/IAP/src/de/ipk/ag_ba/gui/picture_gui/ImageViewMode.java @@ -1,5 +1,5 @@ package de.ipk.ag_ba.gui.picture_gui; public enum ImageViewMode { - SHOW, TIMELINE, HISTOGRAM + SHOW, TIMELINE //, HISTOGRAM } diff --git a/IAP/src/de/ipk/ag_ba/gui/webstart/IAPmain.java b/IAP/src/de/ipk/ag_ba/gui/webstart/IAPmain.java index b76b512aa..308a076cc 100755 --- a/IAP/src/de/ipk/ag_ba/gui/webstart/IAPmain.java +++ b/IAP/src/de/ipk/ag_ba/gui/webstart/IAPmain.java @@ -1,747 +1,747 @@ -/******************************************************************************* - * Copyright (c) 2009 Image Analysis Group, IPK Gatersleben - *******************************************************************************/ -package de.ipk.ag_ba.gui.webstart; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.io.IOException; -import java.lang.ref.WeakReference; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.WeakHashMap; - -import javax.swing.ImageIcon; -import javax.swing.JApplet; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.ApplicationStatus; -import org.ErrorMessageProcessor; -import org.ErrorMsg; -import org.ReleaseInfo; -import org.StringManipulationTools; -import org.SystemAnalysis; -import org.SystemOptions; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.graffiti.editor.GravistoService; -import org.graffiti.editor.MainFrame; -import org.graffiti.editor.MessageType; -import org.graffiti.editor.SplashScreenInterface; -import org.graffiti.managers.pluginmgr.PluginManagerException; -import org.graffiti.options.GravistoPreferences; -import org.graffiti.plugin.io.resources.ResourceIOManager; -import org.graffiti.plugin.view.View; -import org.graffiti.session.Session; - -import application.AnimateLogoIAP; -import bsh.Interpreter; -import de.ipk.ag_ba.datasources.http_folder.NavigationImage; -import de.ipk.ag_ba.gui.IAPfeature; -import de.ipk.ag_ba.gui.images.IAPimages; -import de.ipk.ag_ba.gui.picture_gui.BackgroundThreadDispatcher; -import de.ipk.ag_ba.image.structures.Image; -import de.ipk.ag_ba.mongo.MongoDB; -import de.ipk.ag_ba.mongo.SaveAsCsvDataProcessor; -import de.ipk.ag_ba.mongo.SaveInDatabaseDataProcessor; -import de.ipk.ag_ba.plugins.AbstractIAPplugin; -import de.ipk.ag_ba.postgresql.LTftpHandler; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.helper.DBEgravistoHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.layout_control.dbe.ExperimentDataProcessingManager; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.DBEsplashScreen; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.GravistoMainHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.TextFile; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskHelper; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskStatusProviderSupportingExternalCallImpl; -import info.clearthought.layout.TableLayout; - -/** - * @author klukas - */ -public class IAPmain extends JApplet { - private static final long serialVersionUID = 1L; - - static MainFrame mainFrame1; - - private static Runnable vantedDelayedRunnable; - - // static MainFrame mainFrame2; - - public void setAppletCloseListener(ActionListener l) { - // empty - } - - public void appletDragStarted() { - final JFrame jf = (JFrame) ErrorMsg.findParentComponent(ReleaseInfo.getApplet(), JFrame.class); - if (jf != null) { - jf.setUndecorated(false); - jf.setResizable(true); - jf.setMaximizedBounds(null); - jf.setTitle("Integrated Analysis Platform"); - jf.pack(); - jf.setSize(800, 600); - } else - System.out.println("Drag detected, but frame not found."); - } - - static boolean myClassKnown = false; - - @Override - public void init() { - super.init(); - setRunMode(IAPrunMode.SWING_APPLET); - } - - public static void main(String[] args) { - main(args, null); - } - - public static void main(String[] args, String[] addons) { - long startmaintime = System.currentTimeMillis(); - for (String info : IAPmain.getMainInfoLines()) - System.out.println(info); - - setRunMode(IAPrunMode.SWING_MAIN); - - System.out.println(SystemAnalysis.getCurrentTime() + ">INFO: Initialize IAP start... (run-mode: " + getRunMode() + ")"); - - boolean animate = SystemOptions.getInstance().getBoolean("IAP", "Animated Start-Logo", true); - Runtime.Version version = Runtime.version(); - if (version.major() > 10) - animate = false; - - final ProgressWindow progressWindow; - - progressWindow = animate ? new AnimateLogoIAP() : null; - - if (progressWindow != null) - progressWindow.show(true); - - String title = SystemOptions.getInstance().getString("IAP", "window_title", - "IAP - The Integrated Analysis Platform") + ""; - - SystemOptions.getInstance().getString("IAP", "Result File Type", "png"); - SystemOptions.getInstance().getString("IAP", "Preview File Type", "png"); - SystemOptions.getInstance().getInteger("SYSTEM", "Issue GC Memory Usage Threshold Percent", 60); - SystemOptions.getInstance().getInteger("SYSTEM", "Reduce Workload Memory Usage Threshold Percent", 70); - - JFrame jf = new JFrame(title); - IAPmain iap = new IAPmain(addons, progressWindow); - jf.add("Center", iap.getContentPane()); - jf.pack(); - try { - java.awt.Image img = AbstractIAPplugin.getIAPicon().getImage(); - jf.setIconImage(img); - if (SystemAnalysis.isMacRunning()) { - Interpreter i = new Interpreter(); - i.set("img", img); - i.eval("com.apple.eawt.Application.getApplication().setDockIconImage(img)"); - } - } catch (Exception e) { - ErrorMsg.addErrorMessage(e); - } - final WeakReference fr = new WeakReference(jf); - jf.addWindowListener(new WindowListener() { - @Override - public void windowOpened(WindowEvent e) { - if (progressWindow != null) - progressWindow.hide(); - } - - @Override - public void windowIconified(WindowEvent e) { - } - - @Override - public void windowDeiconified(WindowEvent e) { - } - - @Override - public void windowDeactivated(WindowEvent e) { - } - - @Override - public void windowClosing(WindowEvent e) { - JFrame j = fr.get(); - if (j != null) { - - } - } - - @Override - public void windowClosed(WindowEvent e) { - } - - @Override - public void windowActivated(WindowEvent arg0) { - } - }); - if (startMaximized) { - // jf.setExtendedState(jf.getExtendedState() | JFrame.MAXIMIZED_BOTH); - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - jf.setBounds(0, 0, dim.width, dim.height); - } - if (startMaximized) { - // jf.setExtendedState(jf.getExtendedState() | JFrame.MAXIMIZED_BOTH); - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - jf.setBounds(0, 0, dim.width, dim.height); - jf.setVisible(true); - } else { - Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); - jf.setSize((int) (screenDim.width * 0.75), (int) (screenDim.height * 0.75)); - jf.setLocation((screenDim.width - jf.getWidth()) / 2, - (screenDim.height - jf.getHeight()) / 2); - jf.setVisible(true); - } - long endmaintime = System.currentTimeMillis(); - SystemOptions.getInstance().setInteger("IAP", "FX//Last Startup Time", (int) (endmaintime - startmaintime)); - jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - SystemOptions.getInstance().addChangeListener("IAP", "window_title", new Runnable() { - @Override - public void run() { - JFrame j = fr.get(); - if (j != null) { - String newTitle = SystemOptions.getInstance().getString("IAP", "window_title", "IAP - The Integrated Analysis Platform"); - j.setTitle(newTitle + ""); - } - } - }); - } - - public IAPmain() { - this(null, null); - } - - public IAPmain(final String[] addons, ProgressWindow progressWindow) { - if (getRunMode() == IAPrunMode.UNKNOWN) - setRunMode(IAPrunMode.SWING_APPLET); - if (getRunMode() == IAPrunMode.SWING_APPLET) - ReleaseInfo.setRunningAsApplet(this); - - if (SystemOptions.getInstance().getBoolean("IAP", "Debug - System.Exit in case of error", - IAPmain.getRunMode() == IAPrunMode.CLOUD_HOST_BATCH_MODE)) { - ErrorMsg.setCustomErrorHandler(new ErrorMessageProcessor() { - @Override - public void reportError(Exception exception) { - if (exception != null) - exception.printStackTrace(); - IAPmain.errorCheck(exception.getMessage()); - } - - @Override - public void reportError(String errorMessage) { - if (errorMessage != null) - System.err.println(errorMessage); - IAPmain.errorCheck(errorMessage); - } - }); - } - - ErrorMsg.setRethrowErrorMessages(false); - - setupLogger(); - - registerIOhandlers(); - - GravistoMainHelper.setLookAndFeel(); - - // construct and open the editor's main frame - GravistoPreferences prefs = GravistoPreferences.userNodeForPackage(IAPmain.class); - - GravistoPreferences uiPrefs = prefs.node("ui"); - uiPrefs.put("showPluginManagerMenuOptions", getOptions().getBoolean("VANTED", "debug show plugin_manager_menu_options", false) + ""); - uiPrefs.put("showPluginMenu", getOptions().getBoolean("VANTED", "debug show plugin_menu", false) + ""); - JPanel statusPanel = new JPanel(); - - mainFrame1 = new MainFrame(GravistoMainHelper.getPluginManager(), uiPrefs, statusPanel, true); - - try { - mainFrame1.setIconImage(IAPimages.getImage("img/vanted1_0.png")); - } catch (Exception e) { - e.printStackTrace(); - ErrorMsg.addErrorMessage(e); - } - - // mainFrame2 = new MainFrame(GravistoMainHelper.getNewPluginManager(), uiPrefs, statusPanel, true); - - setLayout(new TableLayout(new double[][] { { TableLayout.FILL }, { TableLayout.FILL } })); - - final BackgroundTaskStatusProviderSupportingExternalCallImpl myStatus = new BackgroundTaskStatusProviderSupportingExternalCallImpl( - "", ""); - - Thread t = new Thread() { - - @Override - public void run() { - // if (IAPmain.myClassKnown) { - // System.out.println("Reload Classes, Problems may occur"); - // ErrorMsg.addErrorMessage("Reload Classes, Problems may occur"); - // } - // IAPmain.myClassKnown = true; - // System.out.println("Class Loader: " + InstanceLoader.getCurrentLoader().getClass().getCanonicalName()); - myAppletLoad(mainFrame1, myStatus, addons, progressWindow); - // myAppletLoad(mainFrame2, myStatus); - } - }; - t.setName("Application Loader"); - t.setPriority(Thread.MIN_PRIORITY); - t.start(); - - JComponent advancedNavigation = IAPgui.getMainGUIcontent(myStatus, false, null); - add(advancedNavigation, "0,0"); - setVisible(true); - validate(); - repaint(); - - } - - private void setupLogger() { - Logger rootLogger = Logger.getRootLogger(); - if (!rootLogger.getAllAppenders().hasMoreElements()) { - rootLogger.setLevel(Level.ERROR); - rootLogger.addAppender(new ConsoleAppender(new PatternLayout("%-5p [%t]: %m%n"))); - - Logger pkgLogger = rootLogger.getLoggerRepository().getLogger("com.mongodb"); - pkgLogger.setLevel(Level.ERROR); - pkgLogger.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN))); - } - } - - private void registerIOhandlers() { - GravistoService.setProxy(); - // ResourceIOManager.registerIOHandler(LoadedVolumeHandler.getInstance()); - // ResourceIOManager.registerIOHandler(LoadedImageHandler.getInstance()); - ResourceIOManager.registerIOHandler(new LTftpHandler()); - for (MongoDB m : MongoDB.getMongos()) - ResourceIOManager.registerIOHandler(m.getHandler()); - - // IIORegistry registry = IIORegistry.getDefaultInstance(); - // registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriterSpi()); - // registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi()); - } - - public void myAppletLoad( - final MainFrame statusPanel, - final BackgroundTaskStatusProviderSupportingExternalCallImpl myStatus, - final String[] addons, ProgressWindow progressWindow) { - String stS = ""; - String stE = ""; - DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT = "IAP"; - String name = stS + DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + stE + " - " + stS + "V" + stE + "isualization and " + stS + "A" + stE - + "nalysis of " + stS + "N" + stE + "e" + stS + "t" + stE + "works
containing " + stS + "E" + stE - + "xperimental " + stS + "D" + stE + "ata"; - DBEgravistoHelper.DBE_GRAVISTO_VERSION = DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + " V" + DBEgravistoHelper.DBE_GRAVISTO_VERSION_CODE; - DBEgravistoHelper.DBE_GRAVISTO_NAME = stS + DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + stE + " - " + stS + "I" + stE - + "ntegrated " + stS + "A" + stE + "nalysis " + stS + "P" + stE + "latform
"; - DBEgravistoHelper.DBE_INFORMATIONSYSTEM_NAME = "Integrated Analysis Platform"; - - DBEgravistoHelper.DBE_INFORMATIONSYSTEM_NAME = ""; - - // AttributeHelper.setMacOSsettings(DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT); - - final JComponent result = new JPanel(); - result.setLayout(TableLayout.getLayout(TableLayout.FILL, TableLayout.FILL)); - - String s = "" - + "
   
Welcome to " - + name - + "!
" - + "" - + "   In the Help menu you find a tutorial section which quickly gives an overview on the various " - + "features of this application.
" - + "   Furthermore you will find [?] buttons throughout the system which point directly to topics of interest.
" - + "   If you experience problems or would like to suggest enhancements, feel free to use the " - + "Send feedback command in the Help menu!
 "; - - ReleaseInfo.setHelpIntroductionText(s); - - // URL config, - final SplashScreenInterface splashScreen = progressWindow != null ? progressWindow : new SplashScreenInterface() { - - private int max, val; - - @Override - public void setVisible(boolean b) { - } - - @Override - public void setValue(int value) { - this.val = value; - double progress = val / (double) max * 100d; - myStatus.setCurrentStatusValueFine(progress); - } - - @Override - public void setText(String text) { - MainFrame.showMessage(text, MessageType.PERMANENT_INFO); - if (SystemOptions.getInstance().getBoolean("IAP", "Debug-Print-Plugin-Loading-Infos", false)) - System.out.println(text); - } - - @Override - public void setMaximum(int maximum) { - this.max = maximum; - } - - @Override - public void setInitialisationFinished() { - MainFrame.showMessage("", MessageType.INFO); - } - - @Override - public int getValue() { - return val; - } - - @Override - public int getMaximum() { - return max; - } - }; - - ClassLoader cl = this.getClass().getClassLoader(); - - String path = // this.getClass().getPackage().getName() - "de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart".replace('.', '/'); - ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); - if (splashScreen instanceof DBEsplashScreen) - ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage()); - // splashScreen.setVisible(true); - - GravistoMainHelper.createApplicationSettingsFolder(splashScreen); - - splashScreen.setText("Read plugin information"); - - URL r1 = cl.getResource("plugins1.txt"); - URL r2 = cl.getResource("plugins2.txt"); - URL r3 = cl.getResource("plugins3.txt"); - URL r4 = cl.getResource("plugins4.txt"); - URL r5 = cl.getResource("pluginsIAP.txt"); - - URL rExcl = cl.getResource("plugins_exclude.txt"); - - splashScreen.setText("Read plugin information..."); - - final ArrayList locations = new ArrayList(); - try { - locations.addAll(new TextFile(r1)); - locations.addAll(new TextFile(r2)); - locations.addAll(new TextFile(r3)); - locations.addAll(new TextFile(r4)); - locations.addAll(new TextFile(r5)); - locations.add("./MultimodalDataHandling.xml"); - // locations.add("./HIVE.xml"); - - if (addons != null) - for (String p : addons) - if (p != null) - locations.add("//" + p); - - locations.remove(""); - - locations.removeIf(l -> l.contains("build.xml")); - - ArrayList locations_exclude = new ArrayList(); - locations_exclude.addAll(new TextFile(rExcl)); - - for (Iterator it = locations_exclude.iterator(); it.hasNext();) { - String remove = it.next(); - if (!locations.remove(remove)) { - if (remove.startsWith("**")) { - remove = remove.substring("**".length()); - ArrayList toRemove = new ArrayList<>(); - for (String loc : locations) { - if (loc.endsWith(remove)) - toRemove.add(loc); - } - locations.removeAll(toRemove); - } else { - // windows compatibility remove also not exact matches - for (Iterator itl = locations.iterator(); itl.hasNext();) { - String loc = itl.next(); - remove = remove.toUpperCase(); - remove = StringManipulationTools.stringReplace(remove, "./", ""); - remove = StringManipulationTools.stringReplace(remove, "\"", ""); - remove = StringManipulationTools.stringReplace(remove, "/", "\\"); - remove = StringManipulationTools.stringReplace(remove, "\\", ""); - remove = StringManipulationTools.stringReplace(remove, " ", ""); - String loc2 = loc.toUpperCase(); - loc2 = StringManipulationTools.stringReplace(loc2, "\\", ""); - loc2 = StringManipulationTools.stringReplace(loc2, " ", ""); - if (loc2.indexOf(remove) >= 0) { - locations.remove(loc); - break; - } - } - } - } - } - splashScreen.setMaximum(locations.size() - 1); - } catch (IOException e) { - ErrorMsg.addErrorMessage(e.getLocalizedMessage()); - } catch (NullPointerException npe) { - if (splashScreen != null) - splashScreen.setVisible(false); - System.err.println("Internal error: Plugin Description files could not be loaded."); - System.err.println("-- Program needs to be stopped"); - System.err.println("EXIT in 10 seconds."); - BackgroundThreadDispatcher.runInSeparateThread(() -> { - try { - Thread.sleep(10000); - } catch (Exception e) { - // - } - SystemAnalysis.exit(1); - }, "System.exit in 60 seconds"); - JOptionPane.showMessageDialog(null, "

ERROR: Plugin-Description files could not be loaded

" - + "Program execution can not continue.
" + "The application needs to be closed (and will be closed in 10 sec.).
" + - "
" + - "Create description files by executing the script createfilelist.cmd from the console (Linux/Mac)
" + - "or by executing createfilelist.bat directly from within Eclipse (works only on Windows).
" + - "These scripts are stored and available within the 'make' project." + - ""); - SystemAnalysis.exit(1); - } - - final boolean onStartup = true; // IAPoptions.getInstance().getBoolean("VANTED", "load_plugins_on_startup", false); - final boolean onDemand = false; // IAPoptions.getInstance().getBoolean("VANTED", "load_plugins_on_demand", true); - // ArrayList remove = new ArrayList(); - // ArrayList importantForEditingSettingValues = new ArrayList(); - // for (String ss : locations) { - // if (ss.endsWith("attributes\\defaults\\plugin.xml") || ss.contains("editcomponents\\defaults\\plugin.xml")) { - // remove.add(ss); - // System.out.println(ss); - // importantForEditingSettingValues.add(ss); - // } - // } - // try { - // GravistoMainHelper.loadPlugins(statusPanel.getPluginManager(), importantForEditingSettingValues, splashScreen); - // } catch (PluginManagerException pme) { - // ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); - // } - // for (String r : remove) - // locations.remove(r); - if (onStartup) { - try { - splashScreen.setText("Load plugins..."); - GravistoMainHelper.loadPlugins(locations, splashScreen); - } catch (PluginManagerException pme) { - ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); - } - } else { - vantedDelayedRunnable = new Runnable() { - @Override - public void run() { - if (onDemand) { - try { - splashScreen.setText("Load plugins..."); - GravistoMainHelper.loadPlugins(locations, splashScreen); - } catch (PluginManagerException pme) { - ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); - } - } - } - }; - } - ExperimentDataProcessingManager.addExperimentDataProcessor(new SaveInDatabaseDataProcessor()); - ExperimentDataProcessingManager.addExperimentDataProcessor(new SaveAsCsvDataProcessor()); - - splashScreen.setText("Initialize GUI..."); - if (progressWindow == null) - splashScreen.setVisible(false); - splashScreen.setInitialisationFinished(); - ErrorMsg.setAppLoadingCompleted(ApplicationStatus.PROGRAM_LOADING_FINISHED); - } - - public static void prepareVantedPlugins() { - if (vantedDelayedRunnable != null) { - vantedDelayedRunnable.run(); - vantedDelayedRunnable = null; - } - } - - public static JComponent showVANTED(boolean inline) { - - prepareVantedPlugins(); - - // inline = false; - // JFrame jf = (JFrame) ErrorMsg.findParentComponent(MainFrame.getInstance(), JFrame.class); - - // mainFrame2 - for (MainFrame jc : new MainFrame[] { mainFrame1 }) { - JFrame jf = (JFrame) ErrorMsg.findParentComponent(jc, JFrame.class); - if (jf != null && !jf.isVisible()) { - if (inline) { - MainFrame.getInstance().getViewManager().viewChanged(null); - JComponent gui = jf.getRootPane(); - return gui; - } else { - jf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - MainFrame.doCloseApplicationOnWindowClose = false; - jf.setVisible(true); - MainFrame.getInstance().getViewManager().viewChanged(null); - } - } else { - if (jf != null) { - // jf.setVisible(false); - // jf.setVisible(true); - } - } - if (jf != null) { - final JFrame jff = jf; - BackgroundTaskHelper.executeLaterOnSwingTask(50, new Runnable() { - @Override - public void run() { - jff.toFront(); - jff.requestFocusInWindow(); - Session s = MainFrame.getInstance().getActiveSession(); - if (s != null) { - View targetView = s.getActiveView(); - if (targetView != null) - MainFrame.getInstance().setActiveSession(s, targetView); - } - } - }); - } - } - return null; - } - - private static WeakHashMap cachedImages = new WeakHashMap(); - - public static synchronized NavigationImage loadIcon(String name) { - NavigationImage ni = cachedImages.get(name); - if (ni != null) - return ni; - NavigationImage res = new NavigationImage( - Image.getBufferedImageFromImage(GravistoService.loadIcon(IAPmain.class, name).getImage()), name); - cachedImages.put(name, res); - return res; - } - - public static boolean isSettingEnabled(IAPfeature feature) { - if (SystemAnalysis.isHeadless()) { - // don't change these return values !!! - // see - switch (feature) { - case REMOTE_EXECUTION: - return getOptions().getBoolean("IAP", "grid_remote_execution", true); - case TOMCAT_AUTOMATIC_HSM_BACKUP: - return getOptions().getBoolean("Watch-Service", "Automatic Copy to Archive//enabled", false) - && getOptions().getBoolean("ARCHIVE", "enabled", false); - case DELETE_CLOUD_JOBS_AND_TEMP_DATA_UPON_CLOUD_START: - return getOptions().getBoolean("IAP", "grid_delete_jobs_when_grid_node_becomes_active", false); - } - } else { - // these may be changed for interactive applet version !!! - switch (feature) { - case REMOTE_EXECUTION: - return getOptions().getBoolean("IAP", "grid_remote_execution", true); - case TOMCAT_AUTOMATIC_HSM_BACKUP: - return getOptions().getBoolean("Watch-Service", "Automatic Copy to Archive//enabled", false) - && getOptions().getBoolean("ARCHIVE", "enabled", false); - case DELETE_CLOUD_JOBS_AND_TEMP_DATA_UPON_CLOUD_START: - return getOptions().getBoolean("IAP", "grid_delete_jobs_when_grid_node_becomes_active", false); - } - } - return false; - } - - private static SystemOptions getOptions() { - return SystemOptions.getInstance(); - } - - private static IAPrunMode currentGuiMode = IAPrunMode.UNKNOWN; - - private static boolean startMaximized; - - public static IAPrunMode getRunMode() { - return currentGuiMode; - } - - public static void setRunMode(IAPrunMode currentGuiMode) { - IAPmain.currentGuiMode = currentGuiMode; - } - - public static ArrayList getMainInfoLines() { - ArrayList res = new ArrayList(); - String line = "****************************************************"; - int l = line.length(); - res.add(line); - res.add(fillLen("**", l)); - res.add(fillLen("*" + SystemOptions.getInstance().getString("IAP", "window_title", - "IAP - The Integrated Analysis Platform") + "*", l)); - res.add(fillLen("*(V" + ReleaseInfo.IAP_VERSION_STRING + ")*", l)); - res.add(fillLen("**", l)); - res.add(fillLen("* - OPEN SOURCE - *", l)); - res.add(fillLen("**", l)); - res.add(fillLen("*-- Systems Biology Cloud Computing --*", l)); - res.add(fillLen("**", l)); - res.add(fillLen("*(c) 2015-2020 Dr. C. Klukas *", l)); - res.add(fillLen("*(c) 2010-2016 Research Group Image Analysis, IPK *", l)); - res.add(fillLen("**", l)); - res.add(line); - res.add(fillLen("**", l)); - res.add(fillLenLA("* Design and main development: *", " ", l, 2)); - res.add(fillLenLA("* Dr. Christian Klukas *", " ", l, 2)); - res.add(fillLen("**", l)); - res.add(fillLenLA("* Contribution to pipeline development: *", " ", l, 2)); - res.add(fillLenLA("* Jean-Michel Pape *", " ", l, 2)); - res.add(fillLen("**", l)); - res.add(line); - return res; - } - - private static String fillLen(String string, int len) { - while (string.length() < len) { - string = string.substring(0, 1) + " " + string.substring(1); - if (string.length() < len) - string = string.substring(0, string.length() - 1) + " " + string.substring(string.length() - 1, string.length()); - } - return string; - } - - private static String fillLenLA(String string, String fill, int len, int retainLeft) { - while (string.length() < len) { - string = string.substring(0, string.length() - retainLeft) + fill + string.substring(string.length() - retainLeft, string.length()); - } - return string; - } - - public static void errorCheck(String errorMessage) { - if (errorMessage != null && errorMessage.toUpperCase().startsWith("INFO:")) - return; - boolean errClose = SystemOptions.getInstance().getBoolean("IAP", "Debug - System.Exit in case of error (" + IAPmain.getRunMode() + ")", - IAPmain.getRunMode() == IAPrunMode.CLOUD_HOST_BATCH_MODE); - int errNum = SystemOptions.getInstance().getInteger( - "IAP", "Debug - System.Exit return value in case of error", 1); - if (errClose) { - Thread.dumpStack(); - System.out.println(SystemAnalysis.getCurrentTime() - + ">INFO: System.exit because of reported error ('Settings > IAP > Debug - System.Exit in case of error' is enabled)"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // - } - SystemAnalysis.exit(errNum); - } - } - - public static void setStartMaximized(boolean startMaximized) { - IAPmain.startMaximized = startMaximized; - } -} - -// ------------------------------------------------------------------------------ -// end of file -// ------------------------------------------------------------------------------ +/******************************************************************************* + * Copyright (c) 2009 Image Analysis Group, IPK Gatersleben + *******************************************************************************/ +package de.ipk.ag_ba.gui.webstart; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionListener; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.io.IOException; +import java.lang.ref.WeakReference; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.WeakHashMap; + +import javax.swing.ImageIcon; +import javax.swing.JApplet; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import org.ApplicationStatus; +import org.ErrorMessageProcessor; +import org.ErrorMsg; +import org.ReleaseInfo; +import org.StringManipulationTools; +import org.SystemAnalysis; +import org.SystemOptions; +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.graffiti.editor.GravistoService; +import org.graffiti.editor.MainFrame; +import org.graffiti.editor.MessageType; +import org.graffiti.editor.SplashScreenInterface; +import org.graffiti.managers.pluginmgr.PluginManagerException; +import org.graffiti.options.GravistoPreferences; +import org.graffiti.plugin.io.resources.ResourceIOManager; +import org.graffiti.plugin.view.View; +import org.graffiti.session.Session; + +//import application.AnimateLogoIAP; +import bsh.Interpreter; +import de.ipk.ag_ba.datasources.http_folder.NavigationImage; +import de.ipk.ag_ba.gui.IAPfeature; +import de.ipk.ag_ba.gui.images.IAPimages; +import de.ipk.ag_ba.gui.picture_gui.BackgroundThreadDispatcher; +import de.ipk.ag_ba.image.structures.Image; +import de.ipk.ag_ba.mongo.MongoDB; +import de.ipk.ag_ba.mongo.SaveAsCsvDataProcessor; +import de.ipk.ag_ba.mongo.SaveInDatabaseDataProcessor; +import de.ipk.ag_ba.plugins.AbstractIAPplugin; +import de.ipk.ag_ba.postgresql.LTftpHandler; +import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.helper.DBEgravistoHelper; +import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.layout_control.dbe.ExperimentDataProcessingManager; +import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.DBEsplashScreen; +import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.GravistoMainHelper; +import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.TextFile; +import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskHelper; +import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskStatusProviderSupportingExternalCallImpl; +import info.clearthought.layout.TableLayout; + +/** + * @author klukas + */ +public class IAPmain extends JApplet { + private static final long serialVersionUID = 1L; + + static MainFrame mainFrame1; + + private static Runnable vantedDelayedRunnable; + + // static MainFrame mainFrame2; + + public void setAppletCloseListener(ActionListener l) { + // empty + } + + public void appletDragStarted() { + final JFrame jf = (JFrame) ErrorMsg.findParentComponent(ReleaseInfo.getApplet(), JFrame.class); + if (jf != null) { + jf.setUndecorated(false); + jf.setResizable(true); + jf.setMaximizedBounds(null); + jf.setTitle("Integrated Analysis Platform"); + jf.pack(); + jf.setSize(800, 600); + } else + System.out.println("Drag detected, but frame not found."); + } + + static boolean myClassKnown = false; + + @Override + public void init() { + super.init(); + setRunMode(IAPrunMode.SWING_APPLET); + } + + public static void main(String[] args) { + main(args, null); + } + + public static void main(String[] args, String[] addons) { + long startmaintime = System.currentTimeMillis(); + for (String info : IAPmain.getMainInfoLines()) + System.out.println(info); + + setRunMode(IAPrunMode.SWING_MAIN); + + System.out.println(SystemAnalysis.getCurrentTime() + ">INFO: Initialize IAP start... (run-mode: " + getRunMode() + ")"); + + boolean animate = SystemOptions.getInstance().getBoolean("IAP", "Animated Start-Logo", true); + // Runtime.Version version = Runtime.version(); + // if (version.major() > 10) + animate = false; + + final ProgressWindow progressWindow; + + progressWindow = null; // animate ? new AnimateLogoIAP() : null; + + if (progressWindow != null) + progressWindow.show(true); + + String title = SystemOptions.getInstance().getString("IAP", "window_title", + "IAP - The Integrated Analysis Platform") + ""; + + SystemOptions.getInstance().getString("IAP", "Result File Type", "png"); + SystemOptions.getInstance().getString("IAP", "Preview File Type", "png"); + SystemOptions.getInstance().getInteger("SYSTEM", "Issue GC Memory Usage Threshold Percent", 60); + SystemOptions.getInstance().getInteger("SYSTEM", "Reduce Workload Memory Usage Threshold Percent", 70); + + JFrame jf = new JFrame(title); + IAPmain iap = new IAPmain(addons, progressWindow); + jf.add("Center", iap.getContentPane()); + jf.pack(); + try { + java.awt.Image img = AbstractIAPplugin.getIAPicon().getImage(); + jf.setIconImage(img); + if (SystemAnalysis.isMacRunning()) { + Interpreter i = new Interpreter(); + i.set("img", img); + i.eval("com.apple.eawt.Application.getApplication().setDockIconImage(img)"); + } + } catch (Exception e) { + ErrorMsg.addErrorMessage(e); + } + final WeakReference fr = new WeakReference(jf); + jf.addWindowListener(new WindowListener() { + @Override + public void windowOpened(WindowEvent e) { + if (progressWindow != null) + progressWindow.hide(); + } + + @Override + public void windowIconified(WindowEvent e) { + } + + @Override + public void windowDeiconified(WindowEvent e) { + } + + @Override + public void windowDeactivated(WindowEvent e) { + } + + @Override + public void windowClosing(WindowEvent e) { + JFrame j = fr.get(); + if (j != null) { + + } + } + + @Override + public void windowClosed(WindowEvent e) { + } + + @Override + public void windowActivated(WindowEvent arg0) { + } + }); + if (startMaximized) { + // jf.setExtendedState(jf.getExtendedState() | JFrame.MAXIMIZED_BOTH); + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + jf.setBounds(0, 0, dim.width, dim.height); + } + if (startMaximized) { + // jf.setExtendedState(jf.getExtendedState() | JFrame.MAXIMIZED_BOTH); + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + jf.setBounds(0, 0, dim.width, dim.height); + jf.setVisible(true); + } else { + Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); + jf.setSize((int) (screenDim.width * 0.75), (int) (screenDim.height * 0.75)); + jf.setLocation((screenDim.width - jf.getWidth()) / 2, + (screenDim.height - jf.getHeight()) / 2); + jf.setVisible(true); + } + long endmaintime = System.currentTimeMillis(); + SystemOptions.getInstance().setInteger("IAP", "FX//Last Startup Time", (int) (endmaintime - startmaintime)); + jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + SystemOptions.getInstance().addChangeListener("IAP", "window_title", new Runnable() { + @Override + public void run() { + JFrame j = fr.get(); + if (j != null) { + String newTitle = SystemOptions.getInstance().getString("IAP", "window_title", "IAP - The Integrated Analysis Platform"); + j.setTitle(newTitle + ""); + } + } + }); + } + + public IAPmain() { + this(null, null); + } + + public IAPmain(final String[] addons, ProgressWindow progressWindow) { + if (getRunMode() == IAPrunMode.UNKNOWN) + setRunMode(IAPrunMode.SWING_APPLET); + if (getRunMode() == IAPrunMode.SWING_APPLET) + ReleaseInfo.setRunningAsApplet(this); + + if (SystemOptions.getInstance().getBoolean("IAP", "Debug - System.Exit in case of error", + IAPmain.getRunMode() == IAPrunMode.CLOUD_HOST_BATCH_MODE)) { + ErrorMsg.setCustomErrorHandler(new ErrorMessageProcessor() { + @Override + public void reportError(Exception exception) { + if (exception != null) + exception.printStackTrace(); + IAPmain.errorCheck(exception.getMessage()); + } + + @Override + public void reportError(String errorMessage) { + if (errorMessage != null) + System.err.println(errorMessage); + IAPmain.errorCheck(errorMessage); + } + }); + } + + ErrorMsg.setRethrowErrorMessages(false); + + setupLogger(); + + registerIOhandlers(); + + GravistoMainHelper.setLookAndFeel(); + + // construct and open the editor's main frame + GravistoPreferences prefs = GravistoPreferences.userNodeForPackage(IAPmain.class); + + GravistoPreferences uiPrefs = prefs.node("ui"); + uiPrefs.put("showPluginManagerMenuOptions", getOptions().getBoolean("VANTED", "debug show plugin_manager_menu_options", false) + ""); + uiPrefs.put("showPluginMenu", getOptions().getBoolean("VANTED", "debug show plugin_menu", false) + ""); + JPanel statusPanel = new JPanel(); + + mainFrame1 = new MainFrame(GravistoMainHelper.getPluginManager(), uiPrefs, statusPanel, true); + + try { + mainFrame1.setIconImage(IAPimages.getImage("img/vanted1_0.png")); + } catch (Exception e) { + e.printStackTrace(); + ErrorMsg.addErrorMessage(e); + } + + // mainFrame2 = new MainFrame(GravistoMainHelper.getNewPluginManager(), uiPrefs, statusPanel, true); + + setLayout(new TableLayout(new double[][] { { TableLayout.FILL }, { TableLayout.FILL } })); + + final BackgroundTaskStatusProviderSupportingExternalCallImpl myStatus = new BackgroundTaskStatusProviderSupportingExternalCallImpl( + "", ""); + + Thread t = new Thread() { + + @Override + public void run() { + // if (IAPmain.myClassKnown) { + // System.out.println("Reload Classes, Problems may occur"); + // ErrorMsg.addErrorMessage("Reload Classes, Problems may occur"); + // } + // IAPmain.myClassKnown = true; + // System.out.println("Class Loader: " + InstanceLoader.getCurrentLoader().getClass().getCanonicalName()); + myAppletLoad(mainFrame1, myStatus, addons, progressWindow); + // myAppletLoad(mainFrame2, myStatus); + } + }; + t.setName("Application Loader"); + t.setPriority(Thread.MIN_PRIORITY); + t.start(); + + JComponent advancedNavigation = IAPgui.getMainGUIcontent(myStatus, false, null); + add(advancedNavigation, "0,0"); + setVisible(true); + validate(); + repaint(); + + } + + private void setupLogger() { + Logger rootLogger = Logger.getRootLogger(); + if (!rootLogger.getAllAppenders().hasMoreElements()) { + rootLogger.setLevel(Level.ERROR); + rootLogger.addAppender(new ConsoleAppender(new PatternLayout("%-5p [%t]: %m%n"))); + + Logger pkgLogger = rootLogger.getLoggerRepository().getLogger("com.mongodb"); + pkgLogger.setLevel(Level.ERROR); + pkgLogger.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN))); + } + } + + private void registerIOhandlers() { + GravistoService.setProxy(); + // ResourceIOManager.registerIOHandler(LoadedVolumeHandler.getInstance()); + // ResourceIOManager.registerIOHandler(LoadedImageHandler.getInstance()); + ResourceIOManager.registerIOHandler(new LTftpHandler()); + for (MongoDB m : MongoDB.getMongos()) + ResourceIOManager.registerIOHandler(m.getHandler()); + + // IIORegistry registry = IIORegistry.getDefaultInstance(); + // registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageWriterSpi()); + // registry.registerServiceProvider(new com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi()); + } + + public void myAppletLoad( + final MainFrame statusPanel, + final BackgroundTaskStatusProviderSupportingExternalCallImpl myStatus, + final String[] addons, ProgressWindow progressWindow) { + String stS = ""; + String stE = ""; + DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT = "IAP"; + String name = stS + DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + stE + " - " + stS + "V" + stE + "isualization and " + stS + "A" + stE + + "nalysis of " + stS + "N" + stE + "e" + stS + "t" + stE + "works
containing " + stS + "E" + stE + + "xperimental " + stS + "D" + stE + "ata"; + DBEgravistoHelper.DBE_GRAVISTO_VERSION = DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + " V" + DBEgravistoHelper.DBE_GRAVISTO_VERSION_CODE; + DBEgravistoHelper.DBE_GRAVISTO_NAME = stS + DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT + stE + " - " + stS + "I" + stE + + "ntegrated " + stS + "A" + stE + "nalysis " + stS + "P" + stE + "latform
"; + DBEgravistoHelper.DBE_INFORMATIONSYSTEM_NAME = "Integrated Analysis Platform"; + + DBEgravistoHelper.DBE_INFORMATIONSYSTEM_NAME = ""; + + // AttributeHelper.setMacOSsettings(DBEgravistoHelper.DBE_GRAVISTO_NAME_SHORT); + + final JComponent result = new JPanel(); + result.setLayout(TableLayout.getLayout(TableLayout.FILL, TableLayout.FILL)); + + String s = "" + + "
   
Welcome to " + + name + + "!
" + + "" + + "   In the Help menu you find a tutorial section which quickly gives an overview on the various " + + "features of this application.
" + + "   Furthermore you will find [?] buttons throughout the system which point directly to topics of interest.
" + + "   If you experience problems or would like to suggest enhancements, feel free to use the " + + "Send feedback command in the Help menu!
 "; + + ReleaseInfo.setHelpIntroductionText(s); + + // URL config, + final SplashScreenInterface splashScreen = progressWindow != null ? progressWindow : new SplashScreenInterface() { + + private int max, val; + + @Override + public void setVisible(boolean b) { + } + + @Override + public void setValue(int value) { + this.val = value; + double progress = val / (double) max * 100d; + myStatus.setCurrentStatusValueFine(progress); + } + + @Override + public void setText(String text) { + MainFrame.showMessage(text, MessageType.PERMANENT_INFO); + if (SystemOptions.getInstance().getBoolean("IAP", "Debug-Print-Plugin-Loading-Infos", false)) + System.out.println(text); + } + + @Override + public void setMaximum(int maximum) { + this.max = maximum; + } + + @Override + public void setInitialisationFinished() { + MainFrame.showMessage("", MessageType.INFO); + } + + @Override + public int getValue() { + return val; + } + + @Override + public int getMaximum() { + return max; + } + }; + + ClassLoader cl = this.getClass().getClassLoader(); + + String path = // this.getClass().getPackage().getName() + "de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart".replace('.', '/'); + ImageIcon icon = new ImageIcon(cl.getResource(path + "/ipklogo16x16_5.png")); + if (splashScreen instanceof DBEsplashScreen) + ((DBEsplashScreen) splashScreen).setIconImage(icon.getImage()); + // splashScreen.setVisible(true); + + GravistoMainHelper.createApplicationSettingsFolder(splashScreen); + + splashScreen.setText("Read plugin information"); + + URL r1 = cl.getResource("plugins1.txt"); + URL r2 = cl.getResource("plugins2.txt"); + URL r3 = cl.getResource("plugins3.txt"); + URL r4 = cl.getResource("plugins4.txt"); + URL r5 = cl.getResource("pluginsIAP.txt"); + + URL rExcl = cl.getResource("plugins_exclude.txt"); + + splashScreen.setText("Read plugin information..."); + + final ArrayList locations = new ArrayList(); + try { + locations.addAll(new TextFile(r1)); + locations.addAll(new TextFile(r2)); + locations.addAll(new TextFile(r3)); + locations.addAll(new TextFile(r4)); + locations.addAll(new TextFile(r5)); + locations.add("./MultimodalDataHandling.xml"); + // locations.add("./HIVE.xml"); + + if (addons != null) + for (String p : addons) + if (p != null) + locations.add("//" + p); + + locations.remove(""); + + locations.removeIf(l -> l.contains("build.xml")); + + ArrayList locations_exclude = new ArrayList(); + locations_exclude.addAll(new TextFile(rExcl)); + + for (Iterator it = locations_exclude.iterator(); it.hasNext();) { + String remove = it.next(); + if (!locations.remove(remove)) { + if (remove.startsWith("**")) { + remove = remove.substring("**".length()); + ArrayList toRemove = new ArrayList<>(); + for (String loc : locations) { + if (loc.endsWith(remove)) + toRemove.add(loc); + } + locations.removeAll(toRemove); + } else { + // windows compatibility remove also not exact matches + for (Iterator itl = locations.iterator(); itl.hasNext();) { + String loc = itl.next(); + remove = remove.toUpperCase(); + remove = StringManipulationTools.stringReplace(remove, "./", ""); + remove = StringManipulationTools.stringReplace(remove, "\"", ""); + remove = StringManipulationTools.stringReplace(remove, "/", "\\"); + remove = StringManipulationTools.stringReplace(remove, "\\", ""); + remove = StringManipulationTools.stringReplace(remove, " ", ""); + String loc2 = loc.toUpperCase(); + loc2 = StringManipulationTools.stringReplace(loc2, "\\", ""); + loc2 = StringManipulationTools.stringReplace(loc2, " ", ""); + if (loc2.indexOf(remove) >= 0) { + locations.remove(loc); + break; + } + } + } + } + } + splashScreen.setMaximum(locations.size() - 1); + } catch (IOException e) { + ErrorMsg.addErrorMessage(e.getLocalizedMessage()); + } catch (NullPointerException npe) { + if (splashScreen != null) + splashScreen.setVisible(false); + System.err.println("Internal error: Plugin Description files could not be loaded."); + System.err.println("-- Program needs to be stopped"); + System.err.println("EXIT in 10 seconds."); + BackgroundThreadDispatcher.runInSeparateThread(() -> { + try { + Thread.sleep(10000); + } catch (Exception e) { + // + } + SystemAnalysis.exit(1); + }, "System.exit in 60 seconds"); + JOptionPane.showMessageDialog(null, "

ERROR: Plugin-Description files could not be loaded

" + + "Program execution can not continue.
" + "The application needs to be closed (and will be closed in 10 sec.).
" + + "
" + + "Create description files by executing the script createfilelist.cmd from the console (Linux/Mac)
" + + "or by executing createfilelist.bat directly from within Eclipse (works only on Windows).
" + + "These scripts are stored and available within the 'make' project." + + ""); + SystemAnalysis.exit(1); + } + + final boolean onStartup = true; // IAPoptions.getInstance().getBoolean("VANTED", "load_plugins_on_startup", false); + final boolean onDemand = false; // IAPoptions.getInstance().getBoolean("VANTED", "load_plugins_on_demand", true); + // ArrayList remove = new ArrayList(); + // ArrayList importantForEditingSettingValues = new ArrayList(); + // for (String ss : locations) { + // if (ss.endsWith("attributes\\defaults\\plugin.xml") || ss.contains("editcomponents\\defaults\\plugin.xml")) { + // remove.add(ss); + // System.out.println(ss); + // importantForEditingSettingValues.add(ss); + // } + // } + // try { + // GravistoMainHelper.loadPlugins(statusPanel.getPluginManager(), importantForEditingSettingValues, splashScreen); + // } catch (PluginManagerException pme) { + // ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); + // } + // for (String r : remove) + // locations.remove(r); + if (onStartup) { + try { + splashScreen.setText("Load plugins..."); + GravistoMainHelper.loadPlugins(locations, splashScreen); + } catch (PluginManagerException pme) { + ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); + } + } else { + vantedDelayedRunnable = new Runnable() { + @Override + public void run() { + if (onDemand) { + try { + splashScreen.setText("Load plugins..."); + GravistoMainHelper.loadPlugins(locations, splashScreen); + } catch (PluginManagerException pme) { + ErrorMsg.addErrorMessage(pme.getLocalizedMessage()); + } + } + } + }; + } + ExperimentDataProcessingManager.addExperimentDataProcessor(new SaveInDatabaseDataProcessor()); + ExperimentDataProcessingManager.addExperimentDataProcessor(new SaveAsCsvDataProcessor()); + + splashScreen.setText("Initialize GUI..."); + if (progressWindow == null) + splashScreen.setVisible(false); + splashScreen.setInitialisationFinished(); + ErrorMsg.setAppLoadingCompleted(ApplicationStatus.PROGRAM_LOADING_FINISHED); + } + + public static void prepareVantedPlugins() { + if (vantedDelayedRunnable != null) { + vantedDelayedRunnable.run(); + vantedDelayedRunnable = null; + } + } + + public static JComponent showVANTED(boolean inline) { + + prepareVantedPlugins(); + + // inline = false; + // JFrame jf = (JFrame) ErrorMsg.findParentComponent(MainFrame.getInstance(), JFrame.class); + + // mainFrame2 + for (MainFrame jc : new MainFrame[] { mainFrame1 }) { + JFrame jf = (JFrame) ErrorMsg.findParentComponent(jc, JFrame.class); + if (jf != null && !jf.isVisible()) { + if (inline) { + MainFrame.getInstance().getViewManager().viewChanged(null); + JComponent gui = jf.getRootPane(); + return gui; + } else { + jf.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + MainFrame.doCloseApplicationOnWindowClose = false; + jf.setVisible(true); + MainFrame.getInstance().getViewManager().viewChanged(null); + } + } else { + if (jf != null) { + // jf.setVisible(false); + // jf.setVisible(true); + } + } + if (jf != null) { + final JFrame jff = jf; + BackgroundTaskHelper.executeLaterOnSwingTask(50, new Runnable() { + @Override + public void run() { + jff.toFront(); + jff.requestFocusInWindow(); + Session s = MainFrame.getInstance().getActiveSession(); + if (s != null) { + View targetView = s.getActiveView(); + if (targetView != null) + MainFrame.getInstance().setActiveSession(s, targetView); + } + } + }); + } + } + return null; + } + + private static WeakHashMap cachedImages = new WeakHashMap(); + + public static synchronized NavigationImage loadIcon(String name) { + NavigationImage ni = cachedImages.get(name); + if (ni != null) + return ni; + NavigationImage res = new NavigationImage( + Image.getBufferedImageFromImage(GravistoService.loadIcon(IAPmain.class, name).getImage()), name); + cachedImages.put(name, res); + return res; + } + + public static boolean isSettingEnabled(IAPfeature feature) { + if (SystemAnalysis.isHeadless()) { + // don't change these return values !!! + // see + switch (feature) { + case REMOTE_EXECUTION: + return getOptions().getBoolean("IAP", "grid_remote_execution", true); + case TOMCAT_AUTOMATIC_HSM_BACKUP: + return getOptions().getBoolean("Watch-Service", "Automatic Copy to Archive//enabled", false) + && getOptions().getBoolean("ARCHIVE", "enabled", false); + case DELETE_CLOUD_JOBS_AND_TEMP_DATA_UPON_CLOUD_START: + return getOptions().getBoolean("IAP", "grid_delete_jobs_when_grid_node_becomes_active", false); + } + } else { + // these may be changed for interactive applet version !!! + switch (feature) { + case REMOTE_EXECUTION: + return getOptions().getBoolean("IAP", "grid_remote_execution", true); + case TOMCAT_AUTOMATIC_HSM_BACKUP: + return getOptions().getBoolean("Watch-Service", "Automatic Copy to Archive//enabled", false) + && getOptions().getBoolean("ARCHIVE", "enabled", false); + case DELETE_CLOUD_JOBS_AND_TEMP_DATA_UPON_CLOUD_START: + return getOptions().getBoolean("IAP", "grid_delete_jobs_when_grid_node_becomes_active", false); + } + } + return false; + } + + private static SystemOptions getOptions() { + return SystemOptions.getInstance(); + } + + private static IAPrunMode currentGuiMode = IAPrunMode.UNKNOWN; + + private static boolean startMaximized; + + public static IAPrunMode getRunMode() { + return currentGuiMode; + } + + public static void setRunMode(IAPrunMode currentGuiMode) { + IAPmain.currentGuiMode = currentGuiMode; + } + + public static ArrayList getMainInfoLines() { + ArrayList res = new ArrayList(); + String line = "****************************************************"; + int l = line.length(); + res.add(line); + res.add(fillLen("**", l)); + res.add(fillLen("*" + SystemOptions.getInstance().getString("IAP", "window_title", + "IAP - The Integrated Analysis Platform") + "*", l)); + res.add(fillLen("*(V" + ReleaseInfo.IAP_VERSION_STRING + ")*", l)); + res.add(fillLen("**", l)); + res.add(fillLen("* - OPEN SOURCE - *", l)); + res.add(fillLen("**", l)); + res.add(fillLen("*-- Systems Biology Cloud Computing --*", l)); + res.add(fillLen("**", l)); + res.add(fillLen("*(c) 2015-2020 Dr. C. Klukas *", l)); + res.add(fillLen("*(c) 2010-2016 Research Group Image Analysis, IPK *", l)); + res.add(fillLen("**", l)); + res.add(line); + res.add(fillLen("**", l)); + res.add(fillLenLA("* Design and main development: *", " ", l, 2)); + res.add(fillLenLA("* Dr. Christian Klukas *", " ", l, 2)); + res.add(fillLen("**", l)); + res.add(fillLenLA("* Contribution to pipeline development: *", " ", l, 2)); + res.add(fillLenLA("* Jean-Michel Pape *", " ", l, 2)); + res.add(fillLen("**", l)); + res.add(line); + return res; + } + + private static String fillLen(String string, int len) { + while (string.length() < len) { + string = string.substring(0, 1) + " " + string.substring(1); + if (string.length() < len) + string = string.substring(0, string.length() - 1) + " " + string.substring(string.length() - 1, string.length()); + } + return string; + } + + private static String fillLenLA(String string, String fill, int len, int retainLeft) { + while (string.length() < len) { + string = string.substring(0, string.length() - retainLeft) + fill + string.substring(string.length() - retainLeft, string.length()); + } + return string; + } + + public static void errorCheck(String errorMessage) { + if (errorMessage != null && errorMessage.toUpperCase().startsWith("INFO:")) + return; + boolean errClose = SystemOptions.getInstance().getBoolean("IAP", "Debug - System.Exit in case of error (" + IAPmain.getRunMode() + ")", + IAPmain.getRunMode() == IAPrunMode.CLOUD_HOST_BATCH_MODE); + int errNum = SystemOptions.getInstance().getInteger( + "IAP", "Debug - System.Exit return value in case of error", 1); + if (errClose) { + Thread.dumpStack(); + System.out.println(SystemAnalysis.getCurrentTime() + + ">INFO: System.exit because of reported error ('Settings > IAP > Debug - System.Exit in case of error' is enabled)"); + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + // + } + SystemAnalysis.exit(errNum); + } + } + + public static void setStartMaximized(boolean startMaximized) { + IAPmain.startMaximized = startMaximized; + } +} + +// ------------------------------------------------------------------------------ +// end of file +// ------------------------------------------------------------------------------ diff --git a/IAP/src/de/ipk/ag_ba/plugins/pipelines/PluginIAPanalyisTemplates.java b/IAP/src/de/ipk/ag_ba/plugins/pipelines/PluginIAPanalyisTemplates.java index 05b346a3e..0668ccae8 100644 --- a/IAP/src/de/ipk/ag_ba/plugins/pipelines/PluginIAPanalyisTemplates.java +++ b/IAP/src/de/ipk/ag_ba/plugins/pipelines/PluginIAPanalyisTemplates.java @@ -24,7 +24,7 @@ import iap.blocks.debug.BlFilterImagesByTopOrSide; import iap.blocks.debug.BlRunExternalShellCommand; import iap.blocks.debug.BlShowIntermediateImages; -import iap.blocks.debug.BlShowThreeDColorHistogram; +//import iap.blocks.debug.BlShowThreeDColorHistogram; import iap.blocks.extraction.BlCalcAreas; import iap.blocks.extraction.BlCalcCOG; import iap.blocks.extraction.BlCalcColorHistograms; @@ -178,7 +178,7 @@ public ImageAnalysisBlock[] getImageAnalysisBlocks() { new BlFlowerDetectionAndFeatureExtraction(), new BlCalcTextureFeatures(), new BlCalcColorfeatures(), - new BlShowThreeDColorHistogram(), + //new BlShowThreeDColorHistogram(), new BlFilterImagesByDate(), new BlFilterImagesByCondition(), new BlShowIntermediateImages(), diff --git a/IPK-Plugins/.classpath b/IPK-Plugins/.classpath index cd3a2400b..8c0c2ea9f 100644 --- a/IPK-Plugins/.classpath +++ b/IPK-Plugins/.classpath @@ -1,62 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/IPK-Plugins/build/classes/plugins4.txt b/IPK-Plugins/build/classes/plugins4.txt index 6677c3fbd..14e7065d3 100644 --- a/IPK-Plugins/build/classes/plugins4.txt +++ b/IPK-Plugins/build/classes/plugins4.txt @@ -1,90 +1,90 @@ -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\addons\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\davidtest\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\graph_generation\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\hamming_distance\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\inverse_graph\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\lines_as_substances\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\naive_pattern_finder\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\ratioview\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\algorithms\som\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\chart_colors\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\chart_settings\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\cluster_colors\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\compound_image\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\font_label_color\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\font_label_settings\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\font_label_style\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\font_settings\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\kegg\kegg_type\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\label_alignment\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\url_attribute\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\editcomponents\xml_attribute\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\dbe\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\editing_tools\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\editing_tools\url_attribute_context_commands\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\enhanced_attribute_editors\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\fast_view\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\info_dialog\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\info_dialog_cluster_analysis\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\info_dialog_dbe\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\ipk_graffitiview\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\kegg_bar\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\layout_control\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\layout_control\pluginClusterTabs.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\rotate\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\set_background_color\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\startlayout\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\gui\zoomfit\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\exporters\biopax\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\exporters\metatool\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\exporters\xwg_wilma\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\biopax\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\kegg_xml\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\kgml\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\pajek\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\petri_ina_pnt\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\text_list\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\ios\importers\xgmml\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\apply_from_graph\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\circle\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\connected_components\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\copy_pattern_layout\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\expand_no_overlapp\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\expand_reduce_space\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\fd_edge_routing\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\fish_eye\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\graph_to_origin_mover\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\grid\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\grid_placement\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\no_overlapp_as_tim\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\pattern_springembedder\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\pattern_springembedder_no_cache\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\radial_tree\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\random\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\resize_and_grid_layout\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\rt_tree\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\shortest_path\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\springembedder_1\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\swig_cola\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\tree_jung\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\layouters\tree_simple\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\add_attributes\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\graph_cleanup\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\invert_selection\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\ko_tree\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\label_editing\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\link_visualization_legend\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\pathway_references\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\print\printer\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\process_alternative_ids\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\scripting\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\de\ipk_gatersleben\ag_nw\graffiti\plugins\misc\svg_exporter\plugin.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureAnalysisCommands.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureClustering.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureDataMapping.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureExtendedFileFormatSupport.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureHierarchies.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureMacroRecording.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureMetaCrop.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureSBGN.xml -C:\Users\Christian Klukas\git\IAP\IPK-Plugins\build\classes\vanted_feature\FeatureStatistics.xml +./vanted_feature/FeatureMacroRecording.xml +./vanted_feature/FeatureClustering.xml +./vanted_feature/FeatureStatistics.xml +./vanted_feature/FeatureExtendedFileFormatSupport.xml +./vanted_feature/FeatureDataMapping.xml +./vanted_feature/FeatureMetaCrop.xml +./vanted_feature/FeatureHierarchies.xml +./vanted_feature/FeatureSBGN.xml +./vanted_feature/FeatureAnalysisCommands.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/font_label_settings/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/chart_settings/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/kegg/kegg_type/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/font_label_style/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/xml_attribute/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/compound_image/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/chart_colors/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/font_settings/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/url_attribute/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/cluster_colors/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/label_alignment/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/font_label_color/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/addons/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/print/printer/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/label_editing/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/add_attributes/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/scripting/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/svg_exporter/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/invert_selection/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/graph_cleanup/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/process_alternative_ids/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/ko_tree/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/pathway_references/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/link_visualization_legend/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/graph_to_origin_mover/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/connected_components/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/radial_tree/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/tree_jung/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/no_overlapp_as_tim/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/copy_pattern_layout/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder_no_cache/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/shortest_path/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/apply_from_graph/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/rt_tree/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/tree_simple/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/grid_placement/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/swig_cola/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/resize_and_grid_layout/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/fd_edge_routing/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_reduce_space/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/circle/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/fish_eye/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_no_overlapp/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/random/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/springembedder_1/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/grid/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/editing_tools/url_attribute_context_commands/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/editing_tools/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/enhanced_attribute_editors/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/zoomfit/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/pluginClusterTabs.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/fast_view/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/dbe/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/set_background_color/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/ipk_graffitiview/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_dbe/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_cluster_analysis/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/startlayout/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/kegg_bar/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/rotate/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/petri_ina_pnt/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/pajek/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/kgml/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/text_list/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/xgmml/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/biopax/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/kegg_xml/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/metatool/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/biopax/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/xwg_wilma/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/naive_pattern_finder/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/ratioview/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/davidtest/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/lines_as_substances/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/som/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/inverse_graph/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/hamming_distance/plugin.xml +./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/graph_generation/plugin.xml diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Compartment_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Compartment_Writer.java deleted file mode 100644 index 0553f85f0..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Compartment_Writer.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * This class writes a Compartment of a model - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.Model; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLCompartment; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLCompartmentHelper; - -public class SBML_Compartment_Writer extends SBML_SBase_Writer { - - /** - * Adds a compartment and its attributes to the model. - * - * @param model the compartments will be added to this model - * @param g contains the values for the export - * @param headline indicates where the information should be read from - * @param internHeadline the intern representation of headline - */ - public void addCompartment(Model model, Graph g, String internHeadline, SBMLCompartmentHelper compartmentHelperObject) { - SBMLCompartment compartmentHelper = compartmentHelperObject.addCompartment(g, internHeadline); - Compartment compartment = model.createCompartment(); - addSBaseAttributes(compartment, g, internHeadline); - - if (compartmentHelper.isSetID()) { - String id = compartmentHelper.getID(); - if (Compartment.isValidId(id, compartment.getLevel(), compartment.getVersion())) { - compartment.setId(compartmentHelper.getID()); - } - } - if (compartmentHelper.isSetName()) { - compartment.setName(compartmentHelper.getName()); - } - if (compartmentHelper.isSetSpatialDimensions()) { - compartment.setSpatialDimensions(compartmentHelper.getSpatialDimensions()); - } - if (compartmentHelper.isSetSize()) { - compartment.setSize(compartmentHelper.getSize()); - } - if (compartmentHelper.isSetUnits()) { - compartment.setUnits(compartmentHelper.getUnits()); - } - if (compartmentHelper.isSetConstant()) { - compartment.setConstant(compartmentHelper.getConstant()); - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Constraint_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Constraint_Writer.java deleted file mode 100644 index 454444e9d..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Constraint_Writer.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This class sets the Constraint attributes - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.text.parser.ParseException; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLConstraint; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLConstraintHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Constraint_Writer extends SBML_SBase_Writer { - - /** - * Adds a constraint and its variables to the model - * - * @param g - * contains the values for the export - * @param model - * the constraint will be added to this model - * @param headline - * indicates where the information should be read from - * @param niceID - * intern representation of headline - */ - public void addConstraint(Graph g, Model model, String internHeadline, - SBMLConstraintHelper constraintHelperObject) { - SBMLConstraint constraintHelper = constraintHelperObject.addConstraint( - g, internHeadline); - Constraint constraint = model.createConstraint(); - addSBaseAttributes(constraint, g, internHeadline); - if (constraintHelper.isSetMessage()) { - String message = constraintHelper.getMessage(); - if (null != message) { - message = "

" - + message + "

"; - XMLNode xmlMessage = new XMLNode(message); - constraint.setMessage(message); - } - } - if (constraintHelper.isSetFunction()) { - String constraintFormula = constraintHelper.getFunction(); - if (!SBML_Constants.EMPTY.equals(constraintFormula)) { - try { - constraint.setMath(ASTNode.parseFormula(constraintFormula)); - } catch (ParseException e) { - e.printStackTrace(); - } - } - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Event_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Event_Writer.java deleted file mode 100644 index f9a5457e7..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Event_Writer.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * This class sets the attributes of Events - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Delay; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Priority; -import org.sbml.jsbml.Trigger; -import org.sbml.jsbml.text.parser.ParseException; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLEventAssignmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLEventHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Event_Writer extends SBML_SBase_Writer { - - /** - * Adds an event to the model - * - * @param g - * contains the data - * @param model - * the data will be added to this model - * @param headline - * indicates where the information will be written from - * @param internHeadline - * intern representation of headline - */ - public void addEvent(Graph g, Model model, String internHeadline) { - SBMLEventHelper eventHelper = new SBMLEventHelper(g, internHeadline); - Event event = model.createEvent(); - addSBaseAttributes(event, g, internHeadline); - if (eventHelper.isSetID()) { - String id = eventHelper.getID(); - if (Event.isValidId(id, event.getLevel(), event.getVersion())) { - event.setId(eventHelper.getID()); - } - } - if (eventHelper.isSetName()) { - event.setName(eventHelper.getName()); - } - if (eventHelper.isSetUseValuesFromTriggerTime()) { - event.setUseValuesFromTriggerTime(eventHelper - .getUseValuesFromTriggerTime()); - } - - // Trigger must be set - Trigger trigger = event.createTrigger(); - if (eventHelper.isSetTriggerFunction()) { - try { - trigger.setMath(ASTNode.parseFormula(eventHelper - .getTriggerFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - if (eventHelper.isSetInitialValue()) { - trigger.setInitialValue(eventHelper.getInitialValue()); - } - if (eventHelper.isSetPersistent()) { - trigger.setPersistent(eventHelper.getPersistent()); - } - - if (eventHelper.isSetPriorityFunction()) { - Priority priority = event.createPriority(); - try { - priority.setMath(ASTNode.parseFormula(eventHelper - .getPriorityFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - addSBaseAttributes(priority, g, internHeadline); - } - - if (eventHelper.isSetDelayFunction()) { - Delay delay = event.createDelay(); - try { - delay.setMath(ASTNode.parseFormula(eventHelper - .getDelayFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - addSBaseAttributes(delay, g, internHeadline); - } - - String eventAssignmentVariable = ""; - int eventAssignmentCount = 1; - // while(event.getNumEventAssignments() <= eventAssignmentCount){ - while (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString())) { - - SBMLEventAssignmentHelper eaHelper = eventHelper - .addEventAssignment(g, internHeadline, eventAssignmentCount); - if (eaHelper.isSetVariable()) { - eventAssignmentVariable = eaHelper.getVariable(); - } - if ((!SBML_Constants.EMPTY.equals(eventAssignmentVariable)) - && null != eventAssignmentVariable) { - EventAssignment eventAssignment = event.createEventAssignment(); - addSBaseAttributes(eventAssignment, g, internHeadline); - - eventAssignment.setVariable(eventAssignmentVariable); - if (eaHelper.isSetFunction()) { - try { - eventAssignment.setMath(ASTNode.parseFormula(eaHelper - .getFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - } - ++eventAssignmentCount; - eventAssignmentVariable = ""; - } - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_FunctionDefinition_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_FunctionDefinition_Writer.java deleted file mode 100644 index 7d7a55f2d..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_FunctionDefinition_Writer.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * This class writes function definitions - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.Model; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLFunctionDefinition; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLFunctionDefinitionHelper; - -public class SBML_FunctionDefinition_Writer extends SBML_SBase_Writer { - - /** - * Adds a function definition and its variables to the model - * - * @param model the function definition will be added to this model - * @param g contains the values for the export - * @param headline indicates where the information should be read from - */ - public void addFunctionDefinition(Model model, Graph g, String internHeadline, SBMLFunctionDefinitionHelper - functionDefinitionHelperObject) { - SBMLFunctionDefinition functionDefinitionHelper = functionDefinitionHelperObject.addFunctionDefinition(g, internHeadline); - FunctionDefinition functionDefinition = model.createFunctionDefinition(); - addSBaseAttributes(functionDefinition, g, internHeadline); - if (functionDefinitionHelper.isSetID()) { - functionDefinition.setId(functionDefinitionHelper.getID()); - } - if (functionDefinitionHelper.isSetName()) { - functionDefinition.setName(functionDefinitionHelper.getName()); - } - if (functionDefinitionHelper.isSetFunction()) { - functionDefinition.setMath(functionDefinitionHelper.getFunction()); - } - /* - * if(functionDefinitionHelper.isSetFunction()){ - * String formel = (String)getAttribute(g, internHeadline, SBML_Constants.FUNCTION_DEFINITION_FUNCTION); - * try{ - * ASTNode h = ASTNode.parseFormula(formel);//"lambda("+formel+")"); - * //ASTNode math = (ASTNode)getAttribute(g, niceID, headline+ATT+"ASTNode Math"); - * //functionDefinition.setMath(math); - * functionDefinition.setMath(h); - * }catch(ParseException e){e.printStackTrace();} - * } - */ - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_InitialAssignment_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_InitialAssignment_Writer.java deleted file mode 100644 index c9eba7ec7..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_InitialAssignment_Writer.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This class set the InitialAssignment attributes - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.text.parser.ParseException; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLInitialAssignment; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLInitialAssignmentHelper; - -public class SBML_InitialAssignment_Writer extends SBML_SBase_Writer { - - /** - * Adds an initial assignment and its variables to the model - * - * @param g contains the values for the export - * @param model the initial assignments will be added to this model - * @param headline indicates where the information should be read from - * @param internHeadline intern representation of headline - */ - public void addInitialAssignment(Graph g, Model model, String internHeadline, SBMLInitialAssignmentHelper iaHelperObject) { - InitialAssignment initialAssignment = model.createInitialAssignment(); - SBMLInitialAssignment iaHelper = iaHelperObject.addInitialAssignment(g, internHeadline); - addSBaseAttributes(initialAssignment, g, internHeadline); - if (iaHelper.isSetSymbol()) { - initialAssignment.setVariable(iaHelper.getSymbol()); - } - if (iaHelper.isSetFunction()) { - try { - initialAssignment.setMath(ASTNode.parseFormula(iaHelper.getFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Model_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Model_Writer.java deleted file mode 100644 index 3999992d9..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Model_Writer.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This class sets the attributes of Model - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Model; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Model_Writer extends SBML_SBase_Writer { - - /** - * Add attributes to the model. The ID has already been set when it exists - * - * @param model - * has the attribute which will be set - * @param g - * contains the values for the export - */ - public void addModel(Model model, Graph g) { - addSBaseAttributes(model, g); - // String id = (String)getAttribute(g, SBML_Constants.SBML_MODEL, - // "SBML Model"+ATT+"ID"); - // if(id.length()>0) - // model.setId(id); - - /* - * if(AttributeHelper.hasAttribute(annotationNode, "SBML", - * "modelannotation")){ Annotation anno = - * (Annotation)AttributeHelper.getAttributeValue(annotationNode, "SBML", - * "modelannotation", SBML_Constants.EMPTY, null); - * model.setAnnotation(anno); } - */ - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NAME)) { - String name = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NAME); - if (name.length() > 0) - model.setName(name); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_ID)) { - String id = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_ID); - if (id.length() > 0) - model.setId(id); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.SUBSTANCE_UNITS)) { - String substranceUnits = (String) getAttribute(g, - SBML_Constants.SBML, SBML_Constants.SUBSTANCE_UNITS); - if (substranceUnits.length() > 0) - model.setSubstanceUnits(substranceUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.TIME_UNITS)) { - String timeUnits = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.TIME_UNITS); - if (timeUnits.length() > 0) - model.setTimeUnits(timeUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.VOLUME_UNITS)) { - String volumeUnits = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.VOLUME_UNITS); - if (volumeUnits.length() > 0) - model.setVolumeUnits(volumeUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.AREA_UNITS)) { - String areaUnits = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.AREA_UNITS); - if (areaUnits.length() > 0) - model.setAreaUnits(areaUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.LENGTH_UNITS)) { - String lengthUnits = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.LENGTH_UNITS); - if (lengthUnits.length() > 0) - model.setLengthUnits(lengthUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.EXTENT_UNITS)) { - String extentUnits = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.EXTENT_UNITS); - if (extentUnits.length() > 0) - model.setExtentUnits(extentUnits); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.CONVERSION_FACTOR)) { - String conversionFactor = (String) getAttribute(g, - SBML_Constants.SBML, SBML_Constants.CONVERSION_FACTOR); - if (conversionFactor.length() > 0) - model.setConversionFactor(conversionFactor); - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Parameter_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Parameter_Writer.java deleted file mode 100644 index 25aaa7802..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Parameter_Writer.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * This class set the Parameter attributes - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Parameter; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLParameter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLParameterHelper; - -public class SBML_Parameter_Writer extends SBML_SBase_Writer { - - /** - * Adds a parameter and its variables to the model - * - * @param g contains the values for the export - * @param model the parameters will be added to this model - * @param headline indicates where the information should be read from - * @param interHeadline intern representation of headline - */ - public void addParameter(Graph g, Model model, String interHeadline, SBMLParameterHelper parameterHelperObject) { - SBMLParameter parameterHelper = parameterHelperObject.addParameter(g, interHeadline); - Parameter parameter = model.createParameter(); - addSBaseAttributes(parameter, g, interHeadline); - if (parameterHelper.isSetID()) { - String id = parameterHelper.getID(); - if (Parameter.isValidId(id, parameter.getLevel(), parameter.getVersion())) { - parameter.setId(parameterHelper.getID()); - } - - } - if (parameterHelper.isSetName()) { - parameter.setName(parameterHelper.getName()); - } - if (parameterHelper.isSetValue()) { - parameter.setValue(parameterHelper.getValue()); - } - if (parameterHelper.isSetUnits()) { - parameter.setUnits(parameterHelper.getUnits()); - } - if (parameterHelper.isSetConstant()) { - parameter.setConstant(parameterHelper.getConstant()); - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Reaction_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Reaction_Writer.java deleted file mode 100644 index 7187a3e8a..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Reaction_Writer.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * This class sets the attributes of Reactions - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.regex.Pattern; - -import org.AttributeHelper; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.text.parser.ParseException; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.KineticLawHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLLocalParameter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLReactionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Reaction_Writer extends SBML_SBase_Writer { - - int localParameterCount = 1; - - /** - * This method adds the reactions to a model - * - * @param g - * contains the required data - * @param model - * the data will be added to this model - */ - public void addReactions(Graph g, Model model) { - Iterator itNodes = g.getNodesIterator(); - SBMLReactionHelper reactionHelper = new SBMLReactionHelper(g); - while (itNodes.hasNext()) { - Node node = (Node) itNodes.next(); - if (AttributeHelper.getSBMLrole(node).equals("reaction")) { - Reaction reaction = model.createReaction(); - - addSBaseAttributes(reaction, node); - - if (reactionHelper.isSetID(node)) { - String id = reactionHelper.getID(node); - if (Reaction.isValidId(id, reaction.getLevel(), - reaction.getVersion())) { - reaction.setId(reactionHelper.getID(node)); - } - } - if (reactionHelper.isSetName(node)) { - reaction.setName(reactionHelper.getName(node)); - } - if (reactionHelper.isSetReversible(node)) { - System.out.println("Reaction: " + reactionHelper.getID(node)); - reaction.setReversible(reactionHelper.getReversible(node)); - } - if (reactionHelper.isSetFast(node)) { - reaction.setFast(reactionHelper.getFast(node)); - } - if (reactionHelper.isSetCompartment(node)) { - reaction.setCompartment(reactionHelper.getCompartment(node)); - } - - Iterator itEdges = node.getEdgesIterator(); - while (itEdges.hasNext()) { - Edge edge = itEdges.next(); - if (AttributeHelper.getSBMLrole(edge).equals("reactant")) { - - SpeciesReference reactant = new SpeciesReference( - model.getLevel(), model.getVersion()); - if (reactionHelper.isSetConstant(edge)) { - reactant.setConstant(reactionHelper - .getConstant(edge)); - } - if (reactionHelper.isSetStoichiometry(edge)) { - reactant.setStoichiometry(Double - .parseDouble(reactionHelper - .getStoichiometry(edge))); - } - if (reactionHelper.isSetID(edge)) { - reactant.setId(reactionHelper.getID(edge)); - } - if (reactionHelper.isSetName(edge)) { - reactant.setName(reactionHelper.getName(edge)); - } - if (reactionHelper.isSetSpecies(edge)) { - reactant.setSpecies(reactionHelper.getSpecies(edge)); - } - - reaction.addReactant(reactant); - addSBaseAttributes(reactant, edge, SBML_Constants.SBML); - } - - if (AttributeHelper.getSBMLrole(edge).equals("product")) { - - SpeciesReference product = new SpeciesReference( - model.getLevel(), model.getVersion()); - if (reactionHelper.isSetConstant(edge)) { - product.setConstant(reactionHelper - .getConstant(edge)); - } - if (reactionHelper.isSetStoichiometry(edge)) { - product.setStoichiometry(Double - .parseDouble(reactionHelper - .getStoichiometry(edge))); - } - if (reactionHelper.isSetID(edge)) { - product.setId(reactionHelper.getID(edge)); - } - if (reactionHelper.isSetName(edge)) { - product.setName(reactionHelper.getName(edge)); - } - if (reactionHelper.isSetSpecies(edge)) { - String[] list = reactionHelper.getSpecies(edge) - .split(Pattern.quote("/")); - product.setSpecies(list[0].trim()); - } - - reaction.addProduct(product); - - addSBaseAttributes(product, edge, SBML_Constants.SBML); - // productCount++; - } - - if (AttributeHelper.getSBMLrole(edge).equals("modifier")) { - ModifierSpeciesReference modifier = new ModifierSpeciesReference( - model.getLevel(), model.getVersion()); - - if (reactionHelper.isSetID(edge)) { - modifier.setId(reactionHelper.getID(edge)); - } - if (reactionHelper.isSetName(edge)) { - modifier.setName(reactionHelper.getName(edge)); - } - if (reactionHelper.isSetSpecies(edge)) { - String[] list = reactionHelper.getSpecies(edge) - .split(Pattern.quote("/")); - modifier.setSpecies(list[0].trim()); - } - - reaction.addModifier(modifier); - - addSBaseAttributes(modifier, edge, SBML_Constants.SBML); - } - } - - ArrayList kineticLawList = headlineHelper(node, - SBML_Constants.SBML_KINETIC_LAW); - // kineticLawList has size 1 or 0 - if (kineticLawList.size() > 0) { - KineticLaw kineticLaw = reaction.createKineticLaw(); - KineticLawHelper kineticLawHelper = new KineticLawHelper(g, reactionHelper.getReactionClones()); - addSBaseAttributes(kineticLaw, node); - - if (kineticLawHelper.isSetFunction(node)) { - try { - kineticLaw.setMath(ASTNode - .parseFormula(kineticLawHelper - .getFunction(node))); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - while (AttributeHelper.hasAttribute( - node, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_ID) - .toString())) { - - LocalParameter localParameter = null; - SBMLLocalParameter localParameterHelper = kineticLawHelper - .addLocalParameter(g, localParameterCount); - if (localParameterHelper.isSetID(node)) { - localParameter = new LocalParameter( - localParameterHelper.getID(node), - model.getLevel(), model.getVersion()); - } else { - localParameter = new LocalParameter(); - } - - if (localParameterHelper.isSetName(node)) { - localParameter.setName(localParameterHelper - .getName(node)); - } - if (localParameterHelper.isSetValue(node)) { - localParameter.setValue(localParameterHelper - .getValue(node)); - } - if (localParameterHelper.isSetUnits(node)) { - localParameter.setUnits(localParameterHelper - .getUnits(node)); - } - kineticLaw.addLocalParameter(localParameter); - addSBaseAttributes(localParameter, node); - - localParameterCount++; - } - localParameterCount = 1; - } - } - } - } - // } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Rule_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Rule_Writer.java deleted file mode 100644 index ab511bf18..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Rule_Writer.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * This class sets the attributes of Rule - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.text.parser.ParseException; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLAlgebraicRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLAssignmentRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLRateRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLRuleHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Rule_Writer extends SBML_SBase_Writer { - - /** - * Controls the processing of rules - * - * @param g - * contains the values for the export - * @param model - * the rules will be added to this model - */ - public void addRules(Graph g, Model model) { - SBMLRuleHelper ruleHelperObject = new SBMLRuleHelper(); - ArrayList assignmentRules = headlineHelper(g, - SBML_Constants.SBML_ASSIGNMENT_RULE); - if (assignmentRules.size() > 0) { - Iterator itAssignmentRules = assignmentRules.iterator(); - int assignmentRuleCount = 1; - while (itAssignmentRules.hasNext()) { - String assignmentRuleHeadline = (String) itAssignmentRules - .next(); - // String presentedHeadline = "SBML Assignment Rule " + - // assignmentRuleCount; - addAssignmentRule(g, model, assignmentRuleHeadline, - ruleHelperObject); - assignmentRuleCount++; - } - } - - ArrayList algebraicRules = headlineHelper(g, - SBML_Constants.SBML_ALGEBRAIC_RULE); - if (algebraicRules.size() > 0) { - Iterator itAlgebraicRules = algebraicRules.iterator(); - int algebraicRuleCount = 1; - while (itAlgebraicRules.hasNext()) { - String algebraicRuleHeadline = (String) itAlgebraicRules.next(); - // String presentedHeadline = "SBML Algebraic Rule " + - // algebraicRuleCount; - addAlgebraicRule(g, model, algebraicRuleHeadline, - ruleHelperObject); - algebraicRuleCount++; - } - } - - ArrayList rateRules = headlineHelper(g, - SBML_Constants.SBML_RATE_RULE); - if (rateRules.size() > 0) { - Iterator itRateRules = rateRules.iterator(); - int rateRuleCount = 1; - while (itRateRules.hasNext()) { - String rateRuleHeadline = (String) itRateRules.next(); - // String presentedHeadline = "SBML Rate Rule " + rateRuleCount; - addRateRules(g, model, rateRuleHeadline, ruleHelperObject); - rateRuleCount++; - } - } - } - - /** - * Adds an algebraic rule and its variables to the model - * - * @param g - * contains the values for the export - * @param model - * the algebraic rule will be added to this model - * @param headline - * indicates where the information should be read from - * @niceID intern representation of headline - */ - private void addAlgebraicRule(Graph g, Model model, String internHeadline, - SBMLRuleHelper ruleHelperObject) { - SBMLAlgebraicRule algebraicRuleHelper = ruleHelperObject - .addAlgebraicRule(g, internHeadline); - AlgebraicRule algebraicRule = (AlgebraicRule) model - .createAlgebraicRule(); - addSBaseAttributes(algebraicRule, g, internHeadline); - if (algebraicRuleHelper.isSetFunction()) { - try { - algebraicRule.setMath(ASTNode.parseFormula(algebraicRuleHelper - .getFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - /* - * if(AttributeHelper.hasAttribute(annotationNode, "SBML", - * "algebraic"+algebraicRuleCount+"annotation")){ Annotation anno = - * (Annotation)AttributeHelper.getAttributeValue(annotationNode, "SBML", - * "algebraic"+algebraicRuleCount+"annotation", SBML_Constants.EMPTY, - * null); algebraicRule.setAnnotation(anno); } - */ - } - - /** - * Adds an assignment rule and its variables to the model - * - * @param g - * contains the values for the export - * @param model - * the assignment rule will be added to this model - * @param interHeadline - * indicates where the information should be read from - * @niceID intern representation of headline - */ - private void addAssignmentRule(Graph g, Model model, String internHeadline, - SBMLRuleHelper ruleHelperObject) { - SBMLAssignmentRule assignmentRuleHelper = ruleHelperObject - .addAssignmentRule(g, internHeadline); - AssignmentRule assignmentRule = (AssignmentRule) model - .createAssignmentRule(); - addSBaseAttributes(assignmentRule, g, internHeadline); - if (assignmentRuleHelper.isSetVariable()) { - assignmentRule.setVariable(assignmentRuleHelper.getVariable()); - } - if (assignmentRuleHelper.isSetFunction()) { - try { - assignmentRule.setMath(ASTNode - .parseFormula(assignmentRuleHelper.getFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - /* - * if(AttributeHelper.hasAttribute(annotationNode, "SBML", - * "assignmet"+assignmentRuleCount+"annotation")){ Annotation anno = - * (Annotation)AttributeHelper.getAttributeValue(annotationNode, "SBML", - * "assignmet"+assignmentRuleCount+"annotation", SBML_Constants.EMPTY, - * null); assignmentRule.setAnnotation(anno); } - */ - - } - - /** - * Adds a rate rule and its variables to the model - * - * @param g - * contains the values for the export - * @param model - * the rate rule will be added to this model - * @param internHeadline - * indicates where the information should be read from - * @niceID intern representation of headline - */ - private void addRateRules(Graph g, Model model, String internHeadline, - SBMLRuleHelper ruleHelperObject) { - SBMLRateRule rateRuleHelper = ruleHelperObject.addRateRule(g, - internHeadline); - RateRule rateRule = (RateRule) model.createRateRule(); - addSBaseAttributes(rateRule, g, internHeadline); - if (rateRuleHelper.isSetVariable()) { - rateRule.setVariable(rateRuleHelper.getVariable()); - } - if (rateRuleHelper.isSetFunction()) { - try { - rateRule.setMath(ASTNode.parseFormula(rateRuleHelper - .getFunction())); - } catch (ParseException e) { - e.printStackTrace(); - } - } - - /* - * if(AttributeHelper.hasAttribute(annotationNode, "SBML", - * "rate"+RateRuleCount+"annotation")){ Annotation anno = - * (Annotation)AttributeHelper.getAttributeValue(annotationNode, "SBML", - * "rate"+RateRuleCount+"annotation", SBML_Constants.EMPTY, null); - * rateRule.setAnnotation(anno); } - */ - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBML_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBML_Writer.java deleted file mode 100644 index fb7af8e72..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBML_Writer.java +++ /dev/null @@ -1,321 +0,0 @@ -/** - * This class sets the attributes of SBML - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.swing.JOptionPane; -import javax.xml.stream.XMLStreamException; - -import org.AttributeHelper; -import org.ErrorMsg; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLErrorLog; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SBMLWriter; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLCompartmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLConstraintHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLFunctionDefinitionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLInitialAssignmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLParameterHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLSpeciesHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_XML_ReaderWriterPlugin; -@SuppressWarnings("unused") -public class SBML_SBML_Writer extends SBML_SBase_Writer { - private Model _model; - - /** - * Processes the reading in an model - * - * @param stream - * the data will be written into this stream - * @param g - * contains the data - */ - public void addSBML(OutputStream stream, Graph g) { - SBML_Constants.init(); - PrintStream ps = null; - try { - ps = new PrintStream(stream, false, "iso-8859-1"); - } catch (UnsupportedEncodingException e1) { - e1.printStackTrace(); - } - SBMLWriter writer = new SBMLWriter(); - int level = 0; - int version = 1; - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.LEVEL)) { - level = (Integer) AttributeHelper.getAttributeValue(g, - SBML_Constants.SBML, SBML_Constants.LEVEL, null, null); - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.VERSION)) { - version = (Integer) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.VERSION); - } - // L3V1 is the current spec - if (level < 3) { - level = 3; - version = 1; - } - SBMLDocument doc = new SBMLDocument(level, version); - addSBaseAttributes(doc, g); - - _model = null; - - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_ID)) { - _model = doc.createModel((String) getAttribute(g, - SBML_Constants.SBML, SBML_Constants.MODEL_ID)); - } else { - _model = doc.createModel(); - } - - SBML_Model_Writer writeModel = new SBML_Model_Writer(); - writeModel.addModel(_model, g); - - ArrayList functionDefinitions = headlineHelper(g, - SBML_Constants.SBML_FUNCTION_DEFINITION); - if (functionDefinitions.size() > 0) { - Iterator itFunctionDefinitions = functionDefinitions - .iterator(); - int i = 1; - SBMLFunctionDefinitionHelper functionDefinitionHelper = new SBMLFunctionDefinitionHelper(); - while (itFunctionDefinitions.hasNext()) { - String functionDefinitionHeadline = (String) itFunctionDefinitions - .next(); - SBML_FunctionDefinition_Writer writeFunctionDefinition = new SBML_FunctionDefinition_Writer(); - writeFunctionDefinition.addFunctionDefinition(_model, g, - functionDefinitionHeadline, functionDefinitionHelper); - i++; - } - } - - ArrayList unitDefinitions = headlineHelper(g, - SBML_Constants.SBML_UNIT_DEFINITION); - if (unitDefinitions.size() > 0) { - Iterator itUnitDefinition = unitDefinitions.iterator(); - int i = 1; - while (itUnitDefinition.hasNext()) { - String unitDefinition = (String) itUnitDefinition.next(); - // String presentedHeadline = "SBML Unit Definition "+i; - // SBML_Constants.put(ATT+unitDefinition, presentedHeadline); - SBML_UnitDefinition_Writer writeUnitDefinition = new SBML_UnitDefinition_Writer(); - writeUnitDefinition.addUnitDefinition(_model, g, unitDefinition); - i++; - } - } - - ArrayList compartments = headlineHelper(g, - SBML_Constants.SBML_COMPARTMENT); - if (compartments.size() > 0) { - SBMLCompartmentHelper compartmentHelperObject = new SBMLCompartmentHelper(); - Iterator itCompartments = compartments.iterator(); - int i = 1; - while (itCompartments.hasNext()) { - String compartmentHeadline = itCompartments.next(); - SBML_Compartment_Writer writeCompartmentDefinition = new SBML_Compartment_Writer(); - writeCompartmentDefinition.addCompartment(_model, g, - compartmentHeadline, compartmentHelperObject); - i++; - } - } - - SBML_Species_Writer writeSpeciesDefinition = new SBML_Species_Writer(); - writeSpeciesDefinition.addSpecies(_model, g); - createExtendedLayoutModel(g); - writeSpeciesDefinition.addSpeciesGlyph(_model, g); - - ArrayList parameters = headlineHelper(g, - SBML_Constants.SBML_PARAMETER); - if (parameters.size() > 0) { - Iterator itParameters = parameters.iterator(); - int i = 1; - SBMLParameterHelper parameterHelperObject = new SBMLParameterHelper(); - while (itParameters.hasNext()) { - String parameterHeadline = itParameters.next(); - // String presentedHeadline = "SBML Parameter "+i; - SBML_Parameter_Writer writeParameter = new SBML_Parameter_Writer(); - writeParameter.addParameter(g, _model, parameterHeadline, - parameterHelperObject); - i++; - } - } - - ArrayList initialAssignments = headlineHelper(g, - SBML_Constants.SBML_INITIAL_ASSIGNMENT); - if (initialAssignments.size() > 0) { - Iterator itInitialAssignments = initialAssignments - .iterator(); - int i = 1; - SBMLInitialAssignmentHelper iaHelperObject = new SBMLInitialAssignmentHelper(); - while (itInitialAssignments.hasNext()) { - String initialAssignmentHeadline = (String) itInitialAssignments - .next(); - // String presentedHeadline = "SBML Initial Assignment " + i; - SBML_InitialAssignment_Writer writeInitialAssignment = new SBML_InitialAssignment_Writer(); - writeInitialAssignment.addInitialAssignment(g, _model, - initialAssignmentHeadline, iaHelperObject); - i++; - } - } - - SBML_Rule_Writer writeRuleDefinition = new SBML_Rule_Writer(); - writeRuleDefinition.addRules(g, _model); - - ArrayList constraints = headlineHelper(g, - SBML_Constants.SBML_CONSTRAINT); - if (constraints.size() > 0) { - Iterator itConstraints = constraints.iterator(); - SBMLConstraintHelper constraintHelperObject = new SBMLConstraintHelper(); - int i = 1; - while (itConstraints.hasNext()) { - String constraintHeadline = (String) itConstraints.next(); - // String presentedHeadline = "SBML Constraint " + i; - SBML_Constraint_Writer writeConstraint = new SBML_Constraint_Writer(); - writeConstraint.addConstraint(g, _model, constraintHeadline, - constraintHelperObject); - i++; - } - } - - SBML_Reaction_Writer writeReaction = new SBML_Reaction_Writer(); - writeReaction.addReactions(g, _model); - - ArrayList events = headlineHelper(g, SBML_Constants.SBML_EVENT); - if (events.size() > 0) { - Iterator itEvents = events.iterator(); - int i = 1; - while (itEvents.hasNext()) { - String eventHeadline = (String) itEvents.next(); - // String presentedHeadline = "SBML Event " + i; - SBML_Event_Writer writeEvent = new SBML_Event_Writer(); - writeEvent.addEvent(g, _model, eventHeadline); - i++; - } - } - - int eventCount = _model.getNumEvents(); - - boolean write = false; - try { - URL url = new URL("http://sbml.org/Facilities/Validator/"); - URLConnection connection = url.openConnection(); - InputStream is = null; - try { - is = connection.getInputStream(); - } catch (Exception e) { - ErrorMsg.addErrorMessage("No internet connection. Can not validate document."); - /* - * JOptionPane .showMessageDialog(null, - * "No internet connection. Can not validate document before saving." - * ); - */ - write = true; - } - if (null != is) { - int validate = 1; - if (!SBML_XML_ReaderWriterPlugin.isTestintMode) - validate = JOptionPane - .showConfirmDialog( - null, - "Do you want to validate the SBML file against the Level 3 Version 1 specification?"); - if (validate == 0) { - - doc.setConsistencyChecks( - CHECK_CATEGORY.GENERAL_CONSISTENCY, true); - doc.setConsistencyChecks( - CHECK_CATEGORY.IDENTIFIER_CONSISTENCY, true); - doc.setConsistencyChecks(CHECK_CATEGORY.UNITS_CONSISTENCY, - true); - doc.setConsistencyChecks(CHECK_CATEGORY.MATHML_CONSISTENCY, - true); - doc.setConsistencyChecks(CHECK_CATEGORY.MODELING_PRACTICE, - true); - doc.setConsistencyChecks(CHECK_CATEGORY.SBO_CONSISTENCY, - true); - doc.setConsistencyChecks( - CHECK_CATEGORY.OVERDETERMINED_MODEL, true); - - int numberOfErrors = doc.checkConsistency(); - if (numberOfErrors > 0) { - SBMLErrorLog errorLog = doc.getListOfErrors(); - for (int i = 0; i < numberOfErrors; i++) { - ErrorMsg.addErrorMessage(errorLog.getError(i)); - } - } - if (numberOfErrors > 0) { - int load = JOptionPane - .showConfirmDialog(null, - "The online validator detected mistakes in the file. Save anyway?"); - if (load == 0) { - write = true; - } - } - if (numberOfErrors == 0) { - write = true; - } - } - if (validate == 1) { - write = true; - } - } else { - write = true; - JOptionPane.showMessageDialog(null, - "Online validation not possible."); - } - } catch (Exception e) { - e.printStackTrace(); - } - - try { - writer.write(doc, ps); - } catch (XMLStreamException e) { - e.printStackTrace(); - } catch (SBMLException e) { - e.printStackTrace(); - } - ps.flush(); - ps.close(); - } - - private void createExtendedLayoutModel(Graph g) { - ExtendedLayoutModel extendedLayoutModel = new ExtendedLayoutModel(_model); - _model.addExtension(SBMLHelper.SBML_LAYOUT_EXTENSION_NAMESPACE, extendedLayoutModel); - SBMLSpeciesHelper speciesHelper = new SBMLSpeciesHelper(g); - List nodeList = speciesHelper.getSpeciesNodes(); - Iterator itSpeicesNodes = nodeList.iterator(); - Set allLayoutIDs = new HashSet(); - while (itSpeicesNodes.hasNext()) { - Node speicesNode = itSpeicesNodes.next(); - String layoutID = (String) AttributeHelper.getAttributeValue(speicesNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, null, null); - if (allLayoutIDs.add(layoutID)) { - Layout layout = extendedLayoutModel.createLayout(); - layout.setId(layoutID); - System.out.println("in create extended layout model: " + layoutID); - } - } - - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBase_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBase_Writer.java deleted file mode 100644 index 9ed394f17..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_SBase_Writer.java +++ /dev/null @@ -1,1229 +0,0 @@ -/** - * This class writes the SBase Attributes - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.AttributeHelper; -import org.graffiti.attributes.Attribute; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.GraphElement; -import org.graffiti.graph.Node; -import org.sbml.jsbml.AbstractSBase; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Delay; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Priority; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_SBase_Writer { - - /** - * Saves the number of the current Unit - */ - int sBaseAttributeUnitCount = 1; - - /** - * Saves the number of the current EventAssignment - */ - int SBaseAttributeFromEACount = 1; - - /** - * Saves the number of the current local parameter - */ - private int localParameterCount = 1; - - /** - * To make the code shorter - */ - public final String ATT = AttributeHelper.attributeSeparator; - - private HashMap nameSpaceCollector = new HashMap(); - - /** - * This Method helps processing the attributes with a variable headline - * inherited by SBase - * - * @param sbase - * has the attribute which will be set - * @param g - * contains the values for the export - * @param headline - * indicates where the information should be read from - * @param intern - * representation of headline - */ - public void addSBaseAttributes(AbstractSBase sbase, Graph g, String niceID) { - if (sbase instanceof org.sbml.jsbml.Priority) { - addSBaseAttributeFromPriority((Priority) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.Delay) { - addSBaseAttributeFromDelay((Delay) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.EventAssignment) { - addSBaseAttributeFromEventAssignment((EventAssignment) sbase, g, - niceID); - } - if (sbase instanceof org.sbml.jsbml.Unit) { - addSBaseAttributeFromUnit((Unit) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.FunctionDefinition) { - addSBaseAttributesFromFunctionDefinition( - (FunctionDefinition) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.UnitDefinition) { - addSBaseAttributesFromUnitDefinition((UnitDefinition) sbase, g, - niceID); - } - if (sbase instanceof org.sbml.jsbml.Compartment) { - addSBaseAttributesFromCompartment((Compartment) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.Parameter) { - addSBaseAttributesFromParameter((Parameter) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.InitialAssignment) { - addSBaseAttributesFromInitialAssignmnet((InitialAssignment) sbase, - g, niceID); - } - if (sbase instanceof org.sbml.jsbml.Rule) { - addSBaseAttributesFromRule((Rule) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.Constraint) { - addSBaseAttributesFromConstraint((Constraint) sbase, g, niceID); - } - if (sbase instanceof org.sbml.jsbml.Event) { - addSBaseAttributesFromEvent((Event) sbase, g, niceID); - } - } - - public void addSBaseAttributes(AbstractSBase sbase, Graph g) { - if (sbase instanceof SBMLDocument) { - // Processing the name spaces - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.NAMESPACE)) { - String globalNamespaces = (String) getAttribute(g, - SBML_Constants.SBML, SBML_Constants.NAMESPACE); - if (!SBML_Constants.EMPTY.equals(globalNamespaces)) { - String[] globalNamespacesArr = globalNamespaces.split(" "); - String namespaceName; - String prefix = SBML_Constants.EMPTY; - String uri; - String postfix = null; - for (int i = 0; i < globalNamespacesArr.length; i++) { - if (globalNamespacesArr[i].contains(":")) { - prefix = globalNamespacesArr[i].split(":")[0]; - if (prefix.equals("xmlns")) { - prefix = SBML_Constants.EMPTY; - } - postfix = globalNamespacesArr[i].split(":")[1]; - } - if (null == postfix) { - postfix = globalNamespacesArr[i]; - } - uri = globalNamespacesArr[i].split("=")[1].replaceAll( - "\"", SBML_Constants.EMPTY); - namespaceName = globalNamespacesArr[i].split("=")[0]; - ((SBMLDocument) sbase).addNamespace(namespaceName, - prefix, uri); - nameSpaceCollector.put(prefix + ":" + namespaceName, - uri); - } - } - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_NOTES)) { - XMLNode notes = (XMLNode) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_NOTES); - if (!SBML_Constants.EMPTY.equals(notes)) { - sbase.setNotes(notes); - } - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_META_ID)) { - String metaid = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_META_ID); - if (!SBML_Constants.EMPTY.equals(metaid)) { - sbase.setMetaId(metaid); - } - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_SBOTERM)) { - String sboterm = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_SBOTERM); - if (!SBML_Constants.EMPTY.equals(sboterm)) { - sbase.setSBOTerm(sboterm); - } - } - addAnnotation(sbase, g, null, SBML_Constants.SBML, - SBML_Constants.SBML_ANNOTATION, - SBML_Constants.SBML_NON_RDF_ANNOTATION, true); - } - if (sbase instanceof Model) { - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NOTES)) { - XMLNode notes = (XMLNode) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NOTES); - if (!SBML_Constants.EMPTY.equals(notes)) { - sbase.setNotes(notes); - } - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_META_ID)) { - String metaid = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_META_ID); - if (!SBML_Constants.EMPTY.equals(metaid)) { - sbase.setMetaId(metaid); - } - } - if (AttributeHelper.hasAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_SBOTERM)) { - String sboterm = (String) getAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_SBOTERM); - if (!SBML_Constants.EMPTY.equals(sboterm)) { - sbase.setSBOTerm(sboterm); - } - } - addAnnotation(sbase, g, null, SBML_Constants.SBML, - SBML_Constants.MODEL_ANNOTATION, - SBML_Constants.MODEL_NON_RDF_ANNOTATION, true); - } - } - - // gIsSet is true if g is used und not element - private void addAnnotation(AbstractSBase sbase, Graph g, - GraphElement element, String headline, String rdfAttributeName, - String nonRDFAttributeName, Boolean gIsSet) { - if (gIsSet) { - Annotation annotation = null; - if (AttributeHelper.hasAttribute(g, headline, rdfAttributeName)) { - annotation = (Annotation) getAttribute(g, headline, - rdfAttributeName); - - } - if (AttributeHelper.hasAttribute(g, headline, nonRDFAttributeName)) { - if (annotation == null) { - annotation = new Annotation(); - } - annotation.appendNoRDFAnnotation((String) getAttribute(g, - headline, nonRDFAttributeName)); - Map namespaces = sbase.getSBMLDocument() - .getSBMLDocumentNamespaces(); - Set> namespacesEntrySet = namespaces - .entrySet(); - for (Entry entry : namespacesEntrySet) { - String key = entry.getKey(); - String prefix = "xmlns"; - String namespaceName = SBML_Constants.EMPTY; - if (key.contains(":")) { - prefix = key.split(":")[0]; - namespaceName = key.split(":")[1]; - } else { - namespaceName = key; - } - if (annotation.getNonRDFannotation().contains( - "<" + namespaceName + ":")) { - annotation.addAnnotationNamespace(namespaceName, - prefix, entry.getValue()); - } - } - } - if (null != annotation) { - if (annotation.isSetNonRDFannotation()) { - if (annotation.getNonRDFannotation().contains(" namespaces; - if (!(sbase instanceof SBMLDocument) - && (!(sbase instanceof SimpleSpeciesReference))) { - namespaces = sbase.getSBMLDocument() - .getSBMLDocumentNamespaces(); - - } else - if (sbase instanceof SimpleSpeciesReference) { - namespaces = nameSpaceCollector; - } else { - namespaces = ((SBMLDocument) sbase) - .getSBMLDocumentNamespaces(); - } - if (null != namespaces) { - Set> namespacesEntrySet = namespaces - .entrySet(); - for (Entry entry : namespacesEntrySet) { - String key = entry.getKey(); - String prefix = "xmlns"; - String namespaceName = SBML_Constants.EMPTY; - if (key.contains(":")) { - prefix = key.split(":")[0]; - namespaceName = key.split(":")[1]; - } else { - namespaceName = key; - } - if (annotation.getNonRDFannotation().contains( - "<" + namespaceName + ":")) { - annotation.addAnnotationNamespace(namespaceName, - prefix, entry.getValue()); - } - } - } - if (null != annotation) { - if (annotation.getNonRDFannotation().contains(" headlineHelper(Graph g, String pattern) { - Map rr = g.getAttributes().getCollection(); - if (rr != null) { - Set> entries = rr.entrySet(); - Iterator> itEntries = entries.iterator(); - ArrayList result = new ArrayList(); - while (itEntries.hasNext()) { - Map.Entry entry = (Map.Entry) itEntries - .next(); - if (entry.getKey().startsWith(pattern)) { - result.add(entry.getKey()); - } - } - return result; - } else - return new ArrayList(); - } - - /** - * Method returns all headlines in the node tab which begin with a certain - * pattern - * - * @param g - * contains the values for the export - * @param pattern - * is the headline to be found - * @return all headlines with the required beginning - */ - public ArrayList headlineHelper(Node n, String pattern) { - Map rr = n.getAttributes().getCollection(); - if (rr != null) { - Set> entries = rr.entrySet(); - Iterator> itEntries = entries.iterator(); - ArrayList result = new ArrayList(); - while (itEntries.hasNext()) { - Map.Entry entry = (Map.Entry) itEntries - .next(); - if (entry.getKey().startsWith(pattern)) { - result.add(entry.getKey()); - } - } - return result; - } else - return new ArrayList(); - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Species_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Species_Writer.java deleted file mode 100644 index 363a093f3..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_Species_Writer.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * This class writes the Species object - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.AttributeHelper; -import org.ErrorMsg; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.SpeciesGlyph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLSpeciesHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Species_Writer extends SBML_SBase_Writer { - - /** - * Provides helpful methods - */ - SBMLSpeciesHelper speciesHelper; - - /** - * Adds a species and its variables to the model - * - * @param g - * contains the values for the export - * @param model - * the species will be added to this model - */ - public void addSpecies(Model model, Graph g) { - speciesHelper = new SBMLSpeciesHelper(g); - List nodeList = speciesHelper.getSpeciesNodes(); - Iterator nodeIt = nodeList.iterator(); - Set speciesIds = new HashSet(); - while (nodeIt.hasNext()) { - Node speciesNode = nodeIt.next(); - Species species = model.createSpecies(); - if (speciesHelper.isSetID(speciesNode)) { - String id = speciesHelper.getID(speciesNode); - if (!speciesIds.contains(id)) { - addSBaseAttributes(species, speciesNode); - speciesIds.add(id); - if (Species.isValidId(id, species.getLevel(), - species.getVersion())) - { - species.setId(id); - } - - if (speciesHelper.isSetName(speciesNode)) { - species.setName(speciesHelper.getName(speciesNode)); - } - if (speciesHelper.isSetCompartment(speciesNode)) { - species.setCompartment(speciesHelper - .getCompartment(speciesNode)); - } - if (speciesHelper.isSetInitialAmount(speciesNode)) { - species.setInitialAmount(speciesHelper - .getInitialAmount(speciesNode)); - } - if (speciesHelper.isSetInitialConcentration(speciesNode)) { - species.setInitialConcentration(speciesHelper - .getInitialConcentration(speciesNode)); - } - if (speciesHelper.isSetSubstanceUnits(speciesNode)) { - species.setSubstanceUnits(speciesHelper - .getSubstanceUnits(speciesNode)); - } - if (speciesHelper.isSetHasOnlySubstanceUnits(speciesNode)) { - species.setHasOnlySubstanceUnits(speciesHelper - .getHasOnlySubstanceUnits(speciesNode)); - } - if (speciesHelper.isSetBoundaryCondition(speciesNode)) { - species.setBoundaryCondition(speciesHelper - .getBoundaryCondition(speciesNode)); - } - if (speciesHelper.isSetConstant(speciesNode)) { - species.setConstant(speciesHelper.getConstant(speciesNode)); - } - if (speciesHelper.isSetConversionFactor(speciesNode)) { - species.setConversionFactor(speciesHelper - .getConversionFactor(speciesNode)); - } - } - } - /* - * if(AttributeHelper.hasAttribute(annotationNode, "SBML", "species" - * +species.getId()+"annotation")){ Annotation anno = - * (Annotation)AttributeHelper.getAttributeValue(annotationNode, - * "SBML", "species" +species.getId()+"annotation", - * SBML_Constants.EMPTY, null); species.setAnnotation(anno); } - */ - } - } - - public void addSpeciesGlyph(Model model, Graph g) { - speciesHelper = new SBMLSpeciesHelper(g); - List nodeList = speciesHelper.getSpeciesNodes(); - Iterator nodeIt = nodeList.iterator(); - ExtendedLayoutModel layoutModel = (ExtendedLayoutModel) model.getExtension(SBMLHelper.SBML_LAYOUT_EXTENSION_NAMESPACE); - if(layoutModel == null) - return; - while (nodeIt.hasNext()) { - Node node = nodeIt.next(); - String layoutID = (String) AttributeHelper.getAttributeValue(node, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, null, null); - for (Layout layout : layoutModel.getListOfLayouts()) { - if (layoutID != null && layoutID.equals(layout.getId())) { - System.out.println("layout id in addSpeciesGlyph: " + layout.getId()); - if (speciesHelper.isSetID(node)) { - String speciesID = speciesHelper.getID(node); - double x = AttributeHelper.getPositionX(node); - double y = AttributeHelper.getPositionY(node); - double width = AttributeHelper.getWidth(node); - double height = AttributeHelper.getHeight(node); - SpeciesGlyph speciesGlyph = layout.createSpeciesGlyph(speciesID); - speciesGlyph.createBoundingBox(width, height, 1, x, y, 0); - } else { - ErrorMsg - .addErrorMessage("Species id must be set! The Node will not be exported to the SBML-Layout-Model."); - } - } - } - } - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_UnitDefinition_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_UnitDefinition_Writer.java deleted file mode 100644 index 96b6b693b..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_UnitDefinition_Writer.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * This class writes the SBase attributes of UnitDefinition - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.util.regex.Pattern; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.UnitDefinition; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_UnitDefinition_Writer extends SBML_SBase_Writer{ - - /** - * Adds an unit definition and its variables to the model - * @param model the unit definition will be added to this model - * @param g contains the values for the export - * @param headline indicates where the information should be read from - * @param intern representation of headline - */ - public void addUnitDefinition(Model model, Graph g, String niceID) { - UnitDefinition unitDefinition = model.createUnitDefinition(); - addSBaseAttributes(unitDefinition, g, niceID); - if(AttributeHelper.hasAttribute(g, niceID, new StringBuffer(niceID).append(SBML_Constants.UNIT_DEFINITION_ID).toString())){ - String id = (String) getAttribute(g, niceID,new StringBuffer(niceID).append(SBML_Constants.UNIT_DEFINITION_ID).toString()); - if (!SBML_Constants.EMPTY.equals(id) && UnitDefinition.isValidId(id, unitDefinition.getLevel(), unitDefinition.getVersion())) { - unitDefinition.setId(id); - } - } - if(AttributeHelper.hasAttribute(g, niceID,new StringBuffer(niceID).append(SBML_Constants.UNIT_DEFINITION_NAME).toString())){ - String name = (String) getAttribute(g, niceID,new StringBuffer(niceID).append(SBML_Constants.UNIT_DEFINITION_NAME).toString()); - if (!SBML_Constants.EMPTY.equals(name)) { - unitDefinition.setName(name); - } - } - - - String subUnit = ""; - int unitCount = 1; - Unit unit = null; - while (AttributeHelper.hasAttribute(g, niceID, new StringBuffer(niceID).append(SBML_Constants.SUB_UNIT). - append(unitCount).append(SBML_Constants.UNDERLINE).toString())){ - subUnit = (String) getAttribute(g, niceID,new StringBuffer(niceID).append(SBML_Constants.SUB_UNIT). - append(unitCount).append(SBML_Constants.UNDERLINE).toString()); - unit = unitDefinition.createUnit(); - addSBaseAttributes(unit, g, niceID); - String[] subUnitArray = subUnit.split(Pattern.quote(")")); - String exponent = subUnitArray[1].replace("^", ""); - String[] subUnitArray2 = subUnitArray[0].split("\\*"); - String multiplier = subUnitArray2[0].replace("(", ""); - String[] subUnitArray3 = subUnitArray2[1].split("\\^"); - String scale = subUnitArray3[1]; - String kind = subUnitArray2[2]; - unit.setExponent(Double.parseDouble(exponent.trim())); - unit.setMultiplier(Double.parseDouble(multiplier.trim())); - unit.setScale(Integer.parseInt(scale.trim())); - unit.setKind(Kind.valueOf(kind.trim().toUpperCase())); - ++unitCount; - subUnit = ""; - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_Writer.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_Writer.java deleted file mode 100644 index edb1b5072..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_Writer.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003-2007 Network Analysis Group, IPK Gatersleben - *******************************************************************************/ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -import org.graffiti.graph.Graph; -import org.graffiti.plugin.io.AbstractOutputSerializer; -import org.graffiti.plugin.io.OutputSerializer; -import org.graffiti.plugin.io.SupportsWriterOutput; - -public class SBML_XML_Writer extends AbstractOutputSerializer implements OutputSerializer, SupportsWriterOutput { - - /** - * Constructor - */ - public SBML_XML_Writer() { - super(); - } - - /** - * Implemented method of interface InputSerializer.java - */ - public void write(Writer writer, Graph g) { - } - - /** - * Return the file extension that can be read in. - * Implemented method of interface InputSerializer.java - */ - public String[] getExtensions() { - return new String[] { ".sbml" }; - } - - /** - * returns the file type description. - * Implemented method of interface InputSerializer.java - */ - public String[] getFileTypeDescriptions() { - return new String[] { "SBML" }; - } - - /** - * starts the reading in of the model - * - * @param stream - * contains the model - * @param g - * the data will be read into this data structure - */ - public void write(OutputStream stream, Graph g) throws IOException { - SBML_SBML_Writer writeSBML = new SBML_SBML_Writer(); - writeSBML.addSBML(stream, g); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_WriterPlugin.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_WriterPlugin.java deleted file mode 100644 index 4e3bf57f4..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/SBML_XML_WriterPlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Plant Bioinformatics Group, IPK Gatersleben - *******************************************************************************/ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml; - -import org.graffiti.plugin.io.OutputSerializer; - -import de.ipk_gatersleben.ag_nw.graffiti.IPK_PluginAdapter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLNodesNiceIdHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -/** - * DOCUMENT ME! - * - * @author Dagmar Kutz, Matthias Klapperstück - */ -public class SBML_XML_WriterPlugin extends IPK_PluginAdapter -{ - public SBML_XML_WriterPlugin() { - - super(); - SBMLNodesNiceIdHelper.initNiceIds(); - SBML_Constants.init(); - this.outputSerializers = new OutputSerializer[] { - new SBML_XML_Writer() - }; - - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/plugin.xml b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/plugin.xml deleted file mode 100644 index 0f26f4c7a..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/sbml/plugin.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Dagmar Kutz, Matthias Klapperstück - SBML-XML-Writer - - - SBML-XML-Writer -
de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_XML_WriterPlugin
- 1.0.0 - mailto:klapper@ipk-gatersleben.de -
-
diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/ConstantsName.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/ConstantsName.java deleted file mode 100644 index f125e4ebf..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/ConstantsName.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -public class ConstantsName { - public static final String SBMLSUBSTANCEUNITS = "sbml_substanceUnits"; -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Compartment_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Compartment_Reader.java deleted file mode 100644 index 9b6d7f8ed..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Compartment_Reader.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This class reads in Compartments - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.ErrorMsg; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLCompartment; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLCompartmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Compartment_Reader { - - /** - * Method reads in compartments and is called from class - * SBML_XML_Reader.java - * - * @param compartmentList - * contains the compartments for the import - * @param g - * the data structure for reading in the information - */ - public void addCompartment(ListOf compartmentList, Graph g) { - Iterator itComp = compartmentList.iterator(); - int compartmentCount = 1; - SBMLCompartmentHelper compartmentHelperObject = new SBMLCompartmentHelper(); - Compartment compartment; - String name; - String id; - Double spatialDimensions; - Double size; - String units; - Boolean constant; - String metaID; - String sboTerm; - String outside; - XMLNode notesObj; - String notes; - String internHeadline; - String presentedHeadline; - while (itComp.hasNext()) { - compartment = itComp.next(); - name = compartment.getName(); - id = compartment.getId(); - spatialDimensions = compartment.getSpatialDimensions(); - size = compartment.getSize(); - units = compartment.getUnits(); - constant = compartment.getConstant(); - metaID = compartment.getMetaId(); - sboTerm = compartment.getSBOTermID(); - outside = compartment.getOutside(); - notesObj = compartment.getNotes(); - notes = compartment.getNotesString(); - internHeadline = new StringBuffer(SBML_Constants.SBML_COMPARTMENT) - .append(id).toString(); - presentedHeadline = SBML_Constants.EMPTY; - if (compartment.isSetName()) { - presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append(name) - .toString(); - } else if (compartment.isSetId()) { - presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append(id) - .toString(); - } else { - presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append( - compartmentCount).toString(); - } - if (size.equals(Double.NaN) && compartment.isSetSize()) { - ErrorMsg.addErrorMessage("Attribute size of " - + presentedHeadline + " is not a valid double value."); - } - SBMLCompartment compartmentHelper = compartmentHelperObject - .addCompartment(g, internHeadline, presentedHeadline); - - if (compartment.isSetId() - && Compartment.isValidId(id, compartment.getLevel(), - compartment.getVersion())) { - compartmentHelper.setID(id); - } - if (compartment.isSetName() && (name != SBML_Constants.EMPTY)) { - compartmentHelper.setName(name); - } - if (compartment.isSetSpatialDimensions()) { - compartmentHelper.setSpatialDimensions(spatialDimensions); - } - if (compartment.isSetSize()) { - compartmentHelper.setSize(size); - } - if (compartment.isSetUnits()) { - compartmentHelper.setUnits(units); - } - if (compartment.isSetConstant()) { - compartmentHelper.setConstant(constant); - } - if (compartment.isSetMetaId()) { - compartmentHelper.setMetaID(metaID); - } - if (compartment.isSetSBOTerm()) { - compartmentHelper.setSBOTerm(sboTerm); - } - if (compartment.isSetOutside()) { - compartmentHelper.setOutside(outside); - } - if (compartment.isSetNotes()) { - compartmentHelper.setNotes(notes, notesObj); - } - if (compartment.isSetAnnotation()) { - if (compartment.getAnnotation().isSetRDFannotation()) { - compartmentHelper - .setAnnotation(compartment.getAnnotation()); - } - if (compartment.getAnnotation().isSetNonRDFannotation()) { - compartmentHelper.setNonRDFAnnotation(compartment - .getAnnotation().getNonRDFannotation()); - } - } - - compartmentCount++; - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Constraint_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Constraint_Reader.java deleted file mode 100644 index fdcde02fa..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Constraint_Reader.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * This class reads in Constraints - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.ListOf; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLConstraint; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLConstraintHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Constraint_Reader extends SBML_SBase_Reader { - - /** - * Method reads in constraints and is called from class SBML_XML_Reader.java - * - * @param listOfConstraints - * contains the constraints for the import - * @param g - * the data structure for reading in the information - */ - public void addConstraint(ListOf listOfConstraints, Graph g) { - int constraintCount = 1; - SBMLConstraintHelper constraintHelperObject = new SBMLConstraintHelper(); - Iterator itConstraint = listOfConstraints.iterator(); - while (itConstraint.hasNext()) { - Constraint constraint = itConstraint.next(); - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_CONSTRAINT).append(constraintCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Constraint ") - .append(constraintCount).toString(); - // initConstraintNideIDs(internHeadline, presentedHeadline); - SBMLConstraint constraintHelper = constraintHelperObject - .addConstraint(g, internHeadline, presentedHeadline); - - String metaID = constraint.getMetaId(); - String sboTerm = constraint.getSBOTermID(); - String mathFormula = ""; - if (constraint.isSetMath()) { - if (null != constraint.getMath()) { - mathFormula = constraint.getMath().toString(); - } - } - String message = ""; - if (constraint.isSetMessage()) { - message = removeTagFromString(constraint.getMessageString()); - constraintHelper.setMessage(message); - } - if (constraint.isSetSBOTerm()) { - constraintHelper.setSBOTerm(sboTerm); - } - if (constraint.isSetMetaId()) { - constraintHelper.setMetaId(metaID); - } - if (constraint.isSetNotes()) { - constraintHelper.setNotes(constraint.getNotesString(), - constraint.getNotes()); - } - if (constraint.isSetAnnotation()) { - if (constraint.getAnnotation().isSetRDFannotation()) { - constraintHelper.setAnnotation(constraint.getAnnotation()); - } - if (constraint.getAnnotation().isSetNonRDFannotation()) { - constraintHelper.setNonRDFAnnotation(constraint - .getAnnotation().getNonRDFannotation()); - } - } - if (constraint.isSetMath()) { - constraintHelper.setFunction(mathFormula); - } - - constraintCount++; - } - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Event_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Event_Reader.java deleted file mode 100644 index e92711997..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Event_Reader.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * This class reads in Events - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.Delay; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.Priority; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Trigger; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLEventAssignmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLEventHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Event_Reader extends SBML_SBase_Reader { - - /** - * Adds an events to the graph tab - * - * @param eventList - * contains the events of the model - * @param g - * is the data structure for reading in the information - */ - public void addEvents(List eventList, Graph g) { - Iterator itEvent = eventList.iterator(); - int eventCount = 1; - while (itEvent.hasNext()) { - Event event = itEvent.next(); - - String internHeadline = new StringBuffer(SBML_Constants.SBML_EVENT) - .append(eventCount).toString(); - String presentedHeadline = new StringBuffer("SBML Event ").append( - eventCount).toString(); - - SBMLEventHelper eventHelper = new SBMLEventHelper(g, - internHeadline, presentedHeadline); - - String eventID = event.getId(); - String eventName = event.getName(); - Boolean useValuesFromTriggerTime = false; - if (event.isSetUseValuesFromTriggerTime()) { - useValuesFromTriggerTime = event.getUseValuesFromTriggerTime(); - } - Trigger trigger = event.getTrigger(); - String triggerFormula = ""; - try { - if (trigger.isSetMath()) { - if (null != trigger.getMath()) { - triggerFormula = trigger.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - Boolean triggerInitialValue = false; - Boolean triggerPersistent = false; - try { - if (trigger.isSetInitialValue()) - triggerInitialValue = trigger.getInitialValue(); - if (trigger.isSetPersistent()) - triggerPersistent = trigger.getPersistent(); - } catch (Exception e1) { - e1.printStackTrace(); - } - - // Boolean triggerInitialValue = trigger.getInitialValue(); - // Boolean triggerPersistent = trigger.getPersistent(); - - String prioritySBOTerm = ""; - String priorityMetaID = ""; - String priorityFormula = ""; - if (event.isSetPriority()) { - Priority priority = event.getPriority(); - if (priority.isSetMetaId()) { - priorityMetaID = priority.getMetaId(); - } - if (priority.isSetSBOTerm()) { - prioritySBOTerm = priority.getSBOTermID(); - } - if (priority.isSetAnnotation()) { - if (priority.getAnnotation().isSetRDFannotation()) { - eventHelper.setPriorityAnnotation(priority - .getAnnotation()); - } - if (priority.getAnnotation().isSetNonRDFannotation()) { - eventHelper.setPriorityNonRDFAnnotation(priority - .getAnnotation().getNonRDFannotation()); - } - } - - if (priority.isSetNotes()) { - eventHelper.setPriorityNotes(priority.getNotesString(), - priority.getNotes()); - } - // addNotes(priority.getNotes(), priority.getNotesString(),g, - // internHeadline, new StringBuffer(internHeadline). - // append(SBML_Constants.PRIORITY_NOTES).toString()); - try { - if (priority.isSetMath()) { - if (null != priority.getMath()) { - priorityFormula = priority.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - } - - String delayMetaID = ""; - String delaySBOTerm = ""; - String delayFormula = ""; - if (event.isSetDelay()) { - Delay delay = event.getDelay(); - if (delay.isSetMetaId()) { - delayMetaID = delay.getMetaId(); - } - if (delay.isSetSBOTerm()) { - delaySBOTerm = delay.getSBOTermID(); - } - - if (delay.isSetAnnotation()) { - if (delay.getAnnotation().isSetRDFannotation()) { - eventHelper.setdelayAnnotation(delay.getAnnotation()); - } - if (delay.getAnnotation().isSetNonRDFannotation()) { - eventHelper.setdelayNonRDFAnnotation(delay - .getAnnotation().getNonRDFannotation()); - } - } - - // addNotes(delay.getNotes(), delay.getNotesString(),g, - // internHeadline, new StringBuffer(internHeadline). - // append(SBML_Constants.DELAY_NOTES).toString()); - - if (delay.isSetNotes()) { - eventHelper.setDelayNotes(delay.getNotesString(), - delay.getNotes()); - } - try { - if (delay.isSetMath()) { - if (null != delay.getMath()) { - delayFormula = delay.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - } - if (event.isSetId() - && Event.isValidId(eventID, event.getLevel(), - event.getVersion())) { - eventHelper.setID(eventID); - } - if (event.isSetName()) { - eventHelper.setName(eventName); - } - if (event.isSetMetaId()) { - eventHelper.setMetaID(event.getMetaId()); - } - if (event.isSetSBOTerm()) { - eventHelper.setSBOTerm(event.getSBOTermID()); - } - if (event.isSetAnnotation()) { - if (event.getAnnotation().isSetRDFannotation()) { - eventHelper.setAnnotation(event.getAnnotation()); - } - if (event.getAnnotation().isSetNonRDFannotation()) { - eventHelper.setNonRDFAnnotation(event.getAnnotation() - .getNonRDFannotation()); - } - } - if (event.isSetUseValuesFromTriggerTime()) { - eventHelper - .setUseValuesFromTriggerTime(useValuesFromTriggerTime); - } - if (event.isSetNotes()) { - eventHelper.setNotes(event.getNotesString(), event.getNotes()); - } - if (trigger.isSetInitialValue()) { - eventHelper.setInitialValue(triggerInitialValue); - } - if (trigger.isSetPersistent()) { - eventHelper.setPersistent(triggerPersistent); - } - if (trigger.isSetMath()) { - eventHelper.setTriggerFunction(triggerFormula); - } - if (!priorityFormula.equals("")) { - eventHelper.setPriorityFunction(priorityFormula); - } - if (!priorityMetaID.equals("")) { - eventHelper.setPriorityMetaID(priorityMetaID); - } - if (!prioritySBOTerm.equals("")) { - eventHelper.setPrioritySBOTerm(prioritySBOTerm); - } - if (!delayFormula.equals("")) { - eventHelper.setDelayFunction(delayFormula); - } - if (!delayMetaID.equals("")) { - eventHelper.setDelayMetaID(delayMetaID); - } - if (!delaySBOTerm.equals("")) { - eventHelper.setDelaySBOTerm(delaySBOTerm); - } - - List listEventAssignment = event - .getListOfEventAssignments(); - Iterator itEventAssignment = listEventAssignment - .iterator(); - int eventAssignmentCount = 1; - while (itEventAssignment.hasNext()) { - EventAssignment eventAssignment = itEventAssignment.next(); - SBMLEventAssignmentHelper eaHelper = eventHelper - .addEventAssignment(g, internHeadline, - presentedHeadline, eventAssignmentCount); - - // initEventAssignmentNideIDs(presentedHeadline, internHeadline, - // eventAssignmentCount); - /* - * String keyEAVariable = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Event Assignment " + eventAssignmentCount + " Variable"); - * String keyEAMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Event Assignment " + eventAssignmentCount + " Meta ID"); - * String keyEASBOTerm = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Event Assignment " + eventAssignmentCount + " SBOTerm"); - * String keyEAToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Event Assignment " + eventAssignmentCount + " ToolTip"); - * String keyEAFormula = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Event Assignment " + eventAssignmentCount + " Formula"); - */ - - String variable = eventAssignment.getVariable(); - String eventAssignmentFormula = ""; - try { - if (eventAssignment.isSetMath()) { - if (null != eventAssignment.getMath()) { - eventAssignmentFormula = eventAssignment.getMath() - .toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - if (eventAssignment.isSetVariable()) { - eaHelper.setVariable(variable); - } - if (eventAssignment.isSetMath()) { - eaHelper.setFunction(eventAssignmentFormula); - } - if (eventAssignment.isSetMetaId()) { - eaHelper.setMetaID(eventAssignment.getMetaId()); - } - if (eventAssignment.isSetSBOTerm()) { - eaHelper.setSBOTerm(eventAssignment.getSBOTermID()); - } - - if (eventAssignment.isSetAnnotation()) { - if (eventAssignment.getAnnotation().isSetRDFannotation()) { - eaHelper.setAnnotation(eventAssignment.getAnnotation()); - } - if (eventAssignment.getAnnotation().isSetNonRDFannotation()) { - eaHelper.setNonRDFAnnotation(eventAssignment - .getAnnotation().getNonRDFannotation()); - } - } - if (eventAssignment.isSetNotes()) { - eaHelper.setNotes(eventAssignment.getNotesString(), - eventAssignment.getNotes()); - } - - eventAssignmentCount++; - } - - eventCount++; - } - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_FunctionDefinition_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_FunctionDefinition_Reader.java deleted file mode 100644 index 54e354634..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_FunctionDefinition_Reader.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This class reads in FunctionDefinitions - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.ListOf; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLFunctionDefinition; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLFunctionDefinitionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_FunctionDefinition_Reader { - - /** - * Method reads in function definitions and is called from class SBML_XML_Reader.java - * - * @param functionDefinitionList contains the function definitions for the import - * @param g the data structure for reading in the information - */ - public void addFunktionDefinition(ListOf functionDefinitionList, Graph g) { - Iterator itFunctionDefinition = functionDefinitionList.iterator(); - int functionCount = 1; - SBMLFunctionDefinitionHelper functionDefinitionHelperObject = new SBMLFunctionDefinitionHelper(); - while (itFunctionDefinition.hasNext()) { - try { - FunctionDefinition functionDefinition = itFunctionDefinition.next(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_FUNCTION_DEFINITION).append(functionCount).toString(); - String presentedHeadline = new StringBuffer("SBML Function Definition ").append(functionCount).toString(); - SBMLFunctionDefinition functionDefinitionHelper = functionDefinitionHelperObject. - addFunctionDefinition(g, internHeadline, presentedHeadline); - String functionID = functionDefinition.getId(); - String functionName = functionDefinition.getName(); - String sboTerm = functionDefinition.getSBOTermID(); - String metaID = functionDefinition.getMetaId(); - - if (functionDefinition.isSetId()) { - functionDefinitionHelper.setID(functionID); - } - if (functionDefinition.isSetMath()) { - ASTNode math = functionDefinition.getMath(); - functionDefinitionHelper.setFunction(math.toString()); - } - if (functionDefinition.isSetName()) { - functionDefinitionHelper.setName(functionName); - } - if (functionDefinition.isSetSBOTerm()) { - functionDefinitionHelper.setSBOTerm(sboTerm); - } - if (functionDefinition.isSetMetaId()) { - functionDefinitionHelper.setMetaID(metaID); - } - if (functionDefinition.isSetNotes()) { - functionDefinitionHelper.setNotes(functionDefinition.getNotesString(), functionDefinition.getNotes()); - } - if (functionDefinition.isSetAnnotation()) { - if (functionDefinition.getAnnotation().isSetRDFannotation()) { - functionDefinitionHelper.setAnnotation(functionDefinition.getAnnotation()); - } - if (functionDefinition.getAnnotation().isSetNonRDFannotation()) { - if (functionDefinition.getAnnotation().isSetNonRDFannotation()) { - functionDefinitionHelper.setNonRDFAnnotation(functionDefinition.getAnnotation().getNonRDFannotation()); - } - } - } - - functionCount++; - } catch (Exception e) - { - e.printStackTrace(); - } - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_InitialAssignment_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_InitialAssignment_Reader.java deleted file mode 100644 index ceb2657bb..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_InitialAssignment_Reader.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * This class reads in InitialAssignments - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.SBMLException; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLInitialAssignment; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLInitialAssignmentHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_InitialAssignment_Reader { - - /** - * Method reads in initial assignments and is called from class - * SBML_XML_Reader.java - * - * @param initialAssignmentList - * contains the initial assignments for the import - * @param g - * the data structure for reading in the information - */ - public void addInitialAssignments( - ListOf initialAssignmentList, Graph g) { - Iterator itInitialAssignment = initialAssignmentList - .iterator(); - int countInitialAssignment = 1; - SBMLInitialAssignmentHelper initialAssignmentHelperObject = new SBMLInitialAssignmentHelper(); - while (itInitialAssignment.hasNext()) { - InitialAssignment initialAssignment = itInitialAssignment.next(); - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_INITIAL_ASSIGNMENT).append( - countInitialAssignment).toString(); - String presentedHeadline = new StringBuffer( - "SBML Initial Assignment ").append(countInitialAssignment) - .toString(); - SBMLInitialAssignment initialAssignmentHelper = initialAssignmentHelperObject - .addInitialAssignment(g, internHeadline, presentedHeadline); - // initInitialAssignmentNideIDs(internHeadline, presentedHeadline); - - /* - * String presentedHeadline = "SBML Initial Assignment " + - * countInitialAssignment; String internHeadline = - * getNiceHeadline(presentedHeadline); - * SBML_Constants.put(internHeadline, presentedHeadline); - */ - - /* - * String keySymbol = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Symbol"); - * String keyMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Meta ID"); - * String keySBOTerm = - * SBML_Constants.addToNiceIdList(presentedHeadline, "SBOTerm"); - * String keyToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, "ToolTip"); - * String keyFunction = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Function"); - */ - - String formula = ""; - try { - if (initialAssignment.isSetMath()) { - ASTNode mathTree = initialAssignment.getMath(); - formula = mathTree.toFormula(); - } - } catch (SBMLException e) { - } - // addNotes(initialAssignment.getNotes(), - // initialAssignment.getNotesString(),g, internHeadline, new - // StringBuffer(internHeadline).append(SBML_Constants.NOTES).toString()); - String sboTerm = initialAssignment.getSBOTermID(); - String metaID = initialAssignment.getMetaId(); - // method getSymbol is for compatibility with libSBML only - - // deprecated - String symbol = initialAssignment.getVariable(); - - if (initialAssignment.isSetSBOTerm()) { - initialAssignmentHelper.setSBOTerm(sboTerm); - } - if (initialAssignment.isSetMetaId()) { - initialAssignmentHelper.setMetaID(metaID); - } - if (initialAssignment.isSetSymbol()) { - initialAssignmentHelper.setSymbol(symbol); - } - if (initialAssignment.isSetMath()) { - initialAssignmentHelper.setFunction(formula); - } - if (initialAssignment.isSetNotes()) { - initialAssignmentHelper.setNotes( - initialAssignment.getNotesString(), - initialAssignment.getNotes()); - } - if (initialAssignment.isSetAnnotation()) { - if (initialAssignment.getAnnotation().isSetRDFannotation()) { - initialAssignmentHelper.setAnnotation(initialAssignment - .getAnnotation()); - } - if (initialAssignment.getAnnotation().isSetNonRDFannotation()) { - initialAssignmentHelper - .setNonRDFAnnotation(initialAssignment - .getAnnotation().getNonRDFannotation()); - } - } - - countInitialAssignment++; - } - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Model_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Model_Reader.java deleted file mode 100644 index d9978f0fc..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Model_Reader.java +++ /dev/null @@ -1,353 +0,0 @@ -/** - * This class reads in the Model tag - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.awt.Point; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.AttributeHelper; -import org.PositionGridGenerator; -import org.apache.log4j.Logger; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SBMLDocument; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.editcomponents.cluster_colors.ClusterColorAttribute; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.editing_tools.script_helper.NodeHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLReactionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLSpeciesHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskStatusProviderSupportingExternalCallImpl; - -public class SBML_Model_Reader extends SBML_SBase_Reader { - - static Logger logger = Logger.getLogger(SBML_Model_Reader.class); - - /** - * Passes the import on to other classes - * - * @param document - * contains the model for the import - * @param g - * the data structure for reading in the information - */ - public void controlImport(SBMLDocument document, Graph g, - BackgroundTaskStatusProviderSupportingExternalCallImpl status) { - if (document.isSetModel()) { - - Model model = document.getModel(); - String modelID = ""; - if (model.isSetId()) { - if (Model.isValidId(model.getId(), document.getLevel(), - document.getVersion())) { - modelID = model.getId(); - } - } - PositionGridGenerator pgg = new PositionGridGenerator(100, 100, - 1000); - - addModel(model, g); - - if (model.isSetListOfFunctionDefinitions()) { - SBML_FunctionDefinition_Reader readFunctionDef = new SBML_FunctionDefinition_Reader(); - readFunctionDef.addFunktionDefinition( - model.getListOfFunctionDefinitions(), g); - } - - if (model.isSetListOfUnitDefinitions()) { - SBML_UnitDefinition_Reader readUnitDef = new SBML_UnitDefinition_Reader(); - readUnitDef.addUnitDefinitions( - model.getListOfUnitDefinitions(), g); - } - - if (model.isSetListOfCompartments()) { - SBML_Compartment_Reader readCompartment = new SBML_Compartment_Reader(); - readCompartment - .addCompartment(model.getListOfCompartments(), g); - } - status.setCurrentStatusText1("create species list"); - status.setCurrentStatusValue(40); - - SBMLSpeciesHelper speciesHelper = null; - if (model.isSetListOfSpecies()) { - speciesHelper = new SBMLSpeciesHelper(g); - SBML_Species_Reader readSpecies = new SBML_Species_Reader(); - readSpecies.addSpecies(g, model.getListOfSpecies(), pgg, speciesHelper); - } - if (model.isSetListOfParameters()) { - SBML_Parameter_Reader readParameter = new SBML_Parameter_Reader(); - readParameter.addParameter(model.getListOfParameters(), g); - } - if (model.isSetListOfInitialAssignments()) { - SBML_InitialAssignment_Reader readInitialAssignment = new SBML_InitialAssignment_Reader(); - readInitialAssignment.addInitialAssignments( - model.getListOfInitialAssignments(), g); - } - - if (model.isSetListOfRules()) { - SBML_Rule_Reader readRule = new SBML_Rule_Reader(); - readRule.addRule(model.getListOfRules(), g); - } - - if (model.isSetListOfConstraints()) { - SBML_Constraint_Reader readConstraint = new SBML_Constraint_Reader(); - readConstraint.addConstraint(model.getListOfConstraints(), g); - } - - status.setCurrentStatusText1("create reaction list"); - status.setCurrentStatusValue(80); - - SBMLReactionHelper reactionHelper = null;; - if (model.isSetListOfReactions()) { - reactionHelper = new SBMLReactionHelper(g); - SBML_Reaction_Reader readReaction = new SBML_Reaction_Reader(); - readReaction.addReactions(g, model.getListOfReactions(), - modelID, pgg, reactionHelper); - } - - if (model.isSetListOfEvents()) { - SBML_Event_Reader readEvent = new SBML_Event_Reader(); - readEvent.addEvents(model.getListOfEvents(), g); - } - - // sets background-color for compartments - AttributeHelper.setAttribute( - g, - "", - ClusterColorAttribute.attributeName, - ClusterColorAttribute.getDefaultValue(document.getModel() - .getListOfCompartments().size())); - AttributeHelper.setAttribute(g, "", "background_coloring", - new Boolean(true)); - - ListOf liste = model.getListOfCompartments(); - for (Compartment compartment : liste) { - if (!compartment.isSetName()) { - AttributeHelper.deleteAttribute( - g, - new StringBuffer(SBML_Constants.SBML_COMPARTMENT) - .append(compartment.getId()).toString(), - new StringBuffer(SBML_Constants.SBML_COMPARTMENT) - .append(compartment.getId()) - .append(SBML_Constants.COMPARTMENT_NAME) - .toString()); - } - } - if (SBML_Constants.isLayoutActive) { - addAdditionalEdges(g, model, speciesHelper, reactionHelper); - computeReactionNodePosition(g); - } - } - } - - private List getListOfReactions(String speciesID, Model model) { - List reactionList = model.getListOfReactions(); - List newReactionList = new ArrayList(); - for (Reaction reaction : reactionList) { - if (reaction.hasReactant(model.getSpecies(speciesID)) || reaction.hasProduct(model.getSpecies(speciesID)) - || reaction.hasModifier(model.getSpecies(speciesID))) { - newReactionList.add(reaction); - } - } - return newReactionList; - } - - private List getPointList(List nodeList) { - List pointList = new ArrayList(); - for (Node node : nodeList) { - NodeHelper nodeHelper = new NodeHelper(node); - pointList.add(nodeHelper.getPosition()); - } - return pointList; - } - - private Edge getEdge(Node reactionNode, String speciesID) { - Node speciesNode = null; - Iterator itNeighbors = reactionNode.getNeighborsIterator(); - while (itNeighbors.hasNext()) { - Node neighbor = itNeighbors.next(); - if (SBMLHelper.getSpeciesID(neighbor).equals(speciesID)) { - speciesNode = neighbor; - } - } - Iterator edgeIt = reactionNode.getEdgesIterator(); - while (edgeIt.hasNext()) { - Edge edge = edgeIt.next(); - if ((edge.getSource() == speciesNode && edge.getTarget() == reactionNode) || (edge.getSource() == reactionNode && edge.getTarget() == speciesNode)) { - return edge; - } - } - return null; - } - - private void addAdditionalEdges(Graph g, Model model, SBMLSpeciesHelper speciesHelper, SBMLReactionHelper reactionHelper) { - Map> speciesCloneList = speciesHelper.getSpeicesClones(); - Set>> speciesClonesEntrySet = speciesCloneList.entrySet(); - Iterator>> speciesClonesEntrySetIt = speciesClonesEntrySet.iterator(); - while (speciesClonesEntrySetIt.hasNext()) { - Entry> speciesCloneEntry = speciesClonesEntrySetIt.next(); - if (speciesCloneEntry.getValue().size() > 1) { - List reactionList = getListOfReactions(speciesCloneEntry.getKey(), model); - if (reactionList.size() > 1) { - - Node species = null; - for (Node node : speciesCloneEntry.getValue()) { - if (node.getEdges().size() > 0) { - species = node; - } - break; - } - - for (Reaction reaction : reactionList) { - Node reactionNode = SBMLHelper.getReactionNode(g, reaction.getId()); - NodeHelper reactionNodeHelper = new NodeHelper(reactionNode); - Point2D positionReaction = reactionNodeHelper.getPosition(); - Double min = Double.POSITIVE_INFINITY; - Node minSpeciesNode = null; - for (Node speciesNode : speciesCloneEntry.getValue()) { - NodeHelper speciesNodeHelper = new NodeHelper(speciesNode); - Point2D speciesPosition = speciesNodeHelper.getPosition(); - Double difference = positionReaction.distance(speciesPosition); - if (difference < min) { - min = difference; - minSpeciesNode = speciesNode; - } - } - Edge edge = getEdge(reactionNode, speciesCloneEntry.getKey()); - if (AttributeHelper.getSBMLrole(edge.getSource()).equals(SBML_Constants.SPECIES)) { - edge.setSource(minSpeciesNode); - } - else if (AttributeHelper.getSBMLrole(edge.getTarget()).equals(SBML_Constants.SPECIES)) { - edge.setTarget(minSpeciesNode); - } - } - } - } - } - } - - /** - * Reads in the model - * - * @param model - * contains the model for the import - * @param g - * the data structure for reading in the information - */ - private void addModel(Model model, Graph g) { - String modelID = model.getId(); - String modelName = model.getName(); - String substanceUnits = model.getSubstanceUnits(); - String timeUnits = model.getTimeUnits(); - String volumeUnits = model.getVolumeUnits(); - String areaUnits = model.getAreaUnits(); - String lenghtUnits = model.getLengthUnits(); - String extendUnits = model.getExtentUnits(); - String conversionFactor = model.getConversionFactor(); - String metaID = model.getMetaId(); - String sboTerm = model.getSBOTermID(); - - if (model.isSetNotes()) { - addNotes(model.getNotes(), model.getNotesString(), g, - SBML_Constants.SBML, SBML_Constants.MODEL_NOTES); - } - if (model.isSetId()) { - if (!modelID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_ID, modelID); - } - } - if (!modelName.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NAME, modelName); - } - - if (model.getLevel() == 3 && model.getVersion() == 1) { - if (model.isSetSubstanceUnits()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.SUBSTANCE_UNITS, substanceUnits); - } - if (model.isSetTimeUnits()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.TIME_UNITS, timeUnits); - } - if (model.isSetVolumeUnits()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.VOLUME_UNITS, volumeUnits); - } - if (!areaUnits.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.AREA_UNITS, areaUnits); - } - if (model.isSetLengthUnits()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.LENGTH_UNITS, lenghtUnits); - } - if (model.isSetExtentUnits()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.EXTENT_UNITS, extendUnits); - } - if (!conversionFactor.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.CONVERSION_FACTOR, conversionFactor); - } - } - - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_META_ID, metaID); - } - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_SBOTERM, sboTerm); - } - if (model.isSetAnnotation()) { - if (model.getAnnotation().isSetRDFannotation()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_ANNOTATION, model.getAnnotation()); - } - if (model.getAnnotation().isSetNonRDFannotation()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.MODEL_NON_RDF_ANNOTATION, model - .getAnnotation().getNonRDFannotation()); - } - } - } - - /** - * iterates over all speices of every reaction and set the reaction position to the average position of all their speices nodes. - */ - private void computeReactionNodePosition(Graph g) { - for (Node reaction : SBMLHelper.getReactionNodes(g)) { - if (!SBMLHelper.isSetLayoutID(g, reaction)) { - Set reactionNeighbours = reaction.getNeighbors(); - if (reactionNeighbours.size() > 0) { - Point2D newReactionPosition = new Point(); - newReactionPosition.setLocation(1d, 1d); - for (Node species : reactionNeighbours) { - double newXPosition = (AttributeHelper.getPosition(species).getX() + newReactionPosition.getX()) / 2d; - double newYPosition = (AttributeHelper.getPosition(species).getY() + newReactionPosition.getY()) / 2d; - newReactionPosition.setLocation(newXPosition, newYPosition); -// System.out.println("process reaction: " + SBMLHelper.getReactionID(reaction) + " new position: " + newXPosition + ", " + newYPosition -// ); - } - AttributeHelper.setPosition(reaction, newReactionPosition); - } - } - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Parameter_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Parameter_Reader.java deleted file mode 100644 index dd3ec3715..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Parameter_Reader.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This class reads in Parameters - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.ErrorMsg; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Parameter; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLParameter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLParameterHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Parameter_Reader { - - /** - * Method reads in parameter and is called from class SBML_XML_Reader.java - * - * @param parameterList - * contains the parameter for the import - * @param g - * the data structure for reading in the information - */ - public void addParameter(ListOf parameterList, Graph g) { - Iterator itParameter = parameterList.iterator(); - int parameterCount = 1; - SBMLParameterHelper parameterHelperObject = new SBMLParameterHelper(); - while (itParameter.hasNext()) { - Parameter parameter = itParameter.next(); - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_PARAMETER).append(parameterCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Parameter ") - .append(parameterCount).toString(); - - SBMLParameter parameterHelper = parameterHelperObject.addParameter( - g, internHeadline, presentedHeadline); - - String parameterID = parameter.getId(); - String parameterName = parameter.getName(); - Double parameterValue = parameter.getValue(); - - // in BIOMD0000000012.xml from BioModels.org this error message would be shown - // nevertheless the model is valid - // so this message is not necessary - // if (parameterValue.equals(Double.NaN)) { - // ErrorMsg.addErrorMessage("Attribute value of parameter " - // + parameterCount + " with the id " + parameterID - // + " is not a valid double value."); - // } - - String parameterUnits = parameter.getUnits(); - Boolean parameterConstant = parameter.isConstant(); - String metaID = parameter.getMetaId(); - String sboTerm = parameter.getSBOTermID(); - if (parameter.isSetId() - && Parameter.isValidId(parameterID, parameter.getLevel(), - parameter.getVersion())) { - parameterHelper.setID(parameterID); - } - if (!Parameter.isValidId(parameterID, parameter.getLevel(), - parameter.getVersion())) { - ErrorMsg.addErrorMessage("ID of parameter " + parameterCount - + " is not valid."); - } - if (parameter.isSetName()) { - parameterHelper.setName(parameterName); - } - if (parameter.isSetValue()) { - parameterHelper.setValue(parameterValue); - } - if (parameter.isSetUnits()) { - parameterHelper.setUnits(parameterUnits); - } - if (parameter.isSetConstant()) { - parameterHelper.setConstant(parameterConstant); - } - if (parameter.isSetMetaId()) { - parameterHelper.setMetaID(metaID); - } - if (parameter.isSetSBOTerm()) { - parameterHelper.setSBOTerm(sboTerm); - } - if (parameter.isSetNotes()) { - parameterHelper.setNotes(parameter.getNotesString(), - parameter.getNotes()); - } - if (parameter.isSetAnnotation()) { - if (parameter.getAnnotation().isSetRDFannotation()) { - parameterHelper.setAnnotation(parameter.getAnnotation()); - } - if (parameter.getAnnotation().isSetNonRDFannotation()) { - parameterHelper.setNonRDFAnnotation(parameter - .getAnnotation().getNonRDFannotation()); - } - } - parameterCount++; - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Reaction_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Reaction_Reader.java deleted file mode 100644 index 4a0180db1..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Reaction_Reader.java +++ /dev/null @@ -1,651 +0,0 @@ -/** - * This class reads in Reactions - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.awt.Color; -import java.util.Iterator; -import java.util.List; - -import org.AlignmentSetting; -import org.AttributeHelper; -import org.ErrorMsg; -import org.PositionGridGenerator; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.ext.layout.BoundingBox; -import org.sbml.jsbml.ext.layout.Dimensions; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.Point; -import org.sbml.jsbml.ext.layout.ReactionGlyph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.KineticLawHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLLocalParameter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLReactionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLSpeciesHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Reaction_Reader { - - /** - * Method reads in function definitions and is called from class - * SBML_XML_Reader.java. Add reaction nodes and edges to the graph - * - * @param g - * the data structure for reading in the information - * @param reactionList - * contains the reactions for the import - * @param modelID - * is the id of the current model - * @param pgg - * is needed for drawing the graph - */ - public void addReactions(Graph g, ListOf reactionList, - String modelID, PositionGridGenerator pgg, SBMLReactionHelper reactionhelper) { - SBMLReactionHelper reactionHelper = reactionhelper; - String reactionID; - String reactionName; - Boolean reversible; - String compartment; - String sboTerm; - String metaID; - Boolean fast; - Node reactionNode; - ListOf reactants; - ListOf products; - ListOf modifiers; - String metaID2; - String sboTerm2; - String kineticFormula; - KineticLaw kineticLaw; - KineticLawHelper kineticLawHelper; - List listLocalParameter; - Iterator itLP; - int countLocalParameter; - LocalParameter localParameter; - String internAttributeName; - String presentedAttributeName; - SBMLLocalParameter localParameterHelper; - String id = SBML_Constants.EMPTY; - String name; - Double value; - String unit; - for (Reaction reaction : reactionList) { - reactionID = reaction.getId(); - reactionName = reaction.getName(); - // reversible = false; - // if (reaction.isSetReversible()) { - reversible = reaction.getReversible(); - // } - fast = reaction.getFast(); - compartment = reaction.getCompartment(); - sboTerm = reaction.getSBOTermID(); - metaID = reaction.getMetaId(); - - // Determines the label of the reaction node - /* - * String ex = null; if(!(reactionName == "")){ ex = reactionName; } - * else{ ex = reactionID; } - */ - reactionNode = g.addNode(); - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_REACTION); - - // CAUTION working with level 3 or higher CAUTION - reactionHelper - .setLabel(reactionNode, reactionName, reactionID, pgg); - // setAttributes(reactionNode, Color.white, ex, - // pgg.getNextPosition(), 8); - AttributeHelper.setBorderWidth(reactionNode, 1d); - // NodeTools.setClusterID(reactionNode, compartment); - if (reaction.isSetCompartment()) { - reactionHelper.setCompartment(reactionNode, compartment); - } - if (reaction.isSetId() - && Reaction.isValidId(reactionID, reaction.getLevel(), - reaction.getVersion())) { - reactionHelper.setID(reactionNode, reactionID); - } - // if(reaction.isSetReversible()){ - reactionHelper.setReversible(reactionNode, reversible); - // } - if (reaction.isSetFast()) { - reactionHelper.setFast(reactionNode, fast); - } - if (reaction.isSetSBOTerm()) { - reactionHelper.setSBOTerm(reactionNode, sboTerm); - } - if (reaction.isSetMetaId()) { - reactionHelper.setMetaID(reactionNode, metaID); - } - if (reaction.isSetNotes()) { - reactionHelper.setNotes(reactionNode, - reaction.getNotesString(), reaction.getNotes()); - } - - if (reaction.isSetAnnotation()) { - if (reaction.getAnnotation().isSetRDFannotation()) { - reactionHelper.setAnnotation(reactionNode, - reaction.getAnnotation()); - } - if (reaction.getAnnotation().isSetNonRDFannotation()) { - reactionHelper.setNonRDFAnnotation(reactionNode, reaction - .getAnnotation().getNonRDFannotation()); - } - } - - // Adds the edges between reactant node and reaction node - reactants = reaction.getListOfReactants(); - addReactants(g, reactants, reactionID, modelID, reactionNode, - reaction.getReversible(), reactionHelper); - - // Adds the edges between product node and reaction node - products = reaction.getListOfProducts(); - addProducts(g, products, reactionID, modelID, reactionNode, - reaction.getReversible(), reactionHelper); - - // Adds the edges between modifier node and reaction node - modifiers = reaction.getListOfModifiers(); - addModifier(g, modifiers, reactionNode, reactionHelper, reactionID); - - if (reaction.isSetKineticLaw()) { - kineticLaw = reaction.getKineticLaw(); - kineticLawHelper = new KineticLawHelper(g, reactionHelper.getReactionClones()); - metaID2 = kineticLaw.getMetaId(); - sboTerm2 = kineticLaw.getSBOTermID(); - kineticFormula = ""; - try { - if (kineticLaw.isSetMath()) { - if (null != kineticLaw.getMath()) { - kineticFormula = kineticLaw.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - if (kineticLaw.isSetMath()) { - kineticLawHelper.setFunction(reactionNode, kineticFormula); - } - if (kineticLaw.isSetSBOTerm()) { - kineticLawHelper.setSBOTerm(reactionNode, sboTerm2); - } - if (kineticLaw.isSetMetaId()) { - kineticLawHelper.setMetaId(reactionNode, metaID2); - } - if (kineticLaw.isSetNotes()) { - kineticLawHelper.setNotes(reactionNode, - kineticLaw.getNotesString(), kineticLaw.getNotes()); - } - if (kineticLaw.isSetAnnotation()) { - if (kineticLaw.getAnnotation().isSetRDFannotation()) { - kineticLawHelper.setAnnotation(reactionNode, - kineticLaw.getAnnotation()); - } - if (kineticLaw.getAnnotation().isSetNonRDFannotation()) { - kineticLawHelper.setNonRDFAnnotation(reactionNode, - kineticLaw.getAnnotation() - .getNonRDFannotation()); - } - } - - // Two ways to read in a Local Parameter. One way is deprecated. - if (kineticLaw.isSetListOfLocalParameters() - || kineticLaw.isSetListOfParameters()) { - listLocalParameter = null; - if (reaction.getModel().getLevel() == 3 - && reaction.getModel().getVersion() == 1) { - if (kineticLaw.isSetListOfLocalParameters()) { - listLocalParameter = kineticLaw - .getListOfLocalParameters(); - } - } else { - if (kineticLaw.isSetListOfParameters()) { - listLocalParameter = kineticLaw - .getListOfParameters(); - } - } - /* - * if(kineticLaw.isSetListOfParameters()){ - * listLocalParameter = kineticLaw.getListOfParameters(); } - * else if(kineticLaw.isSetListOfLocalParameters()){ - * listLocalParameter = - * kineticLaw.getListOfLocalParameters(); } - */ - - itLP = listLocalParameter.iterator(); - countLocalParameter = 1; - while (itLP.hasNext()) { - localParameter = itLP.next(); - internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - countLocalParameter).toString(); - presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - countLocalParameter).toString(); - - localParameterHelper = kineticLawHelper - .addLocalParemeter(g, presentedAttributeName, - internAttributeName); - - id = localParameter.getId(); - name = localParameter.getName(); - value = localParameter.getValue(); - if (value.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute value of reaction " - + reactionID - + " " - + presentedAttributeName - + " is not a valid double value."); - } - unit = localParameter.getUnits(); - - if (localParameter.isSetId()) { - localParameterHelper.setID(reactionNode, id); - } - if (localParameter.isSetName()) { - localParameterHelper.setName(reactionNode, name); - } - if (localParameter.isSetValue()) { - localParameterHelper.setValue(reactionNode, value); - } - if (localParameter.isSetUnits()) { - localParameterHelper.setUnits(reactionNode, unit); - } - if (localParameter.isSetMetaId()) { - localParameterHelper.setMetaID(reactionNode, - localParameter.getMetaId()); - } - if (localParameter.isSetSBOTerm()) { - localParameterHelper.setSBOTerm(reactionNode, - localParameter.getSBOTermID()); - } - if (localParameter.isSetNotes()) { - localParameterHelper.setNotes(reactionNode, - localParameter.getNotesString(), - localParameter.getNotes()); - } - if (localParameter.isSetAnnotation()) { - if (localParameter.getAnnotation() - .isSetRDFannotation()) { - localParameterHelper.setAnnotation( - reactionNode, - localParameter.getAnnotation()); - } - if (localParameter.getAnnotation() - .isSetNonRDFannotation()) { - localParameterHelper.setNonRDFAnnotation( - reactionNode, localParameter - .getAnnotation() - .getNonRDFannotation()); - } - } - - countLocalParameter++; - } - - } - } - - AttributeHelper.setLabel(AttributeHelper.getLabels(reactionNode) - .size(), reactionNode, reactionID, null, - AlignmentSetting.HIDDEN.toGMLstring()); - - if (SBML_Constants.isLayoutActive) { - processLayoutInformation(g, reaction, reactionHelper, reactionNode); - } - - } - } - - private void processLayoutInformation(Graph g, Reaction reaction, SBMLReactionHelper reactionHelper, Node reactionNode) { - ExtendedLayoutModel layoutModel = (ExtendedLayoutModel) reaction.getModel().getExtension(SBMLHelper.SBML_LAYOUT_EXTENSION_NAMESPACE); - if (layoutModel != null) { - - Layout layout = layoutModel.getListOfLayouts().iterator().next(); - ListOf currentReactionGlyphs = new ListOf(); - currentReactionGlyphs.setLevel(layout.getLevel()); - currentReactionGlyphs.setVersion(layout.getVersion()); - Iterator reactionGlyphListIt = layout.getListOfReactionGlyphs().iterator(); - String reactionID = reaction.getId(); - while (reactionGlyphListIt.hasNext()) { - ReactionGlyph nextReactionGlyph = reactionGlyphListIt.next(); - if (nextReactionGlyph.getReaction().equals(reactionID)) { - currentReactionGlyphs.add(nextReactionGlyph); - } - } - // for (int i = 0; i < currentReactionGlyphs.size(); i++) { - for (int i = 0; i < 1; i++) { - ReactionGlyph reactionGlyph = currentReactionGlyphs.get(i); - if (i == 0) { - reactionHelper.addReactionCloneToList(reactionID, reactionNode); - } - if (i >= 1) { - Node reactionNodeClone = g.addNodeCopy(reactionNode); - reactionHelper.addReactionCloneToList(reactionID, reactionNodeClone); - reactionNode = reactionNodeClone; - } - - AttributeHelper.setSize(reactionNode, 40, 40); - BoundingBox boundingBox = null; - if (reactionGlyph != null) - boundingBox = reactionGlyph.getBoundingBox(); - if (boundingBox != null) { - Dimensions dimensions = boundingBox.getDimensions(); - if (dimensions != null) { - double width = dimensions.getWidth(); - double height = dimensions.getHeight(); - AttributeHelper.setSize(reactionNode, width, height); - - if (reactionGlyph.isSetLayoutId()) { - String layoutId = reactionGlyph.getLayoutId(); - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, layoutId); - } - else { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, SBML_Constants.EMPTY); - } - - } else - { - AttributeHelper.setSize(reactionNode, 34, 34); -// System.out.println("reaction id '" + reactionID + "' has no width/height information."); - } - Point position = boundingBox.getPosition(); - if (position != null) { - double x = position.getX(); - double y = position.getY(); - AttributeHelper.setPosition(reactionNode, x, y); - String layoutId = reactionGlyph.getLayoutId(); - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, layoutId); - } else { - System.out.println("species id '" + reactionID + "' has no x/y information."); - } - } - } - } - } - - /** - * The method reads in reactants, products and modifiers. It is called from - * the method addReactions - * - * @param simpleRef - * the reactant, product or modifier object for the import - * @param Edge - * is the reaction node in the graph - * @param presentedHeadline - * is visible for the user - * @param internHeadline - * intern representation of the headline - */ - private void setSimpleSpeciesReferences(SimpleSpeciesReference simpleRef, - Edge edge, String headline, SBMLReactionHelper reactionHelper) { - /* - * String keySpecies = SBML_Constants.addToNiceIdList(presentedHeadline, - * "Species"); String keySpeciesReferenceID = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Species Reference ID"); String keySpeciesReferenceName = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Species Reference Name"); String keyMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Meta ID"); String - * keySBOTerm = SBML_Constants.addToNiceIdList(presentedHeadline, - * "SBOTerm"); String keyToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, "ToolTip"); - */ - - if (simpleRef instanceof org.sbml.jsbml.SpeciesReference) { - /* - * String keyStoichiometry = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Stoichiometry"); String keyConstant = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Constant"); - */ - if (((SpeciesReference) simpleRef).isSetStoichiometry()) { - reactionHelper.setStoichiometry(edge, - ((SpeciesReference) simpleRef).getStoichiometry()); - } - if (((SpeciesReference) simpleRef).isSetConstant()) { - reactionHelper.setConstant(edge, - ((SpeciesReference) simpleRef).getConstant()); - } - } - if (simpleRef.isSetSpecies()) { - reactionHelper.setSpecies(edge, simpleRef.getSpecies()); - } - if (simpleRef.isSetId()) { - reactionHelper.setID(edge, simpleRef.getId()); - } - if (simpleRef.isSetName()) { - reactionHelper.setName(edge, simpleRef.getName()); - } - if (AttributeHelper.getSBMLrole(edge).equals( - SBML_Constants.ROLE_REACTANT)) { - if (simpleRef.isSetMetaId()) { - reactionHelper.setMetaIDReactant(edge, simpleRef.getMetaId()); - } - if (simpleRef.isSetSBOTerm()) { - reactionHelper.setSBOTermReactant(edge, - simpleRef.getSBOTermID()); - } - if (simpleRef.isSetNotes()) { - reactionHelper.setNotesReactant(edge, - simpleRef.getNotesString(), simpleRef.getNotes()); - } - if (simpleRef.isSetAnnotation()) { - if (simpleRef.getAnnotation().isSetRDFannotation()) { - reactionHelper.setAnnotationReactant(edge, - simpleRef.getAnnotation()); - } - if (simpleRef.getAnnotation().isSetNonRDFannotation()) { - reactionHelper.setNonRDFAnnotationReactant(edge, simpleRef - .getAnnotation().getNonRDFannotation()); - } - } - } - if (AttributeHelper.getSBMLrole(edge).equals( - SBML_Constants.ROLE_PRODUCT)) { - if (simpleRef.isSetMetaId()) { - reactionHelper.setMetaIDProduct(edge, simpleRef.getMetaId()); - } - if (simpleRef.isSetSBOTerm()) { - reactionHelper - .setSBOTermProduct(edge, simpleRef.getSBOTermID()); - } - if (simpleRef.isSetNotes()) { - reactionHelper.setNotesProduct(edge, - simpleRef.getNotesString(), simpleRef.getNotes()); - } - if (simpleRef.isSetAnnotation()) { - if (simpleRef.getAnnotation().isSetRDFannotation()) { - reactionHelper.setAnnotationProduct(edge, - simpleRef.getAnnotation()); - } - if (simpleRef.getAnnotation().isSetNonRDFannotation()) { - reactionHelper.setNonRDFAnnotationProduct(edge, simpleRef - .getAnnotation().getNonRDFannotation()); - } - } - } - if (AttributeHelper.getSBMLrole(edge).equals( - SBML_Constants.ROLE_MODIFIER)) { - if (simpleRef.isSetMetaId()) { - reactionHelper.setMetaIDModifier(edge, simpleRef.getMetaId()); - } - if (simpleRef.isSetSBOTerm()) { - reactionHelper.setSBOTermModifier(edge, - simpleRef.getSBOTermID()); - } - if (simpleRef.isSetNotes()) { - reactionHelper.setNotesModifier(edge, - simpleRef.getNotesString(), simpleRef.getNotes()); - } - if (simpleRef.isSetAnnotation()) { - if (simpleRef.getAnnotation().isSetRDFannotation()) { - reactionHelper.setAnnotationModifier(edge, - simpleRef.getAnnotation()); - } - if (simpleRef.getAnnotation().isSetNonRDFannotation()) { - reactionHelper.setNonRDFAnnotationModifier(edge, simpleRef - .getAnnotation().getNonRDFannotation()); - } - } - } - } - - /** - * Adds an edge between an reaction node and a reactant - * - * @param g - * is the data structure for reading in the information. - * @param molecules - * contains the reactants of the reaction - * @param reactionID - * contains the reaction ID - * @param modelID - * contains the model ID - * @param reactionNode - * is the reaction node in the graph - * @param reversible - * indicates if the reaction is reversible - */ - private void addReactants(Graph g, ListOf molecules, - String reactionID, String modelID, Node reactionNode, - boolean reversible, SBMLReactionHelper reactionHelper) { - Iterator it = molecules.iterator(); - String stoichiometry; - SpeciesReference ref; - Edge newReactionEdge; - Node reactantNode; - while (it.hasNext()) { - ref = it.next(); - reactantNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - stoichiometry = Double.toString(ref.getStoichiometry()); - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + reactionID + " species " + ref.getSpecies() - + " is not a valid double value."); - } - newReactionEdge = g.addEdge(reactantNode, reactionNode, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - reactionHelper.addReactantCloneToList(reactionID, ref.getSpecies(), newReactionEdge); -// System.out.println("In Reaction Reader: " + reactionID + " " + ref.getSpecies()); - if (reversible) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - - AttributeHelper.setLabel(newReactionEdge, stoichiometry); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_REACTANT); - // AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - // SBML_Constants.REVERSIBLE, reversible); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge, - SBML_Constants.SBML, reactionHelper); - } - } - - /** - * Adds an edge between an reaction node and a product - * - * @param g - * is the data structure for reading in the information - * @param molecules - * contains the products of the reaction - * @param reactionID - * contains the reaction ID - * @param modelID - * contains the model ID - * @param reactionNode - * is the reaction node in the graph - * @param reversible - * indicates if the reaction is reversible - */ - private void addProducts(Graph g, ListOf molecules, - String reactionID, String modelID, Node reactionNode, - boolean reversible, SBMLReactionHelper reactionHelper) { - Iterator it = molecules.iterator(); - Edge newReactionEdge; - String stoichiometry; - String label; - Node productNode; - SpeciesReference ref; - while (it.hasNext()) { - ref = it.next(); - productNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - stoichiometry = Double.toString(ref.getStoichiometry()); - label = stoichiometry; - - newReactionEdge = g.addEdge(reactionNode, productNode, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - reactionHelper.addProductCloneToList(reactionID, ref.getSpecies(), newReactionEdge); - - if (reversible) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + reactionID + " species " + ref.getSpecies() - + " is not a valid double value."); - } - - AttributeHelper.setLabel(newReactionEdge, label); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_PRODUCT); - // AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - // SBML_Constants.REVERSIBLE, reversible); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge, - SBML_Constants.SBML, reactionHelper); - } - } - - /** - * Adds an edge between an reaction node and a modifier - * - * @param g - * is the data structure for reading in the information. - * @param molecules - * contains the modifiers of the reaction. - * @param reactionNode - * is the node that will be connected with the modifier - */ - private void addModifier(Graph g, - ListOf molecules, Node reactionNode, - SBMLReactionHelper reactionHelper, String reactionID) { - Iterator it = molecules.iterator(); - Edge reactionEdge; - ModifierSpeciesReference ref; - Node modifierNode; - while (it.hasNext()) { - ref = it.next(); - modifierNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - reactionEdge = g.addEdge(modifierNode, reactionNode, false, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.DARK_GRAY, Color.DARK_GRAY, true)); - - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_MODIFIER); - reactionHelper.addModifierCloneToList(reactionID, ref.getSpecies(), reactionEdge); - AttributeHelper.setDashInfo(reactionEdge, 5, 5); - AttributeHelper.setBorderWidth(reactionEdge, 1d); - setSimpleSpeciesReferences(ref, reactionEdge, SBML_Constants.SBML, - reactionHelper); - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Rule_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Rule_Reader.java deleted file mode 100644 index 1e6706c0b..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Rule_Reader.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * This class reads in Rules - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; - -import org.graffiti.graph.Graph; -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.Rule; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLAlgebraicRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLAssignmentRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLRateRule; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLRuleHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Rule_Reader { - - /** - * Method reads in rules and is called from class SBML_XML_Reader.java - * - * @param listOfRules - * contains the rules for the import - * @param g - * the data structure for reading in the information - */ - public void addRule(ListOf listOfRules, Graph g) { - Iterator itRule = listOfRules.iterator(); - int rateCount = 1; - int assignmentCount = 1; - int algebraicCount = 1; - SBMLRuleHelper ruleHelperObject = new SBMLRuleHelper(); - while (itRule.hasNext()) { - Rule rule = itRule.next(); - String metaID = rule.getMetaId(); - String sboTerm = rule.getSBOTermID(); - - String math = ""; - try { - if (rule.isSetMath()) { - if (null != rule.getMath()) { - math = rule.getMath().toFormula(); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - String variable = ""; - if (rule.isAssignment()) { - AssignmentRule assignment = (AssignmentRule) rule; - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_ASSIGNMENT_RULE).append( - assignmentCount).toString(); - String presentedHeadline = new StringBuffer( - "SBML Assignment Rule ").append(assignmentCount) - .toString(); - SBMLAssignmentRule assignmentRuleHelper = ruleHelperObject - .addAssignmentRule(g, internHeadline, presentedHeadline); - // initAssignmnetNiceIDs(internHeadline, presentedHeadline); - - /* - * String presentedHeadline = "SBML Assignment Rule " + - * assignmentCount; String internHeadline = - * getNiceHeadline(presentedHeadline); - * SBML_Constants.put(internHeadline, presentedHeadline); - */ - - /* - * String keyVariable = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Variable"); String keyFormula = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Formula"); - * String keyMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Meta ID"); - * String keySBOTerm = - * SBML_Constants.addToNiceIdList(presentedHeadline, "SBOTerm"); - * String keyToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, "ToolTip"); - */ - - variable = assignment.getVariable(); - if (assignment.isSetMetaId()) { - assignmentRuleHelper.setMetaID(metaID); - } - if (assignment.isSetSBOTerm()) { - assignmentRuleHelper.setSBOTerm(sboTerm); - } - if (assignment.isSetMath()) { - assignmentRuleHelper.setFunction(math); - } - if (assignment.isSetVariable()) { - assignmentRuleHelper.setVariable(variable); - } - if (assignment.isSetNotes()) { - assignmentRuleHelper.setNotes(rule.getNotesString(), - rule.getNotes()); - } - if (assignment.isSetAnnotation()) { - if (assignment.getAnnotation().isSetRDFannotation()) { - assignmentRuleHelper.setAnnotation(assignment - .getAnnotation()); - } - if (assignment.getAnnotation().isSetNonRDFannotation()) { - assignmentRuleHelper.setNonRDFAnnotation(assignment - .getAnnotation().getNonRDFannotation()); - } - } - - assignmentCount++; - } - if (rule.isAlgebraic()) { - AlgebraicRule algebraic = (AlgebraicRule) rule; - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_ALGEBRAIC_RULE).append( - algebraicCount).toString(); - String presentedHeadline = new StringBuffer( - "SBML Algebraic Rule ").append(algebraicCount) - .toString(); - - SBMLAlgebraicRule algebraicRuleHelper = ruleHelperObject - .addAlgebraicRule(g, internHeadline, presentedHeadline); - // initAlgebraicNiceIDs(internHeadline, presentedHeadline); - - /* - * String presentedHeadline = "SBML Algebraic Rule " + - * algebraicCount; String internHeadline = - * getNiceHeadline(presentedHeadline); - * SBML_Constants.put(internHeadline, presentedHeadline); - * String keyFormula = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Formula"); - * String keyMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Meta ID"); - * String keySBOTerm = - * SBML_Constants.addToNiceIdList(presentedHeadline, "SBOTerm"); - * String keyToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, "ToolTip"); - */ - - if (algebraic.isSetMetaId()) { - algebraicRuleHelper.setMetaID(metaID); - } - if (algebraic.isSetSBOTerm()) { - algebraicRuleHelper.setSBOTerm(sboTerm); - } - if (algebraic.isSetMath()) { - algebraicRuleHelper.setFunction(math); - } - if (algebraic.isSetNotes()) { - algebraicRuleHelper.setNotes(rule.getNotesString(), - rule.getNotes()); - } - if (algebraic.isSetAnnotation()) { - if (algebraic.getAnnotation().isSetRDFannotation()) { - algebraicRuleHelper.setAnnotation(algebraic - .getAnnotation()); - } - if (algebraic.getAnnotation().isSetNonRDFannotation()) { - algebraicRuleHelper.setNonRDFAnnotation(algebraic - .getAnnotation().getNonRDFannotation()); - } - } - - algebraicCount++; - } - if (rule.isRate()) { - RateRule rate = (RateRule) rule; - - String internHeadline = new StringBuffer( - SBML_Constants.SBML_RATE_RULE).append(rateCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Rate Rule ") - .append(rateCount).toString(); - SBMLRateRule rateRuleHelper = ruleHelperObject.addRateRule(g, - internHeadline, presentedHeadline); - // initRateNiceIDs(internHeadline, presentedHeadline); - - /* - * String presentedHeadline = "SBML Rate Rule " + rateCount; - * String internHeadline = getNiceHeadline(presentedHeadline); - * SBML_Constants.put(internHeadline, presentedHeadline); - * String keyVariable = - * SBML_Constants.addToNiceIdList(presentedHeadline, - * "Variable"); String keyFormula = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Formula"); - * String keyMetaId = - * SBML_Constants.addToNiceIdList(presentedHeadline, "Meta ID"); - * String keySBOTerm = - * SBML_Constants.addToNiceIdList(presentedHeadline, "SBOTerm"); - * String keyToolTip = - * SBML_Constants.addToNiceIdList(presentedHeadline, "ToolTip"); - */ - - variable = rate.getVariable(); - if (rate.isSetMetaId()) { - rateRuleHelper.setMetaID(metaID); - } - if (rate.isSetSBOTerm()) { - rateRuleHelper.setSBOTerm(sboTerm); - } - if (rate.isSetMath()) { - rateRuleHelper.setFunction(math); - } - if (rate.isSetVariable()) { - rateRuleHelper.setVariable(variable); - } - if (rate.isSetNotes()) { - rateRuleHelper.setNotes(rule.getNotesString(), - rule.getNotes()); - } - if (rate.isSetAnnotation()) { - if (rate.getAnnotation().isSetRDFannotation()) { - rateRuleHelper.setAnnotation(rate.getAnnotation()); - } - if (rate.getAnnotation().isSetNonRDFannotation()) { - rateRuleHelper.setNonRDFAnnotation(rate.getAnnotation() - .getNonRDFannotation()); - } - } - - rateCount++; - } - } - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBML_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBML_Reader.java deleted file mode 100644 index 089ac2e42..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBML_Reader.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * This class reads in the SBML Tag - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.HashMap; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.SBMLDocument; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_SBML_Reader extends SBML_SBase_Reader { - - /** - * Method reads in the model tag information and is called from class - * SBML_XML_Reader.java - * - * @param document - * contains the model for the import - * @param g - * the data structure for reading in the information - */ - public void addSBML(SBMLDocument document, Graph g) { - SBML_Constants.init(); - namespaceCollector = new HashMap(); - addNamespaces(document.getSBMLDocumentNamespaces(), g, - SBML_Constants.SBML, SBML_Constants.NAMESPACE); - - int level = document.getLevel(); - int version = document.getVersion(); - String metaID = document.getMetaId(); - String sboTerm = document.getSBOTermID(); - - if (document.isSetNotes()) { - addNotes(document.getNotes(), document.getNotesString(), g, - SBML_Constants.SBML, SBML_Constants.SBML_NOTES); - } - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_META_ID, metaID); - } - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_SBOTERM, sboTerm); - } - - if (document.isSetAnnotation()) { - if (document.getAnnotation().isSetRDFannotation()) { - if (null != document.getAnnotation()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_ANNOTATION, - document.getAnnotation()); - } - } - if (document.getAnnotation().isSetNonRDFannotation()) { - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.SBML_NON_RDF_ANNOTATION, document - .getAnnotation().getNonRDFannotation()); - - } - } - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.LEVEL, level); - AttributeHelper.setAttribute(g, SBML_Constants.SBML, - SBML_Constants.VERSION, version); - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBase_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBase_Reader.java deleted file mode 100644 index 527d66e60..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_SBase_Reader.java +++ /dev/null @@ -1,262 +0,0 @@ -/** - * Reads in Attributes from the class SBase. All other components of the - * model inherit from this class - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.awt.Color; -import java.awt.geom.Point2D; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.AttributeHelper; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.xml.XMLNamespaces; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_SBase_Reader { - - /** - * To make the code shorter - */ - public static final String ATT = AttributeHelper.attributeSeparator; - - /** - * Stores the namespaces which already has been added to the graph tab - */ - public static HashMap namespaceCollector; - - /** - * This method processes an string with xhtml content - * - * @param xhtml - * @return - */ - public static String removeTagFromString(String xhtml) { - String content = xhtml.replace("\n", "").replace("\t", "").trim(); - // Replace anything between script or style tags - // A regular expression to match anything in between <> - // Reads as: Match a "<" - // Match one or more characters that are not ">" - // Match "<"; - String tagregex = "<[^>]*>"; - Pattern p2 = Pattern.compile(tagregex); - Matcher m2 = p2.matcher(content); - // Replace any matches with nothing - content = m2.replaceAll(""); - return content.trim(); - } - - /** - * Method transforms an presented headline into an intern headline - * - * @param presentedHeadline - * is visible for the user - * @return - */ - public String getNiceHeadline(String presentedHeadline) { - return presentedHeadline.replaceAll(" ", "_").toLowerCase(); - } - - public void addNotes(XMLNode notesObject, String notesString, Edge e, - String path, String notesName) { - // addNamespaces(notesObject, g, "sbml", "sbml_namespaces"); - if ((null != notesString) - && !(SBML_Constants.EMPTY.equals(notesString))) { - // String notes = removeTagFromString(notesString); - // AttributeHelper.setAttribute(g, path, path+"_"+notesName, notes); - // AttributeHelper.setAttribute(e, path, notesName, notes); - AttributeHelper.setAttribute(e, path, notesName, notesObject); - } - } - - /** - * This method adds notes to the current object in the graph tab - * - * @param notesObject - * contains the notes in XML Node form - * @param notesString - * contains the notes as a String - * @param g - * is the data structure for reading in the information - * @param path - * intern representation where to add the notes - * @param notesName - * contains the presented headline and the presented attribute - * name - */ - public void addNotes(XMLNode notesObject, String notesString, Graph g, - String path, String notesName) { - addNamespaces(notesObject, g, "sbml", "sbml_namespaces"); - // if ((null != notesString) - // && !(SBML_Constants.EMPTY.equals(notesString))) { - // String notes = removeTagFromString(notesString); - // AttributeHelper.setAttribute(g, path, path+"_"+notesName, notes); - AttributeHelper.setAttribute(g, path, notesName, notesObject); - // } - } - - /** - * This method adds notes to the current object in the node tab - * - * @param notesObject - * contains the notes in XML Node form - * @param notesString - * contains the notes as a String - * @param node - * is the data structure for reading in the information - * @param path - * intern representation where to add the notes - * @param notesName - * contains the presented headline and the presented attribute - * name - */ - public void addNotes(XMLNode notesObject, String notesString, Node node, - String path, String notesName) { - addNamespaces(notesObject, node, path, notesName + " Namespace"); - if ((null != notesString) - && !(SBML_Constants.EMPTY.equals(notesString))) { - // String notes = removeTagFromString(notesString); - // AttributeHelper.setAttribute(node, path, notesName, notes); - AttributeHelper.setAttribute(node, path, notesName, notesObject); - } - } - - /** - * Method helps to set Attributes - * Creates nodes with 20, 20 height/width - * @param node - * the current node - * @param color - * the aimed color - * @param label - * label of the node - * @param point - * coordinates of the node - * @param size_multiplier - * determines the size of the node - */ - public void setAttributes(Node node, Color color, String label, - Point2D point, int size_multiplier) { - AttributeHelper.setDefaultGraphicsAttribute(node, point); - AttributeHelper.setLabel(node, label); - AttributeHelper.setSize(node, 20d/*label.length() * size_multiplier*/, 20d); - AttributeHelper.setFillColor(node, color); - } - - /** - * Adds the namespaces of an XMLNode to the graph tab - * - * @param node - * contains the namespaces - * @param g - * the graph that should be imported - */ - public static void addNamespaces(XMLNode node, Graph g, String path, - String attribute) { - if (node != null) { - if (!(node.isNamespacesEmpty())) { - XMLNamespaces ns = node.getNamespaces(); - String namespacesList = ""; - String namespaceAttribute = (String) AttributeHelper - .getAttributeValue(g, path, attribute, null, null); - if (namespaceAttribute != null) { - namespacesList = namespaceAttribute; - } - if (null != ns) { - for (int i = 0; i < ns.getLength(); i++) { - if (!(namespaceCollector.containsKey(ns.getPrefix(i)))) { - namespacesList += ns.getPrefix(i) + "=\"" - + ns.getURI(i) + "\""; - namespaceCollector.put(ns.getPrefix(i), - "=\"" + ns.getURI(i) + "\""); - } - } - } - AttributeHelper - .setAttribute(g, path, attribute, namespacesList); - } - } - } - - /** - * Adds the namespaces of an XMLNode to the graph tab - * - * @param node - * contains the namespaces - * @param g - * the graph that should be imported - */ - private void addNamespaces(XMLNode node, Node n, String path, - String attribute) { - if (node != null) { - if (!(node.isNamespacesEmpty())) { - XMLNamespaces ns = node.getNamespaces(); - String namespacesList = ""; - String namespaceAttribute = (String) AttributeHelper - .getAttributeValue(n, path, attribute, null, null); - if (namespaceAttribute != null) { - namespacesList = namespaceAttribute; - } - if (null != ns) { - for (int i = 0; i < ns.getLength(); i++) { - namespacesList += ns.getPrefix(i) + "=\"" - + ns.getURI(i) + "\""; - } - } - AttributeHelper - .setAttribute(n, path, attribute, namespacesList); - } - } - } - - /** - * Adds a map of namespaces (namespace, URL) to the graph tab. - * - * @param namespaces - * contains the namespaces and the URLs - * @param g - * the graph that should be imported - */ - public void addNamespaces(Map namespaces, Graph g, - String path, String attribute) { - if (namespaces != null) { - String namespacesList = ""; - String namespaceAttribute = (String) AttributeHelper - .getAttributeValue(g, path, attribute, null, null); - if (namespaceAttribute != null) { - namespacesList = namespaceAttribute; - } - Set> entries = namespaces.entrySet(); - for (Iterator> iterator = entries.iterator(); iterator - .hasNext();) { - Entry entry = (Entry) iterator - .next(); - if (!(namespaceCollector.containsKey(entry.getKey())) - && entry.getKey().contains(":")) { - namespacesList += (entry.getKey() + "=\"" - + entry.getValue() + "\" "); - namespaceCollector.put(entry.getKey(), - "=\"" + entry.getValue() + "\" "); - } - } - if (!namespacesList.isEmpty()) { - AttributeHelper - .setAttribute(g, path, attribute, namespacesList); - } - } - /* - * else { AttributeHelper.setAttribute(g, path, attribute, ""); } - */ - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Species_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Species_Reader.java deleted file mode 100644 index 3769bbf0a..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_Species_Reader.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This class reads in Species - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - -import org.AttributeHelper; -import org.ErrorMsg; -import org.PositionGridGenerator; -import org.graffiti.attributes.Attribute; -import org.graffiti.attributes.CollectionAttribute; -import org.graffiti.attributes.HashMapAttribute; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.ext.layout.BoundingBox; -import org.sbml.jsbml.ext.layout.Dimensions; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.Point; -import org.sbml.jsbml.ext.layout.SpeciesGlyph; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLSpeciesHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_Species_Reader { - - /** - * Provides useful methods - */ - SBMLSpeciesHelper speciesHelper; - - /** - * reads in species and is called from class SBML_XML_Reader.java. The - * method adds species to the graph and to the node tab - * - * @param g - * the data structure for reading in the information - * @param speciesList - * contains the species for the import - * @param pgg - * is needed for drawing the graph - */ - public void addSpecies(Graph g, ListOf speciesList, - PositionGridGenerator pgg, SBMLSpeciesHelper specieshelper) { - if (!speciesList.isEmpty()) { - speciesHelper = specieshelper; - Iterator itSpecies = speciesList.iterator(); - Node speciesNode; - Species speciesJSBML; - String id; - String name; - String compartment; - Double initialAmount; - Double initialConcentration; - String substanceUnits; - Boolean hasOnlySubstanceUnits; - Boolean boundaryCondition; - Boolean constant; - String conversionFactor; - String metaID; - XMLNode notesObj; - String notes; - Integer charge; - String sboTerm; - - while (itSpecies.hasNext()) { - speciesJSBML = itSpecies.next(); - speciesNode = g.addNode(); - id = speciesJSBML.getId(); - name = speciesJSBML.getName(); - speciesHelper.setLabel(speciesNode, name, id, pgg); - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_SPECIES); - AttributeHelper.setShapeEllipse(speciesNode); - AttributeHelper.setBorderWidth(speciesNode, 1d); - compartment = speciesJSBML.getCompartment(); - initialAmount = speciesJSBML.getInitialAmount(); - if (initialAmount.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute initialAmount of species " - + id - + " is not a valid double value or it is coexistent with the initialConcentration value."); - } - initialConcentration = speciesJSBML.getInitialConcentration(); - if (initialConcentration.equals(Double.NaN) - && !(speciesJSBML.isSetInitialAmount())) { - ErrorMsg.addErrorMessage("Attribute initialConcentration of species " - + id - + " is not a valid double value or it is coexistent with the initialAmount value."); - } - substanceUnits = speciesJSBML.getSubstanceUnits(); - hasOnlySubstanceUnits = speciesJSBML.getHasOnlySubstanceUnits(); - boundaryCondition = speciesJSBML.getBoundaryCondition(); - constant = speciesJSBML.getConstant(); - conversionFactor = speciesJSBML.getConversionFactor(); - metaID = speciesJSBML.getMetaId(); - sboTerm = speciesJSBML.getSBOTermID(); - notesObj = speciesJSBML.getNotes(); - notes = speciesJSBML.getNotesString(); - charge = speciesJSBML.getCharge(); - - if (speciesJSBML.isSetId() - && Species.isValidId(id, speciesJSBML.getLevel(), - speciesJSBML.getVersion())) { - speciesHelper.setID(speciesNode, id); - speciesHelper.setHiddenLabel(speciesNode, id); - } - if (speciesJSBML.isSetCompartment()) { - speciesHelper.setCompartment(speciesNode, compartment); - } - if (speciesJSBML.isSetInitialAmount()) { - speciesHelper.setInitialAmount(speciesNode, initialAmount); - } - if (speciesJSBML.isSetInitialConcentration()) { - speciesHelper.setInitialConcentration(speciesNode, - initialConcentration); - } - if (speciesJSBML.isSetSubstanceUnits()) { - speciesHelper - .setSubstanceUnits(speciesNode, substanceUnits); - } - if (speciesJSBML.isSetHasOnlySubstanceUnits()) { - speciesHelper.setHasOnlySubstanceUnits(speciesNode, - hasOnlySubstanceUnits); - } -// if (speciesJSBML.isSetBoundaryCondition()) { - speciesHelper.setBoundaryConsition(speciesNode, - boundaryCondition); -// } - if (speciesJSBML.isSetConstant()) { - speciesHelper.setConstant(speciesNode, constant); - } - if (speciesJSBML.isSetConversionFactor()) { - speciesHelper.setConversionFactor(speciesNode, - conversionFactor); - } - if (speciesJSBML.isSetMetaId()) { - speciesHelper.setMetaID(speciesNode, metaID); - } - if (speciesJSBML.isSetSBOTerm()) { - speciesHelper.setSBOTerm(speciesNode, sboTerm); - } - if (speciesJSBML.isSetNotes()) { - speciesHelper.setNotes(speciesNode, notes, notesObj); - } - if (speciesJSBML.isSetAnnotation()) { - if (speciesJSBML.getAnnotation().isSetRDFannotation()) { - speciesHelper.setAnnotation(speciesNode, - speciesJSBML.getAnnotation()); - } - if (speciesJSBML.getAnnotation().isSetNonRDFannotation()) { - speciesHelper.setNonRDFAnnotation(speciesNode, - speciesJSBML.getAnnotation() - .getNonRDFannotation()); - } - } - if (speciesJSBML.isSetCharge()) { - speciesHelper.setCharge(speciesNode, charge); - } - if (speciesJSBML.isSetCompartment()) { - speciesHelper.setCompartmentName(speciesNode); - } - if (SBML_Constants.isLayoutActive) { - processLayoutInformation(g, speciesJSBML, speciesNode); - } - } - } - } - - private void processLayoutInformation(Graph g, Species speciesJSBML, Node speciesNode) { - String id = speciesJSBML.getId(); - ExtendedLayoutModel layoutModel = (ExtendedLayoutModel) speciesJSBML.getModel().getExtension(SBMLHelper.SBML_LAYOUT_EXTENSION_NAMESPACE); - if (layoutModel != null) { - Layout layout = layoutModel.getListOfLayouts().iterator().next(); - ListOf currentSpeciesGlyphs = new ListOf(); - currentSpeciesGlyphs.setLevel(layout.getLevel()); - currentSpeciesGlyphs.setVersion(layout.getVersion()); - Iterator speciesGlyphListIt = layout.getListOfSpeciesGlyphs().iterator(); - while (speciesGlyphListIt.hasNext()) { - SpeciesGlyph nextSpeciesGlyph = speciesGlyphListIt.next(); - if (nextSpeciesGlyph.getSpecies().equals(id)) { - nextSpeciesGlyph.setVersion(1); - currentSpeciesGlyphs.add(nextSpeciesGlyph); - - } - } - for (int i = 0; i < currentSpeciesGlyphs.size(); i++) { - SpeciesGlyph speciesGlyph = currentSpeciesGlyphs.get(i); - - if (i == 0) { - speciesHelper.addCloneToList(id, speciesNode); - } - if (i >= 1) { - Node speciesNodeClone = g.addNodeCopy(speciesNode); - speciesHelper.addCloneToList(id, speciesNodeClone); - speciesNode = speciesNodeClone; - } - - AttributeHelper.setSize(speciesNode, 27, 27); - // SpeciesGlyph speciesGlyph = speciesGlyphs.get(i); - BoundingBox boundingBox = speciesGlyph.getBoundingBox(); - if (boundingBox != null) { - Dimensions dimensions = boundingBox.getDimensions(); - if (dimensions != null) { - double width = dimensions.getWidth(); - double height = dimensions.getHeight(); - AttributeHelper.setSize(speciesNode, width, height); - - if (speciesGlyph.isSetLayoutId()) { - String layoutId = speciesGlyph.getLayoutId(); - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, layoutId); - } - else { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, SBML_Constants.EMPTY); - } - } else - { - AttributeHelper.setSize(speciesNode, 27, 27); - } - Point position = boundingBox.getPosition(); - if (position != null) { - double x = position.getX(); - double y = position.getY(); - AttributeHelper.setPosition(speciesNode, x, y); - String layoutId = speciesGlyph.getLayoutId(); - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, layoutId); - } - } - } - } - - } - - private void printAllSBMLAttributes(Node species) { - CollectionAttribute collection = species.getAttributes(); - Map map = collection.getCollection(); - for (Entry entry : map.entrySet()) { - Attribute attr = entry.getValue(); - HashMapAttribute attrHashMap = (HashMapAttribute) attr; - TreeMap collectionAttr = (TreeMap) attr.getValue(); - for (Entry entryAttr : collectionAttr.entrySet()) { - - String[] attrSeparates = entryAttr.getValue().getPath().split("\\" + Attribute.SEPARATOR); - for (String name : attrSeparates) { - } - - } - } - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_UnitDefinition_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_UnitDefinition_Reader.java deleted file mode 100644 index 39264d032..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_UnitDefinition_Reader.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * This class reads in UnitDefinitions - */ - -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.ErrorMsg; -import org.graffiti.graph.Graph; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLUnit; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLUnitDefinition; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLUnitDefinitionHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -public class SBML_UnitDefinition_Reader { - - /** - * Method reads in unit definitions and is called from class - * SBML_XML_Reader.java - * - * @param unitDefinitionList - * contains the unit definitions for the import - * @param g - * the data structure for reading in the information - */ - public void addUnitDefinitions(ListOf unitDefinitionList, - Graph g) { - Iterator itUnitDefinition = unitDefinitionList - .iterator(); - int unitCount = 1; - SBMLUnitDefinitionHelper unitDefinitionHelperObject = new SBMLUnitDefinitionHelper(); - while (itUnitDefinition.hasNext()) { - int subUnitCount = 1; - UnitDefinition unitDefinition = itUnitDefinition.next(); - String internHeadline = new StringBuffer( - SBML_Constants.SBML_UNIT_DEFINITION).append(unitCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Unit Definition ") - .append(unitCount).toString(); - SBMLUnitDefinition unitDefinitionHelper = unitDefinitionHelperObject - .addUnitDefinition(g, internHeadline, presentedHeadline); - - String unitDefinitionID = unitDefinition.getId(); - String unitDefinitionName = unitDefinition.getName(); - String unitDefinitionSBOTerm = ""; - if (unitDefinition.isSetSBOTerm()) { - unitDefinitionSBOTerm = unitDefinition.getSBOTermID(); - } - String unitDefinitionMetaID = ""; - if (unitDefinition.isSetMetaId()) { - unitDefinitionMetaID = unitDefinition.getMetaId(); - } - - if (unitDefinition.isSetNotes()) { - unitDefinitionHelper.setNotes(unitDefinition.getNotesString(), - unitDefinition.getNotes()); - } - if (unitDefinition.isSetId() - && UnitDefinition.isValidId(unitDefinitionID, - unitDefinition.getLevel(), - unitDefinition.getVersion())) { - ; - unitDefinitionHelper.setID(unitDefinitionID); - } - if (unitDefinition.isSetName()) { - unitDefinitionHelper.setName(unitDefinitionName); - } - if (unitDefinition.isSetMetaId()) { - unitDefinitionHelper.setMetaID(unitDefinitionMetaID); - } - if (unitDefinition.isSetSBOTerm()) { - unitDefinitionHelper.setSBOTerm(unitDefinitionSBOTerm); - } - if (unitDefinition.isSetAnnotation()) { - if (unitDefinition.getAnnotation().isSetRDFannotation()) { - unitDefinitionHelper.setAnnotation(unitDefinition - .getAnnotation()); - } - if (unitDefinition.getAnnotation().isSetNonRDFannotation()) { - unitDefinitionHelper.setNonRDFAnnotation(unitDefinition - .getAnnotation().getNonRDFannotation()); - } - } - // The sub units are collected in this list - List ListOfSubUnits = new ArrayList(); - if (unitDefinition.isSetListOfUnits()) { - List unitList = unitDefinition.getListOfUnits(); - Iterator itUnit = unitList.iterator(); - SBMLUnit unitHelper = null; - while (itUnit.hasNext()) { - unitHelper = unitDefinitionHelper.addUnit(subUnitCount); - Unit unit = itUnit.next(); - int scale = unit.getScale(); - Double exponent = unit.getExponent(); - if (exponent.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute exponent of unit definition " - + unitCount - + " sub unit " - + subUnitCount - + " with the id " - + unitDefinitionID - + " is not a valid double value."); - } - Double multiplier = unit.getMultiplier(); - if (multiplier.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute multiplier of unit definition " - + unitCount - + " sub unit " - + subUnitCount - + " with the id " - + unitDefinitionID - + " is not a valid double value."); - } - String kind = unit.getKind().getName(); - String composedSubUnit = "(" + multiplier + " * 10^" - + scale + " * " + kind + ")^" + exponent; - - unitHelper.setComposedSubUnit(composedSubUnit); - if (unit.isSetMetaId()) { - unitHelper.setMetaID(unit.getMetaId()); - } - if (unit.isSetSBOTerm()) { - unitHelper.setSBOTerm(unit.getSBOTermID()); - } - if (unit.isSetNotes()) { - unitHelper.setNotes(unit.getNotesString(), - unit.getNotes()); - } - if (unit.isSetAnnotation()) { - if (unit.getAnnotation().isSetRDFannotation()) { - unitHelper.setAnnotation(unit.getAnnotation()); - } - if (unit.getAnnotation().isSetNonRDFannotation()) { - unitHelper.setNonRDFAnnotation(unit.getAnnotation() - .getNonRDFannotation()); - } - } - ListOfSubUnits.add(composedSubUnit); - - subUnitCount++; - } - String composedUnit = ""; - int size = ListOfSubUnits.size(); - int count = 0; - Iterator itSubUnits = ListOfSubUnits.iterator(); - while (itSubUnits.hasNext()) { - String subUnit = itSubUnits.next(); - composedUnit = composedUnit + subUnit; - count++; - if (count < size) { - composedUnit = composedUnit + " * "; - } - } - unitHelper.setComposedUnit(composedUnit); - } - - unitCount++; - } - - } -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_Reader.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_Reader.java deleted file mode 100644 index 0b3b69cfa..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_Reader.java +++ /dev/null @@ -1,351 +0,0 @@ -/** - * This class reads in SBML files - */ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.io.Reader; -import java.net.URL; -import java.net.URLConnection; -import java.util.List; - -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.xml.stream.XMLStreamException; - -import org.ErrorMsg; -import org.apache.log4j.Logger; -import org.graffiti.editor.GravistoService; -import org.graffiti.editor.MainFrame; -import org.graffiti.graph.Graph; -import org.graffiti.plugin.io.AbstractInputSerializer; -import org.jdom.Document; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLError; -import org.sbml.jsbml.SBMLErrorLog; -import org.sbml.jsbml.SBMLReader; -import org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_XML_ReaderWriterPlugin; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskGUIprovider; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskPanelEntry; -import de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskStatusProviderSupportingExternalCallImpl; - -public class SBML_XML_Reader extends AbstractInputSerializer { - - static Logger logger = Logger.getLogger(SBML_XML_Reader.class); - - public SBML_XML_Reader() { - // System.out.println("SBML_XML_Reader with layout constructor"); - } - - /** - * Method controls the import of the SBML document. - * - * @param document - * contains the data to be imported. - * @param g - * is the data structure for reading in the information. - */ - - public void read(final SBMLDocument document, Graph g, - BackgroundTaskStatusProviderSupportingExternalCallImpl status) { - - try { - - boolean readIn = false; - URL url = new URL("http://sbml.org/Facilities/Validator/"); - URLConnection connection = url.openConnection(); - InputStream is = null; - try { - is = connection.getInputStream(); - } catch (Exception e) { - // ErrorMsg.addErrorMessage("No internet connection"); - readIn = true; - /* - * JOptionPane.showMessageDialog(null, - * "Online validation not possible."); - */ - } - - if (null != is) { - - int validate = 1; - if (!SBML_XML_ReaderWriterPlugin.isTestintMode) - validate = JOptionPane - .showConfirmDialog( - null, - "Do you want to validate the SBML file against the Level 3 Version 1 specification?"); - if (validate == 0) { - - document.setConsistencyChecks( - CHECK_CATEGORY.GENERAL_CONSISTENCY, true); - document.setConsistencyChecks( - CHECK_CATEGORY.IDENTIFIER_CONSISTENCY, true); - document.setConsistencyChecks( - CHECK_CATEGORY.UNITS_CONSISTENCY, true); - document.setConsistencyChecks( - CHECK_CATEGORY.MATHML_CONSISTENCY, true); - document.setConsistencyChecks( - CHECK_CATEGORY.MODELING_PRACTICE, true); - document.setConsistencyChecks( - CHECK_CATEGORY.SBO_CONSISTENCY, true); - document.setConsistencyChecks( - CHECK_CATEGORY.OVERDETERMINED_MODEL, true); - - int numberOfErrors = document.checkConsistency(); - if (numberOfErrors > 0) { - SBMLErrorLog errorLog = document.getListOfErrors(); - for (int i = 0; i < numberOfErrors; i++) { - ErrorMsg.addErrorMessage(errorLog.getError(i)); - } - } - if (numberOfErrors > 0) { - int load = JOptionPane - .showConfirmDialog(null, - "The online validator detected mistakes in the file. Load anyway?"); - if (load == 0) { - readIn = true; - } - } - if (numberOfErrors == 0) { - readIn = true; - } - } - if (validate == 1) { - readIn = true; - } - } else { - readIn = true; - JOptionPane.showMessageDialog(null, - "Online validation not possible."); - } - - // to indicate an possible Exception - for example - // NullPointerException - - if (readIn) { - SBML_SBML_Reader readSBML = new SBML_SBML_Reader(); - readSBML.addSBML(document, g); - SBML_Model_Reader readModel = new SBML_Model_Reader(); - readModel.controlImport(document, g, status); - SBMLErrorLog errors = document.getListOfErrors(); - List validationErrors = errors.getValidationErrors(); - for (SBMLError sbmlError : validationErrors) { - ErrorMsg.addErrorMessage(sbmlError.getMessage() + ": at " - + sbmlError.getLocation().toString() - + "\n near by: " + sbmlError.getExcerpt()); - } - } - - } catch (Exception e) { - e.printStackTrace(); - ErrorMsg.addErrorMessage(e.getMessage()); - } - } - - public void read(final Reader reader, final Graph g) throws Exception { - long starttime = System.currentTimeMillis(); - - final BackgroundTaskStatusProviderSupportingExternalCallImpl status = new BackgroundTaskStatusProviderSupportingExternalCallImpl( - "Load SBML", ""); - final BackgroundTaskGUIprovider taskWindow; - taskWindow = new BackgroundTaskPanelEntry(false); - taskWindow.setStatusProvider(status, "SBML Loader", - "loading from reader"); - - final MainFrame mf = GravistoService.getInstance().getMainFrame(); - if (mf != null) - mf.addStatusPanel((JPanel) taskWindow); - - try { - - status.setCurrentStatusText2("Please wait. This may take a few moments."); - - SAXBuilder builder = new SAXBuilder(); - Document document; - - SBMLDocument sbmlDocument; - - document = builder.build(reader); - if (status.wantsToStop()) { - logger.debug("aborting load"); - taskWindow.setTaskFinished(true, 0); - return; - } - SBMLReader sbmlReader = new SBMLReader(); - status.setCurrentStatusText1("loading SBML document"); - status.setCurrentStatusValue(30); - try { - logger.info("start parsing sbml documet (Reader)"); - sbmlDocument = sbmlReader.readSBMLFromString(document - .toString()); - - if (sbmlDocument != null) { - if (status.wantsToStop()) { - logger.debug("aborting load"); - taskWindow.setTaskFinished(true, 0); - return; - } - status.setCurrentStatusText1("creating SBML graph"); - status.setCurrentStatusValue(60); - read(sbmlDocument, g, status); - if (status.wantsToStop()) { - logger.debug("aborting load"); - taskWindow.setTaskFinished(true, 0); - return; - } - status.setCurrentStatusText1("adding graph to window"); - status.setCurrentStatusValue(90); - - status.setCurrentStatusText1("building graph"); - } else { - ErrorMsg - .addErrorMessage("Document can not be loaded. Check the document manually with the online validator (http://sbml.org/Facilities/Validator/)."); - } - } catch (XMLStreamException e) { - ErrorMsg.addErrorMessage(e); - } - } catch (JDOMException e) { - ErrorMsg.addErrorMessage(e); - } catch (IOException e) { - ErrorMsg.addErrorMessage(e); - } catch (Exception e) { - ErrorMsg.addErrorMessage(e); - } - long endtime = System.currentTimeMillis(); - taskWindow.setTaskFinished(true, endtime - starttime); - - } - - public void read(final InputStream in, final Graph g) throws IOException { - - long starttime = System.currentTimeMillis(); - - final BackgroundTaskStatusProviderSupportingExternalCallImpl status = new BackgroundTaskStatusProviderSupportingExternalCallImpl( - "Load SBML", ""); - final BackgroundTaskGUIprovider taskWindow; - taskWindow = new BackgroundTaskPanelEntry(false); - taskWindow.setStatusProvider(status, "SBML Loader", - "loading from stream"); - - final MainFrame mf = GravistoService.getInstance().getMainFrame(); - if (mf != null) - mf.addStatusPanel((JPanel) taskWindow); - - try { - status.setCurrentStatusText2("Please wait. This may take a few moments."); - - SBMLReader reader = new SBMLReader(); - SBMLDocument document = null; - status.setCurrentStatusText1("loading SBML document"); - status.setCurrentStatusValue(30); - logger.info("start parsing sbml documet (InputStream)"); - document = reader.readSBMLFromStream(in); - if (document != null) { - if (status.wantsToStop()) { - logger.debug("aborting load"); - taskWindow.setTaskFinished(true, 0); - return; - } - read(document, g, status); - if (status.wantsToStop()) { - logger.debug("aborting load"); - taskWindow.setTaskFinished(true, 0); - return; - } - logger.debug("done reading graph"); - status.setCurrentStatusText1("adding graph to window"); - status.setCurrentStatusValue(100); - } else { - logger.info("the sbml document is not valid."); - ErrorMsg - .addErrorMessage("Document can not be loaded. Check the document manually with the online validator (http://sbml.org/Facilities/Validator/)."); - } - } catch (XMLStreamException error) { - - ErrorMsg.addErrorMessage(error); - - logger.error(error.getMessage()); - try { - error.printStackTrace(new PrintWriter("stack_trace.txt")); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - error.printStackTrace(); - } - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - ErrorMsg.addErrorMessage(e); - } - long endtime = System.currentTimeMillis(); - taskWindow.setTaskFinished(true, endtime - starttime); - - } - - @Override - public boolean validFor(InputStream reader) { - return validSBML(reader); - } - - Boolean validSBML(InputStream in) { - InputStreamReader reader = new InputStreamReader(in); - - BufferedReader bufferedReader = new BufferedReader(reader); - StringBuffer finalString = new StringBuffer(); - try { - while (bufferedReader.ready()) { - finalString = finalString.append(bufferedReader.readLine()); - } - } catch (IOException e) { - e.printStackTrace(); - } - String content = finalString.toString(); - content = content.trim(); - try { - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - if (content.contains("sbml") && content.contains("model") - && content.contains("version") && content.contains("level")) { - return true; - } else { - return false; - } - } - - /** - * Implemented method of interface InputSerializer.java Returns the - * extension of files that can be read in with the SBML importer - */ - public String[] getExtensions() { - - String[] ext = new String[] { ".sbml", ".xml" }; - return ext; - } - - /** - * Implemented method of interface InputSerializer.java Returns the - * description of the input format - */ - public String[] getFileTypeDescriptions() { - String[] desc = new String[] { "SBML", "SBML" }; - return desc; - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_ReaderPlugin.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_ReaderPlugin.java deleted file mode 100644 index a858fa02e..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/SBML_XML_ReaderPlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Plant Bioinformatics Group, IPK Gatersleben - *******************************************************************************/ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml; - -import org.graffiti.plugin.io.InputSerializer; - -import de.ipk_gatersleben.ag_nw.graffiti.IPK_PluginAdapter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBMLNodesNiceIdHelper; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml.SBML_Constants; - -/** - * DOCUMENT ME! - * - * @author Dagmar Kutz, Matthias Klapperstück - */ -public class SBML_XML_ReaderPlugin extends IPK_PluginAdapter { - - public SBML_XML_ReaderPlugin() { - - super(); - SBMLNodesNiceIdHelper.initNiceIds(); - SBML_Constants.init(); - this.inputSerializers = new InputSerializer[] { - new SBML_XML_Reader() - }; - - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/plugin.xml b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/plugin.xml deleted file mode 100644 index ba390122d..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/sbml/plugin.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Dagmar Kutz, Matthias Klapperstück - SBML-XML-Reader - - - SBML-XML-Reader -
de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_XML_ReaderPlugin
- 1.0.0 - mailto:klapper@ipk-gatersleben.de -
-
diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/KineticLawHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/KineticLawHelper.java deleted file mode 100644 index 54e2ebaee..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/KineticLawHelper.java +++ /dev/null @@ -1,507 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.AttributeHelper; -import org.BackgroundTaskStatusProviderSupportingExternalCall; -import org.graffiti.attributes.Attributable; -import org.graffiti.event.AttributeEvent; -import org.graffiti.event.AttributeListener; -import org.graffiti.event.ListenerManager; -import org.graffiti.event.TransactionEvent; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class KineticLawHelper implements AttributeListener { - - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - Map> _reactionClones; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - List localParameterList; - - /** - * Constructor. Initializes the graph - * - * @param g - * the graph where the information is read from - */ - public KineticLawHelper(Graph g, Map> reactionClones) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - _reactionClones = reactionClones; - localParameterList = new ArrayList(); - initKineticLawNideIDs(); - ListenerManager listenerManager = g.getListenerManager(); - listenerManager.addAllTimeAttributeListener(this); - } - - public SBMLLocalParameter addLocalParemeter(Graph g, - String presentedAttributeName, String internAttributeName) { - SBMLLocalParameter localParameter = new SBMLLocalParameter(g, - presentedAttributeName, internAttributeName); - localParameterList.add(localParameter); - return localParameter; - } - - public SBMLLocalParameter addLocalParameter(Graph g, int localParameterCount) { - SBMLLocalParameter localParameter = new SBMLLocalParameter(g, - localParameterCount); - localParameterList.add(localParameter); - return localParameter; - } - - public void setMetaId(Node reactionNode, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_META_ID, metaID); - } - } - - public Boolean isSetMetaID(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_META_ID)) { - return true; - } else { - return false; - } - } - - public String getMetaID(Node reactionNode) { - if (isSetMetaID(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteMetaID(Node reactionNode) { - if (isSetMetaID(reactionNode)) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_META_ID); - } - } - - public void setSBOTerm(Node reactionNode, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_SBOTERM, sboTerm); - } - } - - public String getSBOTerm(Node reactionNode) { - if (isSetSBOTerm(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteSBOTerm(Node reactionNode) { - if (isSetSBOTerm(reactionNode)) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_SBOTERM); - } - } - - public Boolean isSetSBOTerm(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_SBOTERM)) { - return true; - } else { - return false; - } - } - - public void setAnnotation(Node reactionNode, Annotation annotation) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_ANNOTATION, annotation); - } - - public Boolean isSetAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void deleteAnnotation(Node reactionNode) { - if (isSetAnnotation(reactionNode)) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_ANNOTATION); - } - } - - public Annotation getAnnotation(Node reactionNode) { - if (isSetAnnotation(reactionNode)) { - return (Annotation) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_ANNOTATION); - } else { - return null; - } - } - - public void setNonRDFAnnotation(Node reactionNode, String nonRDFAnnotation) { - AttributeHelper - .setAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION, - nonRDFAnnotation); - } - - public Boolean isSetNonRDFAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void deleteNonRDFAnnotation(Node reactionNode) { - if (isSetNonRDFAnnotation(reactionNode)) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION); - } - } - - public String getNonRDFAnnotation(Node reactionNode) { - if (isSetNonRDFAnnotation(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setFunction(Node reactionNode, String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION, function); - } - } - - public void setNotes(Node reactionNode, String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_NOTES); - } - } - - public Boolean isSetNotes(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_NOTES)) { - return true; - } else { - return false; - } - } - - public XMLNode getNotes(Node reactionNode) { - if (isSetNotes(reactionNode)) { - return (XMLNode) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_NOTES); - } else { - return null; - } - } - - public void deleteNotes(Node reactionNode) { - if (isSetNotes(reactionNode)) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_NOTES); - } - } - - public Boolean isSetFunction(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION)) { - return true; - } else { - return false; - } - } - - public String getFunction(Node reactionNode) { - if (isSetFunction(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initKineticLawNideIDs() { - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_NOTES, - "SBML Kinetic Law: Notes"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_META_ID, - "SBML Kinetic Law: Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_SBOTERM, - "SBML Kinetic Law: SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_FUNCTION, - "SBML Kinetic Law: Function"); - } - - @Override - public void transactionFinished(TransactionEvent e, BackgroundTaskStatusProviderSupportingExternalCall status) { - - } - - @Override - public void transactionStarted(TransactionEvent e) { - - } - - @Override - public void postAttributeAdded(AttributeEvent e) { - - } - - @Override - public void postAttributeChanged(AttributeEvent e) { - Attributable attributeable = e.getAttributeable(); - if (attributeable instanceof Node) { - if (SBML_Constants.ROLE_REACTION.equals(AttributeHelper.getSBMLrole((Node) attributeable))) { - Node reactionNode = (Node) attributeable; - propagateChanges(reactionNode, e.getAttribute().getName(), e.getAttribute().getValue()); - } - } - } - - private void propagateChanges(Node reactionNode, String attributeName, Object newValue) { - String reactionId = SBMLHelper.getReactionID(reactionNode); - List reactionNodes = _reactionClones.get(reactionId); - if (reactionNodes == null) { - reactionNodes = new ArrayList(); - } - for (Node node : reactionNodes) { - - if (newValue instanceof String && SBMLHelper.isKineticLawFunction(reactionNode)) { - String function = (String) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_FUNCTION) && function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, SBML_Constants.KINETIC_LAW_FUNCTION); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_FUNCTION) && !SBMLHelper.getKineticLawFunction(node).equals(function)) { - setFunction(node, function); - continue; - } - } - if (newValue instanceof String && isSetMetaID(reactionNode)) { - String metaID = (String) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_META_ID) && metaID.equals(SBML_Constants.EMPTY)) { - deleteMetaID(node); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_META_ID) && !getMetaID(node).equals(metaID)) { - setMetaId(node, metaID); - continue; - } - } - if (newValue instanceof String && isSetSBOTerm(reactionNode)) { - String sboTerm = (String) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_SBOTERM) && sboTerm.equals(SBML_Constants.EMPTY)) { - deleteSBOTerm(node); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_SBOTERM) && !getSBOTerm(node).equals(sboTerm)) { - setSBOTerm(node, sboTerm); - continue; - } - } - - if (newValue instanceof XMLNode && isSetNotes(reactionNode)) { - XMLNode notes = (XMLNode) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_NOTES) && notes.equals(SBML_Constants.EMPTY)) { - deleteNotes(node); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_NOTES) && !getNotes(node).equals(notes)) { - setNotes(node, notes.toString(), notes); - continue; - } - } - if (newValue instanceof Annotation && isSetAnnotation(reactionNode)) { - Annotation annotation = (Annotation) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_ANNOTATION) && annotation.equals(SBML_Constants.EMPTY)) { - deleteAnnotation(node); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_ANNOTATION) && !getAnnotation(node).equals(annotation)) { - setAnnotation(node, annotation); - continue; - } - } - - if (newValue instanceof String && isSetNonRDFAnnotation(reactionNode)) { - String annotation = (String) newValue; - if (attributeName.equals(SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION) && annotation.equals(SBML_Constants.EMPTY)) { - deleteNonRDFAnnotation(node); - } else if (attributeName.equals(SBML_Constants.KINETIC_LAW_NON_RDF_ANNOTATION) && !getNonRDFAnnotation(node).equals(annotation)) { - setNonRDFAnnotation(node, annotation); - continue; - } - } - - Iterator localParameterIt = localParameterList.iterator(); - int count = 1; - while (localParameterIt.hasNext()) { - SBMLLocalParameter localParameter = localParameterIt.next(); - if (newValue instanceof String && SBMLHelper.isLocalParameterID(reactionNode, count)) { - String localParameterName = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.LOCAL_PARAMETER_ID; - - String id = (String) newValue; - if (id.equals(SBML_Constants.EMPTY)) { - SBMLHelper.deleteLocalParameterID(node, id); - } - else if (attributeName.equals(localParameterName) && !SBMLHelper.getLocalParameterID(node, count).equals(id)) { - localParameter.setID(node, id); - continue; - } - } - if (newValue instanceof String && SBMLHelper.isLocalParameterName(reactionNode, count)) { - String localParameterName = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.LOCAL_PARAMETER_NAME; - - String name = (String) newValue; - if (name.equals(SBML_Constants.EMPTY)) { - SBMLHelper.deleteLocalParameterName(node, SBMLHelper.getLocalParameterID(node, count)); - } - else if (attributeName.equals(localParameterName) && !SBMLHelper.getLocalParameterName(node, count).equals(name)) { - localParameter.setName(node, name); - continue; - } - - } - if (newValue instanceof Double && SBMLHelper.isLocalParameterValue(reactionNode, count)) { - String localParameterName = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.LOCAL_PARAMETER_VALUE; - - Double value = (Double) newValue; - if (value.equals(SBML_Constants.EMPTY)) { - SBMLHelper.deleteLocalParameterValue(node, SBMLHelper.getLocalParameterID(node, count)); - } - else if (attributeName.equals(localParameterName) && !SBMLHelper.getLocalParameterValue(node, count).equals(value)) { - localParameter.setValue(node, value); - continue; - } - - } - if (newValue instanceof String && SBMLHelper.isLocalParameterUnits(reactionNode, count)) { - String localParameterName = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.LOCAL_PARAMETER_UNITS; - - String units = (String) newValue; - if (units.equals(SBML_Constants.EMPTY)) { - SBMLHelper.deleteLocalParameterUnits(node, SBMLHelper.getLocalParameterID(node, count)); - } - else if (attributeName.equals(localParameterName) && !SBMLHelper.getLocalParameterUnits(node, count).equals(units)) { - localParameter.setUnits(node, units); - continue; - } - - } - if (newValue instanceof String && localParameter.isSetMetaID(reactionNode)) { - String localParameterMetaID = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.META_ID; - - String metaId = (String) newValue; - if (attributeName.equals(localParameterMetaID) && metaId.equals(SBML_Constants.EMPTY)) { - localParameter.deleteMetaID(node); - } - else if (attributeName.equals(localParameterMetaID) && !getMetaID(node).equals(metaId)) { - localParameter.setMetaID(node, metaId); - continue; - } - - } - if (newValue instanceof String && localParameter.isSetSBOTerm(reactionNode)) { - String localParameterSBOTerm = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.SBOTERM; - - String sboTerm = (String) newValue; - String oldValue = getSBOTerm(node); - if (attributeName.equals(localParameterSBOTerm) && sboTerm.equals(SBML_Constants.EMPTY)) { - localParameter.deleteSBOTerm(node); - } - else if (attributeName.equals(localParameterSBOTerm) && !oldValue.equals(sboTerm)) { - localParameter.setSBOTerm(node, sboTerm); - continue; - } - } - - if (newValue instanceof XMLNode && localParameter.isSetNotes(reactionNode)) { - String localParameterNote = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.NOTES; - - XMLNode notes = (XMLNode) newValue; - XMLNode notesOld = getNotes(node); - if (attributeName.equals(localParameterNote) && notes.equals(SBML_Constants.EMPTY)) { - localParameter.deleteNotes(node); - } - else if (attributeName.equals(localParameterNote) && !notesOld.equals(notes)) { - localParameter.setNotes(node, notes.toString(), notes); - continue; - } - } - - if (newValue instanceof Annotation && localParameter.isSetAnnotation(reactionNode)) { - String localParameterAnnotation = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.ANNOTATION; - - Annotation annotation = (Annotation) newValue; - Annotation oldAnnotation = getAnnotation(node); - if (attributeName.equals(localParameterAnnotation) && annotation.equals(SBML_Constants.EMPTY)) { - localParameter.deleteAnnotation(node); - } - else if (attributeName.equals(localParameterAnnotation) && !oldAnnotation.equals(annotation)) { - localParameter.setAnnotation(node, annotation); - continue; - } - } - - if (newValue instanceof String && localParameter.isSetNonRDFAnnotation(reactionNode)) { - String localParameterAnnotation = SBML_Constants.LOCAL_PARAMETER + count + SBML_Constants.NON_RDF_ANNOTATION; - - String annotation = (String) newValue; - String oldAnnotation = getNonRDFAnnotation(node); - if (attributeName.equals(localParameterAnnotation) && annotation.equals(SBML_Constants.EMPTY)) { - localParameter.deleteNonRDFAnnotation(node); - } - else if (attributeName.equals(localParameterAnnotation) && !oldAnnotation.equals(annotation)) { - localParameter.setNonRDFAnnotation(node, annotation); - continue; - } - } - count++; - } - } - } - - @Override - public void postAttributeRemoved(AttributeEvent e) { - - } - - @Override - public void preAttributeAdded(AttributeEvent e) { - - } - - @Override - public void preAttributeChanged(AttributeEvent e) { - - } - - @Override - public void preAttributeRemoved(AttributeEvent e) { - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/ReactionIDSpeciesIDWrapper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/ReactionIDSpeciesIDWrapper.java deleted file mode 100644 index 0a44ecc58..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/ReactionIDSpeciesIDWrapper.java +++ /dev/null @@ -1,60 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -public class ReactionIDSpeciesIDWrapper { - private String _reactionID; - private String _speciesID; - - public ReactionIDSpeciesIDWrapper(String reactionID, String speciesID) { - super(); - _reactionID = reactionID; - _speciesID = speciesID; - } - - public String getReactionID() { - return _reactionID; - } - - public void setReactionID(String _reactionID) { - this._reactionID = _reactionID; - } - - public String getSpeciesID() { - return _speciesID; - } - - public void setSpeciesID(String _speciesID) { - this._speciesID = _speciesID; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((_reactionID == null) ? 0 : _reactionID.hashCode()); - result = prime * result + ((_speciesID == null) ? 0 : _speciesID.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ReactionIDSpeciesIDWrapper other = (ReactionIDSpeciesIDWrapper) obj; - if (_reactionID == null) { - if (other._reactionID != null) - return false; - } else if (!_reactionID.equals(other._reactionID)) - return false; - if (_speciesID == null) { - if (other._speciesID != null) - return false; - } else if (!_speciesID.equals(other._speciesID)) - return false; - return true; - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAlgebraicRule.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAlgebraicRule.java deleted file mode 100644 index c984642e4..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAlgebraicRule.java +++ /dev/null @@ -1,161 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLAlgebraicRule { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden algebraic rule attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLAlgebraicRule(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initAlgebraicNiceIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLAlgebraicRule(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ALGEBRAIC_FUNCTION) - .toString(), function); - } - } - - public Boolean isSetFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initAlgebraicNiceIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ALGEBRAIC_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAssignmentRule.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAssignmentRule.java deleted file mode 100644 index cb64f1ecc..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLAssignmentRule.java +++ /dev/null @@ -1,198 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLAssignmentRule { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden assignmentRule attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLAssignmentRule(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initAssignmnetNiceIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLAssignmentRule(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_FUNCTION) - .toString(), function); - } - } - - public void setVariable(String variable) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_VARIABLE) - .toString(), variable); - } - } - - public Boolean isSetVariable() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_VARIABLE) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public String getVariable() { - if (isSetVariable()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initAssignmnetNiceIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_VARIABLE).toString(), - presentedHeadline + ": Variable"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartment.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartment.java deleted file mode 100644 index dc4908063..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartment.java +++ /dev/null @@ -1,393 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -@SuppressWarnings("unused") -public class SBMLCompartment { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden compartment attributes are stored here - */ - HashSet discardedRowIDs; - - /** - * Constructor. Initializes the graph. Use in SBML_Compartment_Reader.java - * - * @param g - * the graph where the information is read from - */ - public SBMLCompartment(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initCompartmentNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - /** - * Constructor. Initializes the graph. Use in SBML_Compartmetn_Writer.java - * - * @param g - * the graph where the information is read from - * @param internHeadline - * the intern headline of the current Compartment - */ - public SBMLCompartment(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public void countCompartments() { - int i = 0; - - } - - public Compartment getCompartment() { - Compartment comartment = new Compartment(); - comartment.setId(getID()); - comartment.setName(getName()); - comartment.setSpatialDimensions(getSpatialDimensions()); - comartment.setSize(getSize()); - comartment.setUnits(getUnits()); - comartment.setConstant(getConstant()); - return comartment; - } - - public Boolean isSetID() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_ID) - .toString())) { - return true; - } else { - return false; - } - } - - public String getID() { - if (isSetID()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setID(String id) { - if (!id.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_ID) - .toString(), id); - } - } - - public void setName(String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_NAME) - .toString(), name); - } - } - - public Boolean isSetName() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - public String getName() { - if (isSetName()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setSpatialDimensions(Double spatialDimensions) { - if (!spatialDimensions.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SPATIAL_DIMENSIONS) - .toString(), spatialDimensions); - } - } - - public Boolean isSetSpatialDimensions() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SPATIAL_DIMENSIONS) - .toString())) { - return true; - } else { - return false; - } - } - - public Double getSpatialDimensions() { - if (isSetSpatialDimensions()) { - return (Double) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.SPATIAL_DIMENSIONS).toString()); - } else { - return null; - } - } - - public void setSize(Double size) { - if (!size.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SIZE).toString(), - Double.toString(size)); - } - } - - public Boolean isSetSize() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SIZE).toString())) { - return true; - } else { - return false; - } - } - - public Double getSize() { - if (isSetSize()) { - return Double.parseDouble((String) attWriter.getAttribute(g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SIZE).toString())); - } else { - return null; - } - } - - public void setUnits(String units) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNITS).toString(), - units); - } - } - - public Boolean isSetUnits() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNITS).toString())) { - return true; - } else { - return false; - } - } - - public String getUnits() { - if (isSetUnits()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNITS).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setConstant(Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTANT).toString(), - constant); - } - } - - public Boolean isSetConstant() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTANT).toString())) { - return true; - } else { - return false; - } - } - - public Boolean getConstant() { - if (isSetConstant()) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTANT).toString()); - } else { - return null; - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setOutside(String outside) { - if (!outside.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.OUTSIDE).toString(), - outside); - } - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - /** - * Sets the nice id - */ - private void initCompartmentNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.SPATIAL_DIMENSIONS).toString(), - presentedHeadline + ": Spatial Dimensions"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SIZE) - .toString(), presentedHeadline + ": Size"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.UNITS) - .toString(), presentedHeadline + ": Units"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.CONSTANT).toString(), - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.OUTSIDE) - .toString(), presentedHeadline + ": Outside"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - } - -} - -/* - * if(AttributeHelper.hasAttribute(g, internHeadline, new - * StringBuffer(internHeadline - * ).append(SBML_Constants.SPATIAL_DIMENSIONS).toString())){ Object spDim = - * (Object)getAttribute(g, internHeadline, new - * StringBuffer(internHeadline).append - * (SBML_Constants.SPATIAL_DIMENSIONS).toString()); if(spDim instanceof Double){ - * compartment.setSpatialDimensions((Double)spDim); } } - */ -/* - * if(AttributeHelper.hasAttribute(g, internHeadline,new - * StringBuffer(internHeadline).append(SBML_Constants.SIZE).toString())){ try{ - * Double size = Double.parseDouble((String)getAttribute(g, internHeadline,new - * StringBuffer(internHeadline). append(SBML_Constants.SIZE).toString())); - * compartment.setSize(size); }catch(NumberFormatException e){ - * - * } } - */ diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartmentHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartmentHelper.java deleted file mode 100644 index 31f82e9bc..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLCompartmentHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLCompartmentHelper { - - /** - * Stores the SBMLCompartment objects - */ - List compartmentList; - - public SBMLCompartmentHelper(){ - compartmentList = new ArrayList(); - } - - public SBMLCompartment addCompartment(Graph g, String internHeadline){ - SBMLCompartment compartment = new SBMLCompartment(g, internHeadline); - compartmentList.add(compartment); - return compartment; - } - - public SBMLCompartment addCompartment(Graph g, String internHeadline, String presentedHeadline){ - SBMLCompartment compartment = new SBMLCompartment(g, internHeadline, presentedHeadline); - compartmentList.add(compartment); - return compartment; - } - - public List getCompartmentHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_COMPARTMENT); - } - - public List addCompartments(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addCompartment(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraint.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraint.java deleted file mode 100644 index a3367d076..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraint.java +++ /dev/null @@ -1,195 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLConstraint { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden constraint attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLConstraint(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initConstraintNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLConstraint(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setMetaId(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setMessage(String message) { - if (!message.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString(), - message); - } - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTRAINT) - .toString(), function); - } - } - - public Boolean isSetFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTRAINT).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetMessage() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString())) { - return true; - } else { - return false; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTRAINT).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getMessage() { - if (isSetMessage()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.MESSAGE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initConstraintNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTRAINT).toString(), - presentedHeadline + ": Constraint"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.MESSAGE) - .toString(), presentedHeadline + ": Message"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraintHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraintHelper.java deleted file mode 100644 index 373a1b6cd..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLConstraintHelper.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLConstraintHelper { - - /** - * Stores the SBMLConstraint objects - */ - List constraintList; - - public SBMLConstraintHelper() { - constraintList = new ArrayList(); - } - - public SBMLConstraint addConstraint(Graph g, String internHeadline) { - SBMLConstraint constraint = new SBMLConstraint(g, internHeadline); - constraintList.add(constraint); - return constraint; - } - - public SBMLConstraint addConstraint(Graph g, String internHeadline, - String presentedHeadline) { - SBMLConstraint constraint = new SBMLConstraint(g, internHeadline, - presentedHeadline); - constraintList.add(constraint); - return constraint; - } - - public List getConstraintHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_CONSTRAINT); - } - - public List addConstraints(Graph g, - List internHeadlines) { - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while (internHeadlineIt.hasNext()) { - returnList.add(addConstraint(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventAssignmentHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventAssignmentHelper.java deleted file mode 100644 index a6df6b2a2..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventAssignmentHelper.java +++ /dev/null @@ -1,267 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLEventAssignmentHelper { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline = SBML_Constants.EMPTY; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - int eventAssignmentCount; - - /** - * The hidden event attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLEventAssignmentHelper(Graph g, String internHeadline, - String presentedHeadline, int eventAssignmentCount) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - this.eventAssignmentCount = eventAssignmentCount; - initEventAssignmentNideIDs(eventAssignmentCount); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLEventAssignmentHelper(Graph g, String internHeadline, - int eventAssignmentCount) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.eventAssignmentCount = eventAssignmentCount; - this.internHeadline = internHeadline; - } - - public void setVariable(String variable) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString(), - variable); - } - } - - public Boolean isSetVariable() { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString())) { - return true; - } else { - return false; - } - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString(), - function); - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.META_ID).toString(), metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.SBOTERM).toString(), sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount).append(SBML_Constants.ANNOTATION) - .toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.NON_RDF_ANNOTATION).toString(), - nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount).append(SBML_Constants.NOTES) - .toString()); - } - - public Boolean isSetFunction() { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - public String getVariable() { - if (isSetVariable()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initEventAssignmentNideIDs(int eventAssignmentCount) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Variable"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Function"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.META_ID).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Meta ID"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.SBOTERM).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " SBOTerm"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.NOTES).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Notes"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventHelper.java deleted file mode 100644 index b01055655..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLEventHelper.java +++ /dev/null @@ -1,557 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLEventHelper { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - List eaHelperList; - - /** - * The hidden event attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLEventHelper(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - eaHelperList = new ArrayList(); - initEventNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLEventHelper(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - eaHelperList = new ArrayList(); - } - - public SBMLEventAssignmentHelper addEventAssignment(Graph g, - String internHeadline, String presentedHeadline, - int eventAssignmentCount) { - SBMLEventAssignmentHelper eaHelper = new SBMLEventAssignmentHelper(g, - internHeadline, presentedHeadline, eventAssignmentCount); - eaHelperList.add(eaHelper); - return eaHelper; - } - - public SBMLEventAssignmentHelper addEventAssignment(Graph g, - String internHeadline, int eaCount) { - SBMLEventAssignmentHelper eaHelper = new SBMLEventAssignmentHelper(g, - internHeadline, eaCount); - eaHelperList.add(eaHelper); - return eaHelper; - } - - public void setUseValuesFromTriggerTime(Boolean useValuesFromTriggerTime) { - if (!useValuesFromTriggerTime.equals(null)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString(), useValuesFromTriggerTime); - } - } - - public void setID(String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ID).toString(), - ID); - } - } - - public void setName(String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_NAME) - .toString(), name); - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public Boolean isSetName() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_NAME).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetID() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ID).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetUseValuesFromTriggerTime() { - if (AttributeHelper - .hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString())) { - return true; - } else { - return false; - } - } - - public String getID() { - if (isSetID()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName() { - if (isSetName()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Boolean getUseValuesFromTriggerTime() { - if (isSetUseValuesFromTriggerTime()) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString()); - } else { - return null; - } - } - - public void setInitialValue(Boolean initialValue) { - if (!initialValue.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.INITIAL_VALUE) - .toString(), initialValue); - } - } - - public void setPersistent(Boolean persistent) { - if (!persistent.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PERSISTENT) - .toString(), persistent); - } - } - - public void setTriggerFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.TRIGGER_FUNCTION) - .toString(), function); - } - } - - public Boolean isSetTriggerFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.TRIGGER_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetInitialValue() { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.INITIAL_VALUE) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetPersistent() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PERSISTENT).toString())) { - return true; - } else { - return false; - } - } - - public String getTriggerFunction() { - if (isSetTriggerFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.TRIGGER_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Boolean getInitialValue() { - if (isSetInitialValue()) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_VALUE).toString()); - } else { - return null; - } - } - - public Boolean getPersistent() { - if (isSetPersistent()) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PERSISTENT).toString()); - } else { - return null; - } - } - - public void setPriorityFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_FUNCTION) - .toString(), function); - } - } - - public void setPriorityMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_META_ID) - .toString(), metaID); - } - } - - public void setPrioritySBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_SBOTERM) - .toString(), sboTerm); - } - } - - public void setPriorityAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_ANNOTATION) - .toString(), annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_ANNOTATION).toString()); - } - - public void setPriorityNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NON_RDF_ANNOTATION).toString(), - nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NON_RDF_ANNOTATION).toString()); - } - - public void setPriorityNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NOTES).toString()); - } - - public Boolean isSetPriorityFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public String getPriorityFunction() { - if (isSetPriorityFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setDelayFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_FUNCTION) - .toString(), function); - } - } - - public void setDelayMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_META_ID) - .toString(), metaID); - } - } - - public void setdelayAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_ANNOTATION) - .toString(), annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_ANNOTATION).toString()); - } - - public void setdelayNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_NON_RDF_ANNOTATION).toString()); - } - - public void setDelaySBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_SBOTERM) - .toString(), sboTerm); - } - } - - public void setDelayNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_NOTES).toString()); - } - - public Boolean isSetDelayFunction() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public String getDelayFunction() { - if (isSetDelayFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initEventNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper - .setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString(), presentedHeadline - + ": UseValuesFromTriggerTime"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_VALUE).toString(), - presentedHeadline + ": Trigger Initial Value"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PERSISTENT).toString(), - presentedHeadline + ": Trigger Persistent"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.TRIGGER_FUNCTION).toString(), - presentedHeadline + ": Trigger Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_META_ID).toString(), - presentedHeadline + ": Priority Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NOTES).toString(), - presentedHeadline + ": Priority Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_SBOTERM).toString(), - presentedHeadline + ": Priority SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_FUNCTION).toString(), - presentedHeadline + ": Priority Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_META_ID).toString(), - presentedHeadline + ": Delay Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_NOTES).toString(), - presentedHeadline + ": Delay Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_SBOTERM).toString(), - presentedHeadline + ": Delay SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_FUNCTION).toString(), - presentedHeadline + ": Delay Function"); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinition.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinition.java deleted file mode 100644 index 090d907fb..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinition.java +++ /dev/null @@ -1,271 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.text.parser.ParseException; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLFunctionDefinition { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden function definition attributes are stored here - */ - HashSet discardedRowIDs; - - /** - * Constructor. Initializes the graph. Use in - * SBML_FunctionDefinition_Reader.java - * - * @param g - * the graph where the information is read from - */ - public SBMLFunctionDefinition(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initFunctionDefinitionNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - /** - * Constructor. Initializes the graph. Use in - * SBML_FunctionDefinition_Writer.java - * - * @param g - * the graph where the information is read from - * @param internHeadline - * the intern headline of the current Compartment - */ - public SBMLFunctionDefinition(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public Boolean isSetID() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION_DEFINITION_ID) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetName() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetFunction() { - if (AttributeHelper - .hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public String getID() { - if (isSetID()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName() { - if (isSetName()) { - return (String) attWriter - .getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public ASTNode getFunction() { - if (isSetFunction()) { - try { - return ASTNode.parseFormula((String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString())); - } catch (ParseException e) { - e.printStackTrace(); - return null; - } - } else { - return null; - } - } - - public void setName(String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper - .setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString(), name); - - } - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString(), function); - } - } - - public void setID(String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString(), - ID); - } - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - discardedRowIDs.add(internHeadline + "_notes"); - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - private void initFunctionDefinitionNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - AttributeHelper - .setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString(), presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME).toString(), - presentedHeadline + ": Name"); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinitionHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinitionHelper.java deleted file mode 100644 index 491d6ede3..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLFunctionDefinitionHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLFunctionDefinitionHelper { - - /** - * Stores the SBMLFunctionDefinition objects - */ - List functionDefinitionList; - - public SBMLFunctionDefinitionHelper(){ - functionDefinitionList = new ArrayList(); - } - - public SBMLFunctionDefinition addFunctionDefinition(Graph g, String internHeadline){ - SBMLFunctionDefinition functionDefinition = new SBMLFunctionDefinition(g, internHeadline); - functionDefinitionList.add(functionDefinition); - return functionDefinition; - } - - public SBMLFunctionDefinition addFunctionDefinition(Graph g, String internHeadline, String presentedHeadline){ - SBMLFunctionDefinition functionDefinition = new SBMLFunctionDefinition(g, internHeadline, presentedHeadline); - functionDefinitionList.add(functionDefinition); - return functionDefinition; - } - - public List getFunctionDefinitionHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_FUNCTION_DEFINITION); - } - - public List addFunctionDefinitions(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addFunctionDefinition(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLHelper.java deleted file mode 100644 index d2d0acc62..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLHelper.java +++ /dev/null @@ -1,7978 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.AlignmentSetting; -import org.AttributeHelper; -import org.ErrorMsg; -import org.PositionGridGenerator; -import org.Vector2d; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Delay; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Priority; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.Trigger; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.text.parser.ParseException; - -import de.ipk_gatersleben.ag_nw.graffiti.NodeTools; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -@SuppressWarnings({"deprecation", "unused"}) -public class SBMLHelper { - - /** - * Provides necessary methods - */ - public static SBML_SBase_Writer attWriter = new SBML_SBase_Writer(); - - public static PositionGridGenerator _pgg = new PositionGridGenerator(100, 100, 1000); - - public static SBML_SBase_Reader attReader = new SBML_SBase_Reader(); - - public static final String SBML_LAYOUT_EXTENSION_NAMESPACE = "http://www.sbml.org/sbml/level3/version1/layout/version1"; - - private static boolean isInitializedReaction = false; - private static boolean isInitializedKineticLaw = false; - - private static boolean isInitializedLocalParameter = false; - - private static int parameterCount = 1; - private static int initialAssignmentCount = 1; - private static int functionDefinitionCount = 1; - private static int unitDefinitionCount = 1; - private static int subUnitCount = 1; - private static int constraintCount = 1; - private static int assignmentRuleCount = 1; - private static int rateRuleCount = 1; - private static int algebraicRuleCount = 1; - private static int eventCount = 1; - - private static PositionGridGenerator pgg = new PositionGridGenerator(100, 100, - 1000); - - public static FunctionDefinition createFunctionDefinition(Graph g, String id) { - String presentedHeadline = new StringBuffer("SBML Function Definition ").append(functionDefinitionCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_FUNCTION_DEFINITION).append(functionDefinitionCount).toString(); - setFunctionDefinitionID(g, internHeadline, id); - FunctionDefinition fd = new FunctionDefinition(); - fd.setLevel(3); - fd.setId(id); - initFunctionDefinitionNiceIDs(internHeadline, presentedHeadline); - ++functionDefinitionCount; - return fd; - } - - public static void createFunctionDefinition(Graph g, FunctionDefinition fd) { - String presentedHeadline = new StringBuffer("SBML Function Definition ").append(functionDefinitionCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_FUNCTION_DEFINITION).append(functionDefinitionCount).toString(); - initFunctionDefinitionNiceIDs(internHeadline, presentedHeadline); - - fd.setLevel(3); - if (fd.isSetId()) { - setFunctionDefinitionID(g, internHeadline, fd.getId()); - } - if (fd.isSetName()) { - setFunctionDefinitionName(g, internHeadline, fd.getName()); - } - String formula = ""; - try { - if (fd.isSetMath()) { - ASTNode mathTree = fd.getMath(); - formula = mathTree.toFormula(); - setFunctionDefinitionFunction(g, internHeadline, formula); - } - } catch (SBMLException e) { - } - ++functionDefinitionCount; - } - - public static void addFunctionDefinitionName(Graph g, String id, String name) { - setFunctionDefinitionName(g, returnFunctionDefinitionWithID(g, id), name); - } - - public static void addFunctionDefinitionFunction(Graph g, String id, String function) { - setFunctionDefinitionFunction(g, returnFunctionDefinitionWithID(g, id), function); - } - - public static void deleteFunctionDefinitionID(Graph g, String id) { - String headline = returnFunctionDefinitionWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_ID).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_ID).toString()); - } - } - - public static void deleteFunctionDefinitionName(Graph g, String id) { - String headline = returnFunctionDefinitionWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_NAME).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_NAME).toString()); - } - } - - public static void deleteFunctionDefinitionFunction(Graph g, String id) { - String headline = returnFunctionDefinitionWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_FUNCTION).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.FUNCTION_DEFINITION_FUNCTION).toString()); - } - } - - public static void deleteFunctionDefinition(Graph g, String id) { - deleteFunctionDefinitionName(g, id); - deleteFunctionDefinitionFunction(g, id); - deleteFunctionDefinitionID(g, id); - } - - public static boolean isSetFunctionDefinitionName(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnFunctionDefinitionWithID(g, id), - new StringBuffer(returnFunctionDefinitionWithID(g, id)).append(SBML_Constants.FUNCTION_DEFINITION_NAME).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetFunctionDefinitionID(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnFunctionDefinitionWithID(g, id), - new StringBuffer(returnFunctionDefinitionWithID(g, id)).append(SBML_Constants.FUNCTION_DEFINITION_ID).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetFunctionDefinitionFunction(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnFunctionDefinitionWithID(g, id), - new StringBuffer(returnFunctionDefinitionWithID(g, id)).append(SBML_Constants.FUNCTION_DEFINITION_FUNCTION).toString())) { - return true; - } - else { - return false; - } - } - - /** - * Indicates if the id of a specific function definition is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return true if the value is set. - */ - static private Boolean isFunctionDefinitionID(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION_DEFINITION_ID) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the name of a specific function definition is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return true if the value is set. - */ - private static Boolean isFunctionDefinitionName(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the function of a specific function definition is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return true if the value is set. - */ - private static Boolean isFunctionDefinitionFunction(Graph g, - String internHeadline) { - if (AttributeHelper - .hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Deletes the id of a specific function definition - * - * @param g - * the graph where the information is deleted from - * @param internHeadline - * contains the number of the current function definition - */ - /* - * public static void deleteFunctionDefinitionID(Graph g, String internHeadline) { - * if (isFunctionDefinitionID(g, internHeadline)) { - * AttributeHelper.deleteAttribute(g, internHeadline, new StringBuffer(internHeadline).append( - * SBML_Constants.FUNCTION_DEFINITION_ID).toString()); - * } - * } - */ - - /** - * Deletes the name of a specific function definition - * - * @param g - * the graph where the information is deleted from - * @param internHeadline - * contains the number of the current function definition - */ - /* - * public static void deleteFunctionDefinitionName(Graph g, String internHeadline) { - * if (isFunctionDefinitionName(g, internHeadline)) { - * AttributeHelper.deleteAttribute(g, internHeadline, new StringBuffer(internHeadline).append( - * SBML_Constants.FUNCTION_DEFINITION_NAME).toString()); - * } - * } - */ - - /** - * Deletes the function of a specific function definition - * - * @param g - * the graph where the information is deleted from - * @param internHeadline - * contains the number of the current function definition - */ - /* - * public static void deleteFunctionDefinitionFunction(Graph g, String internHeadline) { - * if (isFunctionDefinitionFunction(g, internHeadline)) { - * AttributeHelper.deleteAttribute(g, internHeadline, new StringBuffer(internHeadline).append( - * SBML_Constants.FUNCTION_DEFINITION_FUNCTION).toString()); - * } - * } - */ - - /** - * Returns the function definition id if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return the id if it is set. Else the empty string - */ - private static String getFunctionDefinitionID(Graph g, String internHeadline) { - if (isFunctionDefinitionID(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the function definition name if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return the name if it is set. Else the empty string - */ - private static String getFunctionDefinitionName(Graph g, - String internHeadline) { - if (isFunctionDefinitionName(g, internHeadline)) { - return (String) attWriter - .getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current function definition - * @return the function if it is set. Else null - */ - private static ASTNode getFunctionDefinitionFunction(Graph g, - String internHeadline) { - if (isFunctionDefinitionFunction(g, internHeadline)) { - try { - return ASTNode.parseFormula((String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString())); - } catch (ParseException e) { - e.printStackTrace(); - return null; - } - } else { - return null; - } - } - - /** - * Sets the id of a function definition - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current function definition - * @param ID - * the value that will be read in - */ - private static void setFunctionDefinitionID(Graph g, String internHeadline, - String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString(), - ID); - } - } - - /** - * Sets the name of a function definition - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current function definition - * @param name - * the value that will be read in - */ - private static void setFunctionDefinitionName(Graph g, - String internHeadline, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper - .setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME) - .toString(), name); - - } - } - - /** - * Sets the function of a function definition - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current function definition - * @param function - * the value that will be read in - */ - private static void setFunctionDefinitionFunction(Graph g, - String internHeadline, String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString(), function); - } - } - - /** - * Returns all intern function definition headlines - * - * @param g - * the headlines are stored in this graph - * @return a list of intern headlines - */ - private static ArrayList getFunctionDefinitionHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer - .headlineHelper(g, SBML_Constants.SBML_FUNCTION_DEFINITION); - } - - /** - * Returns the number of function definitions in the graph - * - * @param g - * where the information is read from - * @return number of function definitios - */ - public static int countFunctionDefinitions(Graph g) { - return getFunctionDefinitionHeadlines(g).size(); - } - - /** - * Returns a filled JSBML FunctionDefinition object. The function writes the attributes from a function definition in the graph into a JSBML function - * definition. - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current function definition - * @return a filled FunctionDefinition object - */ - private static FunctionDefinition getFunctionDefinition(Graph g, - String internHeadline) { - FunctionDefinition fd = new FunctionDefinition(); - fd.setLevel(3); - if (isFunctionDefinitionID(g, internHeadline)) { - fd.setId(getFunctionDefinitionID(g, internHeadline)); - } - if (isFunctionDefinitionName(g, internHeadline)) { - fd.setName(getFunctionDefinitionName(g, internHeadline)); - } - if (isFunctionDefinitionFunction(g, internHeadline)) { - fd.setMath(getFunctionDefinitionFunction(g, internHeadline)); - } - return fd; - } - - /** - * Returns a list of filled JSBML FunctionDefinition objects - * - * @param g - * contains the information - * @param internHeadlines - * contains the number of the current function definition - * @return a filled list of function definitions - */ - private static List getAllFunctionDefinitions(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List functionDefinitionList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - functionDefinitionList - .add(getFunctionDefinition(g, internHeadline)); - } - return functionDefinitionList; - } - - /** - * Returns a list of filled JSBML FunctionDefinition objects - * - * @param g - * contains the information - * @return a filled list of function definitions - */ - public static List getAllFunctionDefinitions(Graph g) { - List internHeadlines = getFunctionDefinitionHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List functionDefinitionList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - functionDefinitionList - .add(getFunctionDefinition(g, internHeadline)); - } - return functionDefinitionList; - } - - public static UnitDefinition createUnitDefinition(Graph g, String id) { - String presentedHeadline = new StringBuffer("SBML Unit Definition ") - .append(unitDefinitionCount).toString(); - String internHeadline = new StringBuffer( - SBML_Constants.SBML_UNIT_DEFINITION).append(unitDefinitionCount) - .toString(); - setUnitDefinitionID(g, internHeadline, id); - UnitDefinition ud = new UnitDefinition(); - ud.setId(id); - initUnitDefinitionNideIDs(internHeadline, presentedHeadline); - ++unitDefinitionCount; - return ud; - } - - public static void createUnitDefinition(Graph g, UnitDefinition ud) { - String presentedHeadline = new StringBuffer("SBML Unit Definition ") - .append(unitDefinitionCount).toString(); - String internHeadline = new StringBuffer( - SBML_Constants.SBML_UNIT_DEFINITION).append(unitDefinitionCount) - .toString(); - - if (ud.isSetId()) { - ud.setLevel(3); - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString(), ud.getId()); - } - if (ud.isSetName()) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString(), ud.getName()); - } - - List ListOfSubUnits = new ArrayList(); - if (ud.isSetListOfUnits()) { - List unitList = ud.getListOfUnits(); - Iterator itUnit = unitList.iterator(); - while (itUnit.hasNext()) { - initSubUnitDefinitionNideIDs(internHeadline, presentedHeadline, subUnitCount); - Unit unit = itUnit.next(); - int scale = unit.getScale(); - Double exponent = unit.getExponent(); - if (exponent.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute exponent of unit definition " - + subUnitCount - + " sub unit " - + subUnitCount - + " with the id " - + ud.getId() - + " is not a valid double value."); - } - Double multiplier = unit.getMultiplier(); - if (multiplier.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute multiplier of unit definition " - + subUnitCount - + " sub unit " - + subUnitCount - + " with the id " - + ud.getId() - + " is not a valid double value."); - } - String kind = unit.getKind().getName(); - String composedSubUnit = "(" + multiplier + " * 10^" - + scale + " * " + kind + ")^" + exponent; - setComposedSubUnit(g, internHeadline, composedSubUnit, subUnitCount); - ListOfSubUnits.add(composedSubUnit); - subUnitCount++; - } - String composedUnit = ""; - int size = ListOfSubUnits.size(); - int count = 0; - Iterator itSubUnits = ListOfSubUnits.iterator(); - while (itSubUnits.hasNext()) { - String subUnit = itSubUnits.next(); - composedUnit = composedUnit + subUnit; - count++; - if (count < size) { - composedUnit = composedUnit + " * "; - } - } - setComposedUnit(g, internHeadline, composedUnit); - } - initUnitDefinitionNideIDs(internHeadline, presentedHeadline); - subUnitCount = 1; - ++unitDefinitionCount; - } - - public static void addUnitToUnitDefinition(Graph g, String id, Unit unit) { - String headline = returnUnitDefinitionWithID(g, id); - char index = headline.charAt(headline.length() - 1); - String presentedHeadline = new StringBuffer("SBML Unit Definition ") - .append(index).toString(); - initSubUnitDefinitionNideIDs(headline, presentedHeadline, getSubUnitCount(g, headline) + 1); - - int scale = unit.getScale(); - Double exponent = unit.getExponent(); - if (exponent.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute exponent of unit definition " - + getSubUnitCount(g, headline) - + " sub unit " - + getSubUnitCount(g, headline) - + " is not a valid double value."); - } - Double multiplier = unit.getMultiplier(); - if (multiplier.equals(Double.NaN)) { - ErrorMsg.addErrorMessage("Attribute multiplier of unit definition " - + getSubUnitCount(g, headline) - + " sub unit " - + getSubUnitCount(g, headline) - + " is not a valid double value."); - } - String kind = unit.getKind().getName(); - String composedSubUnit = "(" + multiplier + " * 10^" - + scale + " * " + kind + ")^" + exponent; - setComposedSubUnit(g, headline, composedSubUnit, getSubUnitCount(g, headline) + 1); - String composedUnit = getComposedUnit(g, headline); - String nextComposedUnit = ""; - if (composedUnit != "") { - nextComposedUnit = composedUnit + " * " + composedSubUnit; - } - else { - nextComposedUnit = composedSubUnit; - } - setComposedUnit(g, headline, nextComposedUnit); - - } - - public static void addUnitToUnitDefinition(Graph g, String id, Unit.Kind kind, double exponent, double multiplier, int scale) { - String headline = returnUnitDefinitionWithID(g, id); - char index = headline.charAt(headline.length() - 1); - String presentedHeadline = new StringBuffer("SBML Unit Definition ") - .append(index).toString(); - initSubUnitDefinitionNideIDs(headline, presentedHeadline, getSubUnitCount(g, headline) + 1); - - String composedSubUnit = "(" + multiplier + " * 10^" - + scale + " * " + kind + ")^" + exponent; - setComposedSubUnit(g, headline, composedSubUnit, getSubUnitCount(g, headline) + 1); - String composedUnit = getComposedUnit(g, headline); - String nextComposedUnit = ""; - if (composedUnit != "") { - nextComposedUnit = composedUnit + " * " + composedSubUnit; - } - else { - nextComposedUnit = composedSubUnit; - } - setComposedUnit(g, headline, nextComposedUnit); - - } - - public static void addUnitDefinitionName(Graph g, String id, String name) { - setUnitDefinitionName(g, returnUnitDefinitionWithID(g, id), name); - } - - public static void addUnitDefinitionID(Graph g, String oldID, String newID) { - setUnitDefinitionID(g, returnUnitDefinitionWithID(g, oldID), newID); - } - - public static void deleteUnitDefinitionID(Graph g, String id) { - String headline = returnUnitDefinitionWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString()); - } - } - - public static void deleteUnitDefinitionName(Graph g, String id) { - String headline = returnUnitDefinitionWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString()); - } - } - - public static boolean isSetUnitDefinitionName(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnUnitDefinitionWithID(g, id), new StringBuffer( - returnUnitDefinitionWithID(g, id)).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetUnitDefinitionID(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnUnitDefinitionWithID(g, id), new StringBuffer( - returnUnitDefinitionWithID(g, id)).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString())) { - return true; - } - else { - return false; - } - } - - /** - * Indicates if the unit definition id is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current unit definition - * @return true if the value is set. - */ - private static Boolean isUnitDefinitionID(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the unit definition name is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current unit definition - * @return true if the value is set. - */ - private static Boolean isUnitDefinitionName(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the unit definition id if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current unit definition - * @return the id if it is set. Else the empty string - */ - private static String getUnitDefinitionID(Graph g, String internHeadline) { - if (isUnitDefinitionID(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the unit definition name if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current unit definition - * @return the name if it is set. Else the empty string - */ - private static String getUnitDefinitionName(Graph g, String internHeadline) { - if (isUnitDefinitionName(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the id of a unit definition - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current unit definition - * @param ID - * the value that will be read in - */ - private static void setUnitDefinitionID(Graph g, String internHeadline, - String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString(), ID); - } - } - - /** - * Sets the name of a unit definition - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current unit definition - * @param name - * the value that will be read in - */ - private static void setUnitDefinitionName(Graph g, String internHeadline, - String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString(), name); - } - } - - /** - * Sets a composed sub unit. All composed sub units will merge to a composed - * unit - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current unit definition - * @param composedSubUnit - * the information that will be read in - * @param subUnitCount - * the number of the current sub unit - */ - private static void setComposedSubUnit(Graph g, String internHeadline, - String composedSubUnit, int subUnitCount) { - if (!composedSubUnit.equals(SBML_Constants.EMPTY)) { - System.out.println("drin"); - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT) - .append(subUnitCount).append("_").toString(), - composedSubUnit); - } - } - - /** - * Sets the composed unit which consists of the composed sub units - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current unit definition - * @param composedUnit - * the information that will be set - */ - private static void setComposedUnit(Graph g, String internHeadline, - String composedUnit) { - if (!composedUnit.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT).toString(), - composedUnit); - } - } - - /** - * Indicates if a composed sub unit with a certain index is set - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @param unitCount - * the index of the sub unit - * @return true if a sub unit with a certain index is set - */ - private static boolean isComposedSubUnit(Graph g, String internHeadline, - int unitCount) { - if (AttributeHelper.hasAttribute(g, internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(unitCount) - .append(SBML_Constants.UNDERLINE).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if there is a composed unit - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @return true if the value is set. Else false - */ - private static boolean isComposedUnit(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT).toString())) { - return true; - } else { - return false; - } - } - - /** - * Return the sub unit with a certain number - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @param unitCount - * the number of the sub unit - * @return the sub unit if it is set. Else the empty string - */ - private static String getComposedSubUnit(Graph g, String internHeadline, - int unitCount) { - if (isComposedSubUnit(g, internHeadline, unitCount)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(unitCount) - .append(SBML_Constants.UNDERLINE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the composed unit which consists of the composed sub units - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @return the composed unit if it is set. Else the empty string - */ - private static String getComposedUnit(Graph g, String internHeadline) { - if (isComposedUnit(g, internHeadline)) { - return (String) attWriter.getAttribute(g, internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.UNIT).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the amount of sub units of a certain unit definition - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @return the amount of sub units - */ - private static int getSubUnitCount(Graph g, String internHeadline) { - int suCount = 0; - while (isComposedSubUnit(g, internHeadline, suCount + 1)) { - suCount += 1; - } - return suCount; - } - - /** - * Returns a filled JSBML UnitDefinition object - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current unit definition - * @return a filled UnitDefinition object - */ - private static UnitDefinition getUnitDefinition(Graph g, - String internHeadline) { - UnitDefinition ud = new UnitDefinition(); - ud.setLevel(3); - if (isUnitDefinitionID(g, internHeadline)) { - ud.setId(getUnitDefinitionID(g, internHeadline)); - } - if (isUnitDefinitionName(g, internHeadline)) { - ud.setName(getUnitDefinitionName(g, internHeadline)); - } - for (int i = 1; i <= getSubUnitCount(g, internHeadline); i++) { - String subUnit = getComposedSubUnit(g, internHeadline, i); - String[] subUnitArray = subUnit.split(Pattern.quote(")")); - String exponent = subUnitArray[1].replace("^", ""); - String[] subUnitArray2 = subUnitArray[0].split("\\*"); - String multiplier = subUnitArray2[0].replace("(", ""); - String[] subUnitArray3 = subUnitArray2[1].split("\\^"); - String scale = subUnitArray3[1]; - String kind = subUnitArray2[2]; - Unit u = new Unit(); - u.setLevel(3); - u.setKind(Kind.valueOf(kind.trim().toUpperCase())); - u.setExponent(Double.parseDouble(exponent.trim())); - u.setMultiplier(Double.parseDouble(multiplier.trim())); - u.setScale(Integer.parseInt(scale.trim())); - ud.addUnit(u); - } - return ud; - } - - /** - * Returns a filled list of UnitDefinition objects - * - * @param g - * the graph where the information can be found - * @param internHeadlines - * contains the number of the current unit definition - * @return a filled UnitDefinition list - */ - private static List getAllUnitDefinitions(Graph g, - List internHeadlines) { - List udList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while (internHeadlineIt.hasNext()) { - String internHeadline = internHeadlineIt.next(); - udList.add(getUnitDefinition(g, internHeadline)); - } - return udList; - } - - /** - * Returns a list of all unit definition headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getUnitDefinitionHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_UNIT_DEFINITION); - } - - /** - * Returns a filled list of UnitDefinition objects - * - * @param g - * the graph where the information can be found - * @return a filled UnitDefinition list - */ - public static List getAllUnitDefinitions(Graph g) { - ArrayList internHeadlines = getUnitDefinitionHeadlines(g); - List udList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while (internHeadlineIt.hasNext()) { - String internHeadline = internHeadlineIt.next(); - udList.add(getUnitDefinition(g, internHeadline)); - } - return udList; - } - - /** - * Creates an compartment in the graph tab with an specific id - * - * @return the Compartment object will be returned - */ - public static Compartment createCompartment(Graph g, String id) { - String presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append(id) - .toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_COMPARTMENT) - .append(id).toString(); - setCompartmentID(g, internHeadline, id); - Compartment comp = new Compartment(); - comp.setId(id); - initCompartmentNideIDs(internHeadline, presentedHeadline); - return comp; - } - - /** - * @param compartment - */ - public static void createCompartment(Graph g, Compartment compartment) { - String internHeadline = new StringBuffer(SBML_Constants.SBML_COMPARTMENT) - .append(compartment.getId()).toString(); - String presentedHeadline = SBML_Constants.EMPTY; - if (compartment.isSetName()) { - presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append(compartment.getName()) - .toString(); - } else if (compartment.isSetId()) { - presentedHeadline = new StringBuffer( - SBML_Constants.COMARTMENT_HEADLINE).append(compartment.getId()) - .toString(); - } - initCompartmentNideIDs(internHeadline, presentedHeadline); - - if (compartment.isSetId() - && Compartment.isValidId(compartment.getId(), compartment.getLevel(), - compartment.getVersion())) { - setCompartmentID(g, internHeadline, compartment.getId()); - } - if (compartment.isSetName() && (compartment.getName() != SBML_Constants.EMPTY)) { - setCompartmentName(g, internHeadline, compartment.getName()); - } - if (compartment.isSetSpatialDimensions()) { - setCompartmentSpatialDimensions(g, internHeadline, compartment.getSpatialDimensions()); - } - if (compartment.isSetSize()) { - setCompartmentSize(g, internHeadline, compartment.getSize()); - } - if (compartment.isSetUnits()) { - setCompartmentUnits(g, internHeadline, compartment.getUnits()); - } - if (compartment.isSetConstant()) { - setCompartmentConstant(g, internHeadline, compartment.getConstant()); - } - } - - public static boolean isSetCompartmentName(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.COMPARTMENT_NAME) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetCompartmentID(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.COMPARTMENT_ID) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetCompartmentSpatialDimensions(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.SPATIAL_DIMENSIONS) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetCompartmentSize(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.SIZE) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetCompartmentUnits(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.UNITS) - .toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetCompartmentConstants(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnCommpartmentHeadlineWithID(g, id), - new StringBuffer(returnCommpartmentHeadlineWithID(g, id)).append(SBML_Constants.CONSTANT) - .toString())) { - return true; - } - else { - return false; - } - } - - public static void addCompartmentName(Graph g, String id, String name) { - setCompartmentName(g, returnCommpartmentHeadlineWithID(g, id), name); - } - - public static void addCompartmentSpatialDimensions(Graph g, String id, Double value) { - setCompartmentSpatialDimensions(g, returnCommpartmentHeadlineWithID(g, id), value); - } - - public static void addCompartmentSize(Graph g, String id, Double value) { - setCompartmentSize(g, returnCommpartmentHeadlineWithID(g, id), value); - } - - public static void addCompartmentUnits(Graph g, String id, String units) { - setCompartmentUnits(g, returnCommpartmentHeadlineWithID(g, id), units); - } - - public static void addCompartmentConstant(Graph g, String id, boolean constant) { - setCompartmentConstant(g, returnCommpartmentHeadlineWithID(g, id), constant); - } - - public static void deleteCompartmentID(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.COMPARTMENT_ID).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.COMPARTMENT_ID).toString()); - } - } - - public static void deleteCompartmentName(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.COMPARTMENT_NAME).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.COMPARTMENT_NAME).toString()); - } - } - - public static void deleteCompartmentSpatialDimensions(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SPATIAL_DIMENSIONS).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SPATIAL_DIMENSIONS).toString()); - } - } - - public static void deleteCompartmentSize(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SIZE).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SIZE).toString()); - } - } - - public static void deleteCompartmentUnits(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.UNITS).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.UNITS).toString()); - } - } - - public static void deleteCompartmentConstant(Graph g, String id) { - String headline = returnCommpartmentHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.CONSTANT).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.CONSTANT).toString()); - } - } - - public static void deleteCompartment(Graph g, String id) { - deleteCompartmentSpatialDimensions(g, id); - deleteCompartmentName(g, id); - deleteCompartmentSize(g, id); - deleteCompartmentUnits(g, id); - deleteCompartmentConstant(g, id); - deleteCompartmentID(g, id); - } - - private static String returnCommpartmentHeadlineWithID(Graph g, String id) { - ArrayList headlines = getCompartmentHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Compartment comp = getCompartment(g, headline); - if (comp.getId() == id) { - return headline; - } - } - return ""; - } - - private static String returnParameterHeadlineWithID(Graph g, String id) { - ArrayList headlines = getParameterHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Parameter para = getParameter(g, headline); - if (para.getId() == id) { - return headline; - } - } - return ""; - } - - private static String returnInitialAssignmentWithSymbol(Graph g, String symbol) { - ArrayList headlines = getInitialAssignmentHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - InitialAssignment ia = getInitialAssignment(g, headline); - if (ia.getVariable() == symbol) { - return headline; - } - } - return ""; - } - - private static String returnFunctionDefinitionWithID(Graph g, String id) { - ArrayList headlines = getFunctionDefinitionHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - FunctionDefinition fd = getFunctionDefinition(g, headline); - if (fd.getId() == id) { - return headline; - } - } - return ""; - } - - private static String returnUnitDefinitionWithID(Graph g, String id) { - ArrayList headlines = getUnitDefinitionHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - UnitDefinition ud = getUnitDefinition(g, headline); - ud.setLevel(3); - if (ud.getId() == id) { - return headline; - } - } - return ""; - } - - private static String returnAssignmentRuleWithID(Graph g, String variable) { - ArrayList headlines = getAssignmentRuleHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - AssignmentRule ar = getAssignmentRule(g, headline); - ar.setLevel(3); - if (ar.getVariable() == variable) { - return headline; - } - } - return ""; - } - - private static String returnRateRuleWithID(Graph g, String variable) { - ArrayList headlines = getRateRuleHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - RateRule rr = getRateRule(g, headline); - rr.setLevel(3); - if (rr.getVariable() == variable) { - return headline; - } - } - return ""; - } - - private static String returnAlgebraicRuleWithFormula(Graph g, String formula) { - ArrayList headlines = getAlgebraicRuleHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - AlgebraicRule ar = getAlgebraicRule(g, headline); - ar.setLevel(3); - if (ar.getMath().toFormula().equals(formula)) { - return headline; - } - } - return ""; - } - - private static String returnEventWithID(Graph g, String id) { - ArrayList headlines = getEventHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Event event = getEvent(g, headline); - event.setLevel(3); - if (event.getId() == id) { - return headline; - } - } - return ""; - } - - /** - * Indicates if the compartment id is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentID(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_ID) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment name is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentName(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment spatial dimensions is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentSpatialDimensions(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SPATIAL_DIMENSIONS) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment size is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentSize(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SIZE).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment units is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentUnits(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNITS).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment constant is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return true if the value is set. - */ - private static Boolean isCompartmentConstant(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTANT).toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the compartment id if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return the id if it is set. Else the empty string - */ - private static String getCompartmentID(Graph g, String internHeadline) { - if (isCompartmentID(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the compartment name if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return the name if it is set. Else the empty string - */ - private static String getCompartmentName(Graph g, String internHeadline) { - if (isCompartmentName(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the compartment spatialDimensions if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return the spatialDimensions if it is set. Else null - */ - private static Double getCompartmentSpatialDimensions(Graph g, - String internHeadline) { - if (isCompartmentSpatialDimensions(g, internHeadline)) { - return (Double) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.SPATIAL_DIMENSIONS).toString()); - } else { - return null; - } - } - - /** - * Returns the compartment size if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return the size if it is set. Else null the empty string - */ - private static Double getCompartmentSize(Graph g, String internHeadline) { - if (isCompartmentSize(g, internHeadline)) { - return Double.parseDouble((String) attWriter.getAttribute(g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SIZE).toString())); - } else { - return null; - } - } - - /** - * Returns the compartment units if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return the units if it is set. Else the empty string - */ - private static String getCompartmentUnits(Graph g, String internHeadline) { - if (isCompartmentUnits(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNITS).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the compartment attribute constant if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current compartment - * @return constant if it is set. Else null - */ - private static Boolean getCompartmentConstant(Graph g, String internHeadline) { - if (isCompartmentConstant(g, internHeadline)) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTANT).toString()); - } else { - return null; - } - } - - /** - * Sets the id of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param id - * the value that will be read in - */ - private static void setCompartmentID(Graph g, String internHeadline, - String id) { - if (!id.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_ID) - .toString(), id); - } - } - - /** - * Sets the name of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param name - * the value that will be read in - */ - private static void setCompartmentName(Graph g, String internHeadline, - String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.COMPARTMENT_NAME) - .toString(), name); - } - } - - /** - * Sets the spatial dimension of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param spatialDimension - * the value that will be read in - */ - private static void setCompartmentSpatialDimensions(Graph g, - String internHeadline, Double spatialDimensions) { - if (!spatialDimensions.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SPATIAL_DIMENSIONS) - .toString(), spatialDimensions); - } - } - - /** - * Sets the size of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param size - * the value that will be read in - */ - private static void setCompartmentSize(Graph g, String internHeadline, - Double size) { - if (!size.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SIZE).toString(), - Double.toString(size)); - } - } - - /** - * Sets the units of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param units - * the value that will be read in - */ - private static void setCompartmentUnits(Graph g, String internHeadline, - String units) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNITS).toString(), - units); - } - } - - /** - * Sets the attribute constant of a compartment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current compartment - * @param constant - * the value that will be read in - */ - private static void setCompartmentConstant(Graph g, String internHeadline, - Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTANT).toString(), - constant); - } - } - - /** - * Returns a list of all compartment headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getCompartmentHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_COMPARTMENT); - } - - /** - * Returns a filled JSBML Compartment object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current compartment - * @return a filled Compartment object - */ - private static Compartment getCompartment(Graph g, String internHeadline) { - Compartment compartment = new Compartment(); - compartment.setId(getCompartmentID(g, internHeadline)); - compartment.setName(getCompartmentName(g, internHeadline)); - - if (isCompartmentSpatialDimensions(g, internHeadline) && compartment.getLevel() == 3) { - compartment.setSpatialDimensions(getCompartmentSpatialDimensions(g, - internHeadline)); - } - if (isCompartmentSize(g, internHeadline)) { - compartment.setSize(getCompartmentSize(g, internHeadline)); - } - compartment.setUnits(getCompartmentUnits(g, internHeadline)); - if (isCompartmentConstant(g, internHeadline)) { - compartment.setConstant(getCompartmentConstant(g, internHeadline)); - } - return compartment; - } - - /** - * Returns a list of compartments with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current compartment - * @return a filled list of compartments - */ - private static List getAllCompartments(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List compartmentList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - compartmentList.add(getCompartment(g, internHeadline)); - } - return compartmentList; - } - - /** - * Returns a list of compartments with distinct headlines - * - * @param g - * contains the information - * @return a filled list of compartments - */ - public static List getAllCompartments(Graph g) { - ArrayList internHeadlines = getCompartmentHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List compartmentList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - compartmentList.add(getCompartment(g, internHeadline)); - } - return compartmentList; - } - - /** - * Indicates if the id of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the id is set else false - */ - public static Boolean isSpeciesID(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the name of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the name is set else false - */ - public static Boolean isSpeciesName(Node speciesNode) { - if (!AttributeHelper.getLabel(speciesNode, SBML_Constants.EMPTY) - .equals(SBML_Constants.EMPTY) || AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_NAME)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the compartment id of a species is set - * - * @param node - * the node where the information is read from - * @return true if the compartment id is set else false - */ - public static Boolean isSpeciesCompartment(Node speciesNode) { - if (!NodeTools.getClusterID(speciesNode, SBML_Constants.EMPTY).equals( - SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the initial amount of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the initial amount is set else false - */ - public static Boolean isSpeciesInitialAmount(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the initial concentration of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the initial concentration is set else false - */ - public static Boolean isSpeciesInitialConcentration(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if substance units of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if substance units is set else false - */ - public static Boolean isSpeciesSubstanceUnits(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if hasOnlySubstanceUnits of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if hasOnlySubstanceUnits is set else false - */ - public static Boolean isSpeciesHasOnlySubstanceUnits(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if boundary condition of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if boundary condition is set else false - */ - public static Boolean isSpeciesBoundaryCondition(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if constant of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if constant is set else false - */ - public static Boolean isSpeciesConstant(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if conversion factor of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if conversion factor is set else false - */ - public static Boolean isSpeciesConversionFactor(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR)) { - return true; - } else { - return false; - } - } - - /** - * Returns the id of the species - * - * @param speciesNode - * the node where the information is read from - * @return the species id if it is set else the empty string - */ - public static String getSpeciesID(Node speciesNode) { - if (isSpeciesID(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the name of the species - * - * @param speciesNode - * the node where the information is read from - * @return the species name if it is set else the empty string - */ - public static String getSpeciesName(Node speciesNode) { - if (!isSpeciesName(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_NAME); - } - return AttributeHelper.getLabel(speciesNode, (String) attWriter.getAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_NAME)); - } - - /** - * Returns the compartment id of a species - * - * @param Node - * the node where the information is read from - * @return the compartment id if it is set else the empty string - */ - public static String getSpeciesCompartment(Node speciesNode) { - return NodeTools.getClusterID(speciesNode, SBML_Constants.EMPTY); - } - - /** - * Returns the initial amount of a species - * - * @param speciesNode - * the node where the information is read from - * @return initial amount if it is set else null - */ - public static Double getSpeciesInitialAmount(Node speciesNode) { - if (isSpeciesInitialAmount(speciesNode)) { - return (Double) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.INITIAL_AMOUNT); - } else { - return null; - } - } - - /** - * Returns the initial concentration of a species - * - * @param speciesNode - * the node where the information is read from - * @return initial concentration if it is set else null - */ - public static Double getSpeciesInitialConcentration(Node speciesNode) { - if (isSpeciesInitialConcentration(speciesNode)) { - return (Double) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.INITIAL_CONCENTRATION); - } else { - return null; - } - } - - /** - * Returns the substance units of a species - * - * @param speciesNode - * the node where the information is read from - * @return substance Units if it is set else the empty string - */ - public static String getSpeciesSubstanceUnits(Node speciesNode) { - if (isSpeciesSubstanceUnits(speciesNode)) { - return (String) attWriter - .getAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the boolean value hasOnlySubstanceUnits of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute hasOnlySubstanceUnits is set - * else null - */ - public static Boolean getSpeciesHasOnlySubstanceUnits(Node speciesNode) { - if (isSpeciesHasOnlySubstanceUnits(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS); - } else { - return null; - } - } - - /** - * Returns the boolean value boundaryCondition of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute boundaryCondition is set else - * null - */ - public static Boolean getSpeciesBoundaryCondition(Node speciesNode) { - if (isSpeciesBoundaryCondition(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.BOUNDARY_CONDITION); - } else { - return null; - } - } - - /** - * Returns the boolean value constant of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute constant is set else null - */ - public static Boolean getSpeciesConstant(Node speciesNode) { - if (isSpeciesConstant(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_CONSTANT); - } else { - return null; - } - } - - /** - * Returns the conversion factor units of a species - * - * @param speciesNode - * the node where the information is read from - * @return conversion factor if it is set else null - */ - public static String getSpeciesConversionFactor(Node speciesNode) { - if (isSpeciesConversionFactor(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR); - } else { - return null; - } - } - - /** - * Sets the id of a species node - * - * @param speciesNode - * where the information should be read in - * @param id - * the id to set - */ - public static void addSpeciesID(Node speciesNode, String id) { - if (!id.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID, id); - } - } - - public static void addSpeciesName(Node speciesNode, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_NAME, name); - } - } - - public static void setSpeciesAttributes(Node sbmlNode, String niceID, Object value) { - if (!value.equals(SBML_Constants.EMPTY) && !(value == null)) { - if (value instanceof Boolean) { - AttributeHelper.setAttribute(sbmlNode, SBML_Constants.SBML, - niceID, (Boolean) value); - } - else { - AttributeHelper.setAttribute(sbmlNode, SBML_Constants.SBML, - niceID, (String) value); - } - } - } - - /** - * Sets the label of a node. The id string will be the label if name is not - * set - * - * @param speciesNode - * where the information should be read in - * @param name - * the name to set - * @param id - * will be set if name is empty - * @param _pgg - * helps to set the position of the node - */ - private static void setSpeciesLabel(Node speciesNode, String name, - String id) { - String label = null; - if (!name.equals(SBML_Constants.EMPTY)) { - label = name; - } else { - label = id; - } - if (!label.equals(SBML_Constants.EMPTY)) { - attReader.setAttributes(speciesNode, Color.white, label, - _pgg.getNextPosition(), label.length() + 7); - } - } - - /** - * Sets the compartment of a node - * - * @param speciesNode - * the compartment belongs to this node - * @param compartment - * the id of the compartment that will be set - */ - public static void addSpeciesCompartment(Node speciesNode, - String compartment) { - if (!compartment.equals(SBML_Constants.EMPTY)) { - NodeTools.setClusterID(speciesNode, compartment); - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT, compartment); - } - } - - /** - * Sets the initial amount of a node - * - * @param speciesNode - * the initial amount belongs to this node - * @param initialAmount - * the value that will be set - */ - public static void addSpeciesInitialAmount(Node speciesNode, - Double initialAmount) { - if (!initialAmount.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT, initialAmount); - } - } - - /** - * Sets the initial concentration of a node - * - * @param speciesNode - * the initial concentration belongs to this node - * @param initialConcentration - * the value that will be set - */ - public static void addSpeciesInitialConcentration(Node speciesNode, - Double initialConcentration) { - if (!initialConcentration.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION, initialConcentration); - } - } - - /** - * Sets the substance units of a species node - * - * @param speciesNode - * the substance units belong to this node - * @param substanceUnits - * the substance units to set - */ - public static void addSpeciesSubstanceUnits(Node speciesNode, - String substanceUnits) { - if (!substanceUnits.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS, substanceUnits); - } - } - - /** - * Sets the attribute hasOnlySubstanceUnits of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param hasOnlySubstanceUnits - * the value that will be set - */ - public static void addSpeciesHasOnlySubstanceUnits(Node speciesNode, - Boolean hasOnlySubstanceUnits) { - if (!hasOnlySubstanceUnits.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS, - hasOnlySubstanceUnits); - } - } - - /** - * Sets the attribute boundary condition of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param boundaryCondition - * the value that will be set - */ - public static void addSpeciesBoundaryConsition(Node speciesNode, - Boolean boundaryCondition) { - if (!boundaryCondition.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION, boundaryCondition); - } - } - - /** - * Sets the attribute constant of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param constant - * the value that will be set - */ - public static void addSpeciesConstant(Node speciesNode, Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT, constant); - } - } - - /** - * Sets the attribute conversion factor of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param conversionFactor - * the value that will be set - */ - public static void addSpeciesConversionFactor(Node speciesNode, - String conversionFactor) { - if (!conversionFactor.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR, conversionFactor); - } - } - - public static void deleteSpeciesID(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID); - } - } - - public static void deleteSpeciesName(Node node) { - if (!AttributeHelper.getLabel(node, SBML_Constants.EMPTY) - .equals(SBML_Constants.EMPTY)) { - AttributeHelper.setLabel(node, ""); - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_NAME); - } - } - - public static void deleteSpeciesCompartment(Node node) { - if (!NodeTools.getClusterID(node, SBML_Constants.EMPTY).equals( - SBML_Constants.EMPTY)) { - NodeTools.setClusterID(node, ""); - } - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_COMPARTMENT_NAME)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_COMPARTMENT_NAME); - } - } - - public static void deleteSpeciesInitialAmount(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT); - } - } - - public static void deleteSpeciesInitialConcentration(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION); - } - } - - public static void deleteSpeciesSubstanceUnits(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS); - } - } - - public static void deleteSpeciesHasOnlySubstanceUnits(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS); - } - } - - public static void deleteSpeciesBoundaryCondition(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION); - } - } - - public static void deleteSpeciesConstant(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT); - } - } - - public static void deleteSpeciesConversionFactor(Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR); - } - } - - public static void deleteSpecies(Node node) { - deleteSpeciesID(node); - deleteSpeciesName(node); - deleteSpeciesCompartment(node); - deleteSpeciesInitialConcentration(node); - deleteSpeciesInitialAmount(node); - deleteSpeciesSubstanceUnits(node); - deleteSpeciesHasOnlySubstanceUnits(node); - deleteSpeciesBoundaryCondition(node); - deleteSpeciesConstant(node); - deleteSpeciesConversionFactor(node); - Graph g = node.getGraph(); - g.deleteNode(node); - } - - /** - * Returns all species nodes of the graph - * - * @return a list of all species nodes of the graph - */ - public static List getSpeciesNodes(Graph g) { - List speciesNodeList = new ArrayList(); - Iterator itNode = g.getNodesIterator(); - while (itNode.hasNext()) { - Node node = itNode.next(); - if (AttributeHelper.getSBMLrole(node).equals("species")) { - speciesNodeList.add(node); - } - } - return speciesNodeList; - } - - /** - * Returns the species node with a distinct id - * - * @param id - * the id of the asked node - * @return the node with a certain id or null if no node has this id - */ - public static Node getSpeciesNode(Graph g, String id) { - List nodeList = getSpeciesNodes(g); - Iterator itNode = nodeList.iterator(); - Node currentNode = null; - while (itNode.hasNext()) { - currentNode = itNode.next(); - if (currentNode.equals(id)) { - return currentNode; - } - } - return null; - } - - /** - * Returns a JSBML Species object belonging to a species node - * - * @param node - * the species node - * @return a JSBML Species object - */ - public static Species getSpecies(Node node) { - if (AttributeHelper.getSBMLrole(node).equals("species")) { - Species species = new Species(); - species.setId(getSpeciesID(node)); - species.setName(getSpeciesName(node)); - species.setCompartment(getSpeciesCompartment(node)); - if (isSpeciesInitialAmount(node)) { - species.setInitialAmount(getSpeciesInitialAmount(node)); - } - if (isSpeciesInitialConcentration(node)) { - species.setInitialConcentration(getSpeciesInitialConcentration(node)); - } - species.setSubstanceUnits(getSpeciesSubstanceUnits(node)); - if (isSpeciesHasOnlySubstanceUnits(node)) { - species.setHasOnlySubstanceUnits(getSpeciesHasOnlySubstanceUnits(node)); - } - if (isSpeciesBoundaryCondition(node)) { - species.setBoundaryCondition(getSpeciesBoundaryCondition(node)); - } - if (isSpeciesConstant(node)) { - species.setConstant(getSpeciesConstant(node)); - } - if (isSpeciesConversionFactor(node)) { - species.setConversionFactor(getSpeciesConversionFactor(node)); - } - return species; - } else { - return null; - } - } - - /** - * Creates a new species node and sets its id - * - * @param g - * the node is added to this graph - * @param id - * the value of the id that will be set - * @return a node or null if the id is the empty string - */ - public static Node createSpecies(Graph g, String id, String name) { - if (!SBML_Constants.EMPTY.equals(id) || !SBML_Constants.EMPTY.equals(name)) { - - Node node = g.addNode(AttributeHelper.getDefaultGraphicsAttributeForNode(new Vector2d(pgg.getNextPosition()))); - // AttributeHelper.setDefaultGraphicsAttribute(node, pgg.getNextPosition()); - AttributeHelper.setLabel(node, id); - AttributeHelper.setSize(node, id.length() * id.length() + 7, 20d); - AttributeHelper.setFillColor(node, Color.WHITE); - AttributeHelper.setShapeEllipse(node); - AttributeHelper.setBorderWidth(node, 1); - - AttributeHelper.setSBMLrole(node, SBML_Constants.ROLE_SPECIES); - addSpeciesID(node, id); - if (!name.equals(SBML_Constants.EMPTY)) { - addSpeciesName(node, name); - } - if (SBMLSpeciesHelper.speciesMap == null) { - SBMLSpeciesHelper.speciesMap = new HashMap(); - } - SBMLSpeciesHelper.speciesMap.put(id, node); - return node; - } - else { - return null; - } - } - - /** - * This method converts a node into a species node - * - * @param n the node that will be transformed - * @return the species node that will be returned - */ - public static Node initSpeciesNode(Node n) { - String label = AttributeHelper.getLabel(n, SBML_Constants.EMPTY); - if (label == SBML_Constants.EMPTY) { - return null; - } - else { - addSpeciesName(n, label); - AttributeHelper.setShape(n, "circle"); - AttributeHelper.setSBMLrole(n, "species"); - return n; - } - } - - public static Node createSpecies(Graph g, Species species) { - Node node = g.addNode(); - AttributeHelper.setSBMLrole(node, SBML_Constants.ROLE_SPECIES); - String label = null; - if (!species.getName().equals(SBML_Constants.EMPTY)) { - label = species.getName(); - } else { - label = species.getId(); - } - if (SBMLSpeciesHelper.speciesMap == null) { - SBMLSpeciesHelper.speciesMap = new HashMap(); - } - SBMLSpeciesHelper.speciesMap.put(species.getId(), node); - if (!label.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setSize(node, label.length() * label.length() + 7, 20d); - AttributeHelper.setDefaultGraphicsAttribute(node, pgg.getNextPosition()); - AttributeHelper.setLabel(node, label); - AttributeHelper.setFillColor(node, Color.WHITE); - AttributeHelper.setShapeEllipse(node); - AttributeHelper.setBorderWidth(node, 1); - } - if (species.isSetId()) { - SBMLSpeciesHelper.speciesMap.put(species.getId(), node); - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID, species.getId()); - AttributeHelper.setLabel(AttributeHelper.getLabels(node).size(), - node, species.getId(), null, AlignmentSetting.HIDDEN.toGMLstring()); - } - if (species.isSetCompartment()) { - NodeTools.setClusterID(node, species.getCompartment()); - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT, node); - } - if (species.isSetInitialConcentration()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION, species.getInitialConcentration()); - } - if (species.isSetInitialAmount()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT, species.getInitialAmount()); - } - if (species.isSetSubstanceUnits()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS, species.getSubstanceUnits()); - } - if (species.isSetHasOnlySubstanceUnits()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS, - species.getHasOnlySubstanceUnits()); - } - if (species.isSetBoundaryCondition()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION, species.getBoundaryCondition()); - } - if (species.isSetConstant()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT, species.getConstant()); - } - if (species.isSetConversionFactor()) { - AttributeHelper.setAttribute(node, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR, species.getConversionFactor()); - } - - return node; - } - - public static Parameter createParameter(Graph g, String id) { - String presentedHeadline = new StringBuffer("SBML Parameter ") - .append(parameterCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_PARAMETER).append(parameterCount).toString(); - setCompartmentID(g, internHeadline, id); - Parameter para = new Parameter(); - para.setId(id); - initParameterNideIDs(internHeadline, presentedHeadline); - ++parameterCount; - return para; - } - - public static void createParameter(Graph g, Parameter parameter) { - String presentedHeadline = new StringBuffer("SBML Parameter ") - .append(parameterCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_PARAMETER).append(parameterCount).toString(); - initParameterNideIDs(internHeadline, presentedHeadline); - - if (parameter.isSetId()) { - setParameterID(g, internHeadline, parameter.getId()); - } - if (parameter.isSetName()) { - setParameterName(g, internHeadline, parameter.getName()); - } - if (parameter.isSetValue()) { - setParameterValue(g, internHeadline, parameter.getValue()); - } - if (parameter.isSetUnits()) { - setParameterUnits(g, internHeadline, parameter.getUnits()); - } - if (parameter.isSetConstant()) { - setParameterConstant(g, internHeadline, parameter.isConstant()); - } - ++parameterCount; - } - - public static void addParameterName(Graph g, String id, String name) { - setParameterName(g, returnParameterHeadlineWithID(g, id), name); - } - - public static void addParameterValue(Graph g, String id, Double value) { - setParameterValue(g, returnParameterHeadlineWithID(g, id), value); - } - - public static void addParameterUnits(Graph g, String id, String units) { - setParameterUnits(g, returnParameterHeadlineWithID(g, id), units); - } - - public static void addParameterConstant(Graph g, String id, boolean constant) { - setParameterConstant(g, returnParameterHeadlineWithID(g, id), constant); - } - - public static void deleteParameterName(Graph g, String id) { - String headline = returnParameterHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_NAME).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_NAME).toString()); - } - } - - public static void deleteParameterID(Graph g, String id) { - String headline = returnParameterHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_ID).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_ID).toString()); - } - } - - public static void deleteParameterValue(Graph g, String id) { - String headline = returnParameterHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.VALUE).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.VALUE).toString()); - } - } - - public static void deleteParameterUnits(Graph g, String id) { - String headline = returnParameterHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_UNITS).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_UNITS).toString()); - } - } - - public static void deleteParameterConstant(Graph g, String id) { - String headline = returnParameterHeadlineWithID(g, id); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_CONSTANT).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.PARAMETER_CONSTANT).toString()); - } - } - - public static void deleteParameter(Graph g, String id) { - deleteParameterName(g, id); - deleteParameterValue(g, id); - deleteParameterUnits(g, id); - deleteParameterConstant(g, id); - deleteParameterID(g, id); - } - - public static boolean isSetParameterName(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnParameterHeadlineWithID(g, id), - new StringBuffer(returnParameterHeadlineWithID(g, id)).append(SBML_Constants.PARAMETER_NAME).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetParameterValue(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnParameterHeadlineWithID(g, id), - new StringBuffer(returnParameterHeadlineWithID(g, id)).append(SBML_Constants.VALUE).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetParameterUnits(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnParameterHeadlineWithID(g, id), - new StringBuffer(returnParameterHeadlineWithID(g, id)).append(SBML_Constants.PARAMETER_UNITS).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetParameterConstant(Graph g, String id) { - if (AttributeHelper.hasAttribute(g, returnParameterHeadlineWithID(g, id), - new StringBuffer(returnParameterHeadlineWithID(g, id)).append(SBML_Constants.PARAMETER_CONSTANT).toString())) { - return true; - } - else { - return false; - } - } - - /** - * Indicates if the parameter id is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return true if the value is set. - */ - private static Boolean isParameterID(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_ID).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the parameter name is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return true if the value is set. - */ - private static Boolean isParameterName(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the parameter value is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return true if the value is set. - */ - private static Boolean isParameterValue(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.VALUE).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the parameter units is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return true if the value is set. - */ - private static Boolean isParameterUnits(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_UNITS) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the attribute constant is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return true if the value is set. - */ - private static Boolean isParameterConstant(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_CONSTANT) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the parameter id if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return the id if it is set. Else the empty string - */ - private static String getParameterID(Graph g, String internHeadline) { - if (isParameterID(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the parameter name if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return the name if it is set. Else the empty string - */ - private static String getParameterName(Graph g, String internHeadline) { - if (isParameterName(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the parameter value if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return the value if it is set. Else null - */ - private static Double getParameterValue(Graph g, String internHeadline) { - if (isParameterValue(g, internHeadline)) { - return (Double) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.VALUE).toString()); - } else { - return null; - } - } - - /** - * Returns the parameter units if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return the units if it is set. Else the empty string - */ - private static String getParameterUnits(Graph g, String internHeadline) { - if (isParameterUnits(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_UNITS).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the attribute constant if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current parameter - * @return constant if it is set. Else null - */ - private static Boolean getParameterConstant(Graph g, String internHeadline) { - if (isParameterConstant(g, internHeadline)) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_CONSTANT).toString()); - } else { - return null; - } - } - - /** - * Sets the id of a parameter - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current parameter - * @param ID - * the value that will be read in - */ - private static void setParameterID(Graph g, String internHeadline, String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_ID) - .toString(), ID); - } - } - - /** - * Sets the name of a parameter - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current parameter - * @param name - * the value that will be read in - */ - private static void setParameterName(Graph g, String internHeadline, - String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_NAME) - .toString(), name); - } - } - - /** - * Sets the value of a parameter - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current parameter - * @param value - * the value that will be read in - */ - private static void setParameterValue(Graph g, String internHeadline, - Double value) { - if (!value.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.VALUE).toString(), - value); - } - } - - /** - * Sets the units of a parameter - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current parameter - * @param units - * the value that will be read in - */ - private static void setParameterUnits(Graph g, String internHeadline, - String units) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_UNITS) - .toString(), units); - } - } - - /** - * Sets the attribute constant of a parameter - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current parameter - * @param constant - * the value that will be read in - */ - private static void setParameterConstant(Graph g, String internHeadline, - Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_CONSTANT) - .toString(), constant); - } - } - - /** - * Returns a list of all parameter headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getParameterHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_PARAMETER); - } - - /** - * Returns a filled JSBML Parameter object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current parameter - * @return a filled Parameter object - */ - private static Parameter getParameter(Graph g, String internHeadline) { - Parameter parameter = new Parameter(); - parameter.setId(getParameterID(g, internHeadline)); - parameter.setName(getParameterName(g, internHeadline)); - if (isParameterValue(g, internHeadline)) { - parameter.setValue(getParameterValue(g, internHeadline)); - } - parameter.setUnits(getParameterUnits(g, internHeadline)); - if (isParameterConstant(g, internHeadline)) { - parameter.setConstant(getParameterConstant(g, internHeadline)); - } - return parameter; - } - - /** - * Returns a list of parameter with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current parameter - * @return a filled list of parameters - */ - private static List getAllParameters(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List parameterList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - parameterList.add(getParameter(g, internHeadline)); - } - return parameterList; - } - - /** - * Returns a list of parameter with distinct headlines - * - * @param g - * contains the information - * @return a filled list of parameters - */ - public static List getAllParameters(Graph g) { - ArrayList internHeadlines = getParameterHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List parameterList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - parameterList.add(getParameter(g, internHeadline)); - } - return parameterList; - } - - public static InitialAssignment createInitialAssignment(Graph g, String symbol) { - String presentedHeadline = new StringBuffer("SBML Initial Assignment ").append(initialAssignmentCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_INITIAL_ASSIGNMENT).append(initialAssignmentCount).toString(); - setInitialAssignmentSymbol(g, internHeadline, symbol); - InitialAssignment ia = new InitialAssignment(); - ia.setLevel(3); - ia.setVariable(symbol); - initInitialAssignmentNiceIDs(internHeadline, presentedHeadline); - ++initialAssignmentCount; - return ia; - } - - public static void createInitialAssignment(Graph g, InitialAssignment ia) { - String presentedHeadline = new StringBuffer("SBML Initial Assignment ").append(initialAssignmentCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_INITIAL_ASSIGNMENT).append(initialAssignmentCount).toString(); - initInitialAssignmentNiceIDs(internHeadline, presentedHeadline); - - if (ia.isSetSymbol()) { - setInitialAssignmentSymbol(g, internHeadline, ia.getVariable()); - } - if (!ia.isSetLevel()) { - ia.setLevel(3); - } - String formula = ""; - try { - if (ia.isSetMath()) { - ASTNode mathTree = ia.getMath(); - formula = mathTree.toFormula(); - setInitialAssignmentFunction(g, internHeadline, formula); - } - } catch (SBMLException e) { - } - ++initialAssignmentCount; - - } - - public static void addInitialAssignmentFunction(Graph g, String symbol, String function) { - setInitialAssignmentFunction(g, returnInitialAssignmentWithSymbol(g, symbol), function); - } - - public static void deleteInitialAssignmentSymbol(Graph g, String symbol) { - String headline = returnInitialAssignmentWithSymbol(g, symbol); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SYMBOL).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.SYMBOL).toString()); - } - } - - public static void deleteInitialAssignmentFunction(Graph g, String symbol) { - String headline = returnInitialAssignmentWithSymbol(g, symbol); - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString()); - } - } - - public static void deleteInitialAssignment(Graph g, String symbol) { - deleteInitialAssignmentFunction(g, symbol); - deleteInitialAssignmentSymbol(g, symbol);; - } - - public static boolean isSetInitialAssignmentFunction(Graph g, String symbol) { - if (AttributeHelper.hasAttribute(g, returnInitialAssignmentWithSymbol(g, symbol), - new StringBuffer(returnInitialAssignmentWithSymbol(g, symbol)).append(SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString())) { - return true; - } - else { - return false; - } - } - - public static boolean isSetInitialAssignmentSymbol(Graph g, String symbol) { - if (AttributeHelper.hasAttribute(g, returnInitialAssignmentWithSymbol(g, symbol), - new StringBuffer(returnInitialAssignmentWithSymbol(g, symbol)).append(SBML_Constants.SYMBOL).toString())) { - return true; - } - else { - return false; - } - } - - /** - * Indicates if the attribute symbol is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current initial assignment - * @return true if the value is set. - */ - private static Boolean isInitialAssignmentSymbol(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SYMBOL).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current initial assignment - * @return true if the value is set. - */ - private static Boolean isInitialAssignmentFunction(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - /** - * Sets the symbol of a initial assignment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current initial assignment - * @param symbol - * the value that will be read in - */ - private static void setInitialAssignmentSymbol(Graph g, - String internHeadline, String symbol) { - if (!symbol.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SYMBOL).toString(), - symbol); - } - } - - /** - * Sets the function of a initial assignment - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current initial assignment - * @param function - * the value that will be read in - */ - private static void setInitialAssignmentFunction(Graph g, - String internHeadline, String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION) - .toString(), function); - } - } - - /** - * Returns the initial assignment symbol if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current initial assignment - * @return the symbol if it is set. Else the empty string - */ - private static String getInitialAssignmentSymbol(Graph g, - String internHeadline) { - if (isInitialAssignmentSymbol(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.SYMBOL).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the initial assignment function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current initial assignment - * @return the function if it is set. Else the empty string - */ - private static String getInitialAssignmentFunction(Graph g, - String internHeadline) { - if (isInitialAssignmentFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns a list of all initial assignment headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getInitialAssignmentHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_INITIAL_ASSIGNMENT); - } - - /** - * Returns a filled JSBML initial assignment object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current initial assignment - * @return a filled initial assignment object - */ - private static InitialAssignment getInitialAssignment(Graph g, - String internHeadline) { - InitialAssignment ia = new InitialAssignment(); - ia.setLevel(3); - if (isInitialAssignmentSymbol(g, internHeadline)) { - ia.setVariable(getInitialAssignmentSymbol(g, internHeadline)); - } - if (isInitialAssignmentFunction(g, internHeadline)) { - try { - ia.setFormula(getInitialAssignmentFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - } - return ia; - } - - /** - * Returns a list of initial assignment with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current initial - * assignment - * @return a filled list of initial assignment - */ - private static List getAllInitialAssignment(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List iaList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - iaList.add(getInitialAssignment(g, internHeadline)); - } - return iaList; - } - - /** - * Returns a list of initial assignment with distinct headlines - * - * @param g - * contains the information - * @return a filled list of initial assignment - */ - public static List getAllInitialAssignment(Graph g) { - List internHeadlines = getInitialAssignmentHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List iaList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - iaList.add(getInitialAssignment(g, internHeadline)); - } - return iaList; - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current rate rule - * @return true if the value is set. - */ - private static Boolean isRateRuleFunction(Graph g, String internHeadline) { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the variable is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current rate rule - * @return true if the value is set. - */ - private static Boolean isRateRuleVariable(Graph g, String internHeadline) { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_VARIABLE) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the rate rule variable if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current rate rule - * @return the variable if it is set. Else the empty string - */ - private static String getRateRuleVariable(Graph g, String internHeadline) { - if (isRateRuleVariable(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the rate rule function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current rate rule - * @return the function if it is set. Else the empty string - */ - private static String getRateRuleFunction(Graph g, String internHeadline) { - if (isRateRuleFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the function of a rate rule - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current rate rule - * @param function - * the value that will be read in - */ - private static void setRateRuleFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_FUNCTION) - .toString(), function); - } - } - - /** - * Sets the variable of a rate rule - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current rate rule - * @param variable - * the value that will be read in - */ - private static void setRateRuleVariable(Graph g, String internHeadline, - String variable) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_VARIABLE) - .toString(), variable); - } - } - - /** - * Returns a list of all rate rule headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getRateRuleHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_RATE_RULE); - } - - /** - * Returns a filled JSBML rate rule object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current rate rule - * @return a filled rate rule object - */ - private static RateRule getRateRule(Graph g, String internHeadline) { - RateRule rr = new RateRule(); - if (isRateRuleVariable(g, internHeadline)) { - rr.setVariable(getRateRuleVariable(g, internHeadline)); - } - if (isRateRuleFunction(g, internHeadline)) { - try { - rr.setFormula(getRateRuleFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - } - return rr; - } - - /** - * Returns a list of rate rules with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current rate rule - * @return a filled list of rate rules - */ - private static List getAllRateRules(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List rrList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - rrList.add(getRateRule(g, internHeadline)); - } - return rrList; - } - - /** - * Returns a list of rate rules with distinct headlines - * - * @param g - * contains the information - * @return a filled list of rate rules - */ - private static List getAllRateRules(Graph g) { - List internHeadlines = getRateRuleHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List rrList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - rrList.add(getRateRule(g, internHeadline)); - } - return rrList; - } - - public static void deleteAssignmentRule(Graph g, String variable) { - deleteAssignmentRuleFunction(g, variable); - deleteAssignmentRuleVariable(g, variable); - } - - public static void deleteRateRule(Graph g, String variable) { - deleteRateRuleFunction(g, variable); - deleteRateRuleVariable(g, variable); - } - - public static void deleteAlgebraicRule(Graph g, String formula) { - deleteAlgebraicRuleFunction(g, formula); - } - - public static AssignmentRule createAssignmentRule(Graph g, String variable) { - String presentedHeadline = new StringBuffer("SBML Assignment Rule ").append(assignmentRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_ASSIGNMENT_RULE).append(assignmentRuleCount).toString(); - setAssignmentRuleVariable(g, internHeadline, variable); - AssignmentRule ar = new AssignmentRule(); - ar.setLevel(3); - ar.setVariable(variable); - initAssignmnetRuleNiceIDs(internHeadline, presentedHeadline); - ++assignmentRuleCount; - return ar; - } - - public static RateRule createRateRule(Graph g, String variable) { - String presentedHeadline = new StringBuffer("SBML Rate Rule ").append(rateRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_RATE_RULE).append(rateRuleCount).toString(); - setRateRuleVariable(g, internHeadline, variable); - RateRule rr = new RateRule(); - rr.setLevel(3); - rr.setVariable(variable); - initRateRuleNiceIDs(internHeadline, presentedHeadline); - ++rateRuleCount; - return rr; - } - - public static AlgebraicRule createAlgebraicRule(Graph g, String formula) { - String internHeadline = new StringBuffer(SBML_Constants.SBML_ALGEBRAIC_RULE).append(algebraicRuleCount).toString(); - String presentedHeadline = new StringBuffer("SBML Algebraic Rule ").append(algebraicRuleCount).toString(); - setAlgebraicRuleFunction(g, internHeadline, formula); - AlgebraicRule ar = new AlgebraicRule(); - ar.setLevel(3); - try { - ar.setMath(ASTNode - .parseFormula(formula)); - } catch (ParseException e) { - e.printStackTrace(); - } - initAlgebraicRuleNiceIDs(internHeadline, presentedHeadline); - ++algebraicRuleCount; - return ar; - } - - public static AssignmentRule createAssignmentRule(Graph g, String variable, String formula) { - String presentedHeadline = new StringBuffer("SBML Assignment Rule ").append(assignmentRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_ASSIGNMENT_RULE).append(assignmentRuleCount).toString(); - setAssignmentRuleVariable(g, internHeadline, variable); - setAssignmentRuleFunction(g, internHeadline, formula); - AssignmentRule ar = new AssignmentRule(); - ar.setLevel(3); - ar.setVariable(variable); - try { - ar.setMath(ASTNode - .parseFormula(formula)); - } catch (ParseException e) { - e.printStackTrace(); - } - initAssignmnetRuleNiceIDs(internHeadline, presentedHeadline); - ++assignmentRuleCount; - return ar; - } - - public static RateRule createRateRule(Graph g, String variable, String formula) { - String presentedHeadline = new StringBuffer("SBML Rate Rule ").append(rateRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_RATE_RULE).append(rateRuleCount).toString(); - setRateRuleVariable(g, internHeadline, variable); - setRateRuleFunction(g, internHeadline, formula); - RateRule rr = new RateRule(); - rr.setLevel(3); - rr.setVariable(variable); - try { - rr.setMath(ASTNode.parseFormula(formula)); - } catch (ParseException e) { - e.printStackTrace(); - } - initRateRuleNiceIDs(internHeadline, presentedHeadline); - ++rateRuleCount; - return rr; - } - - public static void createAssignmentRule(Graph g, AssignmentRule ar) { - String presentedHeadline = new StringBuffer("SBML Assignment Rule ").append(assignmentRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_ASSIGNMENT_RULE).append(assignmentRuleCount).toString(); - initAssignmnetRuleNiceIDs(internHeadline, presentedHeadline); - ar.setLevel(3); - if (ar.isSetMath()) { - String math = ""; - try { - if (null != ar.getMath()) { - math = ar.getMath().toFormula(); - } - } catch (Exception e) { - e.printStackTrace(); - } - setAssignmentRuleFunction(g, internHeadline, math); - } - if (ar.isSetVariable()) { - setAssignmentRuleVariable(g, internHeadline, ar.getVariable()); - } - ++assignmentRuleCount; - } - - public static void createRateRule(Graph g, RateRule rr) { - String presentedHeadline = new StringBuffer("SBML Rate Rule ").append(rateRuleCount).toString(); - String internHeadline = new StringBuffer(SBML_Constants.SBML_RATE_RULE).append(rateRuleCount).toString(); - initRateRuleNiceIDs(internHeadline, presentedHeadline); - rr.setLevel(3); - if (rr.isSetMath()) { - String math = ""; - try { - if (null != rr.getMath()) { - math = rr.getMath().toFormula(); - } - } catch (Exception e) { - e.printStackTrace(); - } - setRateRuleFunction(g, internHeadline, math); - } - if (rr.isSetVariable()) { - setRateRuleVariable(g, internHeadline, rr.getVariable()); - } - ++rateRuleCount; - } - - public static void createAlgebraicRule(Graph g, AlgebraicRule ar) { - String internHeadline = new StringBuffer(SBML_Constants.SBML_ALGEBRAIC_RULE).append(algebraicRuleCount).toString(); - String presentedHeadline = new StringBuffer("SBML Algebraic Rule ").append(algebraicRuleCount).toString(); - initAlgebraicRuleNiceIDs(internHeadline, presentedHeadline); - ar.setLevel(3); - if (ar.isSetMath()) { - String math = ""; - try { - if (null != ar.getMath()) { - math = ar.getMath().toFormula(); - } - } catch (Exception e) { - e.printStackTrace(); - } - setAlgebraicRuleFunction(g, internHeadline, math); - } - ++algebraicRuleCount; - } - - public static boolean isSetAssignmentRuleFunction(Graph g, String variable) { - if (isAssignmentRuleFunction(g, returnAssignmentRuleWithID(g, variable))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetAssignmentRuleVariable(Graph g, String variable) { - if (isAssignmentRuleVariable(g, returnAssignmentRuleWithID(g, variable))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetRateRuleFunction(Graph g, String variable) { - if (isRateRuleFunction(g, returnRateRuleWithID(g, variable))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetRateRuleVariable(Graph g, String variable) { - if (isRateRuleVariable(g, returnRateRuleWithID(g, variable))) { - return true; - } - else { - return false; - } - } - - public static void deleteAssignmentRuleVariable(Graph g, String variable) { - String headline = returnAssignmentRuleWithID(g, variable); - if (isAssignmentRuleVariable(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.ASSIGNMENT_VARIABLE).toString()); - } - } - - public static void deleteAssignmentRuleFunction(Graph g, String variable) { - String headline = returnAssignmentRuleWithID(g, variable); - if (isAssignmentRuleFunction(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.ASSIGNMENT_FUNCTION).toString()); - } - } - - public static void deleteRateRuleVariable(Graph g, String variable) { - String headline = returnRateRuleWithID(g, variable); - if (isRateRuleVariable(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.RATE_VARIABLE).toString()); - } - } - - public static void deleteRateRuleFunction(Graph g, String variable) { - String headline = returnRateRuleWithID(g, variable); - if (isRateRuleFunction(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.RATE_FUNCTION).toString()); - } - } - - public static void deleteAlgebraicRuleFunction(Graph g, String function) { - String headline = returnAlgebraicRuleWithFormula(g, function); - if (isAlgebraicRuleFunction(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.ALGEBRAIC_FUNCTION).toString()); - } - } - - public static void addAssignmentRuleFunction(Graph g, String variable, String function) { - setAssignmentRuleFunction(g, returnAssignmentRuleWithID(g, variable), function); - } - - public static void addAssignmentRuleVariable(Graph g, String variable) { - createAssignmentRule(g, variable); - } - - public static void addRateRuleFunction(Graph g, String variable, String function) { - setRateRuleFunction(g, returnRateRuleWithID(g, variable), function); - } - - public static void addRateRuleVariable(Graph g, String variable) { - createRateRule(g, variable); - } - - public static void addAlgebraicRule(Graph g, String function) { - createAlgebraicRule(g, function); - } - - /** - * Indicates if the variable is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current assignment rule - * @return true if the value is set. - */ - private static Boolean isAssignmentRuleVariable(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_VARIABLE) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current assignment rule - * @return true if the value is set. - */ - private static Boolean isAssignmentRuleFunction(Graph g, - String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the assignment rule variable if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current assignment rule - * @return the variable if it is set. Else the empty string - */ - private static String getAssignmentRuleVariable(Graph g, - String internHeadline) { - if (isAssignmentRuleVariable(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the assignment rule function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current assignment rule - * @return the function if it is set. Else the empty string - */ - private static String getAssignmentRuleFunction(Graph g, - String internHeadline) { - if (isAssignmentRuleFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the function of a assignment rule - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current assignment rule - * @param function - * the value that will be read in - */ - private static void setAssignmentRuleFunction(Graph g, - String internHeadline, String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_FUNCTION) - .toString(), function); - } - } - - /** - * Sets the variable of a assignment rule - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current assignment rule - * @param variable - * the value that will be read in - */ - private static void setAssignmentRuleVariable(Graph g, - String internHeadline, String variable) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ASSIGNMENT_VARIABLE) - .toString(), variable); - } - } - - /** - * Returns a list of all assignment rule headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - public static ArrayList getAssignmentRuleHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_ASSIGNMENT_RULE); - } - - /** - * Returns a filled JSBML assignment rule object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current assignment rule - * @return a filled assignment rule object - */ - private static AssignmentRule getAssignmentRule(Graph g, - String internHeadline) { - AssignmentRule ar = new AssignmentRule(); - if (isAssignmentRuleVariable(g, internHeadline)) { - ar.setVariable(getAssignmentRuleVariable(g, internHeadline)); - } - if (isAssignmentRuleFunction(g, internHeadline)) { - try { - ar.setFormula(getAssignmentRuleFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - } - return ar; - } - - /** - * Returns a list of assignment rules with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current assignment - * rule - * @return a filled list of assignment rules - */ - private static List getAllAssignmentRules(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List arList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - arList.add(getAssignmentRule(g, internHeadline)); - } - return arList; - } - - /** - * Returns a list of assignment rules with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current assignment - * rule - * @return a filled list of assignment rules - */ - public static List getAllAssignmentRules(Graph g) { - List internHeadlines = getAssignmentRuleHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List arList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - arList.add(getAssignmentRule(g, internHeadline)); - } - return arList; - } - - /** - * Sets the function of a algebraic rule - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current algebraic rule - * @param function - * the value that will be read in - */ - private static void setAlgebraicRuleFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ALGEBRAIC_FUNCTION) - .toString(), function); - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current algebraic rule - * @return true if the value is set. - */ - private static Boolean isAlgebraicRuleFunction(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the algebraic rule function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current algebraic rule - * @return the function if it is set. Else the empty string - */ - private static String getAlgebraicRuleFunction(Graph g, String internHeadline) { - if (isAlgebraicRuleFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns a list of all algebraic rule headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getAlgebraicRuleHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_ALGEBRAIC_RULE); - } - - /** - * Returns a filled JSBML algebraic rule object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current algebraic rule - * @return a filled algebraic rule object - */ - private static AlgebraicRule getAlgebraicRule(Graph g, String internHeadline) { - AlgebraicRule ar = new AlgebraicRule(); - if (isAlgebraicRuleFunction(g, internHeadline)) { - try { - ar.setFormula(getAlgebraicRuleFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - } - return ar; - } - - /** - * Returns a list of algebraic rules with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current algebraic rule - * @return a filled list of algebraic rules - */ - private static List getAllAlgebraicRules(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List arList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - arList.add(getAlgebraicRule(g, internHeadline)); - } - return arList; - } - - /** - * Returns a list of algebraic rules with distinct headlines - * - * @param g - * contains the information - * @return a filled list of algebraic rules - */ - private static List getAllAlgebraicRules(Graph g) { - List internHeadlines = getAlgebraicRuleHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List arList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - arList.add(getAlgebraicRule(g, internHeadline)); - } - return arList; - } - - public static Constraint createConstraint(Graph g, String math) { - String internHeadline = new StringBuffer( - SBML_Constants.SBML_CONSTRAINT).append(constraintCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Constraint ") - .append(constraintCount).toString(); - initConstraintNiceIDs(internHeadline, presentedHeadline); - setConstraintFunction(g, internHeadline, math); - Constraint constraint = new Constraint(); - try { - constraint.setMath(ASTNode.parseFormula(math)); - } catch (ParseException e) { - e.printStackTrace(); - } - ++constraintCount; - return constraint; - } - - public static void createConstraint(Graph g, Constraint constraint) { - String internHeadline = new StringBuffer( - SBML_Constants.SBML_CONSTRAINT).append(constraintCount) - .toString(); - String presentedHeadline = new StringBuffer("SBML Constraint ") - .append(constraintCount).toString(); - initConstraintNiceIDs(internHeadline, presentedHeadline); - if (constraint.isSetMath()) { - setConstraintFunction(g, internHeadline, constraint.getMath().toString()); - } - if (constraint.isSetMessage()) { - String message = removeTagFromString(constraint.getMessageString()); - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString(), - message); - } - ++constraintCount; - } - - public static void deleteConstraint(Graph g, String formula) { - ArrayList headlines = getConstraintHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Constraint constraint = getConstraint(g, headline); - if (constraint.getMath().toString().trim().equals(formula.trim())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer(headline).append(SBML_Constants.CONSTRAINT).toString()); - if (isConstraintMessage(g, headline)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.MESSAGE).toString()); - } - } - } - } - - public static void addConstraintMessage(Graph g, String formula, String message) { - ArrayList headlines = getConstraintHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Constraint constraint = getConstraint(g, headline); - if (constraint.getMath().toString().trim().equals(formula.trim())) { - AttributeHelper.setAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.MESSAGE).toString(), message); - } - } - } - - public static void addConstraintConstraint(Graph g, String formula) { - ArrayList headlines = getConstraintHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Constraint constraint = getConstraint(g, headline); - if (constraint.getMath().toString().trim().equals(formula.trim())) { - AttributeHelper.setAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.CONSTRAINT) - .toString(), formula); - } - } - } - - public static void deleteConstraintMessage(Graph g, String constraint) { - ArrayList headlines = getConstraintHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Constraint con = getConstraint(g, headline); - if (con.getMath().toString().trim().equals(constraint.trim())) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.MESSAGE).toString()); - } - } - } - - public static boolean isSetConstraintMessage(Graph g, String constraint) { - ArrayList headlines = getConstraintHeadlines(g); - Iterator it = headlines.iterator(); - while (it.hasNext()) { - String headline = it.next(); - Constraint con = getConstraint(g, headline); - if (con.getMath().toString().trim().equals(constraint.trim())) { - if (AttributeHelper.hasAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.MESSAGE).toString())) { - return true; - } - } - } - return false; - } - - private static String removeTagFromString(String xhtml) { - String content = xhtml.replace("\n", "").replace("\t", "").trim(); - // Replace anything between script or style tags - // A regular expression to match anything in between <> - // Reads as: Match a "<" - // Match one or more characters that are not ">" - // Match "<"; - String tagregex = "<[^>]*>"; - Pattern p2 = Pattern.compile(tagregex); - Matcher m2 = p2.matcher(content); - // Replace any matches with nothing - content = m2.replaceAll(""); - return content.trim(); - } - - /** - * Sets the message of a constraint - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current constraint - * @param message - * the value that will be read in - */ - private static void setConstraintMessage(Graph g, String internHeadline, - String message) { - if (!message.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString(), - message); - } - } - - /** - * Sets the function of a constraint - * - * @param g - * the graph where the information will be set - * @param internHeadline - * contains the number of the current constraint - * @param function - * the value that will be read in - */ - private static void setConstraintFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTRAINT) - .toString(), function); - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current constraint - * @return true if the value is set. - */ - private static Boolean isConstraintFunction(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.CONSTRAINT).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the message is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current constraint - * @return true if the value is set. - */ - private static Boolean isConstraintMessage(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the constraint function if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current constraint - * @return the function if it is set. Else the empty string - */ - private static String getConstraintFunction(Graph g, String internHeadline) { - if (isConstraintFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTRAINT).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the constraint message if it is set - * - * @param g - * the graph where the information is read from - * @param internHeadline - * contains the number of the current constraint - * @return the message if it is set. Else the empty string - */ - private static String getConstraintMessage(Graph g, String internHeadline) { - if (isConstraintMessage(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.MESSAGE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns a list of all constraint headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getConstraintHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_CONSTRAINT); - } - - /** - * Returns a filled JSBML constraint object - * - * @param g - * contains the information - * @param internHeadline - * contains the number of the current constraint - * @return a filled constraint object - */ - private static Constraint getConstraint(Graph g, String internHeadline) { - Constraint con = new Constraint(); - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.MESSAGE).toString())) { - String message = getConstraintMessage(g, internHeadline); - String completeMessage = "

" - + message + "

"; - con.setMessage(completeMessage); - } - try { - con.setMath(ASTNode.parseFormula(getConstraintFunction(g, internHeadline))); - } catch (ParseException e) { - e.printStackTrace(); - } - return con; - } - - /** - * Returns a list of constraint with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current constraint - * @return a filled list of constraint - */ - private static List getAllConstraints(Graph g, - List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List conList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - conList.add(getConstraint(g, internHeadline)); - } - return conList; - } - - /** - * Returns a list of constraint with distinct headlines - * - * @param g - * contains the information - * @return a filled list of constraint - */ - public static List getAllConstraints(Graph g) { - List internHeadlines = getCompartmentHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List conList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - conList.add(getConstraint(g, internHeadline)); - } - return conList; - } - - /** - * Indicates if compartment of a reaction is set - * - * @param reactionNode - * the node where the information is read from - * @return true if compartment is set else false - */ - public static Boolean isReactionCompartment(Node reactionNode) { - if (!NodeTools.getClusterID(reactionNode, SBML_Constants.EMPTY).equals( - SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if fast of a reaction is set - * - * @param reactionNode - * the node where the information is read from - * @return true if fast is set else false - */ - public static Boolean isReactionFast(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.FAST)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if reversible of a reaction is set - * - * @param reactionNode - * the node where the information is read from - * @return true if reversible is set else false - */ - public static Boolean isReactionReversible(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE)) { - - return true; - } else { - return false; - } - } - - /** - * Indicates if name of a reaction is set - * - * @param reactionNode - * the node where the information is read from - * @return true if name is set else false - */ - public static Boolean isReactionName(Node reactionNode) { - if (!AttributeHelper.getLabel(reactionNode, SBML_Constants.EMPTY) - .equals(SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if id of a reaction is set - * - * @param reactionNode - * the node where the information is read from - * @return true if id is set else false - */ - public static Boolean isReactionID(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ID)) { - return true; - } else { - return false; - } - } - - /** - * Returns the id of a reaction - * - * @param reactionNode - * the node where the information is read from - * @return id if it is set else the empty string - */ - public static String getReactionID(Node reactionNode) { - if (isReactionID(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the name of a reaction - * - * @param reactionNode - * the node where the information is read from - * @return name if it is set else the empty string - */ - public static String getReactionName(Node reactionNode) { - return AttributeHelper.getLabel(reactionNode, SBML_Constants.EMPTY); - } - - /** - * Returns the attribute reversible of a reaction - * - * @param reactionNode - * the node where the information is read from - * @return reversible if it is set else null - */ - public static Boolean getReactionReversible(Node reactionNode) { - if (isReactionReversible(reactionNode)) { - return (Boolean) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REVERSIBLE); - } else { - return null; - } - } - - /** - * Returns the attribute fast of a reaction - * - * @param reactionNode - * the node where the information is read from - * @return fast if it is set else the empty string - */ - public static Boolean getReactionFast(Node reactionNode) { - if (isReactionFast(reactionNode)) { - return (Boolean) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.FAST); - } else { - return null; - } - } - - /** - * Returns the compartment of a reaction - * - * @param reactionNode - * the node where the information is read from - * @return compartment if it is set else the empty string - */ - public static String getReactionCompartment(Node reactionNode) { - return NodeTools.getClusterID(reactionNode, SBML_Constants.EMPTY); - } - - /** - * Sets the attribute id of a node - * - * @param reactionNode - * the attribute belongs to this node - * @param id - * the value that will be set - */ - public static void setReactionID(Node reactionNode, String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ID, ID); - } - } - - public static void deleteReactionID(Node reactionNode) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ID); - } - - public static void setReactionName(Node reactionNode, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_NAME, name); - } - } - - public static void deleteReactionName(Node reactionNode) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_NAME); - } - - /** - * Sets the attribute name of a node - * - * @param reactionNode - * the attribute belongs to this node - * @param name - * the value that will be set - */ - public static void setReactionLabel(Node reactionNode, String name, - String id, PositionGridGenerator pgg) { - String label = null; - if (!name.equals(SBML_Constants.EMPTY)) { - label = name; - } else { - label = id; - } - if (!label.equals(SBML_Constants.EMPTY)) { - attReader.setAttributes(reactionNode, Color.white, label, - pgg.getNextPosition(), 7); - } - } - - /** - * Sets the attribute reversible of a node - * - * @param reactionNode - * the attribute belongs to this node - * @param reversible - * the value that will be set - */ - public static void setReactionReversible(Node reactionNode, - Boolean reversible) { - if (!reversible.equals(null)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, reversible); - } - } - - public static void deleteReactionReversible(Node reactionNode) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE); - } - - /** - * Sets the attribute fast of a node - * - * @param reactionNode - * the attribute belongs to this node - * @param fast - * the value that will be set - */ - public static void setReactionFast(Node reactionNode, Boolean fast) { - if (!fast.equals(null)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.FAST, fast); - } - } - - public static void deleteReactionFast(Node reactionNode) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.FAST); - } - - /** - * Sets the compartment of a node - * - * @param reactionNode - * the compartment belongs to this node - * @param compartment - * the id of the compartment that will be set - */ - public static void setReactionCompartment(Node reactionNode, - String compartment) { - if (!compartment.equals(SBML_Constants.EMPTY)) { - ; - NodeTools.setClusterID(reactionNode, compartment); - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT, compartment); - } - } - - public static void deleteReactionCompartment(Node reactionNode) { - AttributeHelper.deleteAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT); - NodeTools.setClusterID(reactionNode, ""); - } - - /** - * Sets the species of a reaction - * - * @param reactionEdge - * the edge where the information will be read in - * @param species - * the value that will be read in - */ - public static void setReactionSpecies(Edge reactionEdge, String species) { - if (!species.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES, species); - } - } - - /** - * The id of the species of an reaction - * - * @param reactionEdge - * the edge where the information will be read in - * @param ID - * the value that will be read in - */ - public static void setReactionSpeciesID(Edge reactionEdge, String ID) { - if (!reactionEdge.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_ID, ID); - } - } - - /** - * The name of the species of a reaction - * - * @param reactionEdge - * the edge where the information will be read in - * @param name - * the value that will be read in - */ - public static void setReactionSpeciesName(Edge reactionEdge, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_NAME, name); - } - } - - /** - * Indicates if the species attribute is set - * - * @param reactionEdge - * the edge where the information will be read from - * @return true if the value is set - */ - public static Boolean isReactionSpecies(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the species id attribute is set - * - * @param reactionEdge - * the edge where the information will be read from - * @return true if the value is set - */ - public static Boolean isReactionSpeciesID(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_ID)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the species name attribute is set - * - * @param reactionEdge - * the edge where the information will be read from - * @return true if the value is set - */ - public static Boolean isReactionSpeciesName(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_NAME)) { - return true; - } else { - return false; - } - } - - /** - * Returns the species - * - * @param reactionEdge - * the edge where the information will be read from - * @return the value of the attribute species - */ - public static String getReactionSpecies(Edge reactionEdge) { - if (isReactionSpecies(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the species name - * - * @param reactionEdge - * the edge where the information will be read from - * @return the value of the attribute name - */ - public static String getReactionSpeciesName(Edge reactionEdge) { - if (isReactionSpeciesName(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES_REFERENCE_NAME); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Return the species id - * - * @param reactionEdge - * the edge where the information will be read from - * @return the value of the attribute id - */ - public static String getReactionSpeciesID(Edge reactionEdge) { - if (isReactionSpeciesID(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES_REFERENCE_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Indicates if there is set a value for stoichiometry - * - * @param reactionEdge - * the edge where the information will be read from - * @return true if the attribute stoichiometry is set - */ - public static Boolean isReactionStoichiometry(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if there is set a value for constant - * - * @param reactionEdge - * the edge where the information will be read from - * @return true if the attribute constant is set - */ - public static Boolean isReactionConstant(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTION_CONSTANT)) { - return true; - } else { - return false; - } - } - - /** - * Returns the value of the attribute stoichiometry - * - * @param reactionEdge - * the edge where the information will be read from - * @return the value of stoichiometry if the value is set. Else null - */ - public static String getStoichiometry(Edge reactionEdge) { - if (!AttributeHelper.getSBMLrole(reactionEdge).equals("modifier")) { - if (isReactionStoichiometry(reactionEdge)) { - Object obj = attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.STOICHIOMETRY); - if (obj instanceof String) - return (String) obj; - else if (obj instanceof Double) - return obj.toString(); - else - return SBML_Constants.EMPTY; - } else { - return SBML_Constants.EMPTY; - } - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the value of the attribute constant - * - * @param reactionEdge - * the edge where the information will be read from - * @return the value of constant if the value is set. Else null - */ - public static Boolean getReactionConstant(Edge reactionEdge) { - if (!AttributeHelper.getSBMLrole(reactionEdge).equals("modifier")) { - if (isReactionConstant(reactionEdge)) { - return (Boolean) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.REACTION_CONSTANT); - } else { - return null; - } - } else { - return null; - } - } - - /** - * Sets a value for the attribute stoichiometry - * - * @param reactionEdge - * the edge where the information will be read in - * @param stoichiometry - * the value that will be set - */ - public static void setStoichiometry(Edge reactionEdge, - Double stoichiometry) { - if (!AttributeHelper.getSBMLrole(reactionEdge).equals("modifier")) { - if (!stoichiometry.equals(null)) { - if (isSetStoichiometry(reactionEdge)) { - deleteStoichiometry(reactionEdge); - } - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - AttributeHelper.setLabel(reactionEdge, Double.toString(stoichiometry)); - } - } - } - - // todo: die set methodenfür product, reactant , modifier. - public static void deleteStoichiometry(Edge edge) { - if (isSetStoichiometry(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY); - AttributeHelper.setLabel(edge, ""); - } - } - - public static void deleteConstant(Edge edge) { - if (isSetConstant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTION_CONSTANT); - } - } - - public static void deleteReactionSpecies(Edge edge) { - if (isSetReactionSpecies(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, - SBML_Constants.SPECIES); - } - } - - public static void deleteReactionSpeciesID(Edge edge) { - if (isSetReactionSpeciesID(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_ID); - } - } - - public static void deleteReactionSpeciesName(Edge edge) { - if (isSetReactionSpeciesName(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_NAME); - } - } - - public static boolean isSetStoichiometry(Edge edge) { - if (isReactionStoichiometry(edge)) { - return true; - } - return false; - } - - public static boolean isSetConstant(Edge edge) { - if (isReactionConstant(edge)) { - return true; - } - return false; - } - - public static boolean isSetReactionSpecies(Edge edge) { - if (isReactionSpecies(edge)) { - return true; - } - return false; - } - - public static boolean isSetReactionSpeciesID(Edge edge) { - if (isReactionSpeciesID(edge)) { - return true; - } - return false; - } - - public static boolean isSetReactionSpeciesName(Edge edge) { - if (isReactionSpeciesName(edge)) { - return true; - } - return false; - } - - /** - * Sets a value for the attribute constant - * - * @param reactionEdge - * the edge where the information will be read in - * @param constant - * the value that will be set - */ - public static void setReactionConstant(Edge reactionEdge, Boolean constant) { - if (!AttributeHelper.getSBMLrole(reactionEdge).equals("modifier")) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTION_CONSTANT, constant); - } - } - } - - /** - * Indicates if the function of a kinetic law is set - * - * @param reactionNode - * the node where the information will be read from - * @return true id the value is set. Else false - */ - public static Boolean isKineticLawFunction(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION)) { - return true; - } else { - return false; - } - } - - /** - * Returns the function of a kinetic law - * - * @param reactionNode - * the node where the information will be read from - * @return the function string if it is set. Else the empty string - */ - public static String getKineticLawFunction(Node reactionNode) { - if (isKineticLawFunction(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the function of a kinetic law - * - * @param reactionNode - * the node where the information will be read in - * @param function - * contains the value that will be read in - */ - private static void setKineticLawFunction(Node reactionNode, String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION, function); - } - } - - public static void addKineticLaw(Node reactionNode, String function) { - if (!isInitializedKineticLaw) { - initKineticLawNideIDs(); - isInitializedKineticLaw = true; - } - setKineticLawFunction(reactionNode, function); - } - - public static void addKineticLaw(Node reactionNode, KineticLaw kineticLaw) { - if (!isInitializedKineticLaw) { - initKineticLawNideIDs(); - isInitializedKineticLaw = true; - } - if (kineticLaw.isSetMath()) { - setKineticLawFunction(reactionNode, kineticLaw.getMath().toFormula()); - } - } - - public static void deleteKineticLawFunction(Node node) { - AttributeHelper.deleteAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, - SBML_Constants.KINETIC_LAW_FUNCTION); - } - - /** - * The attribute id will be set - * - * @param reactionNode - * the node where the information will be read in - * @param ID - * contains the information - * @param internAttributeName - * contains the number of the current local parameter - */ - private static void setLocalParameterID(Node reactionNode, String ID, - String internAttributeName) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_ID).toString(), ID); - } - } - - /** - * The attribute name will be set - * - * @param reactionNode - * the node where the information will be read in - * @param name - * contains the information - * @param internAttributeName - * contains the number of the current local parameter - */ - private static void setLocalParameterName(Node reactionNode, String name, - String internAttributeName) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_NAME).toString(), - name); - } - } - - /** - * The attribute value that will be set - * - * @param reactionNode - * the node where the information will be read in - * @param value - * contains the information - * @param internAttributeName - * contains the number of the current local parameter - */ - private static void setLocalParameterValue(Node reactionNode, Double value, - String internAttributeName) { - if (!value.equals(null)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_VALUE).toString(), - value); - } - } - - /** - * The attribute units that will be set - * - * @param reactionNode - * the node where the information will be read in - * @param units - * contains the information - * @param internAttributeName - * contains the number of the current local parameter - */ - private static void setLocalParameterUnits(Node reactionNode, String units, - String internAttributeName) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_UNITS).toString(), - units); - } - } - - /** - * Indicates if the attribute id is set - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return true if the value is set - */ - public static Boolean isLocalParameterID(Node reactionNode, - int localParameterCount) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_ID).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the attribute name is set - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return true if the value is set - */ - public static Boolean isLocalParameterName(Node reactionNode, - int localParameterCount) { - if (AttributeHelper - .hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the attribute value is set - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return true if the value is set - */ - public static Boolean isLocalParameterValue(Node reactionNode, - int localParameterCount) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_VALUE) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the attribute units is set - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return true if the value is set - */ - public static Boolean isLocalParameterUnits(Node reactionNode, - int localParameterCount) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_UNITS) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the value of the attribute id - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return the value if it is set. Else the empty string - */ - public static String getLocalParameterID(Node reactionNode, - int localParameterCount) { - if (isLocalParameterID(reactionNode, localParameterCount)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_ID) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the value of the attribute name - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return the value if it is set. Else the empty string - */ - public static String getLocalParameterName(Node reactionNode, - int localParameterCount) { - if (isLocalParameterName(reactionNode, localParameterCount)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_NAME) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the value of the attribute value - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return the value if it is set. Else the empty string - */ - public static Double getLocalParameterValue(Node reactionNode, - int localParameterCount) { - if (isLocalParameterValue(reactionNode, localParameterCount)) { - return (Double) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_VALUE) - .toString()); - } else { - return null; - } - } - - /** - * Returns the value of the attribute units - * - * @param reactionNode - * the node where the information will be read from - * @param localParameterCount - * the number of the current local parameter - * @return the value if it is set. Else the empty string - */ - public static String getLocalParameterUnits(Node reactionNode, - int localParameterCount) { - if (isLocalParameterUnits(reactionNode, localParameterCount)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_UNITS) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns all reaction nodes of the graph - * - * @return a list of all reaction nodes of the graph - */ - public static List getReactionNodes(Graph g) { - List reactionNodeList = new ArrayList(); - Iterator itNode = g.getNodesIterator(); - while (itNode.hasNext()) { - Node node = itNode.next(); - if (AttributeHelper.getSBMLrole(node).equals("reaction")) { - reactionNodeList.add(node); - } - } - return reactionNodeList; - } - - /** - * Returns the reaction node with a distinct id - * - * @param id - * the id of the asked node - * @return the node with a certain id or null if no node has this id - */ - public static Node getReactionNode(Graph g, String id) { - List nodeList = getReactionNodes(g); - Iterator itNode = nodeList.iterator(); - Node currentNode = null; - while (itNode.hasNext()) { - currentNode = itNode.next(); - if (getReactionID(currentNode).equals(id)) { - return currentNode; - } - } - return null; - } - - /** - * Creates an reaction Node - * - * @param g - * the graph where the node will be added - * @return the created reaction node - */ - private static Node createReactionNode(Graph g, String id) { - Node node = g.addNode(); - AttributeHelper.setSBMLrole(node, (String) SBML_Constants.ROLE_REACTION); - AttributeHelper.setDefaultGraphicsAttribute(node, pgg.getNextPosition()); - AttributeHelper.setLabel(node, id); - AttributeHelper.setSize(node, id.length() * id.length() + 7, 20d); - AttributeHelper.setFillColor(node, Color.WHITE); - AttributeHelper.setShapeEllipse(node); - AttributeHelper.setBorderWidth(node, 1); - return node; - } - - public static Node createReaction(Graph g, String id, String name) { - if (!SBML_Constants.EMPTY.equals(id) || !SBML_Constants.EMPTY.equals(name)) { - if (!isInitializedReaction) { - initReactionNideIDs("sbml", "SBML"); - isInitializedReaction = true; - } - Node node = createReactionNode(g, id); - initReactionNideIDs("sbml", "SBML"); - if (!name.equals(SBML_Constants.EMPTY)) - { - setReactionName(node, name); - } - setReactionID(node, id); - return node; - } - else { - return null; - } - } - - public static Node initReactionNode(Node n) { - String label = AttributeHelper.getLabel(n, SBML_Constants.EMPTY); - if (label == SBML_Constants.EMPTY) { - return null; - } - else { - setReactionName(n, label); - AttributeHelper.setShapeRectangle(n); - AttributeHelper.setSBMLrole(n, "reaction"); - return n; - } - } - - public static Edge addReactant(Node node, String speciesID) { - Node reactantNode = SBMLSpeciesHelper.getSpeciesNode(speciesID); - Edge newReactionEdge = node.getGraph().addEdge(reactantNode, node, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - setReactionSpecies(newReactionEdge, "speciesID"); - - AttributeHelper.setLabel(newReactionEdge, Integer.toString(1)); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_REACTANT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, false); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, 1); - return newReactionEdge; - } - - public static Edge initReactantEdge(Edge e) { - Node node = e.getSource(); - if (isSpeciesID(node)) { - setReactionSpecies(e, getSpeciesID(node)); - } - - String label = AttributeHelper.getLabel(e, "-1"); - if (label.equals("-1")) { - AttributeHelper.setLabel(e, "1"); - setStoichiometry(e, Double.parseDouble("1")); - } - else if (label.equals("")) { - AttributeHelper.setLabel(e, "1"); - setStoichiometry(e, Double.parseDouble("1")); - } - else { - AttributeHelper.setLabel(e, label); - setStoichiometry(e, Double.parseDouble(label)); - } - AttributeHelper.setSBMLrole(e, SBML_Constants.ROLE_REACTANT); - return e; - } - - public static Edge initProductEdge(Edge e) { - Node node = e.getTarget(); - if (isSpeciesID(node)) { - setReactionSpecies(e, getSpeciesID(node)); - } - - String label = AttributeHelper.getLabel(e, "-1"); - if (label.equals("-1")) { - AttributeHelper.setLabel(e, "1"); - setStoichiometry(e, Double.parseDouble("1")); - } - else if (label.equals("")) { - AttributeHelper.setLabel(e, "1"); - setStoichiometry(e, Double.parseDouble("1")); - } - else { - AttributeHelper.setLabel(e, label); - setStoichiometry(e, Double.parseDouble(label)); - } - AttributeHelper.setSBMLrole(e, SBML_Constants.ROLE_PRODUCT); - return e; - } - - public static Edge addProduct(Node node, String speciesID) { - Node productNode = SBMLSpeciesHelper.getSpeciesNode(speciesID); - Edge newReactionEdge = node.getGraph().addEdge(node, productNode, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - setReactionSpecies(newReactionEdge, speciesID); - - AttributeHelper.setLabel(newReactionEdge, Integer.toString(1)); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_PRODUCT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, false); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, 1); - return newReactionEdge; - } - - public static Edge addModifier(Node node, String speciesID) { - Node modifierNode = SBMLSpeciesHelper.getSpeciesNode(speciesID); - Edge reactionEdge = node.getGraph().addEdge(modifierNode, node, false, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.DARK_GRAY, Color.DARK_GRAY, true)); - setReactionSpecies(reactionEdge, speciesID); - - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_MODIFIER); - AttributeHelper.setDashInfo(reactionEdge, 5, 5); - AttributeHelper.setBorderWidth(reactionEdge, 1d); - return reactionEdge; - } - - public static Edge addReactant(Node node, SpeciesReference ref) { - if (SBMLSpeciesHelper.speciesMap == null) { - SBMLSpeciesHelper.speciesMap = new HashMap(); - } - if (!SBMLSpeciesHelper.speciesMap.containsKey(ref.getSpecies())) { - createSpecies(node.getGraph(), ref.getSpecies(), ""); - } - Node reactantNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - String stoichiometry = Double.toString(ref.getStoichiometry()); - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + getReactionID(node) + " species " + ref.getSpecies() - + " is not a valid double value."); - } - Edge newReactionEdge = node.getGraph().addEdge(reactantNode, node, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - if (isReactionReversible(node)) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - - AttributeHelper.setLabel(newReactionEdge, stoichiometry); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_REACTANT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, isReactionReversible(node)); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge); - return newReactionEdge; - } - - private static void deleteEdge(Edge edge) { - edge.getGraph().deleteEdge(edge); - } - - public static void deleteReactant(Edge edge) { - deleteEdge(edge); - } - - public static void deleteProduct(Edge edge) { - deleteEdge(edge); - } - - public static void deleteModifier(Edge edge) { - deleteEdge(edge); - } - - public static Edge addModifier(Node node, ModifierSpeciesReference ref) { - if (SBMLSpeciesHelper.speciesMap == null) { - SBMLSpeciesHelper.speciesMap = new HashMap(); - } - if (!SBMLSpeciesHelper.speciesMap.containsKey(ref.getSpecies())) { - createSpecies(node.getGraph(), ref.getSpecies(), ""); - } - Node modifierNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - Edge reactionEdge = node.getGraph().addEdge(modifierNode, node, false, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.DARK_GRAY, Color.DARK_GRAY, true)); - - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_MODIFIER); - AttributeHelper.setDashInfo(reactionEdge, 5, 5); - AttributeHelper.setBorderWidth(reactionEdge, 1d); - setSimpleSpeciesReferences(ref, reactionEdge); - return reactionEdge; - } - - public static Edge addProduct(Node node, SpeciesReference ref) { - if (SBMLSpeciesHelper.speciesMap == null) { - SBMLSpeciesHelper.speciesMap = new HashMap(); - } - if (!SBMLSpeciesHelper.speciesMap.containsKey(ref.getSpecies())) { - createSpecies(node.getGraph(), ref.getSpecies(), ""); - } - - Node productNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - String stoichiometry = Double.toString(ref.getStoichiometry()); - String label = stoichiometry; - Edge newReactionEdge = node.getGraph().addEdge(node, productNode, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - if (isReactionReversible(node)) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + getReactionID(node) + " species " + ref.getSpecies() - + " is not a valid double value."); - } - - AttributeHelper.setLabel(newReactionEdge, label); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_PRODUCT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, isReactionReversible(node)); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge); - return newReactionEdge; - - } - - public static Node createReaction(Graph g, Reaction reaction) { - Node node = createReactionNode(g, reaction.getId()); - if (!isInitializedReaction) { - initReactionNideIDs("sbml", "SBML"); - isInitializedReaction = true; - } - setReactionID(node, reaction.getId()); - reaction.setLevel(3); - reaction.setVersion(1); - if (reaction.isSetCompartment()) { - setReactionCompartment(node, reaction.getCompartment()); - } - if (reaction.isSetId()) { - setReactionID(node, reaction.getId()); - } - if (reaction.isReversible()) { - setReactionReversible(node, reaction.isReversible()); - } - if (reaction.isSetFast()) { - setReactionFast(node, reaction.getFast()); - } - if (reaction.isSetName()) { - setReactionName(node, reaction.getName()); - } - - // Adds the edges between reactant node and reaction node - ListOf reactants = reaction.getListOfReactants(); - Iterator it = reactants.iterator(); - while (it.hasNext()) { - SpeciesReference ref = it.next(); - Node reactantNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - String stoichiometry = Double.toString(ref.getStoichiometry()); - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + reaction.getId() + " species " + ref.getSpecies() - + " is not a valid double value."); - } - Edge newReactionEdge = g.addEdge(reactantNode, node, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - if (reaction.isReversible()) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - - AttributeHelper.setLabel(newReactionEdge, stoichiometry); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_REACTANT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, reaction.isReversible()); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge); - } - - ListOf products = reaction.getListOfProducts(); - Iterator itProduct = products.iterator(); - while (itProduct.hasNext()) { - SpeciesReference ref = itProduct.next(); - Node productNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - String stoichiometry = Double.toString(ref.getStoichiometry()); - String label = stoichiometry; - Edge newReactionEdge = g.addEdge(node, productNode, true, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.BLACK, Color.BLACK, true)); - if (reaction.isReversible()) { - AttributeHelper.setArrowtail(newReactionEdge, true); - } - if (ref.getStoichiometry() == Double.NaN) { - ErrorMsg.addErrorMessage("Attribute stochiometry of reaction " - + reaction.getId() + " species " + ref.getSpecies() - + " is not a valid double value."); - } - - AttributeHelper.setLabel(newReactionEdge, label); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_PRODUCT); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, reaction.getReversible()); - AttributeHelper.setAttribute(newReactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - setSimpleSpeciesReferences(ref, newReactionEdge); - } - - ListOf modifiers = reaction.getListOfModifiers(); - Iterator itModifier = modifiers.iterator(); - while (itModifier.hasNext()) { - SpeciesReference ref = it.next(); - Node modifierNode = SBMLSpeciesHelper.getSpeciesNode(ref.getSpecies()); - Edge reactionEdge = g.addEdge(modifierNode, node, false, - AttributeHelper.getDefaultGraphicsAttributeForEdge( - Color.DARK_GRAY, Color.DARK_GRAY, true)); - - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SBML_ROLE, SBML_Constants.ROLE_MODIFIER); - AttributeHelper.setDashInfo(reactionEdge, 5, 5); - AttributeHelper.setBorderWidth(reactionEdge, 1d); - setSimpleSpeciesReferences(ref, reactionEdge); - } - - if (reaction.isSetKineticLaw()) { - if (!isInitializedKineticLaw) { - initKineticLawNideIDs(); - isInitializedKineticLaw = true; - } - KineticLaw kineticLaw = reaction.getKineticLaw(); - String kineticFormula = ""; - try { - if (kineticLaw.isSetMath()) { - if (null != kineticLaw.getMath()) { - kineticFormula = kineticLaw.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - if (kineticLaw.isSetMath()) { - setKineticLawFunction(node, kineticFormula); - } - - // Two ways to read in a Local Parameter. One way is deprecated. - if (kineticLaw.isSetListOfLocalParameters() - || kineticLaw.isSetListOfParameters()) { - List listLocalParameter = null; - if (reaction.getModel().getLevel() == 3 - && reaction.getModel().getVersion() == 1) { - if (kineticLaw.isSetListOfLocalParameters()) { - listLocalParameter = kineticLaw - .getListOfLocalParameters(); - } - } else { - if (kineticLaw.isSetListOfParameters()) { - listLocalParameter = kineticLaw - .getListOfParameters(); - } - } - Iterator itLP = listLocalParameter.iterator(); - int countLocalParameter = 1; - while (itLP.hasNext()) { - LocalParameter localParameter = itLP.next(); - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - countLocalParameter).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - countLocalParameter).toString(); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - - String id = localParameter.getId(); - String name = localParameter.getName(); - Double value = localParameter.getValue(); - if (value.equals(Double.NaN)) { - - ErrorMsg.addErrorMessage("Attribute value of reaction " - + reaction.getId() - + " " - + presentedAttributeName - + " is not a valid double value."); - - } - String unit = localParameter.getUnits(); - - if (localParameter.isSetId()) { - setLocalParameterID(node, localParameter.getId(), internAttributeName); - } - if (localParameter.isSetName()) { - setLocalParameterName(node, localParameter.getName(), internAttributeName); - } - if (localParameter.isSetValue()) { - setLocalParameterValue(node, localParameter.getValue(), internAttributeName); - } - if (localParameter.isSetUnits()) { - setLocalParameterUnits(node, localParameter.getUnits(), internAttributeName); - } - countLocalParameter++; - } - } - } - AttributeHelper.setLabel(AttributeHelper.getLabels(node) - .size(), node, reaction.getId(), null, - AlignmentSetting.HIDDEN.toGMLstring()); - return node; - } - - public static void addLocalParameterName(Node node, String lpID, String name) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - i).toString(); - setLocalParameterName(node, name, internAttributeName); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - } - - } - } - - public static boolean isSetLocalParameterName(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterName(node, i)) { - return true; - } - else { - return false; - } - } - } - return false; - } - - public static boolean isSetLocalParameterUnits(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterUnits(node, i)) { - return true; - } - else { - return false; - } - } - } - return false; - } - - public static boolean isSetLocalParameterValue(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterValue(node, i)) { - return true; - } - else { - return false; - } - } - } - return false; - } - - public static void deleteLocalParameterName(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterName(node, i)) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_NAME).toString()); - } - } - } - } - - public static void deleteLocalParameterValue(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterValue(node, i)) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_VALUE).toString()); - } - } - } - } - - public static void deleteLocalParameterUnits(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterUnits(node, i)) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_UNITS).toString()); - } - } - } - } - - public static void deleteLocalParameter(Node node, String lpID) { - deleteLocalParameterValue(node, lpID); - deleteLocalParameterUnits(node, lpID); - deleteLocalParameterName(node, lpID); - deleteLocalParameterID(node, lpID); - } - - public static void deleteLocalParameterID(Node node, String lpID) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - if (isLocalParameterID(node, i)) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_ID).toString()); - } - } - } - } - - public static void addLocalParameterValue(Node node, String lpID, Double value) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - i).toString(); - setLocalParameterValue(node, value, internAttributeName); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - } - - } - } - - public static void addLocalParameterUnits(Node node, String lpID, String units) { - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (getLocalParameterID(node, i) == lpID) { - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - i).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - i).toString(); - setLocalParameterUnits(node, units, internAttributeName); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - } - } - } - - private static void setSimpleSpeciesReferences(SimpleSpeciesReference simpleRef, - Edge edge) { - if (simpleRef instanceof org.sbml.jsbml.SpeciesReference) { - if (((SpeciesReference) simpleRef).isSetStoichiometry()) { - setStoichiometry(edge, ((SpeciesReference) simpleRef).getStoichiometry()); - } - if (((SpeciesReference) simpleRef).isSetConstant()) { - setReactionConstant(edge, ((SpeciesReference) simpleRef).getConstant()); - } - } - if (simpleRef.isSetSpecies()) { - setReactionSpecies(edge, simpleRef.getSpecies()); - } - if (simpleRef.isSetId()) { - setReactionSpeciesID(edge, simpleRef.getId()); - } - if (simpleRef.isSetName()) { - setReactionSpeciesName(edge, simpleRef.getName()); - } - if (AttributeHelper.getSBMLrole(edge).equals( - SBML_Constants.ROLE_REACTANT)) { - } - } - - /** - * The edges with the simple species references will be returned - * - * @param node - * the reaction node - * @return all outgoing edges - */ - public static List getProducts(Node node) { - List edgeList = new ArrayList(); - Iterator edgeIt = node.getEdgesIterator(); - while (edgeIt.hasNext()) { - Edge nextEdge = edgeIt.next(); - if (AttributeHelper.getSBMLrole(node).equals("product")) { - edgeList.add(nextEdge); - } - } - return edgeList; - } - - /** - * The edges with the simple species references will be returned - * - * @param node - * the reaction node - * @return all ingoing edges - */ - public static List getReactants(Node node) { - List edgeList = new ArrayList(); - Iterator edgeIt = node.getEdgesIterator(); - while (edgeIt.hasNext()) { - Edge nextEdge = edgeIt.next(); - if (AttributeHelper.getSBMLrole(node).equals("reactant")) { - edgeList.add(nextEdge); - } - } - return edgeList; - } - - /** - * Returns the modifier edges - * - * @param node - * the reaction node - * @return all modifier edges - */ - public static List getModifier(Node node) { - List edgeList = new ArrayList(); - Iterator edgeIt = node.getEdgesIterator(); - while (edgeIt.hasNext()) { - Edge nextEdge = edgeIt.next(); - if (AttributeHelper.getSBMLrole(node).equals("modifier")) { - edgeList.add(nextEdge); - } - } - return edgeList; - } - - /** - * Returns a JSBML Reaction object belonging to a reaction node - * - * @param node - * the reaction node - * @return a JSBML Reaction object - */ - public static Reaction getReaction(Node node) { - if (AttributeHelper.getSBMLrole(node).equals("reaction")) { - Reaction reaction = new Reaction(); - reaction.setId(getReactionID(node)); - reaction.setName(getReactionName(node)); - if (isReactionReversible(node)) { - reaction.setReversible(getReactionReversible(node)); - } - if (isReactionFast(node)) { - reaction.setFast(getReactionFast(node)); - } - reaction.setCompartment(getReactionCompartment(node)); - - Iterator itEdges = node.getEdgesIterator(); - while (itEdges.hasNext()) { - Edge edge = itEdges.next(); - if (AttributeHelper.getSBMLrole(edge).equals("reactant")) { - SpeciesReference reactant = new SpeciesReference(); - if (isReactionStoichiometry(edge)) { - reactant.setStoichiometry(Double - .parseDouble(getStoichiometry(edge))); - } - if (isReactionConstant(edge)) { - reactant.setConstant(getReactionConstant(edge)); - } - reactant.setId(getReactionSpeciesID(edge)); - reactant.setName(getReactionSpeciesName(edge)); - reactant.setSpecies(getReactionSpecies(edge)); - reaction.addReactant(reactant); - } - if (AttributeHelper.getSBMLrole(edge).equals("product")) { - SpeciesReference product = new SpeciesReference(); - if (isReactionStoichiometry(edge)) { - product.setStoichiometry(Double - .parseDouble(getStoichiometry(edge))); - } - if (isReactionConstant(edge)) { - product.setConstant(getReactionConstant(edge)); - } - product.setId(getReactionSpeciesID(edge)); - product.setName(getReactionSpeciesName(edge)); - product.setSpecies(getReactionSpecies(edge)); - reaction.addProduct(product); - } - if (AttributeHelper.getSBMLrole(edge).equals("modifier")) { - ModifierSpeciesReference modifier = new ModifierSpeciesReference(); - modifier.setId(getReactionSpeciesID(edge)); - modifier.setName(getReactionSpeciesName(edge)); - modifier.setSpecies(getReactionSpecies(edge)); - reaction.addModifier(modifier); - } - } - - if (isKineticLawFunction(node)) { - KineticLaw kl = new KineticLaw(); - try { - kl.setFormula(getKineticLawFunction(node)); - } catch (ParseException e) { - e.printStackTrace(); - } - int lpCount = localParameterCount(node); - for (int i = 1; i <= lpCount; i++) { - if (isLocalParameterID(node, i)) { - LocalParameter lp = new LocalParameter(); - lp.setId(getLocalParameterID(node, i)); - lp.setName(getLocalParameterName(node, i)); - if (isLocalParameterValue(node, lpCount)) { - lp.setValue(getLocalParameterValue(node, i)); - } - lp.setUnits(getLocalParameterUnits(node, i)); - kl.addLocalParameter(lp); - } - } - reaction.setKineticLaw(kl); - } - return reaction; - } else { - return null; - } - } - - public static void addLocalParameter(Node node, LocalParameter lp) { - int lpCount = localParameterCount(node); - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - lpCount + 1).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - lpCount + 1).toString(); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - if (lp.isSetId()) { - setLocalParameterID(node, lp.getId(), internAttributeName); - } - if (lp.isSetName()) { - setLocalParameterName(node, lp.getName(), internAttributeName); - } - if (lp.isSetValue()) { - setLocalParameterValue(node, lp.getValue(), internAttributeName); - } - if (lp.isSetUnits()) { - setLocalParameterUnits(node, lp.getUnits(), internAttributeName); - } - } - - public static void addLocalParameter(Node node, String id) { - int lpCount = localParameterCount(node); - String internAttributeName = new StringBuffer( - SBML_Constants.LOCAL_PARAMETER).append( - lpCount + 1).toString(); - String presentedAttributeName = new StringBuffer( - SBML_Constants.LOCALPARAMETER_HEADLINE).append( - lpCount + 1).toString(); - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, "Kinetic Law"); - setLocalParameterID(node, id, internAttributeName); - } - - /** - * Returns the number of local parameter - * - * @param node - * the current node - * @return the amount of local parameter - */ - public static int localParameterCount(Node node) { - int lpCount = 0; - while (isLocalParameterID(node, lpCount + 1)) { - lpCount++; - } - return lpCount; - } - - public static Event createEvent(Graph g, String id) { - String internHeadline = new StringBuffer(SBML_Constants.SBML_EVENT).append(eventCount).toString(); - String presentedHeadline = new StringBuffer("SBML Event ").append(eventCount).toString(); - setEventID(g, internHeadline, id); - Event event = new Event(); - event.setLevel(3); - event.setId(id); - initEventNiceIDs(internHeadline, presentedHeadline); - ++eventCount; - return event; - } - - public static void createEvent(Graph g, Event event) { - String internHeadline = new StringBuffer(SBML_Constants.SBML_EVENT).append(eventCount).toString(); - String presentedHeadline = new StringBuffer("SBML Event ").append(eventCount).toString(); - initEventNiceIDs(internHeadline, presentedHeadline); - - event.setLevel(3); - if (event.isSetId()) { - setEventID(g, internHeadline, event.getId()); - } - if (event.isSetName()) { - setEventName(g, internHeadline, event.getName()); - } - if (event.isSetUseValuesFromTriggerTime()) { - setEventUseValuesFromTriggerTime(g, internHeadline, event.getUseValuesFromTriggerTime()); - } - Trigger trigger = event.getTrigger(); - String triggerFormula = ""; - try { - if (trigger.isSetMath()) { - if (null != trigger.getMath()) { - triggerFormula = trigger.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - Boolean triggerInitialValue = false; - Boolean triggerPersistent = false; - try { - if (trigger.isSetInitialValue()) - triggerInitialValue = trigger.getInitialValue(); - if (trigger.isSetPersistent()) - triggerPersistent = trigger.getPersistent(); - } catch (Exception e1) { - e1.printStackTrace(); - } - if (trigger.isSetInitialValue()) { - setTriggerInitialValue(g, internHeadline, triggerInitialValue); - } - if (trigger.isSetPersistent()) { - setTriggerPersistent(g, internHeadline, triggerPersistent); - } - if (trigger.isSetMath()) { - setTriggerFunction(g, internHeadline, triggerFormula); - } - if (event.isSetPriority()) { - Priority priority = event.getPriority(); - String priorityFormula = ""; - try { - if (priority.isSetMath()) { - if (null != priority.getMath()) { - priorityFormula = priority.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - if (!priorityFormula.equals("")) { - setPriorityFunction(g, internHeadline, priorityFormula); - } - } - String delayFormula = ""; - if (event.isSetDelay()) { - Delay delay = event.getDelay(); - try { - if (delay.isSetMath()) { - if (null != delay.getMath()) { - delayFormula = delay.getMath().toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - if (!delayFormula.equals("")) { - setDelayFunction(g, internHeadline, delayFormula); - } - } - List listEventAssignment = event - .getListOfEventAssignments(); - Iterator itEventAssignment = listEventAssignment - .iterator(); - int eventAssignmentCount = 1; - while (itEventAssignment.hasNext()) { - initEventAssignmentNideIDs(eventAssignmentCount, internHeadline, presentedHeadline); - EventAssignment eventAssignment = itEventAssignment.next(); - - String variable = eventAssignment.getVariable(); - String eventAssignmentFormula = ""; - try { - if (eventAssignment.isSetMath()) { - if (null != eventAssignment.getMath()) { - eventAssignmentFormula = eventAssignment.getMath() - .toFormula(); - } - } - } catch (SBMLException e) { - e.printStackTrace(); - } - - if (eventAssignment.isSetVariable()) { - setEventAssignmentVariable(g, internHeadline, variable, eventAssignmentCount); - } - if (eventAssignment.isSetMath()) { - setEventAssignmentFunction(g, internHeadline, eventAssignmentFormula, eventAssignmentCount); - } - eventAssignmentCount++; - } - - ++eventCount; - } - - public static void addEventName(Graph g, String id, String name) { - setEventName(g, returnEventWithID(g, id), name); - } - - public static void addEventUseValuesFromTriggerTime(Graph g, String id, boolean useValuesFromTriggerTime) { - setEventUseValuesFromTriggerTime(g, returnEventWithID(g, id), useValuesFromTriggerTime); - } - - public static void addTriggerInitialValue(Graph g, String eventID, boolean initialValue) { - setTriggerInitialValue(g, returnEventWithID(g, eventID), initialValue); - } - - public static void addTriggerPersistent(Graph g, String eventID, boolean persistent) { - setTriggerPersistent(g, returnEventWithID(g, eventID), persistent); - } - - public static void addTriggerFunction(Graph g, String eventID, String function) { - setTriggerFunction(g, returnEventWithID(g, eventID), function); - } - - public static boolean isSetEventName(Graph g, String id) { - if (isEventName(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetEventUseValuesFromTriggerTime(Graph g, String id) { - if (isEventUseValuesFromTriggerTime(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetTriggerInitialValue(Graph g, String id) { - if (isTriggerInitialValue(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetTriggerPersistent(Graph g, String id) { - if (isTriggerPersistent(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetTriggerFunction(Graph g, String id) { - if (isTriggerFunction(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetDelayFunction(Graph g, String id) { - if (isDelayFunction(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetPriority(Graph g, String id) { - if (isPriorityFunction(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static boolean isSetDelay(Graph g, String id) { - if (isDelayFunction(g, returnEventWithID(g, id))) { - return true; - } - else { - return false; - } - } - - public static void deleteEventName(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetEventName(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.EVENT_NAME).toString()); - } - } - - public static void deleteEventUseValuesFromTriggerTime(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetEventUseValuesFromTriggerTime(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME).toString()); - } - } - - public static void deleteEventID(Graph g, String id) { - String headline = returnEventWithID(g, id); - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.EVENT_ID).toString()); - } - - public static void deleteTriggeInitialValue(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetTriggerInitialValue(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.INITIAL_VALUE) - .toString()); - } - } - - public static void deleteTriggerPersistent(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetTriggerPersistent(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.PERSISTENT) - .toString()); - } - } - - public static void deleteTriggerFunction(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetTriggerFunction(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.TRIGGER_FUNCTION) - .toString()); - } - } - - public static void deleteDelayFunction(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetDelayFunction(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.DELAY_FUNCTION) - .toString()); - } - } - - public static void deletePriorityFunction(Graph g, String id) { - String headline = returnEventWithID(g, id); - if (isSetPriority(g, id)) { - AttributeHelper.deleteAttribute(g, headline, new StringBuffer( - headline).append(SBML_Constants.PRIORITY_FUNCTION) - .toString()); - } - } - - public static void deleteTrigger(Graph g, String id) { - deleteTriggeInitialValue(g, id); - deleteTriggerPersistent(g, id); - deleteTriggerFunction(g, id); - } - - public static void deletePriority(Graph g, String id) { - deletePriorityFunction(g, id); - } - - public static void addTriggerToEvent(Graph g, String id, Trigger trigger) { - String headline = returnEventWithID(g, id); - if (trigger.isSetInitialValue()) { - setTriggerInitialValue(g, headline, trigger.getInitialValue()); - } - if (trigger.isSetPersistent()) { - setTriggerPersistent(g, headline, trigger.getPersistent()); - } - if (trigger.isSetMath()) { - setTriggerFunction(g, headline, trigger.getMath().toFormula()); - } - } - - public static void addTriggerToEvent(Graph g, String id, boolean initialValue, boolean persistent, String formula) { - String headline = returnEventWithID(g, id); - setTriggerInitialValue(g, headline, initialValue); - setTriggerPersistent(g, headline, persistent); - if (formula != "" && formula != null) { - setTriggerFunction(g, headline, formula); - } - } - - public static void addPriorityToEvent(Graph g, String id, Priority priority) { - String headline = returnEventWithID(g, id); - if (priority.isSetMath()) { - setPriorityFunction(g, headline, priority.getMath().toFormula()); - } - } - - public static void addDelayToEvent(Graph g, String id, Delay delay) { - String headline = returnEventWithID(g, id); - if (delay.isSetMath()) { - setDelayFunction(g, headline, delay.getMath().toFormula()); - } - } - - public static void addPriorityToEvent(Graph g, String id, String function) { - String headline = returnEventWithID(g, id); - if (function != "" && function != null) { - setPriorityFunction(g, headline, function); - } - } - - public static void addDelayToEvent(Graph g, String id, String function) { - String headline = returnEventWithID(g, id); - if (function != "" && function != null) { - setDelayFunction(g, headline, function); - } - } - - public static void addEventAssignmentToEvent(Graph g, String id, String variable, String function) { - String internHeadline = returnEventWithID(g, id); - char index = internHeadline.charAt(internHeadline.length() - 1); - String presentedHeadline = new StringBuffer("SBML Event ") - .append(index).toString(); - - int eventAssignmentCount = eventAssignmentCount(g, internHeadline); - initEventAssignmentNideIDs(eventAssignmentCount + 1, internHeadline, presentedHeadline); - if (variable != null) { - setEventAssignmentVariable(g, internHeadline, variable, eventAssignmentCount + 1); - } - if (function != null && function != "") { - setEventAssignmentFunction(g, internHeadline, function, eventAssignmentCount + 1); - } - } - - public static void addEventAssignmentToEvent(Graph g, String id, EventAssignment eventAssignment) { - String internHeadline = returnEventWithID(g, id); - char index = internHeadline.charAt(internHeadline.length() - 1); - String presentedHeadline = new StringBuffer("SBML Event ") - .append(index).toString(); - - int eventAssignmentCount = eventAssignmentCount(g, internHeadline); - initEventAssignmentNideIDs(eventAssignmentCount + 1, internHeadline, presentedHeadline); - if (eventAssignment.isSetVariable()) { - setEventAssignmentVariable(g, internHeadline, eventAssignment.getVariable(), eventAssignmentCount + 1); - } - if (eventAssignment.isSetMath()) { - setEventAssignmentFunction(g, internHeadline, eventAssignment.getMath().toFormula(), eventAssignmentCount + 1); - } - } - - public static void deleteEventAssignment(Graph g, String id, String variable) { - String internHeadline = returnEventWithID(g, id); - char index = internHeadline.charAt(internHeadline.length() - 1); - String presentedHeadline = new StringBuffer("SBML Event ") - .append(index).toString(); - int eventAssignmentCount = eventAssignmentCount(g, internHeadline); - - for (int i = eventAssignmentCount; i >= 1; i--) { - if (isEventAssignmentVariable(g, internHeadline, i)) { - System.out.println("variable: " + variable); - System.out.println("Wert: " + getEventAssignmentVariable(g, internHeadline, i)); - if (variable.equals(getEventAssignmentVariable(g, internHeadline, i))) { - AttributeHelper.deleteAttribute(g, internHeadline, new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(i) - .append(SBML_Constants.VARIABLE).toString()); - if (isEventAssignmentFunction(g, internHeadline, i)) { - AttributeHelper.deleteAttribute(g, internHeadline, new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(i) - .append(SBML_Constants.FUNCTION).toString()); - } - } - } - } - } - - public static void deleteEvent(Graph g, String id) { - deleteEventUseValuesFromTriggerTime(g, id); - deleteEventName(g, id); - deleteTrigger(g, id); - deleteDelayFunction(g, id); - deletePriority(g, id); - - String internHeadline = returnEventWithID(g, id); - int eventAssignmentCount = eventAssignmentCount(g, internHeadline); - for (int i = eventAssignmentCount; i >= 1; i--) { - deleteEventAssignment(g, id, getEventAssignmentVariable(g, internHeadline, i)); - } - deleteEventID(g, id); - } - - /** - * Set the value of the attribute UseValuesFromTriggerTime - * - * @param g - * the graph where the information should be read in - * @param internHeadline - * contains the number of the current event - * @param useValuesFromTriggerTime - * the value that will be set - */ - private static void setEventUseValuesFromTriggerTime(Graph g, - String internHeadline, Boolean useValuesFromTriggerTime) { - if (!useValuesFromTriggerTime.equals(null)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString(), useValuesFromTriggerTime); - } - } - - /** - * Set the value of the attribute id - * - * @param g - * the graph where the information should be read in - * @param internHeadline - * contains the number of the current event - * @param id - * the value that will be set - */ - private static void setEventID(Graph g, String internHeadline, String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ID).toString(), - ID); - } - } - - /** - * Set the value of the attribute name - * - * @param g - * the graph where the information should be read in - * @param internHeadline - * contains the number of the current event - * @param name - * the value that will be set - */ - private static void setEventName(Graph g, String internHeadline, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_NAME) - .toString(), name); - } - } - - /** - * Indicate if the attribute name is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the name is set. Else false - */ - private static Boolean isEventName(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_NAME).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicate if the attribute id is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the id is set. Else false - */ - private static Boolean isEventID(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.EVENT_ID).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicate if the attribute UseValuesFromTriggerTime is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if UseValuesFromTriggerTime is set. Else false - */ - private static Boolean isEventUseValuesFromTriggerTime(Graph g, - String internHeadline) { - if (AttributeHelper - .hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Return the value of the attribute id - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the id if it is set. Else the empty string - */ - private static String getEventID(Graph g, String internHeadline) { - if (isEventID(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Return the value of the attribute name - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the name if it is set. Else the empty string - */ - private static String getEventName(Graph g, String internHeadline) { - if (isEventName(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Return the value of the attribute UseValuesFromTriggerTime - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return UseValuesFromTriggerTime if it is set. Else the empty string - */ - private static Boolean getEventUseValuesFromTriggerTime(Graph g, - String internHeadline) { - if (isEventUseValuesFromTriggerTime(g, internHeadline)) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString()); - } else { - return null; - } - } - - /** - * Sets the initial value - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param initialValue - * the value that will be set - */ - private static void setTriggerInitialValue(Graph g, String internHeadline, - Boolean initialValue) { - if (!initialValue.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.INITIAL_VALUE) - .toString(), initialValue); - } - } - - /** - * Sets the attribute persistent - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param persistent - * the value that will be set - */ - private static void setTriggerPersistent(Graph g, String internHeadline, - Boolean persistent) { - if (!persistent.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PERSISTENT) - .toString(), persistent); - } - } - - /** - * Sets the function - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param function - * the String that will be set - */ - private static void setTriggerFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.TRIGGER_FUNCTION) - .toString(), function); - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the function is set. Else false - */ - private static Boolean isTriggerFunction(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.TRIGGER_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the initial value is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the initial value is set. Else false - */ - private static Boolean isTriggerInitialValue(Graph g, String internHeadline) { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.INITIAL_VALUE) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if persistent is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if persistent is set. Else false - */ - private static Boolean isTriggerPersistent(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PERSISTENT).toString())) { - return true; - } else { - return false; - } - } - - /** - * Return the function string - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the function string if it is set. Else the empty string - */ - private static String getTriggerFunction(Graph g, String internHeadline) { - if (isTriggerFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.TRIGGER_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Return initial value - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the initial value if it is set. Else null - */ - private static Boolean getTriggerInitialValue(Graph g, String internHeadline) { - if (isTriggerInitialValue(g, internHeadline)) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_VALUE).toString()); - } else { - return null; - } - } - - /** - * Return the value of the attribute persistent - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the value persistent if it is set. Else null - */ - private static Boolean getTriggerPersistent(Graph g, String internHeadline) { - if (isTriggerPersistent(g, internHeadline)) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PERSISTENT).toString()); - } else { - return null; - } - } - - /** - * Set the function of the current priority - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param function - * the value that will be set - */ - private static void setPriorityFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_FUNCTION) - .toString(), function); - } - } - - /** - * Indicates if the function is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the function is set. Else false - */ - private static Boolean isPriorityFunction(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PRIORITY_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the function string of priority - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the function string if it is set. Else the empty string - */ - private static String getPriorityFunction(Graph g, String internHeadline) { - if (isPriorityFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the value of a function - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param function - * the value that will be set - */ - private static void setDelayFunction(Graph g, String internHeadline, - String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_FUNCTION) - .toString(), function); - } - } - - /** - * Indicates if the value of function is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return true if the function is set. Else false - */ - private static Boolean isDelayFunction(Graph g, String internHeadline) { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.DELAY_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - /** - * Returns the value of the function - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @return the value of the function if it is set. Else the empty string - */ - private static String getDelayFunction(Graph g, String internHeadline) { - if (isDelayFunction(g, internHeadline)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Set the variable of an event assignment - * - * @param g - * the graph where the information should be read in - * @param internHeadline - * contains the number of the current event - * @param variable - * the value that will be set - * @param eventAssignmentCount - * the number of the current event assignment - */ - private static void setEventAssignmentVariable(Graph g, - String internHeadline, String variable, int eventAssignmentCount) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString(), - variable); - } - } - - /** - * Set the function of an event assignment - * - * @param g - * the graph where the information should be read in - * @param internHeadline - * contains the number of the current event - * @param function - * the value that will be set - * @param eventAssignmentCount - * the number of the current event assignment - */ - private static void setEventAssignmentFunction(Graph g, - String internHeadline, String function, int eventAssignmentCount) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString(), - function); - } - } - - /** - * Indicates if the variable of an event assignment is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param eventAssignmentCount - * the number of the current event assignment - * @return true if the variable is set. Else false - */ - private static Boolean isEventAssignmentVariable(Graph g, - String internHeadline, int eventAssignmentCount) { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString())) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the function of an event assignment is set - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param eventAssignmentCount - * the number of the current event assignment - * @return true if the function is set. Else false - */ - private static Boolean isEventAssignmentFunction(Graph g, - String internHeadline, int eventAssignmentCount) { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - /** - * Return the variable of an event assignment - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param eventAssignmentCount - * the number of the current event assignment - * @return the variable if it is set. Else the empty string - */ - private static String getEventAssignmentVariable(Graph g, - String internHeadline, int eventAssignmentCount) { - if (isEventAssignmentVariable(g, internHeadline, eventAssignmentCount)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Return the function of an event assignment - * - * @param g - * the graph where the information should be read from - * @param internHeadline - * contains the number of the current event - * @param eventAssignmentCount - * the number of the current event assignment - * @return the function if it is set. Else the empty string - */ - private static String getEventAssignmentFunction(Graph g, - String internHeadline, int eventAssignmentCount) { - if (isEventAssignmentFunction(g, internHeadline, eventAssignmentCount)) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns a list of all event headlines in the graph - * - * @param g - * the graph where the information can be found - * @return list of headlines - */ - private static ArrayList getEventHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_EVENT); - } - - /** - * Returns a JSBML Event object - * - * @param g - * the graph where the information can be found - * @param internHeadline - * contains the number of the current event - * @return an Event object - */ - private static Event getEvent(Graph g, String internHeadline) { - Event event = new Event(); - event.setLevel(3); - event.setVersion(1); - if (isEventID(g, internHeadline)) { - event.setId(getEventID(g, internHeadline)); - } - if (isEventName(g, internHeadline)) { - event.setName(getEventName(g, internHeadline)); - } - if (isEventUseValuesFromTriggerTime(g, internHeadline)) { - Boolean useValues = getEventUseValuesFromTriggerTime(g, - internHeadline); - event.setUseValuesFromTriggerTime(useValues); - } - Trigger trigger = new Trigger(3, 1); - if (isTriggerInitialValue(g, internHeadline)) { - trigger.setInitialValue(getTriggerInitialValue(g, internHeadline)); - } - if (isTriggerPersistent(g, internHeadline)) { - trigger.setPersistent(getTriggerPersistent(g, internHeadline)); - } - try { - if (isTriggerFunction(g, internHeadline)) { - trigger.setFormula(getTriggerFunction(g, internHeadline)); - } - } catch (ParseException e) { - e.printStackTrace(); - } - - event.setTrigger(trigger); - if (isPriorityFunction(g, internHeadline)) { - Priority prio = new Priority(); - try { - prio.setFormula(getPriorityFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - event.setPriority(prio); - } - if (isDelayFunction(g, internHeadline)) { - Delay delay = new Delay(); - try { - delay.setFormula(getDelayFunction(g, internHeadline)); - } catch (ParseException e) { - e.printStackTrace(); - } - event.setDelay(delay); - } - - int eaCount = eventAssignmentCount(g, internHeadline); - for (int i = 1; i <= eaCount; i++) { - EventAssignment ea = new EventAssignment(); - ea.setVariable(getEventAssignmentVariable(g, internHeadline, i)); - try { - ea.setFormula(getEventAssignmentFunction(g, internHeadline, i)); - } catch (ParseException e) { - e.printStackTrace(); - } - event.addEventAssignment(ea); - } - return event; - } - - /** - * Returns the number of event assignments of an event - * - * @param g - * contains the information - * @param internHeadline - * a list which contains the number of the current event - * @return the number of event assignments - */ - private static int eventAssignmentCount(Graph g, String internHeadline) { - int eaCount = 0; - while (isEventAssignmentVariable(g, internHeadline, eaCount + 1)) { - eaCount++; - } - return eaCount; - } - - /** - * Returns a list of event with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current event - * @return a filled list of event - */ - private static List getAllEvent(Graph g, List internHeadlines) { - Iterator internHeadlinesIt = internHeadlines.iterator(); - List eventList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - eventList.add(getEvent(g, internHeadline)); - } - return eventList; - } - - /** - * Returns a list of event with distinct headlines - * - * @param g - * contains the information - * @param internHeadlines - * a list which contains the number of the current event - * @return a filled list of event - */ - public static List getAllEvent(Graph g) { - List internHeadlines = getEventHeadlines(g); - Iterator internHeadlinesIt = internHeadlines.iterator(); - List eventList = new ArrayList(); - while (internHeadlinesIt.hasNext()) { - String internHeadline = internHeadlinesIt.next(); - eventList.add(getEvent(g, internHeadline)); - } - return eventList; - } - - private static void initCompartmentNideIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.COMPARTMENT_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.SPATIAL_DIMENSIONS).toString(), - presentedHeadline + ": Spatial Dimensions"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SIZE) - .toString(), presentedHeadline + ": Size"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.UNITS) - .toString(), presentedHeadline + ": Units"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.CONSTANT).toString(), - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.OUTSIDE) - .toString(), presentedHeadline + ": Outside"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initParameterNideIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.VALUE) - .toString(), presentedHeadline + ": Value"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_UNITS).toString(), - presentedHeadline + ": Units"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_CONSTANT).toString(), - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - } - - private static void initInitialAssignmentNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SYMBOL) - .toString(), presentedHeadline + ": Symbol"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initFunctionDefinitionNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - AttributeHelper - .setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_FUNCTION) - .toString(), presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.FUNCTION_DEFINITION_NAME).toString(), - presentedHeadline + ": Name"); - } - - private static void initUnitDefinitionNideIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - } - - private static void initSubUnitDefinitionNideIDs(String internHeadline, String presentedHeadline, int subUnitCount) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append("_").toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.UNIT) - .toString(), new StringBuffer(presentedHeadline) - .append(": Unit").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.META_ID).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" Meta ID").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.SBOTERM).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" SBOTerm").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.NOTES).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" Notes").toString()); - } - - private static void initConstraintNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.CONSTRAINT).toString(), - presentedHeadline + ": Constraint"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.MESSAGE) - .toString(), presentedHeadline + ": Message"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initAssignmnetRuleNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_VARIABLE).toString(), - presentedHeadline + ": Variable"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ASSIGNMENT_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initRateRuleNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_VARIABLE).toString(), - presentedHeadline + ": Variable"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initAlgebraicRuleNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.ALGEBRAIC_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } - - private static void initEventNiceIDs(String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.EVENT_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper - .setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.USE_VALUES_FROM_TRIGGER_TIME) - .toString(), presentedHeadline - + ": UseValuesFromTriggerTime"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_VALUE).toString(), - presentedHeadline + ": Trigger Initial Value"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PERSISTENT).toString(), - presentedHeadline + ": Trigger Persistent"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.TRIGGER_FUNCTION).toString(), - presentedHeadline + ": Trigger Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_META_ID).toString(), - presentedHeadline + ": Priority Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_NOTES).toString(), - presentedHeadline + ": Priority Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_SBOTERM).toString(), - presentedHeadline + ": Priority SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PRIORITY_FUNCTION).toString(), - presentedHeadline + ": Priority Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_META_ID).toString(), - presentedHeadline + ": Delay Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_NOTES).toString(), - presentedHeadline + ": Delay Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_SBOTERM).toString(), - presentedHeadline + ": Delay SBOTerm"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.DELAY_FUNCTION).toString(), - presentedHeadline + ": Delay Function"); - } - - private static void initEventAssignmentNideIDs(int eventAssignmentCount, String internHeadline, String presentedHeadline) { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.VARIABLE).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Variable"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.FUNCTION).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Function"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.META_ID).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Meta ID"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.SBOTERM).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " SBOTerm"); - - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.EVENT_ASSIGNMENT) - .append(eventAssignmentCount) - .append(SBML_Constants.NOTES).toString(), - presentedHeadline + ": Event Assignment " - + eventAssignmentCount + " Notes"); - - } - - private static void initReactionNideIDs(String internHeadline, - String presentedHeadline) { - // AttributeHelper.setNiceId(SBML_Constants.REACTION_NAME, - // presentedHeadline+": Name"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_ID, presentedHeadline - + ": ID"); - AttributeHelper.setNiceId(SBML_Constants.REVERSIBLE, presentedHeadline - + ": Reversible"); - AttributeHelper.setNiceId(SBML_Constants.FAST, presentedHeadline - + ": Fast"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_COMPARTMENT, - presentedHeadline + ": Compartment ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.STOICHIOMETRY, - presentedHeadline + ": Stoichiometry"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_CONSTANT, - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES, presentedHeadline - + ": Species"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_REFERENCE_NAME, - presentedHeadline + ": Species Reference Name"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_REFERENCE_ID, - presentedHeadline + ": Species Reference ID"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_SBOTERM, - presentedHeadline + ": SBOTerm"); - } - - private static void initKineticLawNideIDs() { - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_NOTES, - "SBML Kinetic Law: Notes"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_META_ID, - "SBML Kinetic Law: Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_SBOTERM, - "SBML Kinetic Law: SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.KINETIC_LAW_FUNCTION, - "SBML Kinetic Law: Function"); - } - - private static void initLocalParameterNideIDs(String presentedAttributeName, - String internAttributeName, String presentedHeadline) { - presentedHeadline = "SBML " + presentedHeadline; - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.META_ID).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Meta ID") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.SBOTERM).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" SBOTerm") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.NOTES).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Notes") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_ID).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" ID") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_NAME).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Name") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_VALUE).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Value") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_UNITS).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Units") - .toString()); - } - - public static boolean isSetLayoutID(Graph g, Node node) { - if (AttributeHelper.hasAttribute(node, SBML_Constants.SBML, - SBML_Constants.SBML_LAYOUT_ID)) { - return true; - } - return false; - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignment.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignment.java deleted file mode 100644 index 1adfc0ab9..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignment.java +++ /dev/null @@ -1,201 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLInitialAssignment { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline = SBML_Constants.EMPTY; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden initial assignment attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLInitialAssignment(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initInitialAssignmentNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLInitialAssignment(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public Boolean isSetSymbol() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SYMBOL).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetFunction() { - if (AttributeHelper.hasAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString())) { - return true; - } else { - return false; - } - } - - public String getSymbol() { - if (isSetSymbol()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.SYMBOL).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setSymbol(String symbol) { - if (!symbol.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SYMBOL).toString(), - symbol); - } - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION) - .toString(), function); - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - private void initInitialAssignmentNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SYMBOL) - .toString(), presentedHeadline + ": Symbol"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.INITIAL_ASSIGNMENT_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignmentHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignmentHelper.java deleted file mode 100644 index 44b28f201..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLInitialAssignmentHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLInitialAssignmentHelper { - -List initialAssignmentList; - - public SBMLInitialAssignmentHelper(){ - initialAssignmentList = new ArrayList(); - } - - public SBMLInitialAssignment addInitialAssignment(Graph g, String internHeadline){ - SBMLInitialAssignment initialAssignment = new SBMLInitialAssignment(g, internHeadline); - initialAssignmentList.add(initialAssignment); - return initialAssignment; - } - - public SBMLInitialAssignment addInitialAssignment(Graph g, String internHeadline, String presentedHeadline){ - SBMLInitialAssignment initialAssignmet = new SBMLInitialAssignment(g, internHeadline, presentedHeadline); - initialAssignmentList.add(initialAssignmet); - return initialAssignmet; - } - - public List getInitialAssignmentHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_INITIAL_ASSIGNMENT); - } - - public List addInitialAssignments(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addInitialAssignment(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLLocalParameter.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLLocalParameter.java deleted file mode 100644 index 01eaf13c6..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLLocalParameter.java +++ /dev/null @@ -1,473 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLLocalParameter { - - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - String internAttributeName; - - int localParameterCount; - - /** - * The hidden local parameter attributes are stored here - */ - HashSet discardedRowIDs; - - /** - * Constructor. Initializes the graph. In Reader - * - * @param g - * the graph where the information is read from - */ - public SBMLLocalParameter(Graph g, String presentedAttributeName, - String internAttributeName) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internAttributeName = internAttributeName; - initLocalParameterNideIDs(presentedAttributeName, internAttributeName, - "Kinetic Law"); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - // In writer - public SBMLLocalParameter(Graph g, int localParameterCount) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.localParameterCount = localParameterCount; - } - - public void setID(Node reactionNode, String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_ID).toString(), ID); - } - } - - public void setName(Node reactionNode, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_NAME).toString(), - name); - } - } - - public void setValue(Node reactionNode, Double value) { - if (!value.equals(null)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_VALUE).toString(), - value); - } - } - - public void setUnits(Node reactionNode, String units) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_UNITS).toString(), - units); - } - } - - public void setMetaID(Node reactionNode, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.META_ID) - .toString(), metaID); - } - } - - public String getMetaID(Node node) { - if (isSetMetaID(node)) { - return (String) attWriter.getAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.META_ID) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Boolean isSetMetaID(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.META_ID) - .toString())) { - return true; - } else { - return false; - } - } - - public void deleteMetaID(Node node) { - if (isSetMetaID(node)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.META_ID) - .toString()); - } - } - - public void setSBOTerm(Node reactionNode, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.SBOTERM) - .toString(), sboTerm); - } - } - - public Boolean isSetSBOTerm(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.SBOTERM) - .toString())) { - return true; - } else { - return false; - } - } - - public void deleteSBOTerm(Node node) { - if (isSetSBOTerm(node)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.SBOTERM) - .toString()); - } - } - - public String getSBOTerm(Node node) { - if (isSetSBOTerm(node)) { - return (String) attWriter.getAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.SBOTERM) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setAnnotation(Node reactionNode, Annotation annotation) { - AttributeHelper.setAttribute(reactionNode, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.ANNOTATION) - .toString(), annotation); - discardedRowIDs.add(new StringBuffer(internAttributeName).append( - SBML_Constants.ANNOTATION).toString()); - } - - public Boolean isSetAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.ANNOTATION) - .toString())) { - return true; - } else { - return false; - } - } - - public void deleteAnnotation(Node node) { - if (isSetAnnotation(node)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.ANNOTATION) - .toString()); - } - } - - public Annotation getAnnotation(Node node) { - if (isSetAnnotation(node)) { - return (Annotation) attWriter.getAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.ANNOTATION) - .toString()); - } else { - return null; - } - } - - public void setNonRDFAnnotation(Node reactionNode, String nonRDFAnnotation) { - AttributeHelper.setAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(internAttributeName).append( - SBML_Constants.NON_RDF_ANNOTATION).toString(), - nonRDFAnnotation); - // discardedRowIDs.add(new StringBuffer(internAttributeName).append( - // SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public Boolean isSetNonRDFAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString())) { - return true; - } else { - return false; - } - } - - public void deleteNonRDFAnnotation(Node node) { - if (isSetNonRDFAnnotation(node)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString()); - } - } - - public String getNonRDFAnnotation(Node node) { - if (isSetNonRDFAnnotation(node)) { - return (String) attWriter.getAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setNotes(Node reactionNode, String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionNode, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.NOTES) - .toString()); - } - // discardedRowIDs.add(new StringBuffer(internAttributeName).append( - // SBML_Constants.NOTES).toString()); - } - - public void deleteNotes(Node node) { - if (isSetNotes(node)) { - AttributeHelper.deleteAttribute(node, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.NOTES) - .toString()); - } - } - - public Boolean isSetNotes(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer( - internAttributeName).append(SBML_Constants.NOTES) - .toString())) { - return true; - } else { - return false; - } - } - - public String getNotes(Node node) { - if (isSetNotes(node)) { - return (String) attWriter.getAttribute(node, - SBML_Constants.SBML_KINETIC_LAW, new StringBuffer( - internAttributeName).append(SBML_Constants.NOTES) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Boolean isSetID(Node reactionNode) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_ID).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetName(Node reactionNode) { - if (AttributeHelper - .hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetValue(Node reactionNode) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_VALUE) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetUnits(Node reactionNode) { - if (AttributeHelper.hasAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_UNITS) - .toString())) { - return true; - } else { - return false; - } - } - - public String getID(Node reactionNode) { - if (isSetID(reactionNode)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_ID) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName(Node reactionNode) { - if (isSetName(reactionNode)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_NAME) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Double getValue(Node reactionNode) { - if (isSetValue(reactionNode)) { - return (Double) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_VALUE) - .toString()); - } else { - return null; - } - } - - public String getUnits(Node reactionNode) { - if (isSetUnits(reactionNode)) { - return (String) attWriter.getAttribute( - reactionNode, - SBML_Constants.SBML_KINETIC_LAW, - new StringBuffer(SBML_Constants.LOCAL_PARAMETER) - .append(localParameterCount) - .append(SBML_Constants.LOCAL_PARAMETER_UNITS) - .toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initLocalParameterNideIDs(String presentedAttributeName, - String internAttributeName, String presentedHeadline) { - presentedHeadline = "SBML " + presentedHeadline; - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.META_ID).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Meta ID") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.SBOTERM).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" SBOTerm") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.NOTES).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Notes") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_ID).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" ID") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_NAME).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Name") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_VALUE).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Value") - .toString()); - AttributeHelper.setNiceId( - new StringBuffer(internAttributeName).append( - SBML_Constants.LOCAL_PARAMETER_UNITS).toString(), - new StringBuffer(presentedHeadline).append(": ") - .append(presentedAttributeName).append(" Units") - .toString()); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLNodesNiceIdHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLNodesNiceIdHelper.java deleted file mode 100644 index 5e45911d5..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLNodesNiceIdHelper.java +++ /dev/null @@ -1,78 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import org.AttributeHelper; - - -public class SBMLNodesNiceIdHelper { - - private static boolean isInitialized = false; - - /** - * Sets the niceIDs if they are not initialized yet. - */ - public static void initNiceIds() { - if (!isInitialized) { - initSpeciesNiceIDs(); - initReactionNiceIDs(); - isInitialized = true; - } - } - - public static boolean isInitialized() { - return isInitialized; - } - - private static void initReactionNiceIDs() { - AttributeHelper.setNiceId(SBML_Constants.FAST, SBML_Constants.SBML_HEADLINE - + ": Fast"); - AttributeHelper.setNiceId(SBML_Constants.REVERSIBLE, SBML_Constants.SBML_HEADLINE - + ": Reversible"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_ID, SBML_Constants.SBML_HEADLINE - + ": ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_NAME, SBML_Constants.SBML_HEADLINE - + ": Name"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_COMPARTMENT, SBML_Constants.SBML_HEADLINE - + ": Compartment ID"); - } - - /** - * Sets the nice id - * - * @param internHeadline - * how the headline is represented intern - * @param presentedHeadline - * how the user will see the headline - */ - private static void initSpeciesNiceIDs() { - AttributeHelper.setNiceId(SBML_Constants.COMPARTMENT, SBML_Constants.SBML_HEADLINE - + ": Compartment ID"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_ID, SBML_Constants.SBML_HEADLINE - + ": ID"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_NAME, SBML_Constants.SBML_HEADLINE - + ": Name"); - AttributeHelper.setNiceId(SBML_Constants.INITIAL_AMOUNT, - SBML_Constants.SBML_HEADLINE + ": Initial Amount"); - AttributeHelper.setNiceId(SBML_Constants.INITIAL_CONCENTRATION, - SBML_Constants.SBML_HEADLINE + ": Initial Concentration"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_SUBSTANCE_UNITS, - SBML_Constants.SBML_HEADLINE + ": Substance Units"); - AttributeHelper.setNiceId(SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS, - SBML_Constants.SBML_HEADLINE + ": HasOnlySubstanceUnits"); - AttributeHelper.setNiceId(SBML_Constants.BOUNDARY_CONDITION, - SBML_Constants.SBML_HEADLINE + ": Boundary Condition"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_CONSTANT, - SBML_Constants.SBML_HEADLINE + ": Constant"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_CONVERSION_FACTOR, - SBML_Constants.SBML_HEADLINE + ": Conversion Faktor"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_META_ID, - SBML_Constants.SBML_HEADLINE + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_SBOTERM, - SBML_Constants.SBML_HEADLINE + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_NOTES, - SBML_Constants.SBML_HEADLINE + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_COMPARTMENT_NAME, - SBML_Constants.SBML_HEADLINE + ": Compartment ID"); - - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameter.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameter.java deleted file mode 100644 index 9bacef996..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameter.java +++ /dev/null @@ -1,295 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLParameter { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline = SBML_Constants.EMPTY; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden parameter attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLParameter(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initParameterNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLParameter(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public Boolean isSetID() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_ID).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetName() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetValue() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.VALUE).toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetUnits() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_UNITS) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetConstant() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_CONSTANT) - .toString())) { - return true; - } else { - return false; - } - } - - public String getID() { - if (isSetID()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName() { - if (isSetName()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Double getValue() { - if (isSetValue()) { - return (Double) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.VALUE).toString()); - } else { - return null; - } - } - - public String getUnits() { - if (isSetUnits()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_UNITS).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public Boolean getConstant() { - if (isSetConstant()) { - return (Boolean) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_CONSTANT).toString()); - } else { - return null; - } - } - - public void setID(String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_ID) - .toString(), ID); - } - } - - public void setName(String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_NAME) - .toString(), name); - } - } - - public void setValue(Double value) { - if (!value.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.VALUE).toString(), - value); - } - } - - public void setUnits(String units) { - if (!units.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_UNITS) - .toString(), units); - } - } - - public void setConstant(Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.PARAMETER_CONSTANT) - .toString(), constant); - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - private void initParameterNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.VALUE) - .toString(), presentedHeadline + ": Value"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_UNITS).toString(), - presentedHeadline + ": Units"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.PARAMETER_CONSTANT).toString(), - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameterHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameterHelper.java deleted file mode 100644 index 57899027d..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLParameterHelper.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLParameterHelper { - - /** - * Stores the SBMLParameter objects - */ - List parameterList; - - public SBMLParameterHelper() { - parameterList = new ArrayList(); - } - - public SBMLParameter addParameter(Graph g, String internHeadline) { - SBMLParameter parameter = new SBMLParameter(g, internHeadline); - parameterList.add(parameter); - return parameter; - } - - public SBMLParameter addParameter(Graph g, String internHeadline, - String presentedHeadline) { - SBMLParameter parameter = new SBMLParameter(g, internHeadline, - presentedHeadline); - parameterList.add(parameter); - return parameter; - } - - public List getParameterHeadlines(Graph g) { - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_PARAMETER); - } - - public List addParameters(Graph g, - List internHeadlines) { - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while (internHeadlineIt.hasNext()) { - returnList.add(addParameter(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRateRule.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRateRule.java deleted file mode 100644 index fc3963cce..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRateRule.java +++ /dev/null @@ -1,199 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLRateRule { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The hidden function definition attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLRateRule(Graph g, String internHeadline, String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initRateNiceIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLRateRule(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - public void setFunction(String function) { - if (!function.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_FUNCTION) - .toString(), function); - } - } - - public void setVariable(String variable) { - if (!variable.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_VARIABLE) - .toString(), variable); - } - } - - public Boolean isSetFunction() { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_FUNCTION) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetVariable() { - if (AttributeHelper - .hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.RATE_VARIABLE) - .toString())) { - return true; - } else { - return false; - } - } - - public String getVariable() { - if (isSetVariable()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_VARIABLE).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getFunction() { - if (isSetFunction()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_FUNCTION).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - private void initRateNiceIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_VARIABLE).toString(), - presentedHeadline + ": Variable"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.RATE_FUNCTION).toString(), - presentedHeadline + ": Function"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLReactionHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLReactionHelper.java deleted file mode 100644 index 7a2a99c0a..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLReactionHelper.java +++ /dev/null @@ -1,1065 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.AttributeHelper; -import org.PositionGridGenerator; -import org.graffiti.graph.Edge; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.NodeTools; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLReactionHelper { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * contains all reaction ids and all nodes that belong to that reaction id - */ - private Map> _reactionClones; - - /** - * the array contains the reaction id and the species id which is an reactant in this reaction - */ - private Map> _reactantClones; - - private Map> _productClones; - - private Map> _modifierClones; - - /** - * Constructor. Initializes the graph - * - * @param g - * the graph where the information is read from - */ - public SBMLReactionHelper(Graph g) { - this.g = g; - _reactionClones = new HashMap>(); - _reactantClones = new HashMap>(); - _productClones = new HashMap>(); - _modifierClones = new HashMap>(); - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - - initReactionNideIDs(SBML_Constants.SBML, SBML_Constants.SBML_HEADLINE); - } - - public Map> getReactionClones() { - return _reactionClones; - } - - public Map> getReactantClones() { - return _reactantClones; - } - - public Map> getProductClones() { - return _productClones; - } - - public Map> getModifierClones() { - return _modifierClones; - } - - public Node getReactionNode(String layoutId, String reactionId) { - List nodes = _reactionClones.get(reactionId); - for (Node reactionsNode : nodes) { - String reactionNodeLayoutId = (String) AttributeHelper - .getAttributeValue(reactionsNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, null, null); - if (reactionNodeLayoutId != null && reactionNodeLayoutId.equals(layoutId)) { - return reactionsNode; - } - } - return null; - } - - public void addReactionCloneToList(String reactionId, Node reactionNode) { - List reactionNodes = _reactionClones.get(reactionId); - if (reactionNodes == null) { - reactionNodes = new ArrayList(); - } - reactionNodes.add(reactionNode); - _reactionClones.put(reactionId, reactionNodes); - } - - public void addReactantCloneToList(String reactionId, String speciesId, Edge reactantEdge) { - ReactionIDSpeciesIDWrapper reactionSpeciesPair = new ReactionIDSpeciesIDWrapper(reactionId, speciesId); - List edgeList = _reactantClones.get(reactionSpeciesPair); - if (edgeList == null) { - edgeList = new ArrayList(); - } - edgeList.add(reactantEdge); - _reactantClones.put(reactionSpeciesPair, edgeList); - } - - public void addProductCloneToList(String reactionId, String speciesId, Edge reactantEdge) { - ReactionIDSpeciesIDWrapper reactionSpeciesPair = new ReactionIDSpeciesIDWrapper(reactionId, speciesId); - List edgeList = _productClones.get(reactionSpeciesPair); - if (edgeList == null) { - edgeList = new ArrayList(); - } - edgeList.add(reactantEdge); - _productClones.put(reactionSpeciesPair, edgeList); - } - - public void addModifierCloneToList(String reactionId, String speciesId, Edge reactantEdge) { - ReactionIDSpeciesIDWrapper reactionSpeciesPair = new ReactionIDSpeciesIDWrapper(reactionId, speciesId); - List edgeList = _modifierClones.get(reactionSpeciesPair); - if (edgeList == null) { - edgeList = new ArrayList(); - } - edgeList.add(reactantEdge); - _modifierClones.put(reactionSpeciesPair, edgeList); - } - - public Boolean isSetCompartment(Node reactionNode) { - if (!NodeTools.getClusterID(reactionNode, SBML_Constants.EMPTY).equals( - SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - public Boolean isSetFast(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.FAST)) { - return true; - } else { - return false; - } - } - - public Boolean isSetReversible(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE)) { - return true; - } else { - return false; - } - } - - public Boolean isSetName(Node reactionNode) { - if (!AttributeHelper.getLabel(reactionNode, SBML_Constants.EMPTY) - .equals(SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - public Boolean isSetID(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ID)) { - return true; - } else { - return false; - } - } - - public String getID(Node reactionNode) { - if (isSetID(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName(Node reactionNode) { - return AttributeHelper.getLabel(reactionNode, SBML_Constants.EMPTY); - } - - public Boolean getReversible(Node reactionNode) { - if (isSetReversible(reactionNode)) { - return (Boolean) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REVERSIBLE); - } else { - return null; - } - } - - public Boolean getFast(Node reactionNode) { - if (isSetFast(reactionNode)) { - return (Boolean) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.FAST); - } else { - return null; - } - } - - public String getCompartment(Node reactionNode) { - return NodeTools.getClusterID(reactionNode, SBML_Constants.EMPTY); - } - - public void setID(Node reactionNode, String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ID, ID); - } - } - - public void setLabel(Node reactionNode, String name, String id, - PositionGridGenerator pgg) { - String label = null; - if (!name.equals(SBML_Constants.EMPTY)) { - label = name; - } else { - label = id; - } - if (!label.equals(SBML_Constants.EMPTY)) { - attReader.setAttributes(reactionNode, Color.white, label, - pgg.getNextPosition(), 7); - } - } - - public void setReversible(Node reactionNode, Boolean reversible) { - if (!reversible.equals(null)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REVERSIBLE, reversible); - } - } - - public void setFast(Node reactionNode, Boolean fast) { - if (!fast.equals(null)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.FAST, fast); - } - } - - public void setCompartment(Node reactionNode, String compartment) { - if (!compartment.equals(SBML_Constants.EMPTY)) { - NodeTools.setClusterID(reactionNode, compartment); - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT, compartment); - } - } - - public void setMetaID(Node reactionNode, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_META_ID, metaID); - } - } - - public Boolean isSetMetaID(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_META_ID)) { - return true; - } else { - return false; - } - } - - public void deleteMetaID(Node reactinNode) { - if (isSetMetaID(reactinNode)) { - AttributeHelper.deleteAttribute(reactinNode, SBML_Constants.SBML, SBML_Constants.REACTION_META_ID); - } - } - - public String getMetaID(Node reactionNode) { - if (isSetMetaID(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteSBOTerm(Node reactinNode) { - if (isSetSBOTerm(reactinNode)) { - AttributeHelper.deleteAttribute(reactinNode, SBML_Constants.SBML, SBML_Constants.REACTION_SBOTERM); - } - } - - public void setSBOTerm(Node reactionNode, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_SBOTERM, sboTerm); - } - } - - public Boolean isSetSBOTerm(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_SBOTERM)) { - return true; - } else { - return false; - } - } - - public String getSBOTerm(Node reactionNode) { - if (isSetSBOTerm(reactionNode)) { - return (String) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setAnnotation(Node reactionNode, Annotation annotation) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ANNOTATION, annotation); - } - - public Annotation getAnnotation(Node reactionNode) { - if (isSetAnnotation(reactionNode)) { - return (Annotation) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_ANNOTATION); - } else { - return null; - } - } - - public void deleteAnnotation(Node reactinNode) { - if (isSetAnnotation(reactinNode)) { - AttributeHelper.deleteAttribute(reactinNode, SBML_Constants.SBML, SBML_Constants.REACTION_ANNOTATION); - } - } - - public Boolean isSetAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNonRDFAnnotation(Node reactionNode, String nonRDFAnnotation) { - AttributeHelper.setAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_NON_RDF_ANNOTATION, nonRDFAnnotation); - } - - public Annotation getNonRDFAnnotation(Node reactionNode) { - if (isSetNonRDFAnnotation(reactionNode)) { - return (Annotation) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_NON_RDF_ANNOTATION); - } else { - return null; - } - } - - public void deleteNonRDFAnnotation(Node reactinNode) { - if (isSetNonRDFAnnotation(reactinNode)) { - AttributeHelper.deleteAttribute(reactinNode, SBML_Constants.SBML, SBML_Constants.REACTION_NON_RDF_ANNOTATION); - } - } - - public Boolean isSetNonRDFAnnotation(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNotes(Node reactionNode, String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_NOTES); - } - } - - public XMLNode getNotes(Node reactionNode) { - if (isSetNotes(reactionNode)) { - return (XMLNode) attWriter.getAttribute(reactionNode, - SBML_Constants.SBML, SBML_Constants.REACTION_NOTES); - } else { - return null; - } - } - - public Boolean isSetNotes(Node reactionNode) { - if (AttributeHelper.hasAttribute(reactionNode, SBML_Constants.SBML, - SBML_Constants.REACTION_NOTES)) { - return true; - } else { - return false; - } - } - - public void deleteNotes(Node reactinNode) { - if (isSetNotes(reactinNode)) { - AttributeHelper.deleteAttribute(reactinNode, SBML_Constants.SBML, SBML_Constants.REACTION_NOTES); - } - } - - public void setSpecies(Edge reactionEdge, String species) { - if (!species.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES, species); - } - } - - public void setID(Edge reactionEdge, String ID) { - if (!reactionEdge.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_ID, ID); - } - } - - public void setName(Edge reactionEdge, String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_NAME, name); - } - } - - public Boolean isSetSpecies(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES)) { - return true; - } else { - return false; - } - } - - public Boolean isSetID(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_ID)) { - return true; - } else { - return false; - } - } - - public Boolean isSetName(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.SPECIES_REFERENCE_NAME)) { - return true; - } else { - return false; - } - } - - public String getSpecies(Edge reactionEdge) { - if (isSetSpecies(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getName(Edge reactionEdge) { - if (isSetName(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES_REFERENCE_NAME); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getID(Edge reactionEdge) { - if (isSetID(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SPECIES_REFERENCE_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setMetaIDReactant(Edge reactionEdge, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTANT_META_ID, metaID); - } - } - - public String getMetaIDReactant(Edge edge) { - if (isSetMetaIDReactant(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.REACTANT_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteMetaIDReactant(Edge edge) { - if (isSetMetaIDReactant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.REACTANT_META_ID); - } - } - - public Boolean isSetMetaIDReactant(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTANT_META_ID)) { - return true; - } else { - return false; - } - } - - public void setMetaIDProduct(Edge reactionEdge, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_META_ID, metaID); - } - } - - public String getMetaIDProduct(Edge edge) { - if (isSetMetaIDProduct(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteMetaIDProduct(Edge edge) { - if (isSetMetaIDProduct(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.PRODUCT_META_ID); - } - } - - public Boolean isSetMetaIDProduct(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_META_ID)) { - return true; - } else { - return false; - } - } - - public void setMetaIDModifier(Edge reactionEdge, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_META_ID, metaID); - } - } - - public String getMetaIDModifier(Edge edge) { - if (isSetMetaIDModifier(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteMetaIDModifier(Edge edge) { - if (isSetMetaIDModifier(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.MODIFIER_META_ID); - } - } - - public Boolean isSetMetaIDModifier(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_META_ID)) { - return true; - } else { - return false; - } - } - - public void setSBOTermReactant(Edge reactionEdge, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTANT_SBOTERM, sboTerm); - } - } - - public String getSBOTermReactant(Edge edge) { - if (isSetSBOTermReactant(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.REACTANT_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteSBOTermReactant(Edge edge) { - if (isSetSBOTermReactant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.REACTANT_SBOTERM); - } - } - - public Boolean isSetSBOTermReactant(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTANT_SBOTERM)) { - return true; - } else { - return false; - } - } - - public void setSBOTermProduct(Edge reactionEdge, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_SBOTERM, sboTerm); - } - } - - public String getSBOTermProduct(Edge edge) { - if (isSetSBOTermProduct(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteSBOTermProduct(Edge edge) { - if (isSetSBOTermProduct(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.PRODUCT_SBOTERM); - } - } - - public Boolean isSetSBOTermProduct(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_SBOTERM)) { - return true; - } else { - return false; - } - } - - public void setSBOTermModifier(Edge reactionEdge, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_SBOTERM, sboTerm); - } - } - - public String getSBOTermModifier(Edge edge) { - if (isSetSBOTermModifier(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteSBOTermModifier(Edge edge) { - if (isSetSBOTermModifier(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.MODIFIER_SBOTERM); - } - } - - public Boolean isSetSBOTermModifier(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_SBOTERM)) { - return true; - } else { - return false; - } - } - - public void setAnnotationProduct(Edge reactionEdge, Annotation annotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_ANNOTATION, annotation); - } - - public Annotation getAnnotationProduct(Edge edge) { - if (isSetAnnotationProduct(edge)) { - return (Annotation) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_ANNOTATION); - } else { - return null; - } - } - - public void deleteAnnotationProduct(Edge edge) { - if (isSetAnnotationProduct(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.PRODUCT_ANNOTATION); - } - } - - public Boolean isSetAnnotationProduct(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNonRDFAnnotationProduct(Edge reactionEdge, - String nonRDFAnnotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_NON_RDF_ANNOTATION, nonRDFAnnotation); - } - - public String getNonRDFAnnotationProduct(Edge edge) { - if (isSetAnnotationProduct(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_NON_RDF_ANNOTATION); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteNonRDFAnnotationProduct(Edge edge) { - if (isSetNonRDFAnnotationProduct(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.PRODUCT_NON_RDF_ANNOTATION); - } - } - - public Boolean isSetNonRDFAnnotationProduct(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setAnnotationModifier(Edge reactionEdge, Annotation annotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_ANNOTATION, annotation); - } - - public Annotation getAnnotationModifier(Edge edge) { - if (isSetAnnotationModifier(edge)) { - return (Annotation) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_ANNOTATION); - } else { - return null; - } - } - - public void deleteAnnotationModifier(Edge edge) { - if (isSetAnnotationModifier(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.MODIFIER_ANNOTATION); - } - } - - public Boolean isSetAnnotationModifier(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNonRDFAnnotationModifier(Edge reactionEdge, - String nonRDFAnnotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_NON_RDF_ANNOTATION, nonRDFAnnotation); - } - - public String getNonRDFAnnotationModifier(Edge edge) { - if (isSetAnnotationModifier(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_NON_RDF_ANNOTATION); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteNonRDFAnnotationModifier(Edge edge) { - if (isSetNonRDFAnnotationModifier(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.MODIFIER_NON_RDF_ANNOTATION); - } - } - - public Boolean isSetNonRDFAnnotationModifier(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setAnnotationReactant(Edge reactionEdge, Annotation annotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTANT_ANNOTATION, annotation); - } - - public Annotation getAnnotationReactant(Edge edge) { - if (isSetAnnotationReactant(edge)) { - return (Annotation) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.REACTANT_ANNOTATION); - } else { - return null; - } - } - - public void deleteAnnotationReactant(Edge edge) { - if (isSetAnnotationReactant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.REACTANT_ANNOTATION); - } - } - - public Boolean isSetAnnotationReactant(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTANT_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNonRDFAnnotationReactant(Edge reactionEdge, - String nonRDFAnnotation) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTANT_NON_RDF_ANNOTATION, nonRDFAnnotation); - } - - public String getNonRDFAnnotationReactant(Edge edge) { - if (isSetAnnotationReactant(edge)) { - return (String) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.REACTANT_NON_RDF_ANNOTATION); - } else { - return SBML_Constants.EMPTY; - } - } - - public void deleteNonRDFAnnotationReactant(Edge edge) { - if (isSetNonRDFAnnotationReactant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.REACTANT_NON_RDF_ANNOTATION); - } - } - - public Boolean isSetNonRDFAnnotationReactant(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTANT_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void setNotesReactant(Edge reactionEdge, String notes, - XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionEdge, - SBML_Constants.SBML, SBML_Constants.REACTANT_NOTES); - } - } - - public Object getNotesReactant(Edge edge) { - if (isSetNotesReactant(edge)) { - return (Object) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.REACTANT_NOTES); - } else { - return null; - } - } - - public void deleteNotesReactant(Edge edge) { - if (isSetNotesReactant(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.REACTANT_NOTES); - } - } - - public Boolean isSetNotesReactant(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.REACTANT_NOTES)) { - return true; - } else { - return false; - } - } - - public void setNotesProduct(Edge reactionEdge, String notes, - XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionEdge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_NOTES); - } - } - - public Object getNotesProduct(Edge edge) { - if (isSetNotesProduct(edge)) { - return (Object) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.PRODUCT_NOTES); - } else { - return null; - } - } - - public void deleteNotesProduct(Edge edge) { - if (isSetNotesProduct(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.PRODUCT_NOTES); - } - } - - public Boolean isSetNotesProduct(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.PRODUCT_NOTES)) { - return true; - } else { - return false; - } - } - - public void setNotesModifier(Edge reactionEdge, String notes, - XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, reactionEdge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_NOTES); - } - } - - public Object getNotesModifier(Edge edge) { - if (isSetNotesModifier(edge)) { - return (Object) attWriter.getAttribute(edge, - SBML_Constants.SBML, SBML_Constants.MODIFIER_NOTES); - } else { - return null; - } - } - - public void deleteNotesModifier(Edge edge) { - if (isSetNotesModifier(edge)) { - AttributeHelper.deleteAttribute(edge, SBML_Constants.SBML, SBML_Constants.MODIFIER_NOTES); - } - } - - public Boolean isSetNotesModifier(Edge edge) { - if (AttributeHelper.hasAttribute(edge, SBML_Constants.SBML, - SBML_Constants.MODIFIER_NOTES)) { - return true; - } else { - return false; - } - } - - public Boolean isSetStoichiometry(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY)) { - return true; - } else { - return false; - } - } - - public Boolean isSetConstant(Edge reactionEdge) { - if (AttributeHelper.hasAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTION_CONSTANT)) { - return true; - } else { - return false; - } - } - - public String getStoichiometry(Edge reactionEdge) { - if (!AttributeHelper.getSBMLrole(reactionEdge).equals( - SBML_Constants.ROLE_MODIFIER)) { - if (isSetStoichiometry(reactionEdge)) { - return (String) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.STOICHIOMETRY); - } else { - return null; - } - } else { - return null; - } - } - - public Boolean getConstant(Edge reactionEdge) { - if (!AttributeHelper.getAttributeValue(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SBML_ROLE, - SBML_Constants.EMPTY, SBML_Constants.EMPTY).equals( - SBML_Constants.ROLE_MODIFIER)) { - if (isSetConstant(reactionEdge)) { - return (Boolean) attWriter.getAttribute(reactionEdge, - SBML_Constants.SBML, SBML_Constants.REACTION_CONSTANT); - } else { - return null; - } - } else { - return null; - } - } - - public void setStoichiometry(Edge reactionEdge, Double stoichiometry) { - if (!AttributeHelper.getAttributeValue(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SBML_ROLE, - SBML_Constants.EMPTY, SBML_Constants.EMPTY).equals( - SBML_Constants.ROLE_MODIFIER)) { - if (!stoichiometry.equals(null)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.STOICHIOMETRY, stoichiometry); - } - } - } - - public void setConstant(Edge reactionEdge, Boolean constant) { - if (!AttributeHelper.getAttributeValue(reactionEdge, - SBML_Constants.SBML, SBML_Constants.SBML_ROLE, - SBML_Constants.EMPTY, SBML_Constants.EMPTY).equals( - SBML_Constants.ROLE_MODIFIER)) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(reactionEdge, SBML_Constants.SBML, - SBML_Constants.REACTION_CONSTANT, constant); - } - } - } - - private void initReactionNideIDs(String internHeadline, - String presentedHeadline) { - // AttributeHelper.setNiceId(SBML_Constants.REACTION_NAME, - // presentedHeadline+": Name"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_ID, presentedHeadline - + ": ID"); - AttributeHelper.setNiceId(SBML_Constants.REVERSIBLE, presentedHeadline - + ": Reversible"); - AttributeHelper.setNiceId(SBML_Constants.FAST, presentedHeadline - + ": Fast"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_COMPARTMENT, - presentedHeadline + ": Compartment ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.STOICHIOMETRY, - presentedHeadline + ": Stoichiometry"); - AttributeHelper.setNiceId(SBML_Constants.REACTION_CONSTANT, - presentedHeadline + ": Constant"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES, presentedHeadline - + ": Species"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_REFERENCE_NAME, - presentedHeadline + ": Species Reference Name"); - AttributeHelper.setNiceId(SBML_Constants.SPECIES_REFERENCE_ID, - presentedHeadline + ": Species Reference ID"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.PRODUCT_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.REACTANT_SBOTERM, - presentedHeadline + ": SBOTerm"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_META_ID, - presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_NOTES, - presentedHeadline + ": Notes"); - AttributeHelper.setNiceId(SBML_Constants.MODIFIER_SBOTERM, - presentedHeadline + ": SBOTerm"); - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRuleHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRuleHelper.java deleted file mode 100644 index 71623e4bf..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLRuleHelper.java +++ /dev/null @@ -1,100 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLRuleHelper { - -List assignmentRuleList; -List algebraicRuleList; -List rateRuleList; - - public SBMLRuleHelper(){ - assignmentRuleList = new ArrayList(); - algebraicRuleList = new ArrayList(); - rateRuleList = new ArrayList(); - } - - public SBMLAssignmentRule addAssignmentRule(Graph g, String internHeadline){ - SBMLAssignmentRule assignmentRule = new SBMLAssignmentRule(g, internHeadline); - assignmentRuleList.add(assignmentRule); - return assignmentRule; - } - - public SBMLAssignmentRule addAssignmentRule(Graph g, String internHeadline, String presentedHeadline){ - SBMLAssignmentRule assignmentRule = new SBMLAssignmentRule(g, internHeadline, presentedHeadline); - assignmentRuleList.add(assignmentRule); - return assignmentRule; - } - - public SBMLAlgebraicRule addAlgebraicRule(Graph g, String internHeadline){ - SBMLAlgebraicRule algebraicRule = new SBMLAlgebraicRule(g, internHeadline); - algebraicRuleList.add(algebraicRule); - return algebraicRule; - } - - public SBMLAlgebraicRule addAlgebraicRule(Graph g, String internHeadline, String presentedHeadline){ - SBMLAlgebraicRule algebraicRule = new SBMLAlgebraicRule(g, internHeadline, presentedHeadline); - algebraicRuleList.add(algebraicRule); - return algebraicRule; - } - - public SBMLRateRule addRateRule(Graph g, String internHeadline){ - SBMLRateRule rateRule = new SBMLRateRule(g, internHeadline); - rateRuleList.add(rateRule); - return rateRule; - } - - public SBMLRateRule addRateRule(Graph g, String internHeadline, String presentedHeadline){ - SBMLRateRule rateRule = new SBMLRateRule(g, internHeadline, presentedHeadline); - rateRuleList.add(rateRule); - return rateRule; - } - - public List getAssignmentRuleHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_ASSIGNMENT_RULE); - } - - public List addAssignmentRules(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addAssignmentRule(g, internHeadlineIt.next())); - } - return returnList; - } - - public List getRateRuleHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_RATE_RULE); - } - - public List addRateRules(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addRateRule(g, internHeadlineIt.next())); - } - return returnList; - } - - public List getAlgebraicRuleHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_ALGEBRAIC_RULE); - } - - public List addAlgebraicRules(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addAlgebraicRule(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLSpeciesHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLSpeciesHelper.java deleted file mode 100644 index c3e143884..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLSpeciesHelper.java +++ /dev/null @@ -1,830 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.AlignmentSetting; -import org.AttributeHelper; -import org.PositionGridGenerator; -import org.graffiti.graph.Graph; -import org.graffiti.graph.Node; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.NodeTools; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLSpeciesHelper extends SBMLNodesNiceIdHelper { - - /** - * Intern graph object - */ - static Graph _g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - public static Map speciesMap; - - /** - * contains all SpeicesId and all nodes that belong to that species id - */ - private Map> _speicesClones; - - public Map> getSpeicesClones() { - return _speicesClones; - } - - public Node getSpeciesNode(String layoutId, String speciesId) { - List nodes = _speicesClones.get(speciesId); - for (Node speciesNode : nodes) { - String speciesNodeLayoutId = (String) AttributeHelper.getAttributeValue(speciesNode, SBML_Constants.SBML, SBML_Constants.SBML_LAYOUT_ID, null, null); - if (speciesNodeLayoutId != null && speciesNodeLayoutId.equals(layoutId)) { - return speciesNode; - } - } - return null; - } - - /** - * Constructor. Initializes the graph - * - * @param g - * the graph where the information is read from - */ - public SBMLSpeciesHelper(Graph g) { - _g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - if (speciesMap == null) { - speciesMap = new HashMap(); - } - _speicesClones = new HashMap>(); - } - - public void addCloneToList(String speciesId, Node speciesNode) { - List speciesNodes = _speicesClones.get(speciesId); - if (speciesNodes == null) { - speciesNodes = new ArrayList(); - } - speciesNodes.add(speciesNode); - _speicesClones.put(speciesId, speciesNodes); - } - - public String getCompartmentName(Node speciesNode) { - String id = getCompartment(speciesNode); - - if (AttributeHelper.hasAttribute(_g, SBML_Constants.SBML_COMPARTMENT - + id, new StringBuffer(SBML_Constants.SBML_COMPARTMENT + id) - .append("_id").toString())) { - return (String) attWriter - .getAttribute( - _g, - SBML_Constants.SBML_COMPARTMENT + id, - new StringBuffer(SBML_Constants.SBML_COMPARTMENT - + id).append( - SBML_Constants.COMPARTMENT_NAME).toString()); - } - return null; - } - - /** - * Returns all species nodes of the graph - * - * @return a list of all species nodes of the graph - */ - public List getSpeciesNodes() { - List speciesNodeList = new ArrayList(); - Iterator itNode = _g.getNodesIterator(); - while (itNode.hasNext()) { - Node node = itNode.next(); - if (AttributeHelper.getSBMLrole(node).equals("species")) { - speciesNodeList.add(node); - } - } - return speciesNodeList; - } - - /* - * public Collection getSpeciesNodes(){ return speciesMap.values(); } - */ - - /** - * Returns the species with a distinct id - * - * @param id - * the id of the asked node - * @return the node with a certain id or null if no node has this id - */ - public static Node getSpeciesNode(String id) { - return speciesMap.get(id); - } - - /** - * Indicates if the compartment id of a species is set - * - * @param node - * the node where the information is read from - * @return true if the compartment id is set else false - */ - public Boolean isSetCompartment(Node speciesNode) { - if (!NodeTools.getClusterID(speciesNode, SBML_Constants.EMPTY).equals( - SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the id of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the id is set else false - */ - public Boolean isSetID(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the name of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the name is set else false - */ - public Boolean isSetName(Node speciesNode) { - if (!AttributeHelper.getLabel(speciesNode, SBML_Constants.EMPTY) - .equals(SBML_Constants.EMPTY)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the initial amount of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the initial amount is set else false - */ - public Boolean isSetInitialAmount(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if the initial concentration of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if the initial concentration is set else false - */ - public Boolean isSetInitialConcentration(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if substance units of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if substance units is set else false - */ - public Boolean isSetSubstanceUnits(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if hasOnlySubstanceUnits of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if hasOnlySubstanceUnits is set else false - */ - public Boolean isSetHasOnlySubstanceUnits(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if boundary condition of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if boundary condition is set else false - */ - public Boolean isSetBoundaryCondition(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if constant of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if constant is set else false - */ - public Boolean isSetConstant(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT)) { - return true; - } else { - return false; - } - } - - /** - * Indicates if conversion factor of a species is set - * - * @param speciesNode - * the node where the information is read from - * @return true if conversion factor is set else false - */ - public Boolean isSetConversionFactor(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR)) { - return true; - } else { - return false; - } - } - - /** - * Returns the compartment id of a species - * - * @param Node - * the node where the information is read from - * @return the compartment id if it is set else the empty string - */ - public String getCompartment(Node speciesNode) { - return NodeTools.getClusterID(speciesNode, SBML_Constants.EMPTY); - } - - /** - * Returns the id of the species - * - * @param speciesNode - * the node where the information is read from - * @return the species id if it is set else the empty string - */ - public String getID(Node speciesNode) { - if (isSetID(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the name of the species - * - * @param speciesNode - * the node where the information is read from - * @return the species name if it is set else the empty string - */ - public String getName(Node speciesNode) { - return AttributeHelper.getLabel(speciesNode, SBML_Constants.EMPTY); - } - - /** - * Returns the initial amount of a species - * - * @param speciesNode - * the node where the information is read from - * @return initial amount if it is set else null - */ - public Double getInitialAmount(Node speciesNode) { - if (isSetInitialAmount(speciesNode)) { - return (Double) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.INITIAL_AMOUNT); - } else { - return null; - } - } - - /** - * Returns the initial concentration of a species - * - * @param speciesNode - * the node where the information is read from - * @return initial concentration if it is set else null - */ - public Double getInitialConcentration(Node speciesNode) { - if (isSetInitialConcentration(speciesNode)) { - return (Double) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.INITIAL_CONCENTRATION); - } else { - return null; - } - } - - /** - * Returns the substance units of a species - * - * @param speciesNode - * the node where the information is read from - * @return substance Units if it is set else the empty string - */ - public String getSubstanceUnits(Node speciesNode) { - if (isSetSubstanceUnits(speciesNode)) { - return (String) attWriter - .getAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Returns the boolean value hasOnlySubstanceUnits of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute hasOnlySubstanceUnits is set - * else null - */ - public Boolean getHasOnlySubstanceUnits(Node speciesNode) { - if (isSetHasOnlySubstanceUnits(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS); - } else { - return null; - } - } - - /** - * Returns the boolean value boundaryCondition of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute boundaryCondition is set else - * null - */ - public Boolean getBoundaryCondition(Node speciesNode) { - if (isSetBoundaryCondition(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.BOUNDARY_CONDITION); - } else { - return null; - } - } - - /** - * Returns the boolean value constant of the species - * - * @param speciesNode - * the node where the information is read from - * @return a boolean value if the attribute constant is set else null - */ - public Boolean getConstant(Node speciesNode) { - if (isSetConstant(speciesNode)) { - return (Boolean) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_CONSTANT); - } else { - return null; - } - } - - /** - * Returns the conversion factor units of a species - * - * @param speciesNode - * the node where the information is read from - * @return conversion factor if it is set else null - */ - public String getConversionFactor(Node speciesNode) { - if (isSetConversionFactor(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR); - } else { - return null; - } - } - - /** - * Sets the id of a species node - * - * @param speciesNode - * where the information should be read in - * @param id - * the id to set - */ - public void setID(Node speciesNode, String id) { - if (!id.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ID, id); - speciesMap.put(id, speciesNode); - } - } - - /** - * Sets the label of a node. The id string will be the label if name is not - * set - * - * @param speciesNode - * where the information should be read in - * @param name - * the name to set - * @param id - * will be set if name is empty - * @param pgg - * helps to set the position of the node - */ - public void setLabel(Node speciesNode, String name, String id, - PositionGridGenerator pgg) { - String label = null; - if (!name.equals(SBML_Constants.EMPTY)) { - label = name; - } else { - label = id; - } - if (!label.equals(SBML_Constants.EMPTY)) { - attReader.setAttributes(speciesNode, Color.white, label, - pgg.getNextPosition(), label.length() + 7); - } - } - - /** - * Sets the compartment of a node - * - * @param speciesNode - * the compartment belongs to this node - * @param compartment - * the id of the compartment that will be set - */ - public void setCompartment(Node speciesNode, String compartment) { - if (!compartment.equals(SBML_Constants.EMPTY)) { - NodeTools.setClusterID(speciesNode, compartment); - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.COMPARTMENT, compartment); - } - } - - public void setCompartmentName(Node speciesNode) { - String name = getCompartmentName(speciesNode); - if (!SBML_Constants.EMPTY.equals(name)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_COMPARTMENT_NAME, name); - } - } - - /** - * Sets the initial amount of a node - * - * @param speciesNode - * the initial amount belongs to this node - * @param initialAmount - * the value that will be set - */ - public void setInitialAmount(Node speciesNode, Double initialAmount) { - if (!initialAmount.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_AMOUNT, initialAmount); - } - } - - /** - * Sets the initial concentration of a node - * - * @param speciesNode - * the initial concentration belongs to this node - * @param initialConcentration - * the value that will be set - */ - public void setInitialConcentration(Node speciesNode, - Double initialConcentration) { - if (!initialConcentration.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.INITIAL_CONCENTRATION, initialConcentration); - } - } - - /** - * Sets the substance units of a species node - * - * @param speciesNode - * the substance units belong to this node - * @param substanceUnits - * the substance units to set - */ - public void setSubstanceUnits(Node speciesNode, String substanceUnits) { - if (!substanceUnits.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SUBSTANCE_UNITS, substanceUnits); - } - } - - /** - * Sets the attribute hasOnlySubstanceUnits of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param hasOnlySubstanceUnits - * the value that will be set - */ - public void setHasOnlySubstanceUnits(Node speciesNode, - Boolean hasOnlySubstanceUnits) { - if (!hasOnlySubstanceUnits.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.HAS_ONLY_SUBSTANCE_UNITS, - hasOnlySubstanceUnits); - } - } - - /** - * Sets the attribute boundary condition of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param boundaryCondition - * the value that will be set - */ - public void setBoundaryConsition(Node speciesNode, Boolean boundaryCondition) { - if (!boundaryCondition.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.BOUNDARY_CONDITION, boundaryCondition); - } - } - - /** - * Sets the attribute constant of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param constant - * the value that will be set - */ - public void setConstant(Node speciesNode, Boolean constant) { - if (!constant.equals(null)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONSTANT, constant); - } - } - - /** - * Sets the attribute conversion factor of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param conversionFactor - * the value that will be set - */ - public void setConversionFactor(Node speciesNode, String conversionFactor) { - if (!conversionFactor.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_CONVERSION_FACTOR, conversionFactor); - } - } - - /** - * Sets the attribute meta id of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param metaID - * the value that will be set - */ - public void setMetaID(Node speciesNode, String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_META_ID, metaID); - } - } - - public Boolean isSetMetaID(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_META_ID)) { - return true; - } else { - return false; - } - } - - public void deleteMetaID(Node speciesNode) { - if (isSetMetaID(speciesNode)) { - AttributeHelper.deleteAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_META_ID); - } - } - - public String getMetaID(Node speciesNode) { - if (isSetMetaID(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_META_ID); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setAnnotation(Node speciesNode, Annotation annotation) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ANNOTATION, annotation); - } - - public Boolean isSetAnnotation(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void deleteAnnotation(Node speciesNode) { - if (isSetAnnotation(speciesNode)) { - AttributeHelper.deleteAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_ANNOTATION); - } - } - - public Annotation getAnnotation(Node speciesNode) { - if (isSetAnnotation(speciesNode)) { - return (Annotation) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_ANNOTATION); - } else { - return null; - } - } - - public void setNonRDFAnnotation(Node speciesNode, String nonRDFAnnotation) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_NON_RDF_ANNOTATION, nonRDFAnnotation); - } - - public Boolean isSetNonRDFAnnotation(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_NON_RDF_ANNOTATION)) { - return true; - } else { - return false; - } - } - - public void deleteNonRDFAnnotation(Node speciesNode) { - if (isSetNonRDFAnnotation(speciesNode)) { - AttributeHelper.deleteAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_NON_RDF_ANNOTATION); - } - } - - public Annotation getNonRDFAnnotation(Node speciesNode) { - if (isSetNonRDFAnnotation(speciesNode)) { - return (Annotation) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_NON_RDF_ANNOTATION); - } else { - return null; - } - } - - /** - * Sets the attribute sboTerm of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param sboTerm - * the value that will be set - */ - public void setSBOTerm(Node speciesNode, String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SBOTERM, sboTerm); - } - } - - public Boolean isSetSBOTerm(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_SBOTERM)) { - return true; - } else { - return false; - } - } - - public void deleteSBOTerm(Node speciesNode) { - if (isSetSBOTerm(speciesNode)) { - AttributeHelper.deleteAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_SBOTERM); - } - } - - public String getSBOTerm(Node speciesNode) { - if (isSetSBOTerm(speciesNode)) { - return (String) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_SBOTERM); - } else { - return SBML_Constants.EMPTY; - } - } - - /** - * Sets the attribute notes of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param notes - * the value that will be set - * @param notesObj - * the Object that will be set - */ - public void setNotes(Node speciesNode, String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes(notesObj, notes, speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_NOTES); - } - } - - public Boolean isSetNotes(Node speciesNode) { - if (AttributeHelper.hasAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.SPECIES_NOTES)) { - return true; - } else { - return false; - } - } - - public void deleteNotes(Node speciesNode) { - if (isSetNotes(speciesNode)) { - AttributeHelper.deleteAttribute(speciesNode, SBML_Constants.SBML, SBML_Constants.SPECIES_NOTES); - } - } - - public XMLNode getNotes(Node speciesNode) { - if (isSetNotes(speciesNode)) { - return (XMLNode) attWriter.getAttribute(speciesNode, - SBML_Constants.SBML, SBML_Constants.SPECIES_NOTES); - } else { - return null; - } - } - - /** - * Sets the deprecated attribute charge of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param charge - * the value that will be set - */ - public void setCharge(Node speciesNode, Integer charge) { - if (!charge.equals(0)) { - AttributeHelper.setAttribute(speciesNode, SBML_Constants.SBML, - SBML_Constants.CHARGE, charge); - } - } - - /** - * Sets the hidden label of a species node - * - * @param speciesNode - * where the attribute is going to be added - * @param id - * the value that will be set - */ - public void setHiddenLabel(Node speciesNode, String id) { - AttributeHelper.setLabel(AttributeHelper.getLabels(speciesNode).size(), - speciesNode, id, null, AlignmentSetting.HIDDEN.toGMLstring()); - } - -} \ No newline at end of file diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnit.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnit.java deleted file mode 100644 index 6bb52eb31..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnit.java +++ /dev/null @@ -1,189 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLUnit { - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline; - - /** - * The user will see the headline this way - */ - String presentedHeadline; - - /** - * The number of the current sub unit - */ - int subUnitCount; - - /** - * The hidden unit attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLUnit(Graph g, String internHeadline, String presentedHeadline, - int subUnitCount) { - this.g = g; - this.subUnitCount = subUnitCount; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - initSubUnitDefinitionNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLUnit(Graph g, String internHeadline, int subUnitCount) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - this.subUnitCount = subUnitCount; - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT) - .append(subUnitCount) - .append(SBML_Constants.META_ID).toString(), metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper - .setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SUB_UNIT) - .append(subUnitCount) - .append(SBML_Constants.SBOTERM).toString(), sboTerm); - } - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT) - .append(subUnitCount).append(SBML_Constants.NOTES) - .toString()); - } - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.NOTES).toString()); - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.NON_RDF_ANNOTATION).toString(), - nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setComposedSubUnit(String composedSubUnit) { - if (!composedSubUnit.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute( - g, - internHeadline, - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT) - .append(subUnitCount).append("_").toString(), - composedSubUnit); - } - } - - public void setComposedUnit(String composedUnit) { - if (!composedUnit.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT).toString(), - composedUnit); - } - } - - private void initSubUnitDefinitionNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append("_").toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.UNIT) - .toString(), new StringBuffer(presentedHeadline) - .append(": Unit").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.META_ID).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" Meta ID").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.SBOTERM).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" SBOTerm").toString()); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline) - .append(SBML_Constants.SUB_UNIT).append(subUnitCount) - .append(SBML_Constants.NOTES).toString(), - new StringBuffer(presentedHeadline).append(": Sub Unit ") - .append(subUnitCount).append(" Notes").toString()); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinition.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinition.java deleted file mode 100644 index 721e67503..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinition.java +++ /dev/null @@ -1,214 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -import org.AttributeHelper; -import org.graffiti.graph.Graph; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.xml.XMLNode; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_SBase_Reader; - -public class SBMLUnitDefinition { - - /** - * Contains a list of subUnits - */ - List unitList; - - /** - * Intern graph object - */ - Graph g; - - /** - * Provides necessary methods - */ - SBML_SBase_Writer attWriter; - - /** - * Provides necessary methods - */ - SBML_SBase_Reader attReader; - - /** - * intern representation of the headline - */ - String internHeadline = SBML_Constants.EMPTY; - - /** - * The user will see the headline this way - */ - String presentedHeadline = SBML_Constants.EMPTY; - - /** - * The hidden unit definition attributes are stored here - */ - HashSet discardedRowIDs; - - public SBMLUnitDefinition(Graph g, String internHeadline, - String presentedHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.presentedHeadline = presentedHeadline; - this.internHeadline = internHeadline; - unitList = new ArrayList(); - initUnitDefinitionNideIDs(); - - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - discardedRowIDs = new HashSet(colDiscardedRowIDs); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - } - - public SBMLUnitDefinition(Graph g, String internHeadline) { - this.g = g; - attWriter = new SBML_SBase_Writer(); - attReader = new SBML_SBase_Reader(); - this.internHeadline = internHeadline; - unitList = new ArrayList(); - } - - public SBMLUnit addUnit(int unitCount) { - if (!presentedHeadline.equals(SBML_Constants.EMPTY)) { - return new SBMLUnit(g, internHeadline, presentedHeadline, unitCount); - } else { - return new SBMLUnit(g, internHeadline, unitCount); - } - } - - public Boolean isSetID() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString())) { - return true; - } else { - return false; - } - } - - public Boolean isSetName() { - if (AttributeHelper.hasAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString())) { - return true; - } else { - return false; - } - } - - public String getName() { - if (isSetName()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_NAME).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public String getID() { - if (isSetID()) { - return (String) attWriter.getAttribute( - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_ID).toString()); - } else { - return SBML_Constants.EMPTY; - } - } - - public void setID(String ID) { - if (!ID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_ID) - .toString(), ID); - } - } - - public void setName(String name) { - if (!name.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.UNIT_DEFINITION_NAME) - .toString(), name); - } - } - - public void setMetaID(String metaID) { - if (!metaID.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.META_ID).toString(), - metaID); - } - } - - public void setSBOTerm(String sboTerm) { - if (!sboTerm.equals(SBML_Constants.EMPTY)) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.SBOTERM).toString(), - sboTerm); - } - } - - public void setAnnotation(Annotation annotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.ANNOTATION).toString(), - annotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.ANNOTATION).toString()); - } - - public void setNonRDFAnnotation(String nonRDFAnnotation) { - AttributeHelper.setAttribute(g, internHeadline, new StringBuffer( - internHeadline).append(SBML_Constants.NON_RDF_ANNOTATION) - .toString(), nonRDFAnnotation); - - discardedRowIDs.add(new StringBuffer(internHeadline).append( - SBML_Constants.NON_RDF_ANNOTATION).toString()); - } - - public void setNotes(String notes, XMLNode notesObj) { - if (!notes.equals(SBML_Constants.EMPTY)) { - attReader.addNotes( - notesObj, - notes, - g, - internHeadline, - new StringBuffer(internHeadline).append( - SBML_Constants.NOTES).toString()); - } - - discardedRowIDs.add(internHeadline + "_notes"); - } - - private void initUnitDefinitionNideIDs() { - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_ID).toString(), - presentedHeadline + ": ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append( - SBML_Constants.UNIT_DEFINITION_NAME).toString(), - presentedHeadline + ": Name"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.META_ID) - .toString(), presentedHeadline + ": Meta ID"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.NOTES) - .toString(), presentedHeadline + ": Notes"); - AttributeHelper.setNiceId( - new StringBuffer(internHeadline).append(SBML_Constants.SBOTERM) - .toString(), presentedHeadline + ": SBOTerm"); - } - -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinitionHelper.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinitionHelper.java deleted file mode 100644 index 3fe05b696..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBMLUnitDefinitionHelper.java +++ /dev/null @@ -1,47 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.graffiti.graph.Graph; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_SBase_Writer; - -public class SBMLUnitDefinitionHelper { - - /** - * Stores the SBMLUnitDefinition objects - */ - List unitDefinitionList; - - public SBMLUnitDefinitionHelper(){ - unitDefinitionList = new ArrayList(); - } - - public SBMLUnitDefinition addUnitDefinition(Graph g, String internHeadline){ - SBMLUnitDefinition unitDefinition = new SBMLUnitDefinition(g, internHeadline); - unitDefinitionList.add(unitDefinition); - return unitDefinition; - } - - public SBMLUnitDefinition addUnitDefinition(Graph g, String internHeadline, String presentedHeadline){ - SBMLUnitDefinition unitDefinition = new SBMLUnitDefinition(g, internHeadline, presentedHeadline); - unitDefinitionList.add(unitDefinition); - return unitDefinition; - } - - public List getUnitDefinitionHeadlines(Graph g){ - SBML_SBase_Writer writer = new SBML_SBase_Writer(); - return writer.headlineHelper(g, SBML_Constants.SBML_UNIT_DEFINITION); - } - - public List addUnitDefinitions(Graph g, List internHeadlines){ - List returnList = new ArrayList(); - Iterator internHeadlineIt = internHeadlines.iterator(); - while(internHeadlineIt.hasNext()){ - returnList.add(addUnitDefinition(g, internHeadlineIt.next())); - } - return returnList; - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_Constants.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_Constants.java deleted file mode 100644 index 2a5367132..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_Constants.java +++ /dev/null @@ -1,327 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import java.util.Collection; -import java.util.HashSet; - -import org.AttributeHelper; -import org.graffiti.plugins.inspectors.defaults.DefaultEditPanel; - -public class SBML_Constants { - - private static boolean _isInitialized = false; - - /** - * switch, to activate readout of layout information - */ - public static final boolean isLayoutActive = false; - - // Helpful constants - public static final String EMPTY = ""; - public static final String UNDERLINE = "_"; - private static final String ATT = AttributeHelper.attributeSeparator; - - public static final String SBML_LAYOUT_ID = "sbml_layout_id"; - - public static final String LOCALPARAMETER_HEADLINE = "Local Parameter "; - public static final String COMARTMENT_HEADLINE = "SBML Compartment "; - public static final String SBML_HEADLINE = "SBML"; - - public static final String ROLE_REACTANT = "reactant"; - public static final String ROLE_PRODUCT = "product"; - public static final String ROLE_MODIFIER = "modifier"; - public static final String ROLE_SPECIES = "species"; - public static final Object ROLE_REACTION = "reaction"; - public static final String SBML_ROLE = "sbmlRole"; - - public static final String SBOTERM = "_sboterm"; - public static final String META_ID = "_meta_id"; - public static final String NOTES = "_notes"; - public static final String ANNOTATION = "_annotation"; - public static final String NON_RDF_ANNOTATION = "_non_rdf_annotation"; - - // SBML attribute constants - public static final String VERSION = "version"; - public static final String LEVEL = "level"; - public static final String NAMESPACE = "namespace"; - public static final String SBML = "sbml"; - public static final String SBML_NOTES = "sbml_notes"; - public static final String SBML_META_ID = "sbml_meta_id"; - public static final String SBML_SBOTERM = "sbml_sboterm"; - public static final String SBML_ANNOTATION = "sbml_annotation"; - public static final String SBML_NON_RDF_ANNOTATION = "sbml_non_rdf_annotation"; - - // Model attribute constants - public static final String MODEL_ID = "model_sbml_id"; - public static final String MODEL_NAME = "model_name"; - public static final String SUBSTANCE_UNITS = "substance_units"; - public static final String TIME_UNITS = "time_units"; - public static final String VOLUME_UNITS = "volume_units"; - public static final String AREA_UNITS = "area_units"; - public static final String LENGTH_UNITS = "length_units"; - public static final String EXTENT_UNITS = "extent_units"; - public static final String CONVERSION_FACTOR = "conversion_factor"; - public static final String MODEL_NOTES = "model_notes"; - public static final String MODEL_META_ID = "model_meta_id"; - public static final String MODEL_SBOTERM = "model_sboterm"; - public static final String MODEL_ANNOTATION = "model_annotation"; - public static final String MODEL_NON_RDF_ANNOTATION = "model_non_rdf_annotation"; - - // FunctionDefinition attribute constants - public static final String SBML_FUNCTION_DEFINITION = "sbml_function_definition_"; - public static final String FUNCTION_DEFINITION_FUNCTION = "_function"; - public static final String FUNCTION_DEFINITION_ID = "_id"; - public static final String FUNCTION_DEFINITION_NAME = "_name"; - - // UnitDefinition attribute constants - public static final String SBML_UNIT_DEFINITION = "sbml_unit_definition_"; - public static final String UNIT_DEFINITION_ID = "_id"; - public static final String UNIT_DEFINITION_NAME = "_name"; - public static final String SUB_UNIT = "_sub_unit_"; - public static final String UNIT = "unit"; - - // Compartment attribute constants - public static final String SBML_COMPARTMENT = "sbml_compartment_"; - public static final String COMPARTMENT_ID = "_id"; - public static final String COMPARTMENT_NAME = "_name"; - public static final String SPATIAL_DIMENSIONS = "_spatial_Dimensions"; - public static final String SIZE = "_size"; - public static final String UNITS = "_units"; - public static final String CONSTANT = "_constant"; - public static final String OUTSIDE = "_outside"; // Level 2 - - // Species attribute constants - public static final String SPECIES_ID = "species_id"; - public static final String SPECIES_NAME = "species_name"; - public static final String COMPARTMENT = "compartment"; - public static final String INITIAL_AMOUNT = "initial_amount"; - public static final String INITIAL_CONCENTRATION = "initial_concentration"; - public static final String SPECIES_SUBSTANCE_UNITS = "species_substance_units"; - public static final String HAS_ONLY_SUBSTANCE_UNITS = "has_only_substance_units"; - public static final String BOUNDARY_CONDITION = "boundary_condition"; - public static final String SPECIES_CONSTANT = "_species_constant"; - public static final String SPECIES_CONVERSION_FACTOR = "species_conversion_factor"; - public static final String SPECIES_META_ID = "species_meta_id"; - public static final String SPECIES_SBOTERM = "species_sboterm"; - public static final String SPECIES_NOTES = "species_notes"; - public static final String CHARGE = "charge"; // Level 2 - public static final String SPECIES_COMPARTMENT_NAME = "compartment_name"; - public static final String SPECIES_ANNOTATION = "species_annotation"; - public static final String SPECIES_NON_RDF_ANNOTATION = "species_non_rdf_annotation"; - - // Parameter attribute constants - public static final String SBML_PARAMETER = "sbml_parameter_"; - public static final String PARAMETER_ID = "_id"; - public static final String PARAMETER_NAME = "_name"; - public static final String VALUE = "_value"; - public static final String PARAMETER_UNITS = "_units"; - public static final String PARAMETER_CONSTANT = "_constant"; - - // InitialAssignment attribute constants - public static final String SBML_INITIAL_ASSIGNMENT = "sbml_initial_assignment_"; - public static final String SYMBOL = "_symbol"; - public static final String INITIAL_ASSIGNMENT_FUNCTION = "_function"; - - // Rule attribute constants - public static final String SBML_RATE_RULE = "sbml_rate_rule_"; - public static final String SBML_ASSIGNMENT_RULE = "sbml_assignment_rule_"; - public static final String SBML_ALGEBRAIC_RULE = "sbml_algebraic_rule_"; - public static final String ASSIGNMENT_VARIABLE = "_assignmnet_variable"; - public static final String RATE_VARIABLE = "_rate_variable"; - public static final String RATE_FUNCTION = "_function"; - public static final String ASSIGNMENT_FUNCTION = "_function"; - public static final String ALGEBRAIC_FUNCTION = "_function"; - - // Constraint attribute constants - public static final String SBML_CONSTRAINT = "sbml_constraint_"; - public static final String CONSTRAINT = "_constraint"; - public static final String MESSAGE = "_message"; - - // Reaction attribute constants - public static final String REACTION_ID = "reaction_id"; - public static final String REACTION_NAME = "reaction_name"; - public static final String REACTION_COMPARTMENT = "reaction_compartment"; - public static final String REACTION_CONSTANT = "reaction_constant"; - public static final String LOCAL_PARAMETER = "local_parameter_"; - public static final String FAST = "fast"; - public static final String REVERSIBLE = "reversible"; - public static final String STOICHIOMETRY = "stoichiometry"; - public static final String SPECIES = "species"; - public static final String SPECIES_REFERENCE_ID = "species_reference_id"; - public static final String SPECIES_REFERENCE_NAME = "species_reference_name"; - public static final String SBML_KINETIC_LAW = "sbml_kinetic_law"; - public static final String REACTION_META_ID = "reaction_meta_id"; - public static final String REACTION_SBOTERM = "reaction_sboterm"; - public static final String REACTION_NOTES = "reaction_notes"; - public static final String REACTANT_META_ID = "reactant_meta_id"; - public static final String REACTANT_SBOTERM = "reactant_sboterm"; - public static final String REACTANT_NOTES = "reactant_notes"; - public static final String PRODUCT_META_ID = "product_meta_id"; - public static final String PRODUCT_SBOTERM = "product_sboterm"; - public static final String PRODUCT_NOTES = "product_notes"; - public static final String MODIFIER_META_ID = "modifier_meta_id"; - public static final String MODIFIER_SBOTERM = "modifier_sboterm"; - public static final String MODIFIER_NOTES = "modifier_notes"; - public static final String KINETIC_LAW_NOTES = "kinetic_law_notes"; - public static final String KINETIC_LAW_SBOTERM = "kinetic_law_sboterm"; - public static final String KINETIC_LAW_META_ID = "kinetic_law_meta_id"; - public static final String KINETIC_LAW_FUNCTION = "kinetic_law_function"; - public static final String LOCAL_PARAMETER_ID = "_id"; - public static final String LOCAL_PARAMETER_NAME = "_name"; - public static final String LOCAL_PARAMETER_VALUE = "_value"; - public static final String LOCAL_PARAMETER_UNITS = "_units"; - public static final String REACTION_ANNOTATION = "reaction_annotation"; - public static final String REACTION_NON_RDF_ANNOTATION = "reaction_non_rdf_annotation"; - public static final String REACTANT_ANNOTATION = "reactant_annotation"; - public static final String REACTANT_NON_RDF_ANNOTATION = "reactant_non_rdf_annotation"; - public static final String PRODUCT_ANNOTATION = "product_annotation"; - public static final String PRODUCT_NON_RDF_ANNOTATION = "product_non_rdf_annotation"; - public static final String MODIFIER_ANNOTATION = "modifier_annotation"; - public static final String MODIFIER_NON_RDF_ANNOTATION = "modifier_non_rdf_annotation"; - public static final String KINETIC_LAW_ANNOTATION = "kinetic_law_annotation"; - public static final String KINETIC_LAW_NON_RDF_ANNOTATION = "kinetic_law_non_rdf_annotation"; - - // Event attribute constants - public static final String SBML_EVENT = "sbml_event_"; - public static final String EVENT_ID = "_event_id"; - public static final String EVENT_NAME = "_event_name"; - public static final String USE_VALUES_FROM_TRIGGER_TIME = "_use_values_from_trigger_time"; - public static final String PRIORITY_META_ID = "_priority_meta_id"; - public static final String PRIORITY_NOTES = "_priority_notes"; - public static final String PRIORITY_SBOTERM = "_priority_sboterm"; - public static final String PRIORITY_FUNCTION = "_priority_function"; - public static final String PRIORITY_ANNOTATION = "_priority_annotation"; - public static final String PRIORITY_NON_RDF_ANNOTATION = "_priority_non_rdf_annotation"; - public static final String DELAY_META_ID = "_delay_meta_id"; - public static final String DELAY_NOTES = "_delay_notes"; - public static final String DELAY_SBOTERM = "_delay_sboterm"; - public static final String DELAY_ANNOTATION = "_delay_annotation"; - public static final String DELAY_NON_RDF_ANNOTATION = "_delay_non_rdf_annotation"; - public static final String EVENT_ASSIGNMENT = "_event_assignment_"; - public static final String DELAY_FUNCTION = "_delay_function"; - public static final String TRIGGER_FUNCTION = "_trigger_function"; - public static final String PERSISTENT = "_persistent"; - public static final String INITIAL_VALUE = "_initial_value"; - public static final String VARIABLE = "_variable"; - public static final String FUNCTION = "_function"; - - // those stings only used with attached numbers. - public static final String SBML_SPECIES = "sbml_species"; - public static final String SBML_Cluster = "cluster"; - public static final String SBML_Label = "Label"; - - public static void init() { - if (!_isInitialized) { - AttributeHelper.setNiceId(SBML_LAYOUT_ID, "SBML: Layout ID"); - // initialize SBML niceIds - AttributeHelper.setNiceId(LEVEL, "SBML: Level"); - AttributeHelper.setNiceId(VERSION, "SBML: Version"); - AttributeHelper.setNiceId(NAMESPACE, "SBML: Namespace"); - AttributeHelper.setNiceId(SBML_META_ID, "SBML: SBML Meta ID"); - AttributeHelper.setNiceId(SBML_NOTES, "SBML: SBML Notes"); - AttributeHelper.setNiceId(SBML_SBOTERM, "SBML: SBML SBOTerm"); - - // initialize Model niceId - - AttributeHelper.setNiceId(MODEL_ID, "SBML: Model ID"); - AttributeHelper.setNiceId(MODEL_NAME, "SBML: Model Name"); - AttributeHelper.setNiceId(SUBSTANCE_UNITS, "SBML: Substance Units"); - AttributeHelper.setNiceId(TIME_UNITS, "SBML: Time Units"); - AttributeHelper.setNiceId(VOLUME_UNITS, "SBML: Volume Units"); - AttributeHelper.setNiceId(AREA_UNITS, "SBML: Area Units"); - AttributeHelper.setNiceId(LENGTH_UNITS, "SBML: Lenght Units"); - AttributeHelper.setNiceId(EXTENT_UNITS, "SBML: Extent Units"); - AttributeHelper.setNiceId(CONVERSION_FACTOR, "SBML: Conversion Faktor"); - AttributeHelper.setNiceId(MODEL_META_ID, "SBML: Model Meta ID"); - AttributeHelper.setNiceId(MODEL_NOTES, "SBML: Model Notes"); - AttributeHelper.setNiceId(MODEL_SBOTERM, "SBML: Model SBOTerm"); - - /* - * List of Attributes to hide from the information panel in Vanted - */ - Collection colDiscardedRowIDs = DefaultEditPanel - .getDiscardedRowIDs(); - HashSet discardedRowIDs = new HashSet( - colDiscardedRowIDs); - discardedRowIDs.add(MODEL_META_ID); -// discardedRowIDs.add(SBML_NOTES); -// discardedRowIDs.add(MODEL_NOTES); -// discardedRowIDs.add(REACTION_NOTES); -// discardedRowIDs.add(SPECIES_NOTES); -// discardedRowIDs.add(REACTANT_NOTES); -// discardedRowIDs.add(PRODUCT_NOTES); -// discardedRowIDs.add(MODIFIER_NOTES); -// discardedRowIDs.add(KINETIC_LAW_NOTES); -// discardedRowIDs.add(PRIORITY_NOTES); -// discardedRowIDs.add(DELAY_NOTES); - discardedRowIDs.add(SBML_ANNOTATION); - discardedRowIDs.add(SBML_NON_RDF_ANNOTATION); - discardedRowIDs.add(MODEL_ANNOTATION); - discardedRowIDs.add(MODEL_NON_RDF_ANNOTATION); - discardedRowIDs.add(SPECIES_ANNOTATION); - discardedRowIDs.add(SPECIES_NON_RDF_ANNOTATION); - discardedRowIDs.add(REACTION_ANNOTATION); - discardedRowIDs.add(REACTION_NON_RDF_ANNOTATION); - discardedRowIDs.add(REACTANT_ANNOTATION); - discardedRowIDs.add(REACTANT_NON_RDF_ANNOTATION); - discardedRowIDs.add(PRODUCT_ANNOTATION); - discardedRowIDs.add(PRODUCT_NON_RDF_ANNOTATION); - discardedRowIDs.add(MODIFIER_ANNOTATION); - discardedRowIDs.add(MODIFIER_NON_RDF_ANNOTATION); - discardedRowIDs.add(KINETIC_LAW_ANNOTATION); - discardedRowIDs.add(KINETIC_LAW_NON_RDF_ANNOTATION); - discardedRowIDs.add(SBML_LAYOUT_ID); - discardedRowIDs.add(SBML_ROLE); - DefaultEditPanel.setDiscardedRowIDs(discardedRowIDs); - - /* - * AttributeHelper.setNiceId(SBML_Constants.sbml+ATT+SBML_Constants.meta_id - * , "SBML: Meta ID"); - * AttributeHelper.setNiceId(SBML_Constants.sbml+ATT+ - * SBML_Constants.SBOTERM, "SBML: SBOTerm"); - * AttributeHelper.setNiceId(SBML_Constants - * .sbml+ATT+SBML_Constants.NAMESPACE, "SBML: Namespaces"); - * AttributeHelper - * .setNiceId(SBML_Constants.sbml+ATT+SBML_Constants.TOOLTIP, - * "SBML: ToolTip"); - * AttributeHelper.setNiceId(SBML_Constants.sbml+ATT+SBML_Constants.LEVEL - * ,"SBML: Level"); - * AttributeHelper.setNiceId(SBML_Constants.sbml+ATT+SBML_Constants - * .VERSION,"SBML: Version"); - * AttributeHelper.setNiceId(SBML_Constants.sbml_model+ATT+SBML_Constants - * .ID,"SBML Model"+ATT+"ID"); - * AttributeHelper.setNiceId(SBML_Constants.sbml_model - * +ATT+SBML_Constants.NAME,"SBML Model"+ATT+"Name"); - * AttributeHelper.setNiceId - * (SBML_Constants.sbml_model+ATT+SBML_Constants - * .SUBSTANCE_UNITS,"SBML Model"+ATT+"Substance Units"); - * AttributeHelper. - * setNiceId(SBML_Constants.sbml_model+ATT+SBML_Constants - * .TIME_UNITS,"SBML Model"+ATT+"Time Units"); - * AttributeHelper.setNiceId( - * SBML_Constants.sbml_model+ATT+SBML_Constants - * .VOLUME_UNITS,"SBML Model"+ATT+"Volume Units"); - * AttributeHelper.setNiceId - * (SBML_Constants.sbml_model+ATT+SBML_Constants - * .AREA_UNITS,"SBML Model"+ATT+"Area Units"); - * AttributeHelper.setNiceId( - * SBML_Constants.sbml_model+ATT+SBML_Constants - * .EXTENT_UNITS,"SBML Model"+ATT+"Extent Units"); - * AttributeHelper.setNiceId - * (SBML_Constants.sbml_model+ATT+SBML_Constants - * .LENGTH_UNITS,"SBML Model"+ATT+"Length Units"); - * AttributeHelper.setNiceId - * (SBML_Constants.sbml_model+ATT+SBML_Constants - * .CONVERSION_FACTOR,"SBML Model"+ATT+"Conversion Factor"); - * AttributeHelper - * .setNiceId(SBML_Constants.sbml_model+ATT+SBML_Constants - * .meta_id,"Meta ID"); - * AttributeHelper.setNiceId(SBML_Constants.sbml_model - * +ATT+SBML_Constants.SBOTERM,"SBML Model"+ATT+"SBOTerm"); - * AttributeHelper - * .setNiceId(SBML_Constants.sbml_model+ATT+SBML_Constants - * .TOOLTIP,"SBML Model"+ATT+"Tooltip"); - */ - _isInitialized = true; - } - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_XML_ReaderWriterPlugin.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_XML_ReaderWriterPlugin.java deleted file mode 100644 index 3773541c7..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/SBML_XML_ReaderWriterPlugin.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003-2007 Network Analysis Group, IPK Gatersleben - *******************************************************************************/ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; - -import org.apache.log4j.Logger; -import org.graffiti.plugin.io.InputSerializer; -import org.graffiti.plugin.io.OutputSerializer; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.addons.AddonAdapter; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.exporters.sbml.SBML_XML_Writer; -import de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.importers.sbml.SBML_XML_Reader; - -/** - * DOCUMENT ME! - * - * @author Christian Klukas - */ -public class SBML_XML_ReaderWriterPlugin extends AddonAdapter { - private static Logger logger = Logger.getRootLogger(); - - /* - * this static variable is to be set to true,when this plugin is doing - * a JUnit test. - * So in the plugin several code will not be executed which includes GUI dialogs etc. - */ - public static boolean isTestintMode = false; - - @Override - protected void initializeAddon() { - try { - // SimpleLayout layout = new SimpleLayout(); - // ConsoleAppender consoleAppender = new ConsoleAppender( layout ); - // logger.addAppender( consoleAppender ); - // FileAppender fileAppender = new FileAppender( layout, - // "log/jsbml.log", false ); - // logger.addAppender( fileAppender ); - SBML_XML_Reader reader = new SBML_XML_Reader(); - this.inputSerializers = new InputSerializer[] { reader }; - this.outputSerializers = new OutputSerializer[] { new SBML_XML_Writer() }; - - System.out.println("SBML_XML_Reader Writer Plugin started"); - } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); - } - } - - public SBML_XML_ReaderWriterPlugin() { - super(); - initializeAddon(); - } -} diff --git a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/StartSBMLImportExportPlugin.java b/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/StartSBMLImportExportPlugin.java deleted file mode 100644 index f40237a2c..000000000 --- a/IPK-Plugins/src/java/de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/sbml/StartSBMLImportExportPlugin.java +++ /dev/null @@ -1,40 +0,0 @@ -package de.ipk_gatersleben.ag_nw.graffiti.plugins.ios.sbml; -import java.io.File; - -import de.ipk_gatersleben.ag_nw.graffiti.plugins.gui.webstart.MainM; - -public class StartSBMLImportExportPlugin { - - /** - * Startmethod for Vanted. The Add-on will be loaded, if you specify the - * correct xml-file. Starting with more than one Add-on at the same time is - * not supported yet, but should be sufficient for most cases. - *

- * In the Add-on-Example.xml (which may be renamed if you want to) you can specify the description, version, ... for your Add-on. This information is used - * for the listing of your Add-on in the Add-on-Manager dialog. Additionally the Plugin-class is instantiated by entering the location - * (

example_addon.ExemplaryAddon
means that Vanted tries to find the class "ExemplaryAddon" in the package "example_addon") and instantiates it. - *

- * For startup you should also read the readme.txt (as usual). - *

- * For creating a jar of your add-on just use ant to start the updateJar.xml. It will also track your progress by copying the actual jar into an - * "old"-directory before overwriting, which can be used to start vanted with an older version of your add-on. But please don't forget to rename it again - * ("Add-on-Example(09-02-14).jar" -> "Add-on-Example.jar"), because otherwise vanted won't load the plugin. Note that the jar also contains the sourcecode. - * - * @author Hendrik Rohn - */ - public static void main(String[] args) { - File f = new File(getAddonName()); - System.out.println(f.getAbsolutePath()); - System.out.println("Starting VANTED with SBML Add-on " + getAddonName() - + " for development..."); - MainM.startVanted(args, getAddonName()); - - // alternatively you may also start several Addons at the same time: - // Main.startVantedExt(args, new String[]{"","",...}); - } - - public static String getAddonName() { - return "SBML_XML_ReaderWriter.xml"; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ASTNode.java b/IPK_lib/src/org/sbml/jsbml/ASTNode.java deleted file mode 100644 index dd1c8fc06..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ASTNode.java +++ /dev/null @@ -1,3794 +0,0 @@ -/* - * $Id: ASTNode.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ASTNode.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.StringReader; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import javax.swing.tree.TreeNode; -import javax.xml.stream.XMLStreamException; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.text.parser.FormulaParser; -import org.sbml.jsbml.text.parser.ParseException; -import org.sbml.jsbml.util.Maths; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.compilers.ASTNodeCompiler; -import org.sbml.jsbml.util.compilers.ASTNodeValue; -import org.sbml.jsbml.util.compilers.FormulaCompiler; -import org.sbml.jsbml.util.compilers.LaTeXCompiler; -import org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler; -import org.sbml.jsbml.util.compilers.UnitsCompiler; -import org.sbml.jsbml.util.filters.Filter; -import org.sbml.jsbml.xml.stax.SBMLReader; - -/** - * A node in the Abstract Syntax Tree (AST) representation of a mathematical - * expression. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Alexander Dörr - * @since 0.8 - * @version $Rev: 1212 $ - */ -public class ASTNode extends AbstractTreeNode { - - /** - * An enumeration of all possible types that can be represented by an - * abstract syntax tree node. - * - * @author Andreas Dräger - * - */ - public static enum Type { - /** - * If the {@link ASTNode} represents Euler's constant, it should have - * this {@link Type}. - */ - CONSTANT_E, - /** - * If an {@link ASTNode} represents the {@link Boolean} attribute - * {@link Boolean#FALSE} it should have this {@link Type}. - */ - CONSTANT_FALSE, - /** - * If the {@link ASTNode} represents the constant π, it should have - * this {@link Type}. - */ - CONSTANT_PI, - /** - * - */ - CONSTANT_TRUE, - /** - * - */ - DIVIDE, - /** - * The type of an {@link ASTNode} containing a reference to a user-defined - * {@link FunctionDefinition}. - */ - FUNCTION, - /** - * - */ - FUNCTION_ABS, - /** - * - */ - FUNCTION_ARCCOS, - /** - * - */ - FUNCTION_ARCCOSH, - /** - * - */ - FUNCTION_ARCCOT, - /** - * - */ - FUNCTION_ARCCOTH, - /** - * - */ - FUNCTION_ARCCSC, - /** - * - */ - FUNCTION_ARCCSCH, - /** - * - */ - FUNCTION_ARCSEC, - /** - * - */ - FUNCTION_ARCSECH, - /** - * - */ - FUNCTION_ARCSIN, - /** - * - */ - FUNCTION_ARCSINH, - /** - * - */ - FUNCTION_ARCTAN, - /** - * - */ - FUNCTION_ARCTANH, - /** - * - */ - FUNCTION_CEILING, - /** - * - */ - FUNCTION_COS, - /** - * - */ - FUNCTION_COSH, - /** - * - */ - FUNCTION_COT, - /** - * - */ - FUNCTION_COTH, - /** - * - */ - FUNCTION_CSC, - /** - * - */ - FUNCTION_CSCH, - /** - * - */ - FUNCTION_DELAY, - /** - * - */ - FUNCTION_EXP, - /** - * - */ - FUNCTION_FACTORIAL, - /** - * - */ - FUNCTION_FLOOR, - /** - * - */ - FUNCTION_LN, - /** - * - */ - FUNCTION_LOG, - /** - * - */ - FUNCTION_PIECEWISE, - /** - * An {@link ASTNode} of this {@link Type} represents a function call of - * the 'pow' function. This function takes two arguments, the base and - * the exponent. Alternatively, also {@link Type#POWER} can be used, - * which represents the simple text symbol '^' to achieve the same - * effect. - */ - FUNCTION_POWER, - /** - * - */ - FUNCTION_ROOT, - /** - * - */ - FUNCTION_SEC, - /** - * - */ - FUNCTION_SECH, - /** - * - */ - FUNCTION_SIN, - /** - * - */ - FUNCTION_SINH, - /** - * - */ - FUNCTION_TAN, - /** - * - */ - FUNCTION_TANH, - /** - * - */ - INTEGER, - /** - * This type describes function definitions: The first n children of a - * node of this type are the arguments, and the last child is the - * function body. - */ - LAMBDA, - /** - * - */ - LOGICAL_AND, - /** - * - */ - LOGICAL_NOT, - /** - * - */ - LOGICAL_OR, - /** - * - */ - LOGICAL_XOR, - /** - * - */ - MINUS, - /** - * {@link ASTNode}s of this {@link Type} refer to a - * {@link CallableSBase}. - */ - NAME, - /** - * A type to express Avogadro's number. - */ - NAME_AVOGADRO, - /** - * - */ - NAME_TIME, - /** - * - */ - PLUS, - /** - * This {@link Type} represents an operation with two children: a base - * and an exponent. In textual form, this type is represented by the - * symbol '^'. - */ - POWER, - /** - * An {@link ASTNode} of this {@link Type} contains two integer values: - * a numerator and a denominator. - */ - RATIONAL, - /** - * {@link Type} of an {@link ASTNode} that represents a single real - * value, i.e., a double number. - */ - REAL, - /** - * {@link Type} of an {@link ASTNode} with a real value that is split in - * a double mantissa and an integer exponent. - */ - REAL_E, - /** - * An {@link ASTNode} of this {@link Type} represents the relation - * symbol '=' to compare the values of all of its successors in the tree - * for equality. - */ - RELATIONAL_EQ, - /** - * Greater or equal - */ - RELATIONAL_GEQ, - /** - * Greater than - */ - RELATIONAL_GT, - /** - * Less or equal - */ - RELATIONAL_LEQ, - /** - * Less than - */ - RELATIONAL_LT, - /** - * Not equal - */ - RELATIONAL_NEQ, - /** - * - */ - TIMES, - /** - * - */ - UNKNOWN; - - /** - * Returns the {@link Type} corresponding to the given {@link String}. - * - * @param type - * e.g., sin, asin, exp, and so on. See the specification of - * the MathML subset used in SBML. - * @return The type corresponding to the given {@link String} or - * {@link #UNKNOWN} if no matching can be found. - */ - public static Type getTypeFor(String type) { - // Arithmetic operators - if (type.equals("plus")) { - return PLUS; - } else if (type.equals("minus")) { - return MINUS; - } else if (type.equals("times")) { - return TIMES; - } else if (type.equals("divide")) { - return DIVIDE; - } else if (type.equals("power")) { - return FUNCTION_POWER; - } else if (type.equals("root")) { - return FUNCTION_ROOT; - } else if (type.equals("abs")) { - return FUNCTION_ABS; - } else if (type.equals("exp")) { - return FUNCTION_EXP; - } else if (type.equals("ln")) { - return FUNCTION_LN; - } else if (type.equals("log")) { - return FUNCTION_LOG; - } else if (type.equals("floor")) { - return FUNCTION_FLOOR; - } else if (type.equals("ceiling")) { - return FUNCTION_CEILING; - } else if (type.equals("factorial")) { - return FUNCTION_FACTORIAL; - } - - // Logical operators - else if (type.equals("and")) { - return LOGICAL_AND; - } else if (type.equals("or")) { - return LOGICAL_OR; - } else if (type.equals("xor")) { - return LOGICAL_XOR; - } else if (type.equals("not")) { - return LOGICAL_NOT; - } - - // Trigonometric operators - else if (type.equals("cos")) { - return FUNCTION_COS; - } else if (type.equals("sin")) { - return FUNCTION_SIN; - } else if (type.equals("tan")) { - return FUNCTION_TAN; - } else if (type.equals("sec")) { - return FUNCTION_SEC; - } else if (type.equals("csc")) { - return FUNCTION_CSC; - } else if (type.equals("cot")) { - return FUNCTION_COT; - } else if (type.equals("sinh")) { - return FUNCTION_SINH; - } else if (type.equals("cosh")) { - return FUNCTION_COSH; - } else if (type.equals("tanh")) { - return FUNCTION_TANH; - } else if (type.equals("sech")) { - return FUNCTION_SECH; - } else if (type.equals("csch")) { - return FUNCTION_CSCH; - } else if (type.equals("coth")) { - return FUNCTION_COTH; - } else if (type.equals("arcsin")) { - return FUNCTION_ARCSIN; - } else if (type.equals("arccos")) { - return FUNCTION_ARCCOS; - } else if (type.equals("arctan")) { - return FUNCTION_ARCTAN; - } else if (type.equals("arcsec")) { - return FUNCTION_ARCSEC; - } else if (type.equals("arccsc")) { - return FUNCTION_ARCCSC; - } else if (type.equals("arccot")) { - return FUNCTION_ARCCOT; - } else if (type.equals("arcsinh")) { - return FUNCTION_ARCSINH; - } else if (type.equals("arccosh")) { - return FUNCTION_ARCCOSH; - } else if (type.equals("arctanh")) { - return FUNCTION_ARCTANH; - } else if (type.equals("arcsech")) { - return FUNCTION_ARCSECH; - } else if (type.equals("arccsch")) { - return FUNCTION_ARCCSCH; - } else if (type.equals("arccoth")) { - return FUNCTION_ARCCOTH; - } - - // Relational operators - else if (type.equals("eq")) { - return RELATIONAL_EQ; - } else if (type.equals("neq")) { - return RELATIONAL_NEQ; - } else if (type.equals("gt")) { - return RELATIONAL_GT; - } else if (type.equals("lt")) { - return RELATIONAL_LT; - } else if (type.equals("geq")) { - return RELATIONAL_GEQ; - } else if (type.equals("leq")) { - return RELATIONAL_LEQ; - } - - // token : cn, ci, csymbol, sep - // for ci, we have to check if it is a functionDefinition - // for cn, we pass the type attribute to this function to determine the - // proper astNode type - // for csymbol, we pass the definitionURL - else if (type.equalsIgnoreCase("real") || type.equals("cn")) { - // we put the type by default to real in case the type attribute is - // not define on the cn element. - return REAL; - } else if (type.equalsIgnoreCase("e-notation")) { - return REAL_E; - } else if (type.equalsIgnoreCase("integer")) { - return INTEGER; - } else if (type.equalsIgnoreCase("rational")) { - return RATIONAL; - } else if (type.equals("ci")) { - return NAME; - } else if (type.equals("csymbol")) { - return UNKNOWN; - } else if (type.equals("sep")) { - return UNKNOWN; - } else if (type.equals(URI_TIME_DEFINITION)) { - return NAME_TIME; - } else if (type.equals(URI_DELAY_DEFINITION)) { - return FUNCTION_DELAY; - } else if (type.equals(URI_AVOGADRO_DEFINITION)) { - return NAME_AVOGADRO; - } - - // general : apply, piecewise, piece, otherwise, lambda, bvar - else if (type.equals("lambda")) { - return LAMBDA; - } else if (type.equals("bvar")) { - // nothing to do, node ignore when parsing - } else if (type.equals("piecewise")) { - return FUNCTION_PIECEWISE; - } else if (type.equals("piece")) { - // nothing to do, node ignore when parsing - } else if (type.equals("otherwise")) { - // nothing to do, node ignore when parsing - } - - // qualifiers : degree, logbase - else if (type.equals("degree")) { - // nothing to do, node ignore when parsing - } else if (type.equals("logbase")) { - // nothing to do, node ignore when parsing - } - - // constants : true, false, notanumber, pi, infinity, exponentiale - else if (type.equals("true")) { - return CONSTANT_TRUE; - } else if (type.equals("false")) { - return CONSTANT_FALSE; - } else if (type.equals("notanumber")) { - return REAL; - } else if (type.equals("pi")) { - return CONSTANT_PI; - } else if (type.equals("infinity")) { - return REAL; - } else if (type.equals("exponentiale")) { - return CONSTANT_E; - } - - // TODO : possible annotations : semantics, annotation, annotation-xml - - return UNKNOWN; - } - - /** - * Checks whether this type is valid for the given SBML - * Level/Version combination. - * - * @jsbml.warning this method is not implemented - * - * @param level - * @param version - * @return whether this type is valid for the given SBML - * Level/Version combination. - */ - public boolean isDefinedIn(int level, int version) { - // TODO - return false; - } - - } - - /** - * Message to indicate that an {@link ASTNode.Type} type has been chosen - * which cannot be used as an operator. - */ - public static final transient String INVALID_OPERATOR_MSG = "Invalid operator %s. The operator must be one of the following constants: PLUS, MINUS, TIMES, DIVIDE, or POWER."; - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1391327698196553142L; - - /** - * The URI for the definition of the csymbol for avogadro. - */ - public static final transient String URI_AVOGADRO_DEFINITION = "http://www.sbml.org/sbml/symbols/avogadro"; - - /** - * The URI for the definition of the csymbol for delay. - */ - public static final transient String URI_DELAY_DEFINITION = "http://www.sbml.org/sbml/symbols/delay"; - - /** - * URI for the definition of MathML. - */ - public static final transient String URI_MATHML_DEFINITION = "http://www.w3.org/1998/Math/MathML"; - - // TODO : check how we set the math in level 1 - - /** - * URI prefix for the definition of MathML, it will be used to write the sbml file - */ - public static final String URI_MATHML_PREFIX = ""; - - /** - * The URI for the definition of the csymbol for time. - */ - public static final transient String URI_TIME_DEFINITION = "http://www.sbml.org/sbml/symbols/time"; - - /** - * Creates and returns an {@link ASTNode} that computes the absolute value - * of the given double value. - * - * @param d a double value - * @param parent the parent ASTNode - * @return an {@link ASTNode} that computes the absolute value - * of the given double value. - */ - public static ASTNode abs(double d, MathContainer parent) { - ASTNode abs = new ASTNode(Type.FUNCTION_ABS, parent); - abs.addChild(new ASTNode(d, parent)); - return abs; - } - - /** - * Creates and returns an {@link ASTNode} that computes the absolute value - * of the given integer value. - * - * @param integer an integer value - * @param parent the parent ASTNode - * @return an {@link ASTNode} that computes the absolute value - * of the given integer value. - */ - public static ASTNode abs(int integer, MathContainer parent) { - ASTNode abs = new ASTNode(Type.FUNCTION_ABS, parent); - abs.addChild(new ASTNode(integer, parent)); - return abs; - } - - /** - * Creates a new ASTNode of type operator and adds the given nodes as children. - * - * @param operator the type of arithmetic operation - * @param ast the children of the new ASTNode - * @return a new ASTNode of type operator and adds the given nodes as children. - */ - private static ASTNode arithmethicOperation(Type operator, ASTNode... ast) { - LinkedList astList = new LinkedList(); - if (ast != null) { - for (ASTNode node : ast) { - if ((node != null) - && !((operator == Type.TIMES) && node.isOne() && (ast.length > 1))) { - astList.add(node); - } - } - } - if (astList.size() == 0) { - return null; - } - if (astList.size() == 1) { - return astList.getFirst().clone(); - } - if ((operator == Type.PLUS) || (operator == Type.MINUS) - || (operator == Type.TIMES) || (operator == Type.DIVIDE) - || (operator == Type.POWER)) { - MathContainer mc = astList.getFirst().parentSBMLObject; - ASTNode arithmetic = new ASTNode(operator, mc); - for (ASTNode nodes : astList) { - arithmetic.addChild(nodes); - setParentSBMLObject(nodes, mc, 0); - } - if (arithmetic.getChildCount() > 2) { - arithmetic.reduceToBinary(); - } - return arithmetic; - } else { - throw new IllegalArgumentException(String.format( - INVALID_OPERATOR_MSG, operator)); - } - } - - /** - * Creates a new ASTNode of type MINUS and adds the given nodes as children - * - * @param ast the children of the new ASTNode - * @return a new ASTNode of type MINUS and adds the given nodes as children - */ - public static ASTNode diff(ASTNode... ast) { - return arithmethicOperation(Type.MINUS, ast); - } - - /** - * Creates a new ASTNode of type RELATIONAL_EQ. - * - * @param left the left child. - * @param right the right child. - * @return a new ASTNode of type RELATIONAL_EQ. - */ - public static ASTNode eq(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_EQ, left, right); - } - - /** - * Returns a new ASTNode that represents Euler's constant raised by the - * power of the given exponent. - * - * @param exponent the exponent - * @return a new ASTNode that represents Euler's constant raised by the - * power of the given exponent. - */ - public static ASTNode exp(ASTNode exponent) { - ASTNode e = new ASTNode(Type.CONSTANT_E, exponent.getParentSBMLObject()); - return e.raiseByThePowerOf(exponent); - } - - /** - * Returns the formula from the given ASTNode as an SBML Level 1 text-string - * mathematical formula. - * - * - * @param tree - * the root of the ASTNode formula expression tree - * @return the formula from the given AST as an SBML Level 1 text-string - * mathematical formula. The caller owns the returned string and is - * responsible for freeing it when it is no longer needed. NULL is - * returned if the given argument is NULL. - * @throws SBMLException - * @see #toFormula() - * - */ - public static String formulaToString(ASTNode tree) throws SBMLException { - return tree.toFormula(); - } - - /** - * Creates a new ASTNode of type DIVIDE with the given nodes as children. - * - * @param numerator the numerator - * @param denominator the denominator - * @return a new ASTNode of type DIVIDE with the given nodes as children. - */ - public static ASTNode frac(ASTNode numerator, ASTNode denominator) { - return numerator.divideBy(denominator); - } - - /** - * Creates a new ASTNode that of type DIVIDE with the given numerator and - * denominator. - * - * @param numerator the numerator - * @param denominator the denominator - * @return a new ASTNode that of type DIVIDE with the given numerator and - * denominator. - */ - public static ASTNode frac(int numerator, ASTNode denominator) { - return frac(new ASTNode(numerator, denominator.getParentSBMLObject()), - denominator); - } - - /** - * Creates a new ASTNode that divides two named sbase objects. - * - * @param container the parent object - * @param numerator the numerator - * @param denominator the denominator - * @return a new ASTNode that divides two named sbase objects. - */ - public static ASTNode frac(MathContainer container, - CallableSBase numerator, - CallableSBase denominator) { - return frac(new ASTNode(numerator, container), new ASTNode(denominator, - container)); - } - - /** - * Returns a new ASTNode that of type DIVIDE with the two entities as numerator and denominator. - * - * @param container the parent object - * @param numeratorId the numerator - * @param denominatorId the numerator - * @return a new ASTNode that of type DIVIDE with the two entities as numerator and denominator. - */ - public static ASTNode frac(MathContainer container, String numeratorId, - String denominatorId) { - return frac(new ASTNode(numeratorId, container), new ASTNode( - denominatorId, container)); - } - - /** - * Creates an {@link ASTNode} representing greater or equal for - * the two given nodes. - * - * @param left the left child. - * @param right the right child. - * @return an {@link ASTNode} representing greater or equal. - */ - public static ASTNode geq(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_GEQ, left, right); - } - - /** - * Creates an {@link ASTNode} representing greater than for - * the two given left and right child. - * - * @param left the left child. - * @param right the right child. - * @return an {@link ASTNode} representing greater than for - * the two given left and right child. - */ - public static ASTNode gt(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_GT, left, right); - } - - /** - * Creates an {@link ASTNode} representing less or equal for - * the two given left and right child. - * - * @param left the left child. - * @param right the right child. - * @return an {@link ASTNode} representing less or equal for - * the two given left and right child. - */ - public static ASTNode leq(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_LEQ, left, right); - } - - /** - * Creates an {@link ASTNode} representing a logarithm to base 10 of the given value. - * - * @param value the value which is the argument of the logarithm. - * @return an {@link ASTNode} representing a logarithm to base 10 of the given value. - */ - public static ASTNode log(ASTNode value) { - return log(null, value); - } - - /** - * Creates an {@link ASTNode} that represents the logarithm function with - * the given base and value. The parent SBML object will be taken from the - * {@link ASTNode} value. - * - * @param base - * The basis of this logarithm. Can be null; then a base of 10 - * will be assumed. - * @param value - * Must not be null. - * @return An {@link ASTNode} representing the logarithm of the given value - * with respect to the given base or to the base 10 if base is null. - */ - public static ASTNode log(ASTNode base, ASTNode value) { - if (value == null) { - throw new NullPointerException( - "logarithm cannot be created for null values"); - } - ASTNode log = new ASTNode(Type.FUNCTION_LOG, value - .getParentSBMLObject()); - if (base != null) { - log.addChild(base); - } - log.addChild(value); - setParentSBMLObject(log, log.getParentSBMLObject(), 0); - return log; - } - - /** - * Creates an {@link ASTNode} that performs a less than comparison between - * two {@link ASTNode}s. The parent SBML object of the resulting node will - * be taken from the left node. - * - * @param left the left child. - * @param right the right child. - * @return an {@link ASTNode} that performs a less than comparison between - * two {@link ASTNode}s. - */ - public static ASTNode lt(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_LT, left, right); - } - - /** - * Creates an {@link ASTNode} that performs a less than comparison between a - * variable and another {@link ASTNode}. The parent SBML object will be - * taken from the given {@link ASTNode}. - * - * @param variable the left child. - * @param node the right child. - * @return an {@link ASTNode} that performs a less than comparison between a - * variable and another {@link ASTNode}. - */ - public static ASTNode lt(String variable, ASTNode node) { - return lt(new ASTNode(variable, node.getParentSBMLObject()), node); - } - - /** - * Creates an {@link ASTNode} that performs a not equal comparison between - * two {@link ASTNode}s. - * - * @param left the left child. - * @param right the right child. - * @return an {@link ASTNode} that performs a not equal comparison between - * two {@link ASTNode}s. - */ - public static ASTNode neq(ASTNode left, ASTNode right) { - return relational(Type.RELATIONAL_NEQ, left, right); - } - - /** - * Parses a text-string mathematical formula and returns a representation as - * an Abstract Syntax Tree. - * - * @param formula - * a text-string mathematical formula. - * @return an {@link ASTNode} representing the formula. - * @throws ParseException - * If the given formula is not of valid format or cannot be - * parsed for other reasons. - */ - public static ASTNode parseFormula(String formula) throws ParseException { - FormulaParser parser = new FormulaParser(new StringReader(formula)); - return parser.parse(); - } - - /** - * Creates a piecewise {@link ASTNode}. - * - *

At least one {@link ASTNode} must be given - * as a child. The parent SBML object of this first node will be the parent - * of the resulting {@link ASTNode}. - * - * @param node the parent SBML object of this node will be the parent - * of the resulting {@link ASTNode}. - * @param nodes the children of the new piecewise ASTNode - * @return a piecewise {@link ASTNode}. - */ - public static ASTNode piecewise(ASTNode node, ASTNode... nodes) { - ASTNode piecewise = new ASTNode(Type.FUNCTION_PIECEWISE, node - .getParentSBMLObject()); - for (ASTNode n : nodes) { - piecewise.addChild(n); - } - if (nodes.length > 0) { - setParentSBMLObject(piecewise, piecewise.getParentSBMLObject(), 0); - } - return piecewise; - } - - /** - * Creates a power {@link ASTNode}. - * - * @param basis the basis - * @param exponent the exponent - * @return a power {@link ASTNode}. - */ - public static ASTNode pow(ASTNode basis, ASTNode exponent) { - if (!(exponent.isInteger() && exponent.getInteger() == 1) - && !(exponent.getType() == Type.REAL && exponent.getReal() == 1d)) { - if ((exponent.isInteger() && exponent.getInteger() == 0) - || (exponent.getType() == Type.REAL && exponent.getReal() == 0d)) { - basis = new ASTNode(1, basis.getParentSBMLObject()); - } else { - setParentSBMLObject(exponent, basis.getParentSBMLObject(), 0); - basis.raiseByThePowerOf(exponent); - } - } - return basis; - } - - /** - * Creates a power {@link ASTNode}. - * - * @param basis the basis - * @param exponent the exponent - * @return a power {@link ASTNode}. - */ - public static ASTNode pow(ASTNode basis, double exponent) { - basis.raiseByThePowerOf(exponent); - return basis; - } - - /** - * Creates a power {@link ASTNode}. - * - * @param basis the basis - * @param exponent the exponent - * @return a power {@link ASTNode}. - */ - public static ASTNode pow(ASTNode basis, int exponent) { - basis.raiseByThePowerOf(exponent); - return basis; - } - - /** - * Raises the given basis by the power of the given exponent. - * - * @param container the parent object - * @param basis the basis - * @param exponent the exponent - * @return a power {@link ASTNode}. - */ - public static ASTNode pow(MathContainer container, - CallableSBase basis, CallableSBase exponent) { - return pow(new ASTNode(basis, container), new ASTNode(exponent, - container)); - } - - /** - * Reads the MathML from the given XML string. - * - *

Constructs a corresponding - * abstract syntax tree, and returns a pointer to the root of the tree. - * - * @param xml - * the MathML XML string. - * @return an {@link ASTNode} - */ - public static ASTNode readMathMLFromString(String xml) { - try { - return new SBMLReader().readMathML(xml); - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Creates a relational {@link ASTNode} of the given type with the two given - * children left and right. - *

Sets the parent SBML object of all nodes to - * the one provided by the left child. - * - * @param type the type of relational node. - * @param left the left child. - * @param right the right child. - * @return a relational {@link ASTNode} of the given type with the two given - * children left and right. - */ - private static ASTNode relational(Type type, ASTNode left, ASTNode right) { - if ((left == null) || (right == null)) { - throw new NullPointerException( - "Cannot create a relational node with null arguments."); - } - ASTNode relational = new ASTNode(type, left.getParentSBMLObject()); - relational.addChild(left); - relational.addChild(right); - setParentSBMLObject(relational, left.getParentSBMLObject(), 0); - return relational; - } - - /** - * Creates a root {@link ASTNode}. - * - * @param radicand the radicand - * @param rootExponent the exponent of the root element. - * @return a root {@link ASTNode}. - */ - public static ASTNode root(ASTNode rootExponent, ASTNode radicand) { - ASTNode root = new ASTNode(Type.FUNCTION_ROOT, radicand - .getParentSBMLObject()); - root.addChild(rootExponent); - root.addChild(radicand); - setParentSBMLObject(rootExponent, radicand.getParentSBMLObject(), 0); - return root; - } - - /** - * Sets the Parent of the node and its children to the given value - * - * @param node the orphan node - * @param parent the parent - */ - static void setParentSBMLObject(ASTNode node, MathContainer parent) { - setParentSBMLObject(node, parent, 0); - } - - /** - * Sets the Parent of the node and its children to the given value - * - * @param node the orphan node - * @param parent the parent - * @param depth the current depth in the ASTNode tree. - * It is just here for testing purposes to track the depth in the tree - * during the process. - */ - private static void setParentSBMLObject(ASTNode node, MathContainer parent, - int depth) { - node.parentSBMLObject = parent; - for (ASTNode child : node.listOfNodes) { - setParentSBMLObject(child, parent, depth + 1); - } - } - - /** - * Creates a root {@link ASTNode}. - * - * @param radicand - * @return a root {@link ASTNode}. - */ - public static ASTNode sqrt(ASTNode radicand) { - return root(new ASTNode(2, radicand.getParentSBMLObject()), radicand); - } - - /** - * Creates a new ASTNode of type Plus with the given nodes as children. - * - * @param ast the children nodes. - * @return a new ASTNode of type Plus with the given nodes as children. - */ - public static ASTNode sum(ASTNode... ast) { - return arithmethicOperation(Type.PLUS, ast); - } - - /** - * Sum of several NamedSBase objects. - * - * @param parent the parent - * @param sbase - * @return the sum of several NamedSBase objects. - */ - public static ASTNode sum(MathContainer parent, - CallableSBase... sbase) { - ASTNode elements[] = new ASTNode[sbase.length]; - for (int i = 0; i < sbase.length; i++) { - elements[i] = new ASTNode(sbase[i], parent); - } - return sum(elements); - } - - /** - * Creates an ASTNode of type times and adds the given nodes as children. - * - * @param ast - * @return an ASTNode of type times and adds the given nodes as children. - */ - public static ASTNode times(ASTNode... ast) { - return arithmethicOperation(Type.TIMES, ast); - } - - /** - * Multiplies several NamedSBase objects. - * - * @param parent - * @param sbase - * @return the multiplication of several NamedSBase objects. - */ - public static ASTNode times(MathContainer parent, - CallableSBase... sbase) { - ASTNode elements[] = new ASTNode[sbase.length]; - for (int i = 0; i < sbase.length; i++) - elements[i] = new ASTNode(sbase[i], parent); - return times(elements); - } - - /** - * Creates a new ASTNode that has exactly one child and which is of type - * minus, i.e., this negates what is encoded in ast. - * - * @param ast - * @return a new ASTNode that has exactly one child and which is of type - * minus, i.e., this negates what is encoded in ast. - */ - public static ASTNode uMinus(ASTNode ast) { - ASTNode um = new ASTNode(Type.MINUS, ast.getParentSBMLObject()); - um.addChild(ast); - return um; - } - - /** - * Creates a new ASTNode that has exactly one child and which is of type - * minus, i.e., this negates what is encoded in ast. - * - * @param container - * @param sbase - * @return a new ASTNode that has exactly one child and which is of type - * minus, i.e., this negates what is encoded in ast. - */ - public static ASTNode uMinus(MathContainer container, - CallableSBase sbase) { - return uMinus(new ASTNode(sbase, container)); - } - - /** - * The value of the definitionURL for csymbol element. Level 3 extensions - * can create new csymbol element that we would not necessary be aware of, - * so we need to store the attribute value. - */ - private String definitionURL; - - /** - * - */ - private int denominator; - - /** - * - */ - private int exponent; - - /** - * Possible attributes for a MathML element - */ - private String id, style, className, encoding; - - /** - * Tells if the type attribute of the cn element was set and we need to - * write it back or if it is set to the default (REAL). - * - */ - private boolean isSetNumberType = false; - - /** - * Child nodes. - */ - private LinkedList listOfNodes; - - /** - * A {@link Logger} for this class. - */ - private static transient final Logger logger = Logger.getLogger(ASTNode.class); - - /** - * The part of a number in scientific format (with an E) that is on the left - * side of the E (the prefix of the number). For instance, in the number - * 3.5E-2.7 the mantissa is 3.5. - */ - private double mantissa; - - /** - * If no NamedSBase object exists or can be identified when - * {@link #setName(String)} is called, the given name is stored in this - * field. - */ - private String name; - - /** - * This value stores the numerator if this.isRational() is true, or the - * value of an integer if this.isInteger() is true. - */ - private int numerator; - - /** - * The container that holds this ASTNode. - */ - private MathContainer parentSBMLObject; - - /** - * The type of this ASTNode. - */ - private Type type; - - /** - * Since Level 3 SBML allows to equip numbers with unit identifiers. In this - * case a reference to an identifier of a {@link UnitDefinition} in the - * model can be stored here. - */ - private String unitId; - - /** - * A direct pointer to a referenced variable. This can save a lot of - * computation time because it will then not be necessary to query the - * corresponding model again and again for this variable. - */ - private CallableSBase variable; - - /** - * Creates a new {@link ASTNode} of unspecified type and without a pointer - * to its containing {@link MathContainer}. - */ - public ASTNode() { - super(); - this.parentSBMLObject = null; - this.listOfNodes = null; - this.initDefaults(); - } - - /** - * Copy constructor; Creates a deep copy of the given {@link ASTNode}. - * - * @param astNode - * the ASTNode to be copied. - */ - public ASTNode(ASTNode astNode) { - super(astNode); - this.parentSBMLObject = null; - this.initDefaults(); - - logger.debug("Clone constructor : Origin type = " + astNode.type); - - setType(astNode.getType()); - this.denominator = astNode.denominator; - this.exponent = astNode.exponent; - this.mantissa = astNode.mantissa; - this.name = astNode.name == null ? null : new String(astNode.name); - this.variable = astNode.variable; - this.numerator = astNode.numerator; - this.parent = astNode.getParent(); - this.unitId = astNode.unitId == null ? null : new String(astNode.unitId); - - for (ASTNode child : astNode.listOfNodes) { - ASTNode c = child.clone(); - c.parent = this; - this.listOfNodes.add(c); - } - } - - /** - * Creates and returns a new {@link ASTNode} referring to the given {@link CallableSBase}. - * @param nsb - */ - public ASTNode(CallableSBase nsb) { - this(Type.NAME); - setVariable(nsb); - } - - /** - * Creates and returns a new {@link ASTNode} referring to the given {@link CallableSBase}. - * - * @param nsb - * @param parent - */ - public ASTNode(CallableSBase nsb, MathContainer parent) { - this(Type.NAME, parent); - setVariable(nsb); - } - - /** - * Creates a new {@link ASTNode} representing an operator, i.e., an internal - * node. - * - * @param operator - */ - public ASTNode(char operator) { - this(); - setCharacter(operator); - } - - /** - * Creates a new {@link ASTNode} representing an operator, i.e., an internal - * node. - * - * @param operator - * @param parent - */ - public ASTNode(char operator, MathContainer parent) { - this(parent); - setCharacter(operator); - } - - /** - * Creates and returns a new {@link ASTNode}. - * - * @param real - */ - public ASTNode(double real) { - this(Type.REAL); - setValue(real); - } - - /** - * Creates and returns a new {@link ASTNode}. - * - * @param mantissa - * @param exponent - */ - public ASTNode(double mantissa, int exponent) { - this(Type.REAL_E); - setValue(mantissa, exponent); - } - - /** - * Creates and returns a new {@link ASTNode}. - * - * @param mantissa - * @param exponent - * @param parent - */ - public ASTNode(double mantissa, int exponent, MathContainer parent) { - this(Type.REAL_E, parent); - setValue(mantissa, exponent); - } - - /** - * Creates and returns a new {@link ASTNode}. - * - * @param real - * @param parent - */ - public ASTNode(double real, MathContainer parent) { - this(Type.REAL, parent); - setValue(real); - } - - /** - * Creates and returns a new {@link ASTNode} with the given integer value. - * - * @param integer - */ - public ASTNode(int integer) { - this(integer, null); - } - - /** - * Creates and returns a new {@link ASTNode} with the given integer value for - * the - * given {@link MathContainer} as its parent SBML object. - * - * @param integer - * @param parent - */ - public ASTNode(int integer, MathContainer parent) { - this(integer, null, parent); - } - - /** - * Creates and returns a new {@link ASTNode} with the given integer value with - * the given associated {@link #unitId} for the - * given {@link MathContainer} as its parent SBML object. - * - * @param integer - * @param unitsID - * @param parent - */ - public ASTNode(int integer, String unitsID, MathContainer parent) { - this(Type.INTEGER, parent); - setValue(integer); - if (unitsID != null) { - setUnits(unitsID); - } - } - - /** - * Creates and returns a new {@link ASTNode}. - * - * By default, the returned node will have a type of {@link Type#UNKNOWN}. - * The calling code should set the node type to something else as soon as - * possible using setType(int) - * - * @param parent - * the parent SBML object - */ - public ASTNode(MathContainer parent) { - this(); - parentSBMLObject = parent; - if (parentSBMLObject != null) { - addAllChangeListeners(parent.getListOfTreeNodeChangeListeners()); - } - } - - /** - * Creates and returns a new {@link ASTNode} with the given name. - * - * @param name the name of this ASTNode - */ - public ASTNode(String name) { - this(Type.NAME); - setName(name); - } - - /** - * Creates and returns a new {@link ASTNode} with the given name. - * - * @param name the name of this ASTNode - * @param parent - * the parent SBML object. - */ - public ASTNode(String name, MathContainer parent) { - this(Type.NAME, parent); - setName(name); - } - - /** - * Creates a new {@link ASTNode} of the given {@link Type} but without a - * pointer to its {@link MathContainer}. - * - * @param type - */ - public ASTNode(Type type) { - this(); - setType(type); - } - - /** - * Creates and returns a new ASTNode. - * - * @param type - * the type of the ASTNode to create. - * @param parent - * the parent SBML object. - */ - public ASTNode(Type type, MathContainer parent) { - this(parent); - setType(type); - } - - /** - * Adds a child to this node. - * - * @param child - * the node to add as child. - */ - public void addChild(ASTNode child) { - listOfNodes.add(child); - child.parent = this; - child.fireNodeAddedEvent(); - } - - /** - * Creates a new node with the type of this node, moves all children of this - * node to this new node, sets the type of this node to the given operator, - * adds the new node as left child of this node and the given astnode as the - * right child of this node. The parentSBMLObject of the whole resulting - * ASTNode is then set to the parent of this node. - * - * @param operator - * The new type of this node. This has to be one of the - * following: PLUS, MINUS, TIMES, DIVIDE, or POWER. Otherwise a - * runtime error is thrown. - * @param astnode - * The new right child of this node - */ - private void arithmeticOperation(Type operator, ASTNode astnode) { - if (operator == Type.PLUS || operator == Type.MINUS - || operator == Type.TIMES || operator == Type.DIVIDE - || operator == Type.POWER || operator == Type.FUNCTION_ROOT) { - if (astnode.isZero() && operator == Type.DIVIDE) { - throw new RuntimeException(new IllegalArgumentException( - "Cannot divide by zero.")); - } - if (!(astnode.isOne() && (operator == Type.TIMES || operator == Type.DIVIDE))) { - ASTNode swap = new ASTNode(type, getParentSBMLObject()); - swap.denominator = denominator; - swap.exponent = exponent; - swap.mantissa = mantissa; - swap.name = name; - swap.numerator = numerator; - swap.variable = variable; - swapChildren(swap); - setType(operator); - if (operator == Type.FUNCTION_ROOT) { - addChild(astnode); - addChild(swap); - } else { - addChild(swap); - addChild(astnode); - } - setParentSBMLObject(astnode, getParentSBMLObject(), 0); - } - } else { - throw new IllegalArgumentException(String.format( - INVALID_OPERATOR_MSG, operator)); - } - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - public ASTNode clone() { - return new ASTNode(this); - } - - /** - * Compiles this {@link ASTNode} and returns the result. - * - * @param compiler - * An instance of an {@link ASTNodeCompiler} that provides - * methods to translate this {@link ASTNode} into something - * different. - * @return Some value wrapped in an {@link ASTNodeValue}. The content of the - * wrapper depends on the {@link ASTNodeCompiler} used to create it. - * However, this {@link ASTNode} will ensure that level and version - * are set appropriately according to this node's parent SBML - * object. - * @throws SBMLException - * Thrown if an error occurs during the compilation process. - * - */ - public ASTNodeValue compile(ASTNodeCompiler compiler) throws SBMLException { - ASTNodeValue value; - switch (getType()) { - /* - * Numbers - */ - case REAL: - double real = getReal(); - if (Double.isInfinite(real)) { - value = (real > 0d) ? compiler.getPositiveInfinity() : compiler - .getNegativeInfinity(); - } else { - value = compiler.compile(real, getUnits()); - } - break; - case INTEGER: - value = compiler.compile(getInteger(), getUnits()); - break; - /* - * Operators - */ - case POWER: - value = compiler.pow(getLeftChild(), getRightChild()); - break; - case PLUS: - value = compiler.plus(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case MINUS: - if (getChildCount() < 2) { - value = compiler.uMinus(getLeftChild()); - value.setUIFlag(true); - } else { - value = compiler.minus(getChildren()); - value.setUIFlag(false); - } - break; - case TIMES: - value = compiler.times(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case DIVIDE: - int childCount = getChildCount(); - if (childCount != 2) { - throw new SBMLException(String.format( - "Fractions must have one numerator and one denominator, here %s elements are given.", - childCount)); - } - value = compiler.frac(getLeftChild(), getRightChild()); - break; - case RATIONAL: - value = compiler.frac(getNumerator(), getDenominator()); - break; - case NAME_TIME: - value = compiler.symbolTime(getName()); - break; - case FUNCTION_DELAY: - value = compiler.delay(getName(), getLeftChild(), getRightChild(), - getUnits()); - break; - /* - * Names of identifiers: parameters, functions, species etc. - */ - case NAME: - if (variable == null) { - variable = getVariable(); - } - if (variable != null) { - if (variable instanceof FunctionDefinition) { - value = compiler.function((FunctionDefinition) variable, - getChildren()); - } else { - value = compiler.compile(variable); - } - } else { - value = compiler.compile(getName()); - } - break; - /* - * Type: pi, e, true, false, Avogadro - */ - case CONSTANT_PI: - value = compiler.getConstantPi(); - break; - case CONSTANT_E: - value = compiler.getConstantE(); - break; - case CONSTANT_TRUE: - value = compiler.getConstantTrue(); - break; - case CONSTANT_FALSE: - value = compiler.getConstantFalse(); - break; - case NAME_AVOGADRO: - value = compiler.getConstantAvogadro(getName()); - break; - case REAL_E: - value = compiler.compile(getMantissa(), getExponent(), - isSetUnits() ? getUnits() : null); - break; - /* - * Basic Functions - */ - case FUNCTION_LOG: - if (getChildCount() == 2) { - value = compiler.log(getLeftChild(), getRightChild()); - } else { - value = compiler.log(getRightChild()); - } - break; - case FUNCTION_ABS: - value = compiler.abs(getRightChild()); - break; - case FUNCTION_ARCCOS: - value = compiler.arccos(getLeftChild()); - break; - case FUNCTION_ARCCOSH: - value = compiler.arccosh(getLeftChild()); - break; - case FUNCTION_ARCCOT: - value = compiler.arccot(getLeftChild()); - break; - case FUNCTION_ARCCOTH: - value = compiler.arccoth(getLeftChild()); - break; - case FUNCTION_ARCCSC: - value = compiler.arccsc(getLeftChild()); - break; - case FUNCTION_ARCCSCH: - value = compiler.arccsch(getLeftChild()); - break; - case FUNCTION_ARCSEC: - value = compiler.arcsec(getLeftChild()); - break; - case FUNCTION_ARCSECH: - value = compiler.arcsech(getLeftChild()); - break; - case FUNCTION_ARCSIN: - value = compiler.arcsin(getLeftChild()); - break; - case FUNCTION_ARCSINH: - value = compiler.arcsinh(getLeftChild()); - break; - case FUNCTION_ARCTAN: - value = compiler.arctan(getLeftChild()); - break; - case FUNCTION_ARCTANH: - value = compiler.arctanh(getLeftChild()); - break; - case FUNCTION_CEILING: - value = compiler.ceiling(getLeftChild()); - break; - case FUNCTION_COS: - value = compiler.cos(getLeftChild()); - break; - case FUNCTION_COSH: - value = compiler.cosh(getLeftChild()); - break; - case FUNCTION_COT: - value = compiler.cot(getLeftChild()); - break; - case FUNCTION_COTH: - value = compiler.coth(getLeftChild()); - break; - case FUNCTION_CSC: - value = compiler.csc(getLeftChild()); - break; - case FUNCTION_CSCH: - value = compiler.csch(getLeftChild()); - break; - case FUNCTION_EXP: - value = compiler.exp(getLeftChild()); - break; - case FUNCTION_FACTORIAL: - value = compiler.factorial(getLeftChild()); - break; - case FUNCTION_FLOOR: - value = compiler.floor(getLeftChild()); - break; - case FUNCTION_LN: - value = compiler.ln(getLeftChild()); - break; - case FUNCTION_POWER: - value = compiler.pow(getLeftChild(), getRightChild()); - break; - case FUNCTION_ROOT: - ASTNode left = getLeftChild(); - if (getChildCount() == 2) { - if (left.isInteger()) { - int leftValue = left.getInteger(); - if (leftValue == 2) { - value = compiler.sqrt(getRightChild()); - } else { - value = compiler.root(leftValue, getRightChild()); - } - } else if (left.isReal()) { - double leftValue = left.getReal(); - if (leftValue == 2d) { - value = compiler.sqrt(getRightChild()); - } else { - value = compiler.root(leftValue, getRightChild()); - } - } else { - value = compiler.root(left, getRightChild()); - } - } else if (getChildCount() == 1) { - value = compiler.sqrt(getRightChild()); - } else { - value = compiler.root(left, getRightChild()); - } - break; - case FUNCTION_SEC: - value = compiler.sec(getLeftChild()); - break; - case FUNCTION_SECH: - value = compiler.sech(getLeftChild()); - break; - case FUNCTION_SIN: - value = compiler.sin(getLeftChild()); - break; - case FUNCTION_SINH: - value = compiler.sinh(getLeftChild()); - break; - case FUNCTION_TAN: - value = compiler.tan(getLeftChild()); - break; - case FUNCTION_TANH: - value = compiler.tanh(getLeftChild()); - break; - case FUNCTION: { - if (variable == null) { - variable = getVariable(); - } - if (variable != null) { - if (variable instanceof FunctionDefinition) { - value = compiler.function((FunctionDefinition) variable, - getChildren()); - } else { - logger - .warn("ASTNode of type FUNCTION but the variable is not a FunctionDefinition! (" - + getName() - + ", " - + getParentSBMLObject() - + ")"); - throw new SBMLException( - "ASTNode of type FUNCTION but the variable is not a FunctionDefinition! (" - + getName() + ", " + getParentSBMLObject() - + ")"); - // value = compiler.compile(variable); - } - } else { - logger.warn(String.format( - "ASTNode of type FUNCTION but the variable is null: (%s, %s)! Check that your object is linked to a Model.", - getName(), getParentSBMLObject())); - value = compiler.function(getName(), getChildren()); - } - break; - } - case FUNCTION_PIECEWISE: - value = compiler.piecewise(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case LAMBDA: - value = compiler.lambda(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - /* - * Logical and relational functions - */ - case LOGICAL_AND: - value = compiler.and(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case LOGICAL_XOR: - value = compiler.xor(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case LOGICAL_OR: - value = compiler.or(getChildren()); - value.setUIFlag(getChildCount() <= 1); - break; - case LOGICAL_NOT: - value = compiler.not(getLeftChild()); - break; - case RELATIONAL_EQ: - value = compiler.eq(getLeftChild(), getRightChild()); - break; - case RELATIONAL_GEQ: - value = compiler.geq(getLeftChild(), getRightChild()); - break; - case RELATIONAL_GT: - value = compiler.gt(getLeftChild(), getRightChild()); - break; - case RELATIONAL_NEQ: - value = compiler.neq(getLeftChild(), getRightChild()); - break; - case RELATIONAL_LEQ: - value = compiler.leq(getLeftChild(), getRightChild()); - break; - case RELATIONAL_LT: - value = compiler.lt(getLeftChild(), getRightChild()); - break; - default: // UNKNOWN: - value = compiler.unknownValue(); - break; - } - value.setType(getType()); - MathContainer parent = getParentSBMLObject(); - if (parent != null) { - value.setLevel(parent.getLevel()); - value.setVersion(parent.getVersion()); - } - return value; - } - - /** - * Returns true or false depending on whether this - * {@link ASTNode} refers to elements such as parameters or numbers with - * undeclared units. - * - * A return value of true indicates that the UnitDefinition - * returned by {@link Variable#getDerivedUnitDefinition()} may not accurately - * represent the units of the expression. - * - * @return true if the math expression of this {@link ASTNode} - * includes parameters/numbers with undeclared units, - * false otherwise. - */ - public boolean containsUndeclaredUnits() { - if (isLeaf()) { - if (isNumber() || isRational() || isUnknown()) { - return true; - } - if (isString()) { - if ((type == Type.NAME_TIME) && (isSetParentSBMLObject())) { - Model model = getParentSBMLObject().getModel(); - if ((model != null) && model.isSetTimeUnits()) { - return false; - } - } else if ((type == Type.NAME_AVOGADRO) || (getVariable() != null) - && (!getVariable().containsUndeclaredUnits())) { - return false; - } - return true; - } - } else { - for (ASTNode child : getListOfNodes()) { - if (child.containsUndeclaredUnits()) { - return true; - } - } - } - return false; - } - - /** - * Evaluates recursively this ASTNode and creates a new UnitDefinition with - * respect of all referenced elements. - * - * @return the derived unit of the node. - * @throws SBMLException - * if they are problems going through the ASTNode tree. - */ - public UnitDefinition deriveUnit() throws SBMLException { - MathContainer container = getParentSBMLObject(); - int level = -1; - int version = -1; - if (container != null) { - level = container.getLevel(); - version = container.getVersion(); - } - return compile(new UnitsCompiler(level, version)).getUnits().simplify(); - } - - /** - * Divides this node by the given node - * - * @param ast - * an ASTNode - * @return the current node for convenience. - */ - public ASTNode divideBy(ASTNode ast) { - arithmeticOperation(Type.DIVIDE, ast); - return this; - } - - /** - * Divides this node by the given SBML element. - * - * @param namedSBase - * an SBML element that can be represented by a value. - * @return the current node for convenience. - */ - public ASTNode divideBy(CallableSBase namedSBase) { - return divideBy(new ASTNode(namedSBase, getParentSBMLObject())); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equal = super.equals(object); - if (equal) { - ASTNode ast = (ASTNode) object; - equal &= ast.getType() == type; - - if (isInteger() && ast.isInteger()) { - equal &= ast.getInteger() == getInteger(); - } - if (isString() && ast.isString()) { - equal &= ast.isSetName() == isSetName(); - if (equal && isSetName()) { - equal &= ast.getName().equals(getName()); - } - } - if (isRational() && ast.isRational()) { - equal &= ast.getNumerator() == getNumerator() - && ast.getDenominator() == getDenominator(); - } - if ((ast.getType() == Type.REAL_E) && (type == Type.REAL_E)) { - equal &= ast.getMantissa() == getMantissa() - && ast.getExponent() == getExponent(); - } else if (isReal() && ast.isReal()) { - equal &= ast.getReal() == getReal(); - } - - equal &= isSetClassName() == ast.isSetClassName(); - if (equal && isSetClassName()) { - equal &= getClassName().equals(ast.getClassName()); - } - equal &= isSetDefinitionURL() == ast.isSetDefinitionURL(); - if (equal && isSetDefinitionURL()) { - equal &= getDefinitionURL().equals(ast.getDefinitionURL()); - } - equal &= isSetEncoding() == ast.isSetEncoding(); - if (equal && isSetEncoding()) { - equal &= getEncoding().equals(ast.getEncoding()); - } - equal &= isSetId() == ast.isSetId(); - if (equal && isSetId()) { - equal &= getId().equals(ast.getId()); - } - equal &= isSetStyle() == ast.isSetStyle(); - if (equal && isSetStyle()) { - equal &= getStyle().equals(ast.getStyle()); - } - equal &= isSetUnits() == ast.isSetUnits(); - if (equal && isSetUnits()) { - equal &= getUnits().equals(ast.getUnits()); - } - } - return equal; - } - - /** - * Goes through the formula and identifies all global parameters that are - * referenced by this rate equation. - * - * @return all global parameters that are referenced by this rate equation. - */ - public List findReferencedGlobalParameters() { - LinkedList pList = new LinkedList(); - if (getType().equals(ASTNode.Type.NAME) - && (getVariable() instanceof Parameter) - && (getParentSBMLObject().getModel().getParameter( - getVariable().getId()) != null)) { - pList.add((Parameter) getVariable()); - } - for (ASTNode child : getListOfNodes()) { - pList.addAll(child.findReferencedGlobalParameters()); - } - return pList; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return !(isConstant() || isInfinity() || isNumber() || isNegInfinity() - || isNaN() || isRational()); - } - - /** - * Gets the value of this node as a single character. This function should - * be called only when ASTNode.getType() is one of PLUS, MINUS, TIMES, - * DIVIDE or POWER. - * - * @return the value of this ASTNode as a single character - * @throws IllegalArgumentException - * if the type of the node is not one of PLUS, MINUS, TIMES, - * DIVIDE or POWER. - */ - public char getCharacter() { - if (isOperator()) - switch (type) { - case PLUS: - return '+'; - case MINUS: - return '-'; - case TIMES: - return '*'; - case DIVIDE: - return '/'; - case POWER: - return '^'; - default: - break; - } - throw new IllegalArgumentException( - "getCharacter() should be called only when isOperator()."); - } - - /** - * Gets a child of this node according to an index number. - * - * @param index - * the index of the child to get - * @return the child of this {@link ASTNode} with the given index. - * @throws IndexOutOfBoundsException - * - if the index is out of range (index < 0 || index >= - * size()). - */ - public ASTNode getChild(int index) { - return listOfNodes.get(index); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int i) { - return getChild(i); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - return listOfNodes == null ? 0 : listOfNodes.size(); - } - - /** - * Returns the list of children of the current ASTNode. - * - * @return the list of children of the current ASTNode. - */ - public List getChildren() { - return listOfNodes; - } - - /** - * Returns the class name of the mathML element represented by this ASTNode. - * - * @return the class name of the mathML element represented by this ASTNode. - */ - public String getClassName() { - return className; - } - - /** - * Returns the definitionURL - * - * @return the definitionURL - */ - public String getDefinitionURL() { - return definitionURL; - } - - /** - * Gets the value of the denominator of this node. This function should be - * called only when getType() == RATIONAL, otherwise an Exception is thrown. - * - * @return the value of the denominator of this ASTNode. - * @throws IllegalArgumentException - * if the method is called on a node that is not of type - * rational. - */ - public int getDenominator() { - if (isRational()) { - return denominator; - } - throw new IllegalArgumentException( - "getDenominator() should be called only when getType() == RATIONAL."); - } - - /** - * Returns the encoding of the mathML element represented by this ASTNode. - * - * @return the encoding of the mathML element represented by this ASTNode. - */ - public String getEncoding() { - return encoding; - } - - /** - * Gets the exponent value of this ASTNode. This function should be called - * only when getType() returns REAL_E or REAL, otherwise an Exception is - * thrown. - * - * @return the value of the exponent of this ASTNode. - * @throws IllegalArgumentException - * if the method is called on a node that is not of type real. - */ - public int getExponent() { - if (type == Type.REAL || type == Type.REAL_E) { - return exponent; - } - throw new IllegalArgumentException( - "getExponent() should be called only when getType() == REAL_E or REAL"); - } - - /** - * Returns the id of the mathML element represented by this ASTNode. - * - * @return the id of the mathML element represented by this ASTNode. - */ - public String getId() { - return id; - } - - /** - * Gets the value of this node as an integer. This function should be called - * only when getType() == INTEGER, otherwise an Exception is thrown. - * - * @return the value of this ASTNode as an integer. - * @throws IllegalArgumentException - * if the node is not of type integer. - */ - public int getInteger() { - if (isInteger()) { - return numerator; - } - throw new IllegalArgumentException( - "getInteger() should be called only when getType() == INTEGER"); - } - - /** - * Gets the left child of this node. - * - * @return the left child of this ASTNode. This is equivalent to - * getChild(0); - */ - public ASTNode getLeftChild() { - return getChild(0); - } - - /** - * Returns the list of children of the current ASTNode. - * - * @return the list of children of the current ASTNode. - */ - public List getListOfNodes() { - return listOfNodes; - } - - /** - * Returns the list of children of the current ASTNode that satisfy the - * given filter. - * - * @param filter - * @return the list of children of the current ASTNode that satisfy the - * given filter. - */ - public List getListOfNodes(Filter filter) { - ArrayList filteredList = new ArrayList(); - - for (ASTNode node : listOfNodes) { - if (filter.accepts(node)) { - filteredList.add(node); - } - } - - return filteredList; - } - - /** - * Gets the mantissa value of this node. This function should be called only - * when getType() returns REAL_E or REAL, otherwise an Exception is thrown. - * If getType() returns REAL, this method is identical to getReal(). - * - * @return the value of the mantissa of this ASTNode. - */ - public double getMantissa() { - if ((type == Type.REAL) || type == Type.REAL_E) { - return mantissa; - } - throw new IllegalArgumentException( - "getMantissa() should be called only when getType() == REAL or REAL_E"); - } - - /** - * Gets the name of this node. This method may be called on nodes that are - * not operators (isOperator() == false) or numbers (isNumber() == false). - * - * @return the name of this node. - * @throws IllegalArgumentException - * if the method is called on nodes that are operators or - * numbers. - */ - public String getName() { - if (!isOperator() && !isNumber()) { - return (variable == null) ? name : variable.getId(); - } - throw new IllegalArgumentException( - "getName() should be called only when !isNumber() && !isOperator()"); - } - - /** - * Gets the value of the numerator of this node. This method should be - * called only when getType() == RATIONAL, otherwise an Exception is thrown. - * - * - * @return the value of the numerator of this ASTNode. - * @throws IllegalArgumentException - * if this method is called on a node type other than rational. - */ - public int getNumerator() { - if (isRational()) { - return numerator; - } - throw new IllegalArgumentException( - "getNumerator() should be called only when isRational()"); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getParent() - */ - @Override - public ASTNode getParent() { - return (ASTNode) parent; - } - - /** - * This method is convenient when holding an object nested inside other - * objects in an SBML model. It allows direct access to the - * {@link MathContainer}; element containing it. From this - * {@link MathContainer} even the overall {@link Model} can be accessed. - * - * @return Returns the parent SBML object. - */ - public MathContainer getParentSBMLObject() { - return parentSBMLObject; - } - - /** - * Gets the real-numbered value of this node. This function should be called - * only when isReal() == true, otherwise and Exception is thrown. - * - * This function performs the necessary arithmetic if the node type is - * REAL_E (mantissa^exponent) or RATIONAL (numerator / denominator). - * - * @return the value of this ASTNode as a real (double). - * @throws IllegalArgumentException - * if this node is not of type real. - */ - public double getReal() { - if (isReal() || (type == Type.CONSTANT_E) || (type == Type.CONSTANT_PI) || (type == Type.NAME_AVOGADRO)) { - switch (type) { - case NAME_AVOGADRO: - // TODO: in case that there will be different values for this constant in later versions, we will need a LV check here. - return Maths.AVOGADRO_L3V1; - case REAL: - return mantissa; - case REAL_E:{ - // mantissa * Math.pow(10, getExponent())) ==> this formula does not give exact values. - // for example : mantissa = 3.0, exponent = -17 ==> 2.9999999999999994E-17 instead of 3.0E-17 - return Double.parseDouble(mantissa + "E" + getExponent()); - } - case RATIONAL: - // One cast is enough; we don't need to cast twice here. - return ((double) getNumerator()) / getDenominator(); - case CONSTANT_E: - return Math.E; - case CONSTANT_PI: - return Math.PI; - default: - break; - } - } else if (isInteger()) { - return getInteger(); - } - throw new IllegalArgumentException( - "getReal() should be called only when isReal() returns true."); - } - - /** - * Returns a set of all the {@link NamedSBase} referenced on this node and - * all his descendant. - * - * Just for testing purposes... - * - * @return a set of all the {@link NamedSBase} referenced on this node and - * all his descendant. - */ - public Set getReferencedNamedSBases() { - Set l = new HashSet(); - if (isString()) { - if (getVariable() != null) { - l.add(getVariable()); - } else { - System.err.printf( - "Name of this node is %s but no variable is set.\n", - getName()); - } - } - for (ASTNode child : listOfNodes) { - l.addAll(child.getReferencedNamedSBases()); - } - return l; - } - - /** - * Returns the last child in the list of children of this node. - * - * @return This is equivalent to calling - * getListOfNodes().getLast(). - */ - public ASTNode getRightChild() { - return listOfNodes.getLast(); - } - - /** - * Returns the style of the mathML element represented by this ASTNode. - * - * @return the style of the mathML element represented by this ASTNode. - */ - public String getStyle() { - return style; - } - - /** - * Returns the type of this node. - * - * @return the type of this node. - */ - public Type getType() { - return type; - } - - /** - * Returns the units attribute. - * - * @return the units attribute. - */ - public String getUnits() { - return unitId; - } - - /** - * Creates or obtains a {@link UnitDefinition} corresponding to the unit - * that has been set for this {@link ASTNode} and returns a pointer to it. - * Note that in case that this {@link ASTNode} is associated with a - * {@link Kind}, the created {@link UnitDefinition} will not be part of the - * model, it is just a container for the {@link Kind}. - * - * @return A {@link UnitDefinition} or null. - */ - public UnitDefinition getUnitsInstance() { - MathContainer parent = getParentSBMLObject(); - int level = parent != null ? parent.getLevel() : -1; - int version = parent != null ? parent.getVersion() : -1; - if (!isSetUnits() || (getParentSBMLObject() == null)) { - if (isName()) { - CallableSBase variable = getVariable(); - if (variable != null) { - return variable.getDerivedUnitDefinition(); - } else if (isConstant()) { - UnitDefinition ud = new UnitDefinition(level, level); - ud.addUnit(Unit.Kind.DIMENSIONLESS); - return ud; - } - } - return null; - } - if (Unit.Kind.isValidUnitKindString(getUnits(), level, version)) { - return UnitDefinition.getPredefinedUnit(getUnits(), level, version); - } else if (getParentSBMLObject().getModel() == null) { - return null; - } - return getParentSBMLObject().getModel().getUnitDefinition(getUnits()); - } - - /** - * Returns the variable of this node. This function should be called only - * when {@link #isString()} == true, otherwise and Exception is thrown. - * - * @return the variable of this node - * @throws IllegalArgumentException - * if {@link #isString()} returns false. - */ - public CallableSBase getVariable() { - if ((type == Type.NAME) || (type == Type.FUNCTION)) { - if ((variable == null) && (getParentSBMLObject() != null)) { - if (getParentSBMLObject() instanceof KineticLaw) { - variable = ((KineticLaw) getParentSBMLObject()) - .getLocalParameter(getName()); - } - if (variable == null) { - Model m = getParentSBMLObject().getModel(); - if (m != null) { - variable = m.findCallableSBase(getName()); - if (variable instanceof LocalParameter) { - // in this case the parameter originates from a - // different kinetic law. - variable = null; - } else if (variable == null) { - /* - * Possibly the name is just from the argument list - * of some function definition. Hence, it won't be - * possible to determine an element with the same - * identifier within the model. In this case, this - * warning is kind of senseless. - */ - logger.debug(String.format( - "This ASTNode with name '%s' is not linked to the model, the variable attribute is left to null!", - getName())); - } - } else { - logger.debug(String.format( - "This ASTNode is not yet linked to a model and can therefore not determine its variable '%s'.", - getName())); - } - } - } - return variable; - } - throw new IllegalArgumentException("getVariable() should be called only when isName() == true."); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 787; - int hashCode = super.hashCode(); - hashCode += prime * getType().hashCode(); - if (isInteger()) { - hashCode += prime * getInteger(); - } else if (!isNumber() && !isOperator() && (isSetName() || (variable != null))) { - hashCode += prime * getName().hashCode(); - } else if (isRational()) { - hashCode += prime * getNumerator() + prime * getDenominator(); - } else if (isReal()) { - hashCode += prime * getReal(); - } - if (isSetDefinitionURL()) { - hashCode += prime * getDefinitionURL().hashCode(); - } - if (isSetEncoding()) { - hashCode += prime * getEncoding().hashCode(); - } - if (isSetId()) { - hashCode += prime * getId().hashCode(); - } - if (isSetStyle()) { - hashCode += prime * getStyle().hashCode(); - } - if (isSetClassName()) { - hashCode += prime * getClassName().hashCode(); - } - return hashCode; - } - - /** - * Returns true if the current ASTNode or any of his descendant has a unit - * defined. - * - * @return true if the current ASTNode or any of his descendant has a unit - * defined. - */ - public boolean hasUnits() { - boolean hasUnits = isSetUnits(); - - if (!hasUnits) { - for (ASTNode child : getChildren()) { - hasUnits = child.hasUnits(); - if (hasUnits) { - break; - } - } - } - - return hasUnits; - } - - /** - * Initializes the default values/attributes of the node. - * - */ - private void initDefaults() { - ASTNode old = this; - logger.debug("initDefaults called !! type was " + (type == null ? Type.UNKNOWN : type)); - - type = Type.UNKNOWN; - - id = null; - style = null; - className = null; - encoding = null; - denominator = 0; - exponent = 0; - name = null; - numerator = 0; - // parent = null; // don't remove this node from the tree - isSetNumberType = false; - definitionURL = null; - unitId = null; - - if (listOfNodes == null) { - listOfNodes = new LinkedList(); - } else { - listOfNodes.clear(); - } - variable = null; - mantissa = Double.NaN; - this.firePropertyChange(TreeNodeChangeEvent.initialValue, old, this); - } - - /** - * Inserts the given ASTNode at point n in the list of children of this - * ASTNode. Inserting a child within an ASTNode may result in an inaccurate - * representation. - * - * @param n - * long the index of the ASTNode being added - * @param newChild - * ASTNode to insert as the nth child - */ - public void insertChild(int n, ASTNode newChild) { - listOfNodes.add(n, newChild); - newChild.fireNodeAddedEvent(); - } - - /** - * Returns true if this node has a boolean type (a logical operator, a - * relational operator, or the constants true or false). - * - * @return true if this ASTNode is a boolean, false otherwise. - */ - public boolean isBoolean() { - return type == Type.CONSTANT_FALSE || type == Type.CONSTANT_TRUE - || isLogical() || isRelational(); - } - - /** - * Returns true if this node represents a MathML constant (e.g., true, Pi). - * - * @return true if this ASTNode is a MathML constant, false otherwise. - */ - public boolean isConstant() { - return type.toString().startsWith("CONSTANT") - || type == Type.NAME_AVOGADRO; - } - - /** - * Checks if this {@link ASTNode} represents a difference. - * - * @return true if this {@link ASTNode} represents a difference, false - * otherwise. - */ - public boolean isDifference() { - return type == Type.MINUS; - } - - /** - * Returns true if this node represents a function. In this context, the - * term function means pre-defined functions such as "ceil", "abs" or "sin" - * or whether this {@link ASTNode} refers to a user-defined - * {@link FunctionDefinition} object. Without having a valid reference to - * the {@link MathContainer} that owns this {@link ASTNode} it is impossible - * to identify the referenced {@link FunctionDefinition}. - * - * @return true if this {@link ASTNode} is a function, false otherwise. - */ - public boolean isFunction() { - return type.toString().startsWith("FUNCTION"); - } - - /** - * Returns true if this node represents the special IEEE 754 value infinity, - * false otherwise. - * - * @return true if this ASTNode is the special IEEE 754 value infinity, - * false otherwise. - */ - public boolean isInfinity() { - if (isReal()) { - double real = getReal(); - return Double.isInfinite(real) && (real > 0d); - } - return false; - } - - /** - * Returns true if this node contains an integer value, false otherwise. - * - * @return true if this ASTNode is of type INTEGER, false otherwise. - */ - public boolean isInteger() { - return type == Type.INTEGER; - } - - /** - * Returns true if this node is a MathML <lambda>, false otherwise. - * - * @return true if this ASTNode is of type LAMBDA, false otherwise. - */ - public boolean isLambda() { - return type == Type.LAMBDA; - } - - /** - * Returns true if this node represents a log10() function, false otherwise. - * More precisely, this predicate returns true if the node type is - * FUNCTION_LOG with two children, the first of which is an INTEGER equal to - * 10. - * - * @return true if the given ASTNode represents a log10() function, false - * otherwise. - */ - public boolean isLog10() { - return type == Type.FUNCTION_LOG && listOfNodes.size() == 2 - && getLeftChild().isInteger() - && getLeftChild().getInteger() == 10; - } - - /** - * Returns true if this node is a MathML logical operator (i.e., and, or, - * not, xor). - * - * @return true if this ASTNode is a MathML logical operator. - */ - public boolean isLogical() { - return type.toString().startsWith("LOGICAL_"); - } - - /** - * Returns true if this astnode represents the number minus one (either as - * integer or as real value). - * - * @return true if this astnode represents the number minus one (either as - * integer or as real value). - */ - public boolean isMinusOne() { - return (isReal() && getReal() == -1d) - || (isInteger() && getInteger() == -1); - } - - /** - * Returns true if this node is a user-defined {@link Variable} name in SBML L1, L2 - * (MathML), or the special symbols delay or time. The predicate returns - * false otherwise. - * - * @return true if this {@link ASTNode} is a user-defined variable name in SBML L1, - * L2 (MathML) or the special symbols time or Avogadro. - */ - public boolean isName() { - return (type == Type.NAME) || (type == Type.NAME_TIME) - || (type == Type.NAME_AVOGADRO); - } - - /** - * Returns true if this node is a type Real and represents the special IEEE - * 754 value 'not a number' {@link Double#NaN}, false otherwise. - * - * @return true if this ASTNode is the {@link Double#NaN} - */ - public boolean isNaN() { - return isReal() && Double.isNaN(getReal()); - } - - /** - * Returns true if this node represents the special IEEE 754 value 'negative - * infinity' {@link Double#NEGATIVE_INFINITY}, false otherwise. - * - * @return true if this ASTNode is {@link Double#NEGATIVE_INFINITY}, false - * otherwise. - */ - public boolean isNegInfinity() { - if (isReal()) { - double real = getReal(); - return Double.isInfinite(real) && (real < 0); - } - return false; - } - - /** - * Returns true if this node contains a number, false otherwise. This is - * functionally equivalent to the following code: - * - *

-	 * isInteger() || isReal()
-	 * 
- * - * @return true if this ASTNode is a number, false otherwise. - */ - public boolean isNumber() { - return isInteger() || isReal(); - } - - /** - * Returns true if this {@link ASTNode} represents the number one (either as - * integer or as real value). - * - * @return true if this {@link ASTNode} represents the number one. - */ - public boolean isOne() { - return (isReal() && getReal() == 1d) - || (isInteger() && getInteger() == 1); - } - - /** - * Returns true if this node is a mathematical operator, meaning, +, -, *, / - * or ^ (power). - * - * @return true if this ASTNode is an operator. - */ - public boolean isOperator() { - return type == Type.PLUS || type == Type.MINUS || type == Type.TIMES - || type == Type.DIVIDE || type == Type.POWER; - } - - /** - * Returns true if this node is the MathML <piecewise> construct, - * false otherwise. - * - * @return true if this ASTNode is a MathML piecewise function - */ - public boolean isPiecewise() { - return type == Type.FUNCTION_PIECEWISE; - } - - /** - * Returns true if this node represents a rational number, false otherwise. - * - * @return true if this ASTNode is of type {@link Type#RATIONAL}. - */ - public boolean isRational() { - return type == Type.RATIONAL; - } - - /** - * Returns true if this node can represent a real number, false otherwise. - * More precisely, this node must be of one of the following types: REAL, - * REAL_E or RATIONAL. - * - * @return true if the value of this ASTNode can represented a real number, - * false otherwise. - */ - public boolean isReal() { - return type == Type.REAL || type == Type.REAL_E - || type == Type.RATIONAL; - } - - /** - * Returns true if this node is a MathML relational operator, meaning ==, - * >=, >, <, and !=. - * - * @return true if this ASTNode is a MathML relational operator, false - * otherwise. - */ - public boolean isRelational() { - return type == Type.RELATIONAL_EQ || type == Type.RELATIONAL_GEQ - || type == Type.RELATIONAL_GT || type == Type.RELATIONAL_LEQ - || type == Type.RELATIONAL_LT || type == Type.RELATIONAL_NEQ; - } - - /** - * @return - */ - public boolean isSetClassName() { - return className != null; - } - - /** - * @return - */ - public boolean isSetDefinitionURL() { - return definitionURL != null; - } - - /** - * @return - */ - public boolean isSetEncoding() { - return encoding != null; - } - - /** - * @return - */ - public boolean isSetId() { - return id != null; - } - - /** - * @return - */ - public boolean isSetName() { - return name != null; - } - - /** - * Returns true if the number type is set. - * - * @return true if the number type is set. - */ - public boolean isSetNumberType() { - return isSetNumberType; - } - - /** - * Checks if a parent SBML object, i.e., a {@link MathContainer}, is set as a - * parent SBML object for this {@link ASTNode}. - * - * @return - */ - public boolean isSetParentSBMLObject() { - return parentSBMLObject != null; - } - - /** - * @return - */ - public boolean isSetStyle() { - return style != null; - } - - /** - * Returns true if a unit is defined on this node. - * - * @return true if a unit is defined on this node. - */ - public boolean isSetUnits() { - return unitId != null; - } - - /** - * Returns true if this node represents a square root function, false - * otherwise. - * - * More precisely, the node type must be {@link Type#FUNCTION_ROOT} with two - * children, the first of which is an {@link Type#INTEGER} node having value - * equal to 2. - * - * @return true if the given ASTNode represents a sqrt() function, false - * otherwise. - */ - public boolean isSqrt() { - return type == Type.FUNCTION_ROOT && listOfNodes.size() == 2 - && getLeftChild().isInteger() - && getLeftChild().getInteger() == 2; - } - - /** - * Returns true if this node is a name or refers to a - * {@link FunctionDefinition}. - * - * @return true if this {@link ASTNode} is a user-defined variable name in SBML L1, - * L2 (MathML) or the special symbols time or Avogadro. - * @see #isName() - */ - public boolean isString() { - return isName() || (type == Type.FUNCTION); - } - - /** - * Checks if this {@link ASTNode} represents a sum. - * - * @return true if this {@link ASTNode} represents a sum, false otherwise. - */ - public boolean isSum() { - return type == Type.PLUS; - } - - /** - * Returns true if this node is a unary minus operator, false otherwise. A - * node is defined as a unary minus node if it is of type MINUS and has - * exactly one child. - * - * For numbers, unary minus nodes can be 'collapsed' by negating the number. - * In fact, SBML_parseFormula() does this during its parse. However, unary - * minus nodes for symbols (NAMES) cannot be 'collapsed', so this predicate - * function is necessary. - * - * @return true if this ASTNode is a unary minus, false otherwise. - */ - public boolean isUMinus() { - return (type == Type.MINUS) && (getChildCount() == 1); - } - - /** - * Checks whether the number of child nodes is exactly one. - * - * @return true if the number of child nodes is exactly one. - */ - public boolean isUnary() { - return getChildCount() == 1; - } - - /** - * Returns true if this node has an unknown type. - * - * 'Unknown' nodes have the type UNKNOWN. Nodes with unknown types will not - * appear in an ASTNode tree returned by libSBML based upon valid SBML - * input; the only situation in which a node with type UNKNOWN may appear is - * immediately after having create a new, untyped node using the ASTNode - * constructor. Callers creating nodes should endeavor to set the type to a - * valid node type as soon as possible after creating new nodes. - * - * @return true if this ASTNode is of type UNKNOWN, false otherwise. - */ - public boolean isUnknown() { - return type == Type.UNKNOWN; - } - - /** - * Returns true if this node represents the number zero (either as integer - * or as real value). - * - * @return true if this node represents the number zero. - */ - public boolean isZero() { - return (isReal() && getReal() == 0d) - || (isInteger() && getInteger() == 0); - } - - /** - * Subtracts the given ASTNode from this node. - * - * @param ast - * an ASTNode - * @return the current node for convenience. - */ - public ASTNode minus(ASTNode ast) { - arithmeticOperation(Type.MINUS, ast); - return this; - } - - /** - * Subtracts the given number from this node. - * - * @param real - * a double number. - * @return the current node for convenience. - */ - public ASTNode minus(double real) { - minus(new ASTNode(real, getParentSBMLObject())); - return this; - } - - /** - * Subtracts the given integer from this node. - * - * @param integer - * an integer number. - * @return the current node for convenience. - */ - public ASTNode minus(int integer) { - return minus(integer, null); - } - - /** - * - * @param integer - * @param unitsID - * @return - */ - public ASTNode minus(int integer, String unitsID) { - minus(new ASTNode(integer, unitsID, getParentSBMLObject())); - return this; - } - - /** - * Multiplies this ASTNode with the given node - * - * @param ast - * an ASTNode - * @return the current node for convenience. - */ - public ASTNode multiplyWith(ASTNode ast) { - arithmeticOperation(Type.TIMES, ast); - return this; - } - - /** - * Multiplies this ASTNode with the given nodes, i.e., all given nodes will - * be children of this node, whose type will be set to {@link Type#TIMES}. - * - * @param nodes - * some ASTNode - * @return The current node for convenience. - */ - public ASTNode multiplyWith(ASTNode... nodes) { - for (ASTNode node : nodes) { - multiplyWith(node); - } - reduceToBinary(); - return this; - } - - /** - * Multiplies this ASTNode with the given SBML element. - * - * @param nsb - * an SBML element that can be represented by a value. - * @return the current node for convenience. - */ - public ASTNode multiplyWith(CallableSBase nsb) { - return multiplyWith(new ASTNode(nsb, getParentSBMLObject())); - } - - /** - * Adds a given node to this node. - * - * @param ast - * an ASTNode - * @return the current node for convenience. - */ - public ASTNode plus(ASTNode ast) { - arithmeticOperation(Type.PLUS, ast); - return this; - } - - /** - * Adds an SBML element to this node. - * - * @param nsb - * an SBML element that can be represented by a value. - * @return the current node for convenience. - */ - public ASTNode plus(CallableSBase nsb) { - plus(new ASTNode(nsb, getParentSBMLObject())); - return this; - } - - /** - * Adds a number to this node. - * - * @param real - * a double number. - * @return the current node for convenience. - */ - public ASTNode plus(double real) { - plus(new ASTNode(real, getParentSBMLObject())); - return this; - } - - /** - * Adds an integer number to this node. - * - * @param integer - * an integer number. - * @return the current node for convenience. - */ - public ASTNode plus(int integer) { - plus(new ASTNode(integer, getParentSBMLObject())); - return this; - } - - /** - * Adds the given node as a child of this ASTNode. This method adds child - * nodes from right to left. - * - * @param child - * an ASTNode - */ - public void prependChild(ASTNode child) { - listOfNodes.addLast(child); - child.fireNodeAddedEvent(); - } - - /** - * Raises this ASTNode by the power of the value of the given node. - * - * @param exponent - * an ASTNode - * @return the current node for convenience. - */ - public ASTNode raiseByThePowerOf(ASTNode exponent) { - arithmeticOperation(Type.POWER, exponent); - return this; - } - - /** - * Raises this ASTNode by the power of the value of this named SBase object. - * - * @param nsb - * an SBML element that can be represented by a value. - * @return the current node for convenience. - */ - public ASTNode raiseByThePowerOf(CallableSBase nsb) { - return raiseByThePowerOf(new ASTNode(nsb, getParentSBMLObject())); - } - - /** - * Raises this ASTNode by the power of the given number. - * - * @param exponent - * a double number. - * @return the current node for convenience. - */ - public ASTNode raiseByThePowerOf(double exponent) { - if (exponent == 0d) { - // Clear list of nodes first because this won't notify any listeners. - listOfNodes.clear(); - // This will notify listeners that will receive this ASTNode with an empty list of children. - setValue(1); - // The units of this ASTNode must be dimensionless now. - if (isSetParentSBMLObject() && (getParentSBMLObject().getLevel() > 2)) { - setUnits(Unit.Kind.DIMENSIONLESS.toString().toLowerCase()); - } - } else if (exponent != 1d) { - return raiseByThePowerOf(new ASTNode(exponent, getParentSBMLObject())); - } - return this; - } - - /** - * Reduces this ASTNode to a binary tree, e.g., if the formula in this - * ASTNode is and(x, y, z) then the formula of the reduced node would be - * and(and(x, y), z) - * - * NotYetImplemented - */ - // TODO : should we return an exception to tell people that the method is - // not complete ? - private void reduceToBinary() { - if (getChildCount() > 2) { - int i; - switch (type) { - case PLUS: - ASTNode plus = new ASTNode(Type.PLUS, parentSBMLObject); - for (i = getChildCount() - 1; i > 0; i--) { - plus.addChild(listOfNodes.remove(i)); - } - addChild(plus); - break; - case MINUS: - // TODO - break; - case TIMES: - ASTNode times = new ASTNode(Type.TIMES, parentSBMLObject); - for (i = getChildCount() - 1; i > 0; i--) { - times.addChild(listOfNodes.remove(i)); - } - addChild(times); - // if (getLeftChild().isMinusOne() || - // getRightChild().isMinusOne()) { - // TODO - // } - break; - case DIVIDE: - // TODO - break; - case LOGICAL_AND: - ASTNode and = new ASTNode(Type.LOGICAL_AND, parentSBMLObject); - for (i = getChildCount() - 1; i > 0; i--) { - and.addChild(listOfNodes.remove(i)); - } - addChild(and); - break; - case LOGICAL_OR: - ASTNode or = new ASTNode(Type.LOGICAL_OR, parentSBMLObject); - for (i = getChildCount() - 1; i > 0; i--) { - or.addChild(listOfNodes.remove(i)); - } - addChild(or); - break; - case LOGICAL_NOT: - // TODO - break; - case LOGICAL_XOR: - // TODO - break; - default: - // TODO - break; - } - } - // recursively restructure this tree. - for (ASTNode child : listOfNodes) { - child.reduceToBinary(); - } - } - - /** - * Returns true if this node or one of its descendants contains some - * identifier with the given id. This method can be used to scan a formula - * for a specific parameter or species and detect whether this component is - * used by this formula. This search is done using a DFS. - * - * @param id - * the id of an SBML element. - * @return true if this node or one of its descendants contains the given - * id. - */ - public boolean refersTo(String id) { - if (isString() && (getName() != null) && getName().equals(id)) { - return true; - } - boolean childContains = false; - for (ASTNode child : listOfNodes) { - childContains |= child.refersTo(id); - } - return childContains; - } - - /** - * Removes child n of this ASTNode. Removing a child from an ASTNode may - * result in an inaccurate representation. - * - * @param n - * the index of the child to remove - * @return boolean indicating the success or failure of the operation - * - */ - public boolean removeChild(int n) { - if ((listOfNodes.size() > n) && (n >= 0)) { - ASTNode removed = listOfNodes.remove(n); - removed.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Replaces occurrences of a name within this ASTNode with the - * name/value/formula represented by the second argument ASTNode, e.g., if - * the formula in this ASTNode is x + y; bvar is x and arg is an ASTNode - * representing the real value 3 ReplaceArgument substitutes 3 for x within - * this ASTNode. - * - * @param bvar - * a string representing the variable name to be substituted - * @param arg - * an ASTNode representing the name/value/formula to substitute - */ - public void replaceArgument(String bvar, ASTNode arg) { - int n = 0; - for (ASTNode child : listOfNodes) { - if (child.isString() && child.getName().equals(bvar)) { - replaceChild(n, arg.clone()); - } else if (child.getChildCount() > 0) { - child.replaceArgument(bvar, arg); - } - n++; - } - } - - /** - * Replaces the nth child of this ASTNode with the given ASTNode. - * - * @param n - * long the index of the child to replace - * @param newChild - * ASTNode to replace the nth child - * @return the element previously at the specified position - */ - public ASTNode replaceChild(int n, ASTNode newChild) { - setParentSBMLObject(newChild, parentSBMLObject, 0); - newChild.parent = this; - return listOfNodes.set(n, newChild); - } - - /** - * Sets the value of this ASTNode to the given character. If character is - * one of +, -, *, / or ^, the node type will be set accordingly. For all - * other characters, the node type will be set to UNKNOWN. - * - * @param value - * the character value to which the node's value should be set. - */ - public void setCharacter(char value) { - Type oldValue = this.type; - switch (value) { - case '+': - type = Type.PLUS; - break; - case '-': - type = Type.MINUS; - break; - case '*': - type = Type.TIMES; - break; - case '/': - type = Type.DIVIDE; - break; - case '^': - type = Type.POWER; - break; - default: - type = Type.UNKNOWN; - break; - } - this.firePropertyChange(TreeNodeChangeEvent.value, oldValue, type); - } - - /** - * Sets the class name of the mathML element represented by this ASTNode. - * - * @param className - * the class name. - */ - public void setClassName(String className) { - String oldValue = this.className; - this.className = className; - this.firePropertyChange(TreeNodeChangeEvent.className, oldValue, className); - } - - /** - * - * @param definitionURL - */ - public void setDefinitionURL(String definitionURL) { - String oldValue = this.definitionURL; - this.definitionURL = definitionURL; - this.firePropertyChange(TreeNodeChangeEvent.definitionURL, oldValue, definitionURL); - } - - /** - * Sets the encoding of the mathML element represented by this ASTNode. - * - * @param encoding - * the encoding - */ - public void setEncoding(String encoding) { - String oldValue = this.encoding; - this.encoding = encoding; - this.firePropertyChange(TreeNodeChangeEvent.encoding, oldValue, encoding); - } - - /** - * Sets the id of the mathML element represented by this ASTNode. - * - * @param id - * the id. - */ - public void setId(String id) { - String oldValue = this.id; - this.id = id; - this.firePropertyChange(TreeNodeChangeEvent.id, oldValue, id); - } - - /** - * - * @param isSetNumberType - */ - public void setIsSetNumberType(boolean isSetNumberType) { - Boolean oldValue = this.isSetNumberType; - this.isSetNumberType = isSetNumberType; - this.firePropertyChange(TreeNodeChangeEvent.isSetNumberType, oldValue, isSetNumberType); - } - - /** - * Sets the value of this ASTNode to the given name. - * - * The node type will be set (to NAME) only if the ASTNode was previously an - * operator (isOperator(node) == true) or number (isNumber(node) == true). - * This allows names to be set for FUNCTIONs and the like. - * - * @param name - */ - // TODO : javadoc not synchronized with the code, we are not using - // isOperator() or isNumber() but may be we should. - public void setName(String name) { - String oldValue = this.name; - this.name = name; - this.firePropertyChange(TreeNodeChangeEvent.name, oldValue, name); - if ((!type.toString().startsWith("NAME")) && type != Type.FUNCTION - && type != Type.FUNCTION_DELAY) - { - Type oldType = this.type; - type = variable == null ? Type.FUNCTION : Type.NAME; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, type); - } - } - - /** - * Sets the style of the mathML element represented by this ASTNode. - * - * @param style - * the style. - */ - public void setStyle(String style) { - String oldValue = this.style; - this.style = style; - this.firePropertyChange(TreeNodeChangeEvent.style, oldValue, style); - } - - /** - * Sets the type from a String. The method accept all the supported mathML - * elements, the possible types of cn elements or the possible definitionURL - * of csymbol elements. - * - * @param typeStr - * the type as a String. - */ - public void setType(String typeStr) { - // System.out.println("ASTNode : setType(String) called."); - Type type = Type.getTypeFor(typeStr); - setType(type); - if (type != Type.UNKNOWN) { - if (type == Type.REAL) { - if (typeStr.equals("notanumber")) { - setValue(Double.NaN); - } else if (typeStr.equals("infinity")) { - setValue(Double.POSITIVE_INFINITY); - } - } - } - } - - /** - * Sets the type of this ASTNode to the given Type. A side-effect of doing - * this is that any numerical values previously stored in this node are - * reset to zero. - * - * @param type - * the type to which this node should be set - */ - // TODO : javadoc not synchronized, we are not reseting previously stored - // values but we are modifying the name. - // TODO : we should probably simplify the code to avoid future problems - public void setType(Type type) { - - // TODO : check that the calls to initDefaults() do not delete anything - // important when reading the XML file, see MathMLStaxParser.java - // System.out.println("ASTNode : setType(Type) called : type = " + - // type); - - String sType = type.toString(); - - logger.debug("setType called : typeBefore = " + this.type + " typeAfter= " + sType); - - if (sType.startsWith("NAME") || sType.startsWith("CONSTANT")) { - // TODO : check, a user might have set some values before calling - // the setType() - initDefaults(); - } - // TODO : setting the name should not be necessary and a user could have - // set a name before calling setType - if (type == Type.NAME_TIME) { - name = "time"; - definitionURL = URI_TIME_DEFINITION; - } else if (type == Type.FUNCTION_DELAY) { - initDefaults(); - name = "delay"; - definitionURL = URI_DELAY_DEFINITION; - } else if (type == Type.NAME_AVOGADRO) { - initDefaults(); - name = "Avogadro's number"; - setValue(6.02214179e23); - definitionURL = URI_AVOGADRO_DEFINITION; - } - Type oldValue = this.getType(); - this.type = type; - this.firePropertyChange(TreeNodeChangeEvent.type, oldValue, type); - } - - /** - * Sets the units attribute. - * - * @param unitId - * @throws IllegalArgumentException - * if the ASTNode is not a kind of numbers (<cn> in mathml) or - * if the unitId is not a valid unit kind or the id - * of a unit definition. - */ - public void setUnits(String unitId) { - if (!isNumber()) { - throw new IllegalArgumentException(MessageFormat.format( - "Unexpected attribute {0}, only literal numbers can defined a unit.", - unitId)); - } - if (parentSBMLObject != null) { - if (!Unit.isValidUnit(parentSBMLObject.getModel(), unitId)) { - throw new IllegalArgumentException(MessageFormat.format( - "Unexpected attribute {0}, only a valid unit kind or the identifier of a unit definition are allowed here.", - unitId)); - } - if (parentSBMLObject.isSetLevel() && (parentSBMLObject.getLevel() < 3)) { - throw new IllegalArgumentException(MessageFormat.format( - "Cannot set unit {0} for a numbers in an ASTNode before SBML Level 3.", - unitId)); - } - } - String oldValue = this.unitId; - this.unitId = unitId; - this.firePropertyChange(TreeNodeChangeEvent.units, oldValue, unitId); - } - - /** - * Sets the value of this ASTNode to the given double number and sets the - * node type to REAL. - * - * This is functionally equivalent to: - * - *
-	 * setValue(value, 0);
-	 * 
- * - * @param value - * the double format number to which this node's value should be - * set - */ - public void setValue(double value) { - Type oldType = this.type; - double oldMantissa = this.mantissa; - int oldExponent = this.exponent; - type = Type.REAL; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, type); - this.mantissa = value; - this.firePropertyChange(TreeNodeChangeEvent.mantissa, oldMantissa, mantissa); - this.exponent = 0; - this.firePropertyChange(TreeNodeChangeEvent.exponent, oldExponent, exponent); - } - - /** - * Sets the value of this ASTNode to the given real (double) in two parts: - * the mantissa and the exponent. The node type is set to REAL_E. - * - * @param mantissa - * the mantissa of this node's real-numbered value - * @param exponent - * the exponent of this node's real-numbered value - */ - public void setValue(double mantissa, int exponent) { - Type oldType = this.type; - double oldMantissa = this.mantissa; - int oldExponent = this.exponent; - type = Type.REAL_E; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, type); - this.mantissa = mantissa; - this.firePropertyChange(TreeNodeChangeEvent.mantissa, oldMantissa, mantissa); - this.exponent = exponent; - this.firePropertyChange(TreeNodeChangeEvent.exponent, oldExponent, exponent); - } - - /** - * Sets the value of this ASTNode to the given (long) integer and sets the - * node type to INTEGER. - * - * @param value - */ - public void setValue(int value) { - Type oldType = this.type; - int oldNumerator = this.numerator; - int oldDenominator = this.denominator; - type = Type.INTEGER; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, type); - numerator = value; - this.firePropertyChange(TreeNodeChangeEvent.numerator, oldNumerator, numerator); - denominator = 1; - this.firePropertyChange(TreeNodeChangeEvent.denominator, oldDenominator, denominator); - } - - /** - * Sets the value of this ASTNode to the given rational in two parts: the - * numerator and denominator. The node type is set to RATIONAL. - * - * @param numerator - * the numerator value of the rational - * @param denominator - * the denominator value of the rational - */ - public void setValue(int numerator, int denominator) { - Type oldType = this.type; - int oldNumerator = this.numerator; - int oldDenominator = this.denominator; - type = Type.RATIONAL; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, type); - this.numerator = numerator; - this.firePropertyChange(TreeNodeChangeEvent.numerator, oldNumerator, numerator); - this.denominator = denominator; - this.firePropertyChange(TreeNodeChangeEvent.denominator, oldDenominator, denominator); - } - - /** - * - * @param variable - */ - public void setVariable(CallableSBase variable) { - CallableSBase oldValue = this.variable; - if (variable instanceof FunctionDefinition) { - type = Type.FUNCTION; - } else { - type = Type.NAME; - } - - this.variable = variable; - this.firePropertyChange(TreeNodeChangeEvent.variable, oldValue, variable); - } - - /** - * Applies the square root function on this syntax tree and returns the - * resulting tree. - * - * @return the current node for convenience. - */ - public ASTNode sqrt() { - arithmeticOperation(Type.FUNCTION_ROOT, new ASTNode(2, - getParentSBMLObject())); - return this; - } - - /** - * Swaps the children of this ASTNode with the children of that ASTNode. - * - * @param that - * the other node whose children should be used to replace this - * node's children - */ - public void swapChildren(ASTNode that) { - LinkedList swap = that.listOfNodes; - that.listOfNodes = listOfNodes; - listOfNodes = swap; - this.firePropertyChange(TreeNodeChangeEvent.childNode, that.listOfNodes, this.listOfNodes); - that.firePropertyChange(TreeNodeChangeEvent.childNode, this.listOfNodes, that.listOfNodes); - } - - /** - *

- * Converts this ASTNode to a text string using a specific syntax for - * mathematical formulas. - *

- *

- * The text-string form of mathematical formulas produced by - * formulaToString() and read by parseFormula() are simple C-inspired infix - * notation taken from SBML Level 1. A formula in this text-string form - * therefore can be handed to a program that understands SBML Level 1 - * mathematical expressions, or used as part of a formula translation - * system. The syntax is described in detail in the documentation for - * ASTNode. - *

- * - * @return the formula from the given AST as an SBML Level 1 text-string - * mathematical formula. The caller owns the returned string and is - * responsible for freeing it when it is no longer needed. NULL is - * returned if the given argument is NULL. - * @throws SBMLException - * if there is a problem in the ASTNode tree. - */ - public String toFormula() throws SBMLException { - return compile(new FormulaCompiler()).toString(); - } - - /** - * Converts this node recursively into a LaTeX formatted String. - * - * @return A String representing the LaTeX code necessary to write the - * formula corresponding to this node in a document. - * @throws SBMLException - * if there is a problem in the ASTNode tree. - */ - public String toLaTeX() throws SBMLException { - return compile(new LaTeXCompiler()).toString(); - } - - /** - * Converts this node recursively into a MathML string that corresponds to - * the subset of MathML defined in the SBML specification. - * - * @return the representation of this node in MathML. - */ - public String toMathML() { - try { - return MathMLXMLStreamCompiler.toMathML(this); - } catch (RuntimeException e) { - // added to prevent a crash when we cannot create the mathML - // TODO : log the exception - // e.printStackTrace(); - } - return ""; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - String formula = ""; - String errorMsg = "Could not compile ASTNode to formula : "; - try { - formula = compile(new FormulaCompiler()).toString(); - } catch (SBMLException e) { - // log the exception - e.printStackTrace(); - - if (logger.isDebugEnabled()) { - logger.error(errorMsg, e); - } else { - // TODO : Do not print this message if parsing the file !!! Or remove it - logger.warn(errorMsg + e.getMessage()); - } - } catch (RuntimeException e) { - // added to prevent a crash when we cannot create the formula - if (logger.isDebugEnabled()) { - logger.error(errorMsg, e); - } - } - return formula; - } - - /** - * Unset the units attribute. - * - */ - public void unsetUnits() { - String oldValue = this.unitId; - unitId = null; - this.firePropertyChange(TreeNodeChangeEvent.units, oldValue, null); - } - - /** - * For a better performance ASTNodes can store a direct pointer to a - * variable element. This is particularly useful when performing more - * complex computation on these data structures. However, if the model is - * changed, it may happen that these pointer become invalid. For instance, a - * previously local parameter may be added to the model in form of a global - * parameter while keeping the same identifier. The local parameter may then - * be removed. Whenever performing changes like this, you may want to update - * pointers within {@link ASTNode} constructs as well. - */ - public void updateVariables() { - if (isString()) { - if (variable != null) { - CallableSBase oldValue = this.getVariable(); - name = variable.getId(); - variable = null; - variable = getVariable(); - this.firePropertyChange(TreeNodeChangeEvent.variable, oldValue, variable); - } else if ((type != Type.NAME_TIME) && (type != Type.NAME_AVOGADRO)){ - // Try to register a direct link to the variable (if the name represent one). - variable = getVariable(); - } - } - for (ASTNode child : getChildren()) { - child.updateVariables(); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AbstractMathContainer.java b/IPK_lib/src/org/sbml/jsbml/AbstractMathContainer.java deleted file mode 100644 index 41e6502ed..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AbstractMathContainer.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * $Id: AbstractMathContainer.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AbstractMathContainer.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.text.parser.ParseException; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Base class for all the SBML components which contain MathML nodes. - * - * @author Andreas Dräger - * @author marine - * @since 0.8 - * @version $Rev: 1204 $ - */ -public abstract class AbstractMathContainer extends AbstractSBase implements - MathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6630349025482311163L; - /** - * A logger for user-messages. - */ - private static final Logger logger = Logger.getLogger(AbstractMathContainer.class); - - /** - * The math formula as an abstract syntax tree. - */ - private ASTNode math; - - /** - * Creates a MathContainer instance. By default, the math object is null. - */ - public AbstractMathContainer() { - super(); - math = null; - } - - /** - * Creates a MathContainer instance from a given MathContainer. - * - * @param sb an AbstractMathContainer object to clone - */ - public AbstractMathContainer(AbstractMathContainer sb) { - super(sb); - if (sb.isSetMath()) { - setMath(sb.getMath().clone()); - } else { - this.math = null; - } - } - - /** - * Creates a MathContainer instance from an ASTNode, level and version. By - * default, the math is null. - * - * @param math the ASTNode representing the math. - * @param level the SBML level - * @param version the SBML version - */ - public AbstractMathContainer(ASTNode math, int level, int version) { - super(level, version); - if (math != null) { - setMath(math.clone()); - } else { - this.math = null; - } - } - - /** - * Creates a MathContainer instance from a level and version. By default, - * the formula, math and mathBuffer are null. - * - * @param level the SBML level - * @param version the SBML version - */ - public AbstractMathContainer(int level, int version) { - super(level, version); - math = null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - public abstract AbstractMathContainer clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#containsUndeclaredUnits() - */ - public boolean containsUndeclaredUnits() { - return isSetMath() ? math.containsUndeclaredUnits() : false; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetMath()) { - if (index == pos) { - return getMath(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - @Override - public int getChildCount() { - return super.getChildCount() + (isSetMath() ? 1 : 0); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnitDefinition() - */ - public UnitDefinition getDerivedUnitDefinition() { - UnitDefinition ud = null; - if (isSetMath()) { - try { - ud = math.deriveUnit(); - } catch (Throwable exc) { - // Doesn't matter. We'll simply return an undefined unit. - String name; - if (this instanceof NamedSBase) { - name = toString(); - } else { - name = getElementName(); - SBase parent = getParentSBMLObject(); - if ((parent != null) && (parent instanceof NamedSBase)) { - name += " in " + parent.toString(); - } - } - logger.warn(MessageFormat.format( - "Could not derive unit from syntax tree of {0}: {1}", name, - exc.getLocalizedMessage())); - logger.debug(exc.getLocalizedMessage(), exc); - } - } - if (ud != null) { - Model m = getModel(); - if (m != null) - for (UnitDefinition u : m.getListOfUnitDefinitions()) { - if (UnitDefinition.areEquivalent(u, ud)) { - ud = u; - break; - } - } - } else { - ud = new UnitDefinition(getLevel(), getVersion()); - ud.addUnit(ud.createUnit()); - } - return ud; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnits() - */ - @SuppressWarnings("deprecation") - public String getDerivedUnits() { - UnitDefinition ud = getDerivedUnitDefinition(); - Model m = getModel(); - if (m != null) { - if (m.getUnitDefinition(ud.getId()) != null) - return ud.getId(); - } - if (ud.getUnitCount() == 1) { - Unit u = ud.getUnit(0); - if ((u.getOffset() == 0) && (u.getMultiplier() == 1) - && (u.getScale() == 0) && (u.getExponent() == 1)) - return u.getKind().toString(); - } - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#getFormula() - */ - @Deprecated - public String getFormula() { - try { - return isSetMath() ? getMath().toFormula() : ""; - } catch (Throwable e) { - logger.warn("Could not create infix formula from syntax tree.", e); - return "invalid"; - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#getMath() - */ - public ASTNode getMath() { - return math; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#getMathMLString() - */ - public String getMathMLString() { - if (isSetMath()) { - return math.toMathML(); - } - return ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#isSetMath() - */ - public boolean isSetMath() { - return math != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - if (attributeName.equals("formula")) { - try { - setFormula(value); - return true; - } catch (ParseException exc) { - throw new IllegalArgumentException(exc); - } - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#setFormula(java.lang.String) - */ - @Deprecated - public void setFormula(String formula) throws ParseException { - setMath(ASTNode.parseFormula(formula)); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#setMath(org.sbml.jsbml.ASTNode) - */ - public void setMath(ASTNode math) { - ASTNode oldMath = this.math; - this.math = math; - if (oldMath != null) { - oldMath.fireNodeRemovedEvent(); - } - if (this.math != null) { - ASTNode.setParentSBMLObject(math, this); - firePropertyChange(TreeNodeChangeEvent.math, oldMath, this.math); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#toString() - */ - @Override - public String toString() { - if (isSetMath()) { - return math.toString(); - } - return StringTools.firstLetterLowerCase(getElementName()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#unsetFormula() - */ - @Deprecated - public void unsetFormula() { - unsetMath(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#unsetMath() - */ - public void unsetMath() { - setMath(null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetMath() && isSetLevel() && (getLevel() < 2)) { - attributes.put("formula", getFormula()); - } - return attributes; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBase.java b/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBase.java deleted file mode 100644 index b401342ee..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBase.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * $Id: AbstractNamedSBase.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AbstractNamedSBase.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.Map; -import java.util.regex.Pattern; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * The base class for each SBML element with an optional id and name. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1177 $ - */ -public abstract class AbstractNamedSBase extends AbstractSBase implements - NamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -9186483076164094500L; - - private static final String underscore = "_"; - private static final String letter = "a-zA-Z"; - private static final String digit = "0-9"; - private static final String idChar = "[" + letter + digit + underscore + "]"; - private static final String SIdL2 = "^[" + letter + underscore + "]" + idChar + '*'; - private static final Pattern SIdL2Pattern = Pattern.compile(SIdL2); - - /** - * Checks whether the given idCandidate is a valid identifier according to - * the SBML specifications. - * - * @param idCandidate - * The {@link String} to be tested. - * @param level - * Level of the SBML to be used. - * @param version - * Version of the SBML to be used. - * @return True if the argument satisfies the specification of identifiers - * in the SBML specifications or false otherwise. - */ - public static final boolean isValidId(String idCandidate, int level, - int version) { - - if (level == 1) { - String reservedNames[] = {"abs", "acos", "and", "asin", "atan", "ceil", - "cos", "exp", "floor", "hilli", "hillmmr", "hillmr", "hillr", "isouur", - "log", "log10", "massi", "massr", "not", "or", "ordbbr", "ordbur", - "ordubr", "pow", "ppbr", "sin", "sqr", "sqrt", "tan", "uai", "ualii", - "uar", "ucii", "ucir", "ucti", "uctr", "uhmi", "uhmr", "umai", "umar", - "umi", "umr", "unii", "unir", "usii", "usir", "uuci", "uucr", "uuhr", - "uui", "uur", "xor"}; - /* - * These reserved words can occur in case of UnitDefinitions: - * "substance", "time", "volume" - */ - if (Arrays.binarySearch(reservedNames, idCandidate) < 0) { - if (version == 1) { - String SNameL1V1 = underscore + "*[" + letter + "]" + idChar + '*'; - return Pattern.matches(SNameL1V1, idCandidate); - } else if (version == 2) { - String SNameL1V2 = "[" + letter + underscore + "]" + idChar + '*'; - return !idCandidate.equals("uaii") /* a reserved name in L1V2 */ - && Pattern.matches(SNameL1V2, idCandidate); - } - } else { - // id is one of the reserved names. - return false; - } - } - - // level undefined or level > 1 - return SIdL2Pattern.matcher(idCandidate).matches(); - } - - /** - * id of the SBML component (can be optional depending on the level and - * version). Matches the id attribute of an element in a SBML file. - */ - private String id; - - /** - * name of the SBML component (can be optional depending on the level and - * version). Matches the name attribute of an element in a SBML file. - */ - private String name; - - /** - * Creates an {@link AbstractNamedSBase}. By default, id and name are null. - */ - public AbstractNamedSBase() { - super(); - id = null; - name = null; - } - - /** - * Creates an {@link AbstractNamedSBase} from a given {@link AbstractNamedSBase}. - * - * @param nsb an AbstractNamedSBase object to clone - */ - public AbstractNamedSBase(AbstractNamedSBase nsb) { - super(nsb); - this.id = nsb.isSetId() ? new String(nsb.getId()) : null; - this.name = nsb.isSetName() ? new String(nsb.getName()) : null; - } - - /** - * Creates an {@link AbstractNamedSBase} from a level and version. By default, id - * and name are null. - * - * @param level the SBML level - * @param version the SBML version - */ - public AbstractNamedSBase(int level, int version) { - this(); - setLevel(level); - setVersion(version); - } - - /** - * Creates an {@link AbstractNamedSBase} with the given identifier. Note - * that with this constructor the level and version of the element are not - * specified. These elements are however required to ensure the validity of - * the SBML data structure. Without level and version, it may not be - * possible to serialize this class to SBML. - * - * @param id the id of this AbstractNamedSBase - */ - public AbstractNamedSBase(String id) { - this(); - setId(id); - } - - /** - * Creates an AbctractNamedSBase from an id, level and version. - * - * @param id the id of this AbstractNamedSBase - * @param level the SBML level - * @param version the SBML version - */ - public AbstractNamedSBase(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * Creates an AbctractNamedSBase from an id, name, level and version. - * - * @param id the id of this AbstractNamedSBase - * @param name the name of this AbstractNamedSBase - * @param level the SBML level - * @param version the SBML version - */ - public AbstractNamedSBase(String id, String name, int level, int version) { - this(level, version); - setId(id); - setName(name); - } - - /** - * Checks if the sID is a valid identifier. - * - * @param sID - * the identifier to be checked. If null or an invalid - * identifier, an exception will be thrown. - * @return true only if the sID is a valid identifier. - * Otherwise this method throws an {@link IllegalArgumentException}. - * This is an intended behavior. - * @throws IllegalArgumentException - * if the given id is not valid in this model. - */ - boolean checkIdentifier(String sID) { - if ((sID == null) || !isValidId(sID, getLevel(), getVersion())) { - throw new IllegalArgumentException(MessageFormat.format( - "\"{0}\" is not a valid identifier for this {1}.", sID, getElementName())); - } - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - NamedSBase nsb = (NamedSBase) object; - equals &= nsb.isSetId() == isSetId(); - if (nsb.isSetId() && isSetId()) { - equals &= nsb.getId().equals(getId()); - } - equals &= nsb.isSetName() == isSetName(); - if (equals && nsb.isSetName()) { - equals &= nsb.getName().equals(getName()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#getId() - */ - public String getId() { - return isSetId() ? this.id : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#getName() - */ - public String getName() { - return isSetName() ? this.name : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 829; - int hashCode = super.hashCode(); - if (isSetId()) { - hashCode += prime * getId().hashCode(); - } - if (isSetName()) { - hashCode += prime * getName().hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isSetId() - */ - public boolean isSetId() { - return id != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isSetName() - */ - public boolean isSetName() { - return name != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - // TODO : we should probably be careful there and check if there is a - // prefix set before reading the id or name - // as there are not defined at the level of the SBase on the SBML - // specifications and some packages might define them in their own - // name space. - - if (!isAttributeRead) { - if (attributeName.equals("id") && (getLevel() > 1)) { - this.setId(value); - return true; - } else if (attributeName.equals("name")) { - this.setName(value); - if (isSetLevel() && (getLevel() == 1)) { - this.setId(value); - } - return true; - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#setId(java.lang.String) - */ - public void setId(String id) { - String property = getLevel() == 1 ? TreeNodeChangeEvent.name - : TreeNodeChangeEvent.id; - String oldId = this.id; - Model model = getModel(); - if ((oldId != null) && (model != null)) { - // Delete previous identifier only if defined. - model.registerId(this, false); - } - if ((id == null) || (id.trim().length() == 0)) { - this.id = null; - } else if (checkIdentifier(id)) { - this.id = id; - } - if ((model != null) && !model.registerId(this, true)) { - IdentifierException exc = new IdentifierException(this, this.id); - this.id = oldId; // restore the previous setting! - throw new IllegalArgumentException(exc); - } - firePropertyChange(property, oldId, this.id); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#setName(java.lang.String) - */ - public void setName(String name) { - // removed the call to the trim() function as a name with only space - // should be considered valid. - String oldName = this.name; - if ((name == null) || (name.length() == 0)) { - this.name = null; - } else { - this.name = name; - } - if (!isSetId() && (getLevel() == 1)) { - /* - * Note: In Level 1 there is no id attribute but the name is actually the - * id. Since Level 2 the name attribute has been intended to be a human-readable - * name, not a unique identifier (this was the meaning in Level 1). JSBML therefore - * has to set the id (and not the name) when calling this method in Level 1 models. - */ - setId(name); - } else { - // else part to avoid calling this method twice. - firePropertyChange(TreeNodeChangeEvent.name, oldName, this.name); - } - } - - /** - * Returns the name of the component, if it is available. Otherwise, - * the identifier is returned. If both is not possible, the class name of - * this element is returned. - */ - public String toString() { - if (isSetName() && (getName().length() > 0)) { - return name; - } - if (isSetId()) { - return id; - } - return getElementName(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#unsetId() - */ - public void unsetId() { - setId(null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#unsetName() - */ - public void unsetName() { - setName(null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetId()) { - if (getLevel() != 1) { - attributes.put("id", getId()); - } else { - attributes.put("name", getId()); - } - } - if (isSetName()) { - attributes.put("name", getName()); - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java b/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java deleted file mode 100644 index 44ac4439f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * $Id: AbstractNamedSBaseWithUnit.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AbstractNamedSBaseWithUnit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * This simple implementation of the interfaces - * {@link NamedSBaseWithDerivedUnit} and {@link SBaseWithUnit} defines elements - * that can be addressed by their identifier and are or can be associated with a - * defined {@link Unit} or {@link UnitDefinition}. Derived elements from this - * class might be directly or indirectly associated with some value, i.e., the - * value might be derived by evaluating some expression in form of an - * {@link ASTNode}, or it might be directly defined as an attribute. - * - * @author Andreas Dräger - * @date 2010-12-16 - * @since 0.8 - * @version $Rev: 1177 $ - */ -public abstract class AbstractNamedSBaseWithUnit extends AbstractNamedSBase - implements NamedSBaseWithDerivedUnit, SBaseWithUnit { - - /** - * - */ - private static final long serialVersionUID = 3611229078069091891L; - - /** - * The unit attribute of this variable. - */ - protected String unitsID; - - /** - * Initializes a new object of type {@link AbstractNamedSBaseWithUnit} whose - * identifier and name are set to null and whose level and - * version are set to -1 each. - */ - public AbstractNamedSBaseWithUnit() { - this(null, null, -1, -1); - } - - /** - * @param nsbu - */ - public AbstractNamedSBaseWithUnit(AbstractNamedSBaseWithUnit nsbu) { - super(nsbu); - if (nsbu.isSetUnits()) { - setUnits(new String(nsbu.getUnits())); - } else { - unitsID = nsbu.unitsID == null ? null : new String(nsbu.unitsID); - } - } - - /** - * @param level - * @param version - */ - public AbstractNamedSBaseWithUnit(int level, int version) { - this(null, null, level, version); - } - - /** - * @param id - */ - public AbstractNamedSBaseWithUnit(String id) { - this(id, null, -1, -1); - } - - /** - * @param id - * @param level - * @param version - */ - public AbstractNamedSBaseWithUnit(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * @param id - * @param name - * @param level - * @param version - */ - public AbstractNamedSBaseWithUnit(String id, String name, int level, - int version) { - super(id, name, level, version); - this.unitsID = null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - public abstract AbstractNamedSBaseWithUnit clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#containsUndeclaredUnits() - */ - public boolean containsUndeclaredUnits() { - return !isSetUnits(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - AbstractNamedSBaseWithUnit v = (AbstractNamedSBaseWithUnit) object; - equals &= v.isSetUnits() == isSetUnits(); - if (equals && isSetUnits()) { - equals &= v.getUnits().equals(getUnits()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnitDefinition() - */ - public UnitDefinition getDerivedUnitDefinition() { - if (isSetUnitsInstance()) { - return getUnitsInstance(); - } - String derivedUnits = getDerivedUnits(); - Model model = getModel(); - if ((model != null) && (derivedUnits.length() > 0)) { - return model.getUnitDefinition(derivedUnits); - } - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnits() - */ - public String getDerivedUnits() { - if (isSetUnits()) { - return unitsID; - } - String predef = getPredefinedUnitID(); - return predef != null ? predef : ""; - } - - /** - * Returns the predefined unit identifier for this data type with the - * current level/version combination. - * - * @return an identifier of a unit in the containing {@link Model}. This can - * be one of the predefined unit identifiers if there are any. - */ - public abstract String getPredefinedUnitID(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#getUnits() - */ - public String getUnits() { - return isSetUnits() ? unitsID : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#getUnitsInstance() - */ - public UnitDefinition getUnitsInstance() { - String unitsId = this.unitsID; - if (isSetUnits()) { - int level = getLevel(), version = getVersion(); - if (Unit.isUnitKind(unitsId, level, version)) { - UnitDefinition ud = new UnitDefinition(unitsId + "_base", level, version); - ud.addUnit(Unit.Kind.valueOf(unitsId.toUpperCase())); - return ud; - } - } else { - unitsId = getPredefinedUnitID(); - } - Model model = getModel(); - return model == null ? null : model.getUnitDefinition(unitsId); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 859; - int hashCode = super.hashCode(); - if (isSetUnits()) { - hashCode += prime * getUnits().hashCode(); - } - return hashCode; - } - - /** - * Checks whether or not a given identifier for a {@link Kind} or - * {@link UnitDefinition} equals a predefined unit identifier for this type. - * - * @param unitsID the identifier to be checked. - * @return true if the given identifier equals the unit definition - * identifier that is predefined under the Level/Version combination - * for this data type. - */ - public boolean isPredefinedUnitsID(String unitsID) { - if (unitsID != null) { - String predefID = getPredefinedUnitID(); - return (predefID != null) && unitsID.equals(predefID); - } - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#isSetUnits() - */ - public boolean isSetUnits() { - return (unitsID != null) /*&& !isPredefinedUnitsID(unitsID)*/; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#isSetUnitsInstance() - */ - public boolean isSetUnitsInstance() { - if (isSetUnits()) { - if (Unit.isUnitKind(this.unitsID, getLevel(), getVersion())) { - return true; - } - Model model = getModel(); - return model == null ? false : model - .getUnitDefinition(this.unitsID) != null; - } - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit.Kind) - */ - public void setUnits(Kind unitKind) { - setUnits(unitKind.toString().toLowerCase()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(java.lang.String) - */ - public void setUnits(String units) { - if ((units != null) && (units.trim().length() == 0)) { - units = null; // If we pass the empty String or null, the value is reset. - } - - String oldUnits = this.unitsID; - if (units == null) { - unitsID = null; - } else { - units = units.trim(); - boolean illegalArgument = false; - if (units.length() == 0) { - illegalArgument = true; - } else { - Model model = getModel(); - if ((model == null) - || (Kind.isValidUnitKindString(units, getLevel(), getVersion()))) { - unitsID = units; - } else if ((model != null) - && (model.getUnitDefinition(units) != null)) { - unitsID = units; - } else { - illegalArgument = true; - } - } - if (illegalArgument) { - throw new IllegalArgumentException(String.format( - JSBML.ILLEGAL_UNIT_EXCEPTION_MSG, units)); - } - } - if (oldUnits != unitsID) { - firePropertyChange(TreeNodeChangeEvent.units, oldUnits, unitsID); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit) - */ - @SuppressWarnings("deprecation") - public void setUnits(Unit unit) { - if ((unit.getExponent() != 1) || (unit.getScale() != 0) - || (unit.getMultiplier() != 1d) || (unit.getOffset() != 0d)) { - StringBuilder sb = new StringBuilder(); - sb.append('_'); - sb.append(unit.getMultiplier()); - sb.append('_'); - sb.append(unit.getScale()); - sb.append('_'); - sb.append(unit.getKind().toString()); - sb.append('_'); - sb.append(unit.getExponent()); - UnitDefinition ud = new UnitDefinition(sb.toString().replace('.', '_'), - getLevel(), getVersion()); - ud.addUnit(unit); - Model m = getModel(); - if (m != null) { - m.addUnitDefinition(ud); - } - setUnits(ud); - } else { - // must be a base unit - setUnits(unit.getKind().toString().toLowerCase()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.UnitDefinition) - */ - public void setUnits(UnitDefinition units) { - if (units != null) { - setUnits(units.getId()); - } else { - unsetUnits(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#unsetUnits() - */ - public void unsetUnits() { - setUnits((String) null); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AbstractSBase.java b/IPK_lib/src/org/sbml/jsbml/AbstractSBase.java deleted file mode 100644 index a71de955c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AbstractSBase.java +++ /dev/null @@ -1,1668 +0,0 @@ -/* - * $Id: AbstractSBase.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AbstractSBase.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.ext.SBasePlugin; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.ValuePair; -import org.sbml.jsbml.xml.XMLNode; -import org.sbml.jsbml.xml.stax.SBMLWriter; - -/** - * The base class for each {@link SBase} component. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1240 $ - */ -public abstract class AbstractSBase extends AbstractTreeNode implements SBase { - - /** - * @author Nicolas Rodrigues - */ - private static enum NOTES_TYPE { - /** - * - */ - NotesAny, - /** - * - */ - NotesBody, - /** - * - */ - NotesHTML - }; - - /** - * A logger for this class. - */ - private static final Logger logger = Logger.getLogger(AbstractSBase.class); - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 8781459818293592636L; - - /** - * Returns true is the level and version combination is a valid one, false otherwise. - * - * @param level the SBML level - * @param version the SBML version - * @return true is the level and version combination is a valid one, false otherwise. - */ - public static boolean isValidLevelAndVersionCombination(int level, - int version) { - switch (level) { - case 1: - return ((1 <= version) && (version <= 2)); - case 2: - return ((1 <= version) && (version <= 4)); - case 3: - return ((1 <= version) && (version <= 1)); - default: - return false; - } - } - - /** - * annotations of the SBML component. Matches the annotation XML node in a - * SBML file. - */ - private Annotation annotation; - - /** - * Contains all the namespaces declared on the XML node with their prefixes. - */ - private Map declaredNamespaces; - - /** - * map containing the SBML extension object of additional packages with the - * appropriate name space of the package. - */ - private SortedMap extensions; - - /** - * Level and version of the SBML component. Matches the level XML attribute of a SBML - * node. - */ - ValuePair lv; - - /** - * metaid of the SBML component. Matches the metaid XML attribute of an - * element in a SBML file. - */ - private String metaId; - - /** - * notes of the SBML component. Matches the notes XML node in a SBML file. - */ - private XMLNode notesXMLNode; - - /** - * sbo term of the SBML component. Matches the sboTerm XML attribute of an - * element in a SBML file. - */ - private int sboTerm; - - /** - * Contains all the namespaces used by this SBase element. - */ - private SortedSet usedNamespaces; - - /** - * Creates an AbstractSBase instance. - *

- * By default, the sboTerm is -1, the metaid, notes, parentSBMLObject, annotation, and notes are null. The level and version are set to -1. The - * setOfListeners list and the extensions hash map are empty. - */ - public AbstractSBase() { - super(); - sboTerm = -1; - metaId = null; - notesXMLNode = null; - lv = getLevelAndVersion(); - annotation = null; - extensions = new TreeMap(); - usedNamespaces = new TreeSet(); - declaredNamespaces = new HashMap(); - } - - /** - * Creates an {@link AbstractSBase} instance with the given Level and - * Version. - *

- * By default, the sboTerm is -1, the metaid, notes, {@link #parent}, {@link #annotation}, and notes are null. The {@link #setOfListeners} list and the - * {@link #extensions} {@link Map} are empty. - * - * @param level - * the SBML level - * @param version - * the SBML version - */ - public AbstractSBase(int level, int version) { - this(); - if ((0 < level) && (level < 4)) { - this.lv.setL(Integer.valueOf(level)); - } else { - this.lv.setL(null); - } - if ((0 < version)) { - this.lv.setV(Integer.valueOf(version)); - } else { - this.lv.setV(null); - } - if (!hasValidLevelVersionNamespaceCombination()) { - throw new LevelVersionError(this); - } - } - - /** - * Creates an AbstractSBase instance from a given AbstractSBase. - * - * @param sb an AbstractSBase object to clone - */ - public AbstractSBase(SBase sb) { - super(sb); - - // extensions is needed when doing getChildCount() - extensions = new TreeMap(); - usedNamespaces = new TreeSet(); - declaredNamespaces = new HashMap(); - - if (sb.isSetLevel()) { - setLevel(sb.getLevel()); - } - if (sb.isSetVersion()) { - setVersion(sb.getVersion()); - } - if (sb.isSetSBOTerm()) { - this.sboTerm = sb.getSBOTerm(); - } else { - sboTerm = -1; - } - if (sb.isSetMetaId()) { - this.metaId = new String(sb.getMetaId()); - } - if (sb.isSetNotes()) { - this.notesXMLNode = sb.getNotes().clone(); - } - if (sb.isSetAnnotation()) { - this.annotation = sb.getAnnotation().clone(); - this.annotation.parent = this; - } - // TODO : we need to clone these extensions objects !! - if (sb.isExtendedByOtherPackages()) { - this.extensions.putAll(sb.getExtensionPackages()); - } - // cloning namespaces - if (sb.getNamespaces().size() > 0) { - for (String namespace : sb.getNamespaces()) { - usedNamespaces.add(new String(namespace)); - } - } - if (sb.getDeclaredNamespaces().size() > 0) { - for (String namespacePrefix : sb.getDeclaredNamespaces().keySet()) { - declaredNamespaces.put(new String(namespacePrefix), new String(sb.getDeclaredNamespaces().get(namespacePrefix))); - } - } - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#addCVTerm(org.sbml.jsbml.CVTerm) - */ - public boolean addCVTerm(CVTerm term) { - return getAnnotation().addCVTerm(term); - } - - /** - * Adds an additional name space to the set of declared namespaces of this {@link SBase}. - * - * @param prefix the prefix of the namespace to add - * @param namespace the namespace to add - */ - public void addDeclaredNamespace(String prefix, String namespace) { - this.declaredNamespaces.put(prefix, namespace); - firePropertyChange(TreeNodeChangeEvent.addDeclaredNamespace, null, namespace); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#addExtension(java.lang.String, org.sbml.jsbml.SBase) - */ - public void addExtension(String namespace, SBasePlugin sbase) { - this.extensions.put(namespace, sbase); - addNamespace(namespace); - firePropertyChange(TreeNodeChangeEvent.addExtension, null, sbase); - } - - /** - * Adds an additional namespace to the set of namespaces of this {@link SBase} if the given namespace is not yet present within this {@link SortedSet}. - * - * @param namespace the namespace to add - */ - public void addNamespace(String namespace) { - this.usedNamespaces.add(namespace); - firePropertyChange(TreeNodeChangeEvent.addNamespace, null, namespace); - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#appendNotes(java.lang.String) - */ - public void appendNotes(String notes) { - XMLNode addedNotes = XMLNode.convertStringToXMLNode(StringTools - .toXMLNotesString(notes)); - if (isSetNotes()) { - XMLNode oldNotes = notesXMLNode.clone(); - appendNotes(addedNotes); - firePropertyChange(TreeNodeChangeEvent.notes, oldNotes, notesXMLNode); - } else { - setNotes(addedNotes); - } - } - - /** - * Appends notes to the existing notes. - *

- * This allows other notes to be preserved whilst adding additional information. - * - * @param notes - */ - public void appendNotes(XMLNode notes) { - - if (notes == null) - { - return; - } - - String name = notes.getName(); - - // The content of notes in SBML can consist only of the following - // possibilities: - // - // 1. A complete XHTML document (minus the XML and DOCTYPE - // declarations), that is, XHTML content beginning with the - // html tag. - // (notesType is NotesHTML.) - // - // 2. The body element from an XHTML document. - // (notesType is NotesBody.) - // - // 3. Any XHTML content that would be permitted within a body - // element, each one must declare the XML namespace separately. - // (notesType is NotesAny.) - // - - NOTES_TYPE addedNotesType = NOTES_TYPE.NotesAny; - XMLNode addedNotes = new XMLNode(); - - // ------------------------------------------------------------ - // - // STEP1 : identifies the type of the given notes - // - // ------------------------------------------------------------ - - if (name == "notes") - { - /* - * check for notes tags on the added notes and strip if present and - * the notes tag has "html" or "body" element - */ - - if (notes.getChildCount() > 0) - { - // notes.getChildAt(0) must be "html", "body", or any XHTML - // element that would be permitted within a "body" element - // (e.g.

..

,
..
and so forth). - - String cname = notes.getChildAt(0).getName(); - - if (cname == "html") - { - addedNotes = notes.getChildAt(0); - addedNotesType = NOTES_TYPE.NotesHTML; - } - else if (cname == "body") - { - addedNotes = notes.getChildAt(0); - addedNotesType = NOTES_TYPE.NotesBody; - } - else - { - // the notes tag must NOT be stripped if notes.getChildAt(0) node - // is neither "html" nor "body" element because the children of - // the addedNotes will be added to the current notes later if the node - // is neither "html" nor "body". - addedNotes = notes; - addedNotesType = NOTES_TYPE.NotesAny; - } - } - else - { - // the given notes is empty - // TODO : log an error - return; - } - } - else - { - // if the XMLNode argument notes has been created from a string and - // it is a set of subelements there may be a single empty node - // as parent - leaving this in doesn't affect the writing out of notes - // but messes up the check for correct syntax - - // TODO : check that we are doing that when parsing a String into XMLNode - - if (!notes.isStart() && !notes.isEnd() && !notes.isText()) - { - if (notes.getChildCount() > 0) - { - addedNotes = notes; - addedNotesType = NOTES_TYPE.NotesAny; - } - else - { - // the given notes is empty - return; - } - } - else - { - if (name == "html") - { - addedNotes = notes; - addedNotesType = NOTES_TYPE.NotesHTML; - } - else if (name == "body") - { - addedNotes = notes; - addedNotesType = NOTES_TYPE.NotesBody; - } - else - { - // The given notes node needs to be added to a parent node - // if the node is neither "html" nor "body" element because the - // children of addedNotes will be added to the current notes later if the - // node is neither "html" nor "body" (i.e. any XHTML element that - // would be permitted within a "body" element) - addedNotes.addChild(notes); - addedNotesType = NOTES_TYPE.NotesAny; - } - } - } - - // - // checks the addedNotes of "html" if the html tag contains "head" and - // "body" tags which must be located in this order. - // - if (addedNotesType == NOTES_TYPE.NotesHTML) - { - if ((addedNotes.getChildCount() != 2) || - ((addedNotes.getChildAt(0).getName() != "head") || - (addedNotes.getChildAt(1).getName() != "body") - )) - { - // TODO : log an error to the user or throw an exception or both ? - return; - } - } - - // We do not have a Syntax checker working on XMLNode !! - // check whether notes is valid xhtml ?? (libsbml is doing that) - - if (notesXMLNode != null) - { - // ------------------------------------------------------------ - // - // STEP2: identifies the type of the existing notes - // - // ------------------------------------------------------------ - - NOTES_TYPE curNotesType = NOTES_TYPE.NotesAny; - XMLNode curNotes = notesXMLNode; - - // curNotes.getChildAt(0) must be "html", "body", or any XHTML - // element that would be permitted within a "body" element . - - String cname = curNotes.getChildAt(0).getName(); - - if (cname == "html") - { - XMLNode curHTML = curNotes.getChildAt(0); - // - // checks the curHTML if the html tag contains "head" and "body" tags - // which must be located in this order, otherwise nothing will be done. - // - if ((curHTML.getChildCount() != 2) || - ((curHTML.getChildAt(0).getName() != "head") || - (curHTML.getChildAt(1).getName() != "body") - )) - { - // TODO : log an error - return; - } - curNotesType = NOTES_TYPE.NotesHTML; - } - else if (cname == "body") - { - curNotesType = NOTES_TYPE.NotesBody; - } - else - { - curNotesType = NOTES_TYPE.NotesAny; - } - - /* - * BUT we also have the issue of the rules relating to notes - * contents and where to add them ie we cannot add a second body element - * etc... - */ - - // ------------------------------------------------------------ - // - // STEP3: appends the given notes to the current notes - // - // ------------------------------------------------------------ - - int i; - - if (curNotesType == NOTES_TYPE.NotesHTML) - { - XMLNode curHTML = curNotes.getChildAt(0); - XMLNode curBody = curHTML.getChildAt(1); - - if (addedNotesType == NOTES_TYPE.NotesHTML) - { - // adds the given html tag to the current html tag - - XMLNode addedBody = addedNotes.getChildAt(1); - - for (i = 0; i < addedBody.getChildCount(); i++) - { - if (curBody.addChild(addedBody.getChildAt(i)) < 0) - // TODO : log an error - return; - } - } - else if ((addedNotesType == NOTES_TYPE.NotesBody) || (addedNotesType == NOTES_TYPE.NotesAny)) - { - // adds the given body or other tag (permitted in the body) to the current - // html tag - - for (i = 0; i < addedNotes.getChildCount(); i++) - { - if (curBody.addChild(addedNotes.getChildAt(i)) < 0) - // TODO : log an error - return; - } - } - } - else if (curNotesType == NOTES_TYPE.NotesBody) - { - if (addedNotesType == NOTES_TYPE.NotesHTML) - { - // adds the given html tag to the current body tag - - XMLNode addedHTML = new XMLNode(addedNotes); - XMLNode addedBody = addedHTML.getChildAt(1); - XMLNode curBody = curNotes.getChildAt(0); - - for (i = 0; i < curBody.getChildCount(); i++) - { - addedBody.insertChild(i, curBody.getChildAt(i)); - } - - curNotes.removeChildren(); - if (curNotes.addChild(addedHTML) < 0) - // TODO : log an error - return; - } - else if ((addedNotesType == NOTES_TYPE.NotesBody) || (addedNotesType == NOTES_TYPE.NotesAny)) - { - // adds the given body or other tag (permitted in the body) to the current - // body tag - - XMLNode curBody = curNotes.getChildAt(0); - - for (i = 0; i < addedNotes.getChildCount(); i++) - { - if (curBody.addChild(addedNotes.getChildAt(i)) < 0) - // TODO : log an error - return; - } - } - } - else if (curNotesType == NOTES_TYPE.NotesAny) - { - if (addedNotesType == NOTES_TYPE.NotesHTML) - { - // adds the given html tag to the current any tag permitted in the body. - - XMLNode addedHTML = new XMLNode(addedNotes); - XMLNode addedBody = addedHTML.getChildAt(1); - - for (i = 0; i < curNotes.getChildCount(); i++) - { - addedBody.insertChild(i, curNotes.getChildAt(i)); - } - - curNotes.removeChildren(); - if (curNotes.addChild(addedHTML) < 0) - // TODO : log an error - return; - } - else if (addedNotesType == NOTES_TYPE.NotesBody) - { - // adds the given body tag to the current any tag permitted in the body. - - XMLNode addedBody = new XMLNode(addedNotes); - - for (i = 0; i < curNotes.getChildCount(); i++) - { - addedBody.insertChild(i, curNotes.getChildAt(i)); - } - - curNotes.removeChildren(); - if (curNotes.addChild(addedBody) < 0) - // TODO : log an error - return; - } - else if (addedNotesType == NOTES_TYPE.NotesAny) - { - // adds the given any tag permitted in the boy to that of the current - // any tag. - - for (i = 0; i < addedNotes.getChildCount(); i++) - { - if (curNotes.addChild(addedNotes.getChildAt(i)) < 0) - // TODO : log an error - return; - } - } - } - } - else // if (mNotes == NULL) - { - // setNotes accepts XMLNode with/without top level notes tags. - setNotes(notes); - } - } - - /** - * Checks whether or not the given {@link SBase} has the same level and - * version configuration than this element. If the L/V combination for the - * given sbase is not yet defined, this method sets it to the - * identical values as it is for the current object. - * - * @param sbase - * the element to be checked. - * @return true if the given sbase and this object - * have the same L/V configuration. - * @throws LevelVersionError - * In case the given {@link SBase} has a different, but defined - * Level/Version combination than this current {@link SBase}, an {@link LevelVersionError} is thrown. This method is only - * package-wide visible because it is not intended to be a - * "real" check, rather than to indicate potential errors. - */ - protected boolean checkLevelAndVersionCompatibility(SBase sbase) { - if (sbase.getLevelAndVersion().equals(getLevelAndVersion())) { - return true; - } - if (isSetLevelAndVersion() - && (!sbase.isSetLevelAndVersion() || (sbase.isSetLevel() - && (sbase.getLevel() == getLevel()) && !sbase - .isSetVersion())) && (sbase instanceof AbstractSBase)) { - ((AbstractSBase) sbase).setLevelAndVersion(getLevel(), - getVersion(), true); - return true; - } - throw new LevelVersionError(this, sbase); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#clone() - */ - public abstract AbstractSBase clone(); - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - /* - * Casting will be no problem because the super class has just - * checked that the class of this Object equals the class of the - * given object. - */ - SBase sbase = (SBase) object; - equals &= sbase.isSetMetaId() == isSetMetaId(); - if (equals && sbase.isSetMetaId()) { - equals &= sbase.getMetaId().equals(getMetaId()); - } - /* - * All child nodes are already checked by the recursive method in - * AbstractTreeNode. We here have to check the following own items - * only: - */ - equals &= sbase.isSetSBOTerm() == isSetSBOTerm(); - if (equals && sbase.isSetSBOTerm()) { - equals &= sbase.getSBOTerm() == getSBOTerm(); - } - equals &= sbase.getLevelAndVersion().equals(getLevelAndVersion()); - /* - * Note: Listeners are not included in the equals check. - */ - } - return equals; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#filterCVTerms(org.sbml.jsbml.CVTerm.Qualifier) - */ - public List filterCVTerms(CVTerm.Qualifier qualifier) { - return getAnnotation().filterCVTerms(qualifier); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#filterCVTerms(org.sbml.jsbml.CVTerm.Qualifier, java.lang.String) - */ - public List filterCVTerms(CVTerm.Qualifier qualifier, String pattern) { - List l = new LinkedList(); - for (CVTerm c : filterCVTerms(qualifier)) { - l.addAll(c.filterResources(pattern)); - } - return l; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#filterCVTerms(org.sbml.jsbml.CVTerm.Qualifier, java.lang.String, boolean) - */ - public List filterCVTerms(CVTerm.Qualifier qualifier, String pattern, - boolean recursive) { - List l = filterCVTerms(qualifier, pattern); - if (recursive) { - TreeNode child; - for (int i = 0; i < getChildCount(); i++) { - child = getChildAt(i); - if (child instanceof SBase) { - l.addAll(((SBase) child).filterCVTerms(qualifier, pattern, recursive)); - } - } - } - return l; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#fireNodeRemovedEvent() - */ - @Override - public void fireNodeRemovedEvent() { - if (isSetMetaId() || !isLeaf()) { - // update the set of meta identifiers within the SBMLDocument. - SBMLDocument doc = getSBMLDocument(); - if (doc != null) { - /* - * Recursively remove pointers to this element's and all - * sub-element's meta identifiers from the SBMLDocument. - */ - doc.registerMetaIds(this, true, true); - } - } - if ((this instanceof NamedSBase) || (getChildCount() > 0)) { - /* - * Do the same for all identifiers below this element. - */ - Model model = getModel(); - if (model != null) { - model.registerIds(getParent(), this, true, true); - } - } - super.fireNodeRemovedEvent(); - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getAnnotation() - */ - public Annotation getAnnotation() { - if (!isSetAnnotation()) { - annotation = new Annotation(); - annotation.parent = this; - annotation.addAllChangeListeners(getListOfTreeNodeChangeListeners()); - } - return annotation; - } - - /** - * Returns the {@link Annotation} of this SBML object as a {@link String}. - * - * @return the {@link Annotation} of this SBML object as a {@link String} or - * an empty {@link String} if there are no {@link Annotation}. - */ - public String getAnnotationString() { - return isSetAnnotation() ? (new SBMLWriter()).writeAnnotation(this) : ""; - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - if (childIndex < 0) { - throw new IndexOutOfBoundsException(childIndex + " < 0"); - } - int pos = 0; - if (isSetNotes()) { - if (childIndex == pos) { - return getNotes(); - } - pos++; - } - if (isSetAnnotation()) { - if (childIndex == pos) { - return getAnnotation(); - } - pos++; - } - - // TODO : check this to get correctly the extensions children - - if (extensions.size() > 0) { - - for (SBasePlugin sbasePlugin : extensions.values()) { - int sbasePluginNbChildren = sbasePlugin.getChildCount(); - - if ((pos + sbasePluginNbChildren) > childIndex) { - return sbasePlugin.getChildAt(childIndex - pos); - } else { - pos += sbasePluginNbChildren; - } - } - - } - - throw new IndexOutOfBoundsException(isLeaf() ? MessageFormat.format( - "Node {0} has no children.", getElementName()) : MessageFormat.format( - "Index {0,number,integer} >= {1,number,integer}", childIndex, - +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - int count = 0; - if (isSetNotes()) { - count++; - } - if (isSetAnnotation()) { - count++; - } - - for (SBasePlugin sbasePlugin : extensions.values()) { - count += sbasePlugin.getChildCount(); - } - - return count; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getCVTerm(int) - */ - public CVTerm getCVTerm(int index) { - if (isSetAnnotation()) { - return annotation.getCVTerm(index); - } - throw new IndexOutOfBoundsException(MessageFormat.format( - "No such controlled vocabulary term with index {0,number,integer}.", index)); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getCVTerms() - */ - public List getCVTerms() { - return getAnnotation().getListOfCVTerms(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getNamespaces() - */ - public Map getDeclaredNamespaces() { - // Need to separate the list of name spaces from the extensions. - // SBase object directly from the extension need to set their name space. - - return this.declaredNamespaces; - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#getElementName() - */ - public String getElementName() { - return StringTools.firstLetterLowerCase(getClass().getSimpleName()); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getExtension(java.lang.String) - */ - public SBasePlugin getExtension(String namespace) { - return this.extensions.get(namespace); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getExtensionPackages() - */ - public Map getExtensionPackages() { - return extensions; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getHistory() - */ - public History getHistory() { - return getAnnotation().getHistory(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#getLevel() - */ - public int getLevel() { - return isSetLevel() ? this.lv.getL().intValue() : -1; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getLevelAndVersion() - */ - public ValuePair getLevelAndVersion() { - if (this.lv == null) { - this.lv = new ValuePair(Integer.valueOf(-1), - Integer.valueOf(-1)); - } - return this.lv; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getMetaId() - */ - public String getMetaId() { - return isSetMetaId() ? metaId : ""; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getModel() - */ - public Model getModel() { - if (this instanceof Model) { - return (Model) this; - } - return getParentSBMLObject() != null ? getParentSBMLObject().getModel() - : null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getNamespaces() - */ - public SortedSet getNamespaces() { - // Need to separate the list of name spaces from the extensions. - // SBase object directly from the extension need to set their name space. - - return this.usedNamespaces; - } - - /** - * Returns an XMLNode object that represent the notes of this element. - * - * @return an XMLNode object that represent the notes of this element. - */ - public XMLNode getNotes() { - return notesXMLNode; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getNotesString() - */ - public String getNotesString() { - return notesXMLNode != null ? notesXMLNode.toXMLString() : ""; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getNumCVTerms() - */ - @Deprecated - public int getNumCVTerms() { - return getCVTermCount(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getCVTermCount() - */ - public int getCVTermCount() { - return isSetAnnotation() ? annotation.getListOfCVTerms().size() : 0; - } - - /** - * This is equivalent to calling {@link #getParentSBMLObject()}, but this - * method is needed for {@link TreeNode}. - * - * @return the parent element of this element. - * @see #getParentSBMLObject() - */ - @Override - public SBase getParent() { - return (SBase) super.getParent(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getParentSBMLObject() - */ - public SBase getParentSBMLObject() { - return getParent(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getSBMLDocument() - */ - public SBMLDocument getSBMLDocument() { - if (this instanceof SBMLDocument) { - return (SBMLDocument) this; - } - SBase parent = getParentSBMLObject(); - return (parent != null) ? parent.getSBMLDocument() : null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getSBOTerm() - */ - public int getSBOTerm() { - return sboTerm; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getSBOTermID() - */ - public String getSBOTermID() { - return SBO.intToString(sboTerm); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#getVersion() - */ - public int getVersion() { - return isSetVersion() ? this.lv.getV().intValue() : -1; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 773; - int hashCode = super.hashCode(); - if (isSetMetaId()) { - hashCode += prime * getMetaId().hashCode(); - } - if (isSetSBOTerm()) { - hashCode += prime * getSBOTerm(); - } - return hashCode + prime * getLevelAndVersion().hashCode(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#hasValidAnnotation() - */ - public boolean hasValidAnnotation() { - if (isSetAnnotation()) { - if (isSetMetaId()) { - Annotation annotation = getAnnotation(); - if (!annotation.isSetAbout()) { - /* - * Ok, let's set this about tag silently because - * when writing SBML, we would set this tag anyway. - * This method just complains incorrectly set about - * tags. - */ - annotation.setAbout('#' + getMetaId()); - return true; - } - if (annotation.getAbout().equals('#' + getMetaId())) { - return true; - } - } - if (getAnnotation().isSetNonRDFannotation() - && !getAnnotation().isSetRDFannotation()) { - return true; - } - return false; - } - return true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#hasValidLevelVersionNamespaceCombination() - */ - public boolean hasValidLevelVersionNamespaceCombination() { - return isValidLevelAndVersionCombination(getLevel(), getVersion()); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isExtendedByOtherPackages() - */ - public boolean isExtendedByOtherPackages() { - return !this.extensions.isEmpty(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetAnnotation() - */ - public boolean isSetAnnotation() { - return (annotation != null) && annotation.isSetAnnotation(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetHistory() - */ - public boolean isSetHistory() { - if (isSetAnnotation()) { - return annotation.isSetHistory(); - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetLevel() - */ - public boolean isSetLevel() { - return (lv != null) && (lv.getL() != null) - && (lv.getL().intValue() > -1); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetLevelAndVersion() - */ - public boolean isSetLevelAndVersion() { - return isSetLevel() && isSetVersion(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetMetaId() - */ - public boolean isSetMetaId() { - return metaId != null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetNotes() - */ - public boolean isSetNotes() { - return notesXMLNode != null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetParentSBMLObject() - */ - public boolean isSetParentSBMLObject() { - return isSetParent(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetSBOTerm() - */ - public boolean isSetSBOTerm() { - return sboTerm != -1; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#isSetVersion() - */ - public boolean isSetVersion() { - return (lv != null) && (lv.getV() != null) - && (lv.getV().intValue() > -1); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#notifyChildChange(javax.swing.tree.TreeNode, javax.swing.tree.TreeNode) - */ - @Override - protected void notifyChildChange(TreeNode oldChild, TreeNode newChild) { - if (oldChild instanceof SBase) { - SBMLDocument doc = getSBMLDocument(); - if (doc != null) { - /* - * Recursively remove pointers to oldValue's and all - * sub-element's meta identifiers from the - * SBMLDocument. - */ - doc.registerMetaIds((SBase) oldChild, true, true); - } - if (oldChild instanceof NamedSBase) { - /* - * Do the same for all identifiers under the old value. - */ - Model model = getModel(); - if (model != null) { - model.registerIds(this, (NamedSBase) oldChild, true, true); - NamedSBase newNsb = (NamedSBase) newChild; - if (!model.registerIds(this, newNsb, true, false)) { - throw new IdentifierException(newNsb, newNsb.getId()); - } - } - } - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - public boolean readAttribute(String attributeName, String prefix, - String value) { - if (attributeName.equals("sboTerm")) { - setSBOTerm(value); - return true; - } else if (attributeName.equals("metaid")) { - setMetaId(value); - return true; - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#registerChild(org.sbml.jsbml.SBase) - */ - public void registerChild(SBase sbase) throws LevelVersionError { - if ((sbase != null) && checkLevelAndVersionCompatibility(sbase)) { - SBMLDocument doc = getSBMLDocument(); - if (doc != null) { - /* - * In case that sbase did not have access to the document we - * have to recursively check the metaId property. - */ - doc.registerMetaIds(sbase, (sbase.getSBMLDocument() == null) - && (sbase instanceof AbstractSBase), false); - } - Model model = getModel(); - /* - * Check if the model to which this node is assigned equals the one to - * which the given SBase belongs. This is important because if both - * belong to the identical model, we don't have to register all - * identifiers recursively. - * In this case, it will be enough to check this one new node only. - */ - boolean recursively = (model == null) || (sbase.getModel() != model); - - /* - * Memorize all TreeNodeChangeListeners that are currently assigned to the new - * SBase in order to re-use these later. For now we must remove all those to - * avoid listeners to be called before we could really add the SBase to this - * subtree. - */ - List listeners = sbase.getListOfTreeNodeChangeListeners(); - sbase.removeAllTreeNodeChangeListeners(); - - /* - * Make sure the new SBase is part of the subtree rooted at this element - * before (recursively) registering all ids: - */ - TreeNode oldParent = sbase.getParent(); // Memorize the old parent (may be null). - sbase.setParentSBML(this); - - // If possible, recursively register all ids of the SBase in our model: - if ((model != null) - && !model.registerIds(this, sbase, recursively, false)) { - // Something went wrong: We have to restore the previous state: - if (oldParent == null) { - sbase.setParentSBML(null); - } else if (oldParent instanceof SBase) { - sbase.setParentSBML((SBase) oldParent); - } - sbase.addAllChangeListeners(listeners); - - throw new IllegalArgumentException(MessageFormat.format("Cannot register {0}.", - sbase.getElementName())); - } - - /* - * Now, we cann add all previous listeners. The next change will - * be fired after registering all ids. - */ - sbase.addAllChangeListeners(listeners); - - // Add all TreeNodeChangeListeners from this current node also to the new SBase: - sbase.addAllChangeListeners(getListOfTreeNodeChangeListeners()); - // Notify all listeners that a new node has been added to this subtree: - sbase.fireNodeAddedEvent(); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#unregisterChild(org.sbml.jsbml.SBase) - */ - public void unregister(SBase sbase) { - if ((sbase != null)) { - SBMLDocument doc = getSBMLDocument(); - - if (doc != null) { - // unregister recursively all metaIds. - doc.registerMetaIds(sbase, true, true); - } - - Model model = getModel(); - - // remove all changeListeners - sbase.removeAllTreeNodeChangeListeners(); - - // If possible, recursively unregister all ids of the SBase in our model: - if ((model != null) - && !model.registerIds(this, sbase, true, true)) { - throw new IllegalArgumentException(MessageFormat.format("Cannot unregister {0}.", - sbase.getElementName())); - } - - // Notify all listeners that a new node has been added to this subtree: - sbase.fireNodeRemovedEvent(); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setAnnotation(org.sbml.jsbml.Annotation) - */ - public void setAnnotation(Annotation annotation) { - Annotation oldAnnotation = this.annotation; - this.annotation = annotation; - this.annotation.parent = this; - firePropertyChange(TreeNodeChangeEvent.setAnnotation, oldAnnotation, this.annotation); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setHistory(org.sbml.jsbml.History) - */ - public void setHistory(History history) { - History oldHistory = isSetHistory() ? getHistory() : null; - getAnnotation().setHistory(history); - firePropertyChange(TreeNodeChangeEvent.history, oldHistory, history); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setLevel(int) - */ - public void setLevel(int level) { - SBase parent = getParent(); - if ((parent != null) && (parent != this) - && parent.isSetLevel()) { - if (level != parent.getLevel()) { - throw new LevelVersionError(this, parent); - } - } - Integer oldLevel = getLevelAndVersion().getL(); - this.lv.setL(Integer.valueOf(level)); - firePropertyChange(TreeNodeChangeEvent.level, oldLevel, this.lv.getL()); - } - - /** - * Sets recursively the level and version attribute for this element - * and all sub-elements. - * - * @param level the SBML level - * @param version the SBML version - * @param strict a boolean to say if the method need to be strict or not (not used at the moment) - * @return true if the operation as been successful. - */ - boolean setLevelAndVersion(int level, int version, boolean strict) { - if (isValidLevelAndVersionCombination(level, version)) { - setLevel(level); - setVersion(version); - // TODO: perform necessary conversion! - boolean success = true; - Enumeration children = children(); - TreeNode child; - while (children.hasMoreElements()) { - child = children.nextElement(); - if (child instanceof AbstractSBase) { - success &= ((AbstractSBase) child).setLevelAndVersion( - level, version, strict); - } - } - return success; - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setMetaId(java.lang.String) - */ - public void setMetaId(String metaId) { - if ((metaId != null) && (getLevel() == 1)) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.metaId, this); - } - SBMLDocument doc = getSBMLDocument(); - if ((doc != null) && doc.containsMetaId(metaId)) { - throw new IdentifierException(this, metaId); - } - String oldMetaId = this.metaId; - this.metaId = metaId; - if (doc != null) { - doc.registerMetaId(this, true); - } - firePropertyChange(TreeNodeChangeEvent.metaId, oldMetaId, metaId); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#setNotes(java.lang.String) - */ - public void setNotes(String notes) { - setNotes(XMLNode.convertStringToXMLNode(StringTools - .toXMLNotesString(notes))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setNotes(java.lang.String) - */ - public void setNotes(XMLNode notes) { - XMLNode oldNotes = this.notesXMLNode; - this.notesXMLNode = notes; - this.notesXMLNode.setParent(this); - firePropertyChange(TreeNodeChangeEvent.notes, oldNotes, this.notesXMLNode); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setParentSBML(org.sbml.jsbml.SBase) - */ - public void setParentSBML(SBase parent) { - SBase oldParent = getParent(); - this.parent = parent; - firePropertyChange(TreeNodeChangeEvent.parentSBMLObject, oldParent, parent); - } - - /** - * Checks the Level/Version configuration of the new parent (if it is - * compliant to the one of this {@link SBase}), adds all changeListeners from - * the parent to this {@link SBase}, fires a {@link TreeNodeChangeListener#nodeAdded(TreeNode)} event, and and finally, - * it will forward the new parent to {@link #setParentSBML(SBase)}. - * Note that this will cause another event to be triggered: {@link TreeNodeChangeListener#propertyChange(java.beans.PropertyChangeEvent)} with the old and - * the new parent. - * - * @param sbase - * the new parent element. - * @throws LevelVersionError - * if the SBML Level and Version configuration of the new parent - * differs from the one of this {@link SBase}. - * @see {@link #setParentSBML(SBase)} - */ - public void setParentSBMLObject(SBase sbase) throws LevelVersionError { - if (sbase instanceof AbstractSBase) { - ((AbstractSBase) sbase).checkLevelAndVersionCompatibility(this); - } - addAllChangeListeners(sbase.getListOfTreeNodeChangeListeners()); - fireNodeAddedEvent(); - setParentSBML(sbase); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setSBOTerm(int) - */ - public void setSBOTerm(int term) { - if (getLevelAndVersion().compareTo(Integer.valueOf(2), - Integer.valueOf(2)) < 0) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.sboTerm, this); - } - if (!SBO.checkTerm(term)) { - throw new IllegalArgumentException(MessageFormat.format( - "Cannot set invalid SBO term {0,number,integer} because it must not be smaller than zero or larger than 9999999.", - term)); - } - Integer oldTerm = Integer.valueOf(sboTerm); - sboTerm = term; - firePropertyChange(TreeNodeChangeEvent.sboTerm, oldTerm, sboTerm); - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#setSBOTerm(java.lang.String) - */ - public void setSBOTerm(String sboid) { - setSBOTerm(SBO.stringToInt(sboid)); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setThisAsParentSBMLObject(org.sbml.jsbml.SBase) - */ - @Deprecated - public void setThisAsParentSBMLObject(SBase sbase) throws LevelVersionError { - registerChild(sbase); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#setVersion(int) - */ - public void setVersion(int version) { - SBase parent = getParent(); - if ((parent != null) && (parent != this) - && parent.isSetVersion()) { - if (version != parent.getVersion()) { - throw new LevelVersionError(parent, this); - } - } - Integer oldVersion = getLevelAndVersion().getV(); - this.lv.setV(Integer.valueOf(version)); - firePropertyChange(TreeNodeChangeEvent.version, oldVersion, version); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public abstract String toString(); - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#unsetAnnotation() - */ - public void unsetAnnotation() { - if (isSetAnnotation()) { - Annotation oldAnnotation = annotation; - annotation = null; - firePropertyChange(TreeNodeChangeEvent.annotation, oldAnnotation, - annotation); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#unsetCVTerms() - */ - public void unsetCVTerms() { - if (isSetAnnotation() && getAnnotation().isSetListOfCVTerms()) { - List list = annotation.getListOfCVTerms(); - annotation.unsetCVTerms(); - firePropertyChange(TreeNodeChangeEvent.unsetCVTerms, list, null); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#unsetHistory() - */ - public void unsetHistory() { - if (isSetHistory()) { - this.annotation.unsetHistory(); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#unsetMetaId() - */ - public void unsetMetaId() { - if (isSetMetaId()) { - setMetaId(null); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#unsetNotes() - */ - public void unsetNotes() { - if (isSetNotes()) { - XMLNode oldNotes = notesXMLNode; - notesXMLNode = null; - firePropertyChange(TreeNodeChangeEvent.notes, oldNotes, getNotes()); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jlibsbml.SBase#unsetSBOTerm() - */ - public void unsetSBOTerm() { - if (isSetSBOTerm()) { - Integer oldSBOTerm = Integer.valueOf(sboTerm); - sboTerm = -1; - firePropertyChange(TreeNodeChangeEvent.sboTerm, oldSBOTerm, Integer - .valueOf(getSBOTerm())); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBase#writeXMLAttributes() - */ - public Map writeXMLAttributes() { - Map attributes = new TreeMap(); - int level = getLevel(); - - if (1 < level) { - /* - * This ensures that the metaid of this element is always defined if - * there is an annotation present. - */ - if (isSetAnnotation() && getAnnotation().isSetRDFannotation() - && !isSetMetaId()) { - SBMLDocument doc = getSBMLDocument(); - if (doc != null) { - setMetaId(doc.nextMetaId()); - logger.info(MessageFormat.format( - "Some annotations would get lost because there was no metaid defined on {0}. To avoid this, an automatic metaid '{0}' as been generated.", - getElementName(), getMetaId())); - // Setting the new metaid in the RDF about attribute. - getAnnotation().setAbout("#" + getMetaId()); - } else { - logger.warn(MessageFormat.format( - "Some annotations can get lost because no metaid is defined on {0}.", - getElementName())); - } - } - if (isSetMetaId()) { - attributes.put("metaid", getMetaId()); - } - if (((level == 2) && (getVersion() >= 2)) || (level == 3)) { - if (isSetSBOTerm()) { - attributes.put("sboTerm", getSBOTermID()); - } - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AbstractTreeNode.java b/IPK_lib/src/org/sbml/jsbml/AbstractTreeNode.java deleted file mode 100644 index e32005dba..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AbstractTreeNode.java +++ /dev/null @@ -1,597 +0,0 @@ -/* - * $Id: AbstractTreeNode.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AbstractTreeNode.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.TreeNodeWithChangeSupport; -import org.sbml.jsbml.util.filters.Filter; - -/** - * A basic implementation of the {@link TreeNode} interface. - * - * @author Andreas Dräger - * @version $Rev: 1212 $ - * @since 0.8 - * @date 11.07.2011 - */ -public abstract class AbstractTreeNode implements TreeNodeWithChangeSupport { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 8629109724566600238L; - - /** - * Searches the given child in the list of sub-nodes of the parent element. - * - * @param parent - * @param child - * @return the index of the child in the parent's list of childs or -1 if no - * such child can be found. - */ - public static int indexOf(TreeNode parent, TreeNode child) { - if (child == null) { - throw new IllegalArgumentException("Argument is null."); - } - // linear search - Enumeration e = (Enumeration) parent.children(); - for (int i = 0; e.hasMoreElements(); i++) { - TreeNode elem = e.nextElement(); - if ((child == elem) || child.equals(elem)) { - return i; - } - } - // not found => node is not a child. - return -1; - } - - /** - * {@link List} of listeners for this component - */ - protected List listOfListeners; - - /** - * The parent element of this {@link Annotation}. - */ - protected TreeNode parent; - - /** - * Any kind of {@link Object} that can be stored in addition to all other - * features of this {@link AbstractTreeNode} in form of key-value pairs. - * Note that things stored here will not be written to SBML files. This - * only provides a possibility to attach some in-memory information to - * derived classes. - */ - private Map userObjects; - - /** - * Creates an empty {@link AbstractTreeNode} without child nodes and an - * empty list of {@link TreeNodeChangeListener}s. The pointer to the parent - * of this node is set to null. - */ - public AbstractTreeNode() { - super(); - this.listOfListeners = new LinkedList(); - this.parent = null; - } - - /** - * Constructor for cloning. {@link AbstractTreeNode} has two properties: - * {@link #parent} and {@link #listOfListeners}. Both of them are not cloned - * by this method, for two reasons: - *
    - *
  • The {@link #parent} is not cloned and is left as null - * because the new {@link AbstractTreeNode} will get a parent set as soon as - * it is added/linked again to a {@link Model}. Note that only the top-level - * element of the cloned sub-tree will have a null value as its - * parent. All sub-element will point to their correct parent element.
  • - *
  • {@link #listOfListeners} is needed in all other setXX() methods. - * Cloning these might lead to strange and unexpected behavior, because when - * doing a deep cloning, the listeners of the old object would suddenly be - * informed about all value changes within this new object. Since we do - * cloning, all values of all child elements have to be touched, i.e., all - * listeners would be informed many times, but each time receive the identical - * value as it was before. Since it is totally unclear of which type listeners - * are, a deep cloning of these is not possible.
  • - *
- * Therefore, it is necessary to keep in mind that the parent of the clone - * will be null and that you have to care by yourself if you are using - * {@link TreeNodeChangeListener}s. - * - * @param node - * The original {@link TreeNode} to be cloned. - */ - public AbstractTreeNode(TreeNode node) { - this(); - // the parent is not cloned and is left as null - // The Object will get a parent set as soon as it is added/linked - // again to a model somehow. - // this.parent = node.getParent(); - - /* - * listOfListeners is needed in all other setXX() methods. - * Cloning these might lead to strange and unexpected behavior. - * This is actually not deep cloning anyway: - */ - if (node instanceof AbstractTreeNode) { - AbstractTreeNode anode = (AbstractTreeNode) node; - // Do not clone listeners! - // this.listOfListeners.addAll(anode.listOfListeners); - if (anode.isSetUserObjects()) { - this.userObjects = new HashMap(); - this.userObjects.putAll(anode.userObjects); - } - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#addAllChangeListeners(java.util.Collection) - */ - @Override - public boolean addAllChangeListeners( - Collection listeners) { - boolean success = listOfListeners.addAll(listeners); - Enumeration children = children(); - while (children.hasMoreElements()) { - TreeNode node = children.nextElement(); - if (node instanceof AbstractTreeNode) { - success &= ((AbstractTreeNode) node) - .addAllChangeListeners(listeners); - } - } - return success; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#addTreeNodeChangeListener(org.sbml.jsbml.util.TreeNodeChangeListener) - */ - @Override - public void addTreeNodeChangeListener(TreeNodeChangeListener listener) { - if (!listOfListeners.contains(listener)) { - listOfListeners.add(listener); - } - Enumeration children = children(); - while (children.hasMoreElements()) { - TreeNode node = children.nextElement(); - if (node instanceof AbstractTreeNode) { - ((AbstractTreeNode) node).addTreeNodeChangeListener(listener); - } - } - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#children() - */ - @Override - public Enumeration children() { - return new Enumeration() { - /** - * Total number of children in this enumeration. - */ - private int childCount = getChildCount(); - /** - * Current position in the list of children. - */ - private int index; - - /* - * (non-Javadoc) - * @see java.util.Enumeration#hasMoreElements() - */ - @Override - public boolean hasMoreElements() { - return index < childCount; - } - - /* - * (non-Javadoc) - * @see java.util.Enumeration#nextElement() - */ - @Override - public TreeNode nextElement() { - synchronized (this) { - if (index < childCount) { - return getChildAt(index++); - } - } - throw new NoSuchElementException("Enumeration"); - } - }; - } - - /** - * Removes all of the mappings from the map of user objects (optional operation). The map - * will be empty after this call returns. - */ - public void clearUserObjects() { - if (isSetUserObjects()) { - userObjects.clear(); - } - } - - /* - * (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public abstract TreeNode clone(); - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - // Check if the given object is a pointer to precisely the same object: - if (super.equals(object)) { - return true; - } - // Check if the given object is of identical class and not null: - if ((object == null) || (!getClass().equals(object.getClass()))) { - return false; - } - // Check all child nodes recursively: - if (object instanceof TreeNode) { - TreeNode stn = (TreeNode) object; - int childCount = getChildCount(); - boolean equal = stn.isLeaf() == isLeaf(); - /* - * This is not good because cloned AbstractTreeNodes may not point - * to the same parent as the original and would hence not be equal - * to the cloned object. - */ - // equal &= ((stn.getParent() == null) && isRoot()) - // || (stn.getParent() == getParent()); - equal &= stn.getChildCount() == childCount; - if (equal && (childCount > 0)) { - for (int i = 0; i < childCount; i++) { - if (!stn.getChildAt(i).equals(getChildAt(i))) { - return false; - } - } - } - return equal; - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#filter(org.sbml.jsbml.util.filters.Filter) - */ - @Override - public List filter(Filter filter) { - return filter(filter, false); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#filter(org.sbml.jsbml.util.filters.Filter, boolean) - */ - @Override - public List filter(Filter filter, boolean retainInternalNodes) { - List list = new LinkedList(), childList; - TreeNode child; - boolean accepts = filter.accepts(this); - if (accepts) { - list.add(this); - } - for (int i = 0; i < getChildCount(); i++) { - child = getChildAt(i); - if (child instanceof TreeNodeWithChangeSupport) { - childList = ((TreeNodeWithChangeSupport) child).filter(filter, retainInternalNodes); - if (!accepts && retainInternalNodes && (childList.size() > 0)) { - list.add(this); - // prevent adding the current node more often than once: - accepts = true; - } - list.addAll(childList); - } - } - return list; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#fireNodeAddedEvent() - */ - @Override - public void fireNodeAddedEvent() { - for (TreeNodeChangeListener listener : listOfListeners) { - listener.nodeAdded(this); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#fireNodeRemovedEvent() - */ - @Override - public void fireNodeRemovedEvent() { - for (TreeNodeChangeListener listener : listOfListeners) { - listener.nodeRemoved(this); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#firePropertyChange(java.lang.String, java.lang.Object, java.lang.Object) - */ - @Override - public void firePropertyChange(String propertyName, Object oldValue, - Object newValue) { - if (listOfListeners.size() > 0) { - short changeType = -1; // no property change at all - if ((oldValue == null) && (newValue != null)) { - changeType = 0; // element added - } else - if ((oldValue != null) && (newValue == null)) { - changeType = 1; // element removed - } else - if ((oldValue != null) && !oldValue.equals(newValue)) { - changeType = 2; // real property change - } - if (-1 < changeType) { - boolean newValTreeNode = newValue instanceof AbstractTreeNode; - boolean oldValTreeNode = oldValue instanceof AbstractTreeNode; - if ((changeType == 0) && newValTreeNode) { - ((AbstractTreeNode) newValue).fireNodeAddedEvent(); - } else - if ((changeType == 1) && oldValTreeNode) { - ((AbstractTreeNode) oldValue).fireNodeRemovedEvent(); - } else { - // TODO: check if notifying and updating the metaId is necessary - // because of the method AbstractSBase.setThisAsParentSBMLObject - if (oldValTreeNode && newValTreeNode) { - notifyChildChange((TreeNode) oldValue, (TreeNode) newValue); - } - /* - * It is not necessary to add the metaId of the new value to - * the SBMLDocument because this is already done in the - * method setThisAsParentSBMLObject, a method that is called - * to link a new element to an existing SBML tree. - */ - // Now we can notify all listeners about the change: - TreeNodeChangeEvent changeEvent = new TreeNodeChangeEvent(this, - propertyName, oldValue, newValue); - for (TreeNodeChangeListener listener : listOfListeners) { - listener.propertyChange(changeEvent); - } - } - } - } - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode) - */ - @Override - public int getIndex(TreeNode node) { - return indexOf(this, node); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#getListOfTreeNodeChangeListeners() - */ - @Override - public List getListOfTreeNodeChangeListeners() { - return listOfListeners; - } - - /** - * Returns the number of child elements of this {@link TreeNode}. - * - * @return the number of children TreeNodes the receiver contains. - * @deprecated use {@link #getChildCount()} - */ - @Deprecated - public int getNumChildren() { - return getChildCount(); - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getParent() - */ - @Override - public TreeNode getParent() { - return parent; - } - - /** - * @return the userObject - */ - public Object getUserObject(Object key) { - if (userObjects == null) { - userObjects = new HashMap(); - } - return userObjects.get(key); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - // A constant and arbitrary, sufficiently large prime number: - final int prime = 769; - /* - * This method is implemented as suggested in the JavaDoc API - * documentation of the List interface. - */ - - // Compute the initial hashCode based on the name of the actual class. - int hashCode = getClass().getName().hashCode(); - /* - * The following start wouldn't work because it will compute the - * hashCode from the address in memory of the object. - */ - // int hashCode = super.hashCode(); - - // Recursively compute the hashCode for each child node: - TreeNode child; - for (int i = 0; i < getChildCount(); i++) { - child = getChildAt(i); - hashCode = prime * hashCode + (child == null ? 0 : child.hashCode()); - } - - return hashCode; - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#isLeaf() - */ - @Override - public boolean isLeaf() { - return getChildCount() == 0; - } - - /** - * Opposite of {@link #isSetParent()}. - * Returns true if this {@link AbstractTreeNode} is the root - * node of a tree, false otherwise. - * - * @return True if this {@link AbstractTreeNode} is the root - * node of a tree, false otherwise. - * @see #isSetParent() - */ - public boolean isRoot() { - return !isSetParent(); - } - - /** - * @return - */ - public boolean isSetParent() { - return parent != null; - } - - /** - * Checks whether any user-defined key-value pairs have been attached - * to this object. - * - * @return true if at least one user-defined key-value pair has - * been attached to this object. - */ - public boolean isSetUserObjects() { - return (userObjects != null) && !userObjects.isEmpty(); - } - - /** - * This method is called when one child has been swapped with another one - * and can be used to check certain properties of the resulting changed - * tree. - * - * @param oldChild - * the element that was a child of this node before the change. - * @param newChild - * the new child whose new parent is this node. - */ - protected void notifyChildChange(TreeNode oldChild, TreeNode newChild) { - // default: empty body, nothing to do. - } - - /** - * @param key - * some user-defined key under which the given userObject can be found. - * @param userObject - * the userObject to set - */ - public void putUserObject(Object key, Object userObject) { - if (userObjects == null) { - userObjects = new HashMap(); - } - Object oldObject = userObjects.put(key, userObject); - firePropertyChange(key.toString(), oldObject, userObject); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#removeAllTreeNodeChangeListeners() - */ - @Override - public void removeAllTreeNodeChangeListeners() { - listOfListeners.clear(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeWithChangeSupport#removeTreeNodeChangeListener(org.sbml.jsbml.util.TreeNodeChangeListener) - */ - @Override - public void removeTreeNodeChangeListener(TreeNodeChangeListener l) { - listOfListeners.remove(l); - Enumeration children = children(); - while (children.hasMoreElements()) { - TreeNode node = children.nextElement(); - if (node instanceof AbstractTreeNode) { - ((AbstractTreeNode) node).removeTreeNodeChangeListener(l); - } - } - } - - /** - * @param key - * @return - */ - public Object removeUserObject(Object key) { - if (userObjects != null) { - return userObjects.remove(key); - } - return null; - } - - /** - * @param parent - * the parent to set - */ - protected void setParent(TreeNode parent) { - TreeNode oldValue = this.parent; - this.parent = parent; - this.firePropertyChange(TreeNodeChangeEvent.parentSBMLObject, oldValue, this.parent); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return StringTools.firstLetterLowerCase(getClass().getSimpleName()); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AlgebraicRule.java b/IPK_lib/src/org/sbml/jsbml/AlgebraicRule.java deleted file mode 100644 index b591f7578..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AlgebraicRule.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * $Id: AlgebraicRule.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AlgebraicRule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.validator.ModelOverdeterminedException; -import org.sbml.jsbml.validator.OverdeterminationValidator; - -/** - * Represents the algebraicRule XML element of a SBML file. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class AlgebraicRule extends Rule { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -3952858495318158175L; - - /** - * Creates an AlgebraicRule instance. - */ - public AlgebraicRule() { - super(); - } - - /** - * Creates an AlgebraicRule instance from a given {@link AlgebraicRule} - * instance. - * - * @param ar an AlgebraicRule to clone. - */ - public AlgebraicRule(AlgebraicRule ar) { - super(ar); - } - - /** - * Creates an AlgebraicRule instance from math, level and version. - * - * @param math the math of the AlgebraicRule - * @param level the SBML level - * @param version the SBML version - */ - public AlgebraicRule(ASTNode math, int level, int version) { - super(math, level, version); - } - - /** - * Creates an AlgebraicRule instance from level and version. - * - * @param level the SBML level - * @param version the SBML version - */ - public AlgebraicRule(int level, int version) { - super(level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Rule#clone() - */ - @Override - public AlgebraicRule clone() { - return new AlgebraicRule(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isCompartmentVolume() - */ - public boolean isCompartmentVolume() { - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isParameter() - */ - public boolean isParameter() { - return false; - } - - /** - * Provides a convenient way to obtain the variable whose amount - * is determined by this rule. However, you should better directly use the - * {@link OverdeterminationValidator} instead of calling this method. Each - * time you call this method, the bipartite matching between all - * {@link MathContainer}s in the model and all - * {@link NamedSBaseWithDerivedUnit}s will be executed again, leading to a - * probably high computational effort. - * - * An example of how to use the {@link OverdeterminationValidator} is given - * here: - * - *
-	 * int ruleIndex = 0; // some arbitrary algebraic rule
-	 * AlgebraicRule ar = model.getRule(ruleIndex);
-	 * OverdeterminationValidator odv = new OverdeterminationValidator(model);
-	 * Variable varialbe;
-	 * if (!odv.isOverdetermined()) {
-	 * 	variable = (Variable) odv.getMatching().get(ar);
-	 *  System.out.printf("Rule %d determines Variable %s.", ruleIndex, variable.getId());
-	 * }
-	 * 
- * - * @return The {@link Variable} determined by this {@link AlgebraicRule} - * @throws ModelOverdeterminedException - * if the model containing this {@link Rule} is over determined. - * @throws NullPointerException - * Calling this method requires that this {@link Rule} is - * already part of a {@link Model}. If you just created a - * {@link Rule} and didn't add it to a {@link Model} you'll - * receive a {@link NullPointerException}. - */ - public Variable getDerivedVariable() throws ModelOverdeterminedException { - OverdeterminationValidator odv = new OverdeterminationValidator( - getModel()); - if (odv.isOverdetermined()) { - throw new ModelOverdeterminedException(); - } - return (Variable) odv.getMatching().get(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isSpeciesConcentration() - */ - public boolean isSpeciesConcentration() { - return false; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Annotation.java b/IPK_lib/src/org/sbml/jsbml/Annotation.java deleted file mode 100644 index bac35d9ba..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Annotation.java +++ /dev/null @@ -1,910 +0,0 @@ -/* - * $Id: Annotation.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Annotation.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.CVTerm.Type; -import org.sbml.jsbml.util.TreeNodeAdapter; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.filters.CVTermFilter; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; - -/** - * An Annotation represents the annotations of an {@link SBase} element. It - * contains the list of {@link CVTerm} objects, a {@link Map} containing an XML - * name space and a {@link String} containing all the annotation elements of - * this name space. - * - * @author Marine Dumousseau - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Annotation extends AnnotationElement { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 2127495202258145900L; - - /** - * The RDF syntax name space definition URI. - */ - public static final transient String URI_RDF_SYNTAX_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - - /** - * Copies one {@link Map} instance into another. - * - * @param origin - * copy from here - * @param target - * copy everything into this target {@link Map}. - */ - private static final void copy(Map origin, - Map target) { - for (Map.Entry entry : origin.entrySet()) { - target.put(new String(entry.getKey().toString()), - new String(entry.getValue().toString())); - } - } - - /** - * Returns a {@link String} which represents the given {@link Qualifier}. - * - * @param qualifier a Qualifier - * @return a {@link String} which represents the given {@link Qualifier}. - */ - public static String getElementNameEquivalentToQualifier(Qualifier qualifier) { - return qualifier.getElementNameEquivalent(); - } - - /** - * matches the about XML attribute of an annotation element in a SBML - * file. - */ - private String about; - - /** - * contains all the name spaces of the matching XML annotation node - */ - private Map annotationNamespaces; - - /** - * contains all the annotation extension objects with the name space of - * their package. - */ - private Map extensions; - - /** - * The ModelHistory which represents the history section of a RDF - * annotation - */ - private History history; - - /** - * contains all the CVTerm of the RDF annotation - */ - private List listOfCVTerms; - - /** - * contains all the annotation information which are not RDF. - * - */ - private StringBuilder nonRDFannotation; - - /** - * contains all the name spaces of the matching XML RDF annotation node - */ - private Map rdfAnnotationNamespaces; - - /** - * Creates an Annotation instance. By default, the {@link History} and - * otherAnnotation Strings are null. The list of {@link CVTerm}s, annotationNamespaces, - * rdfAnnotationNamespaces and extensions are empty. - * - */ - public Annotation() { - super(); - this.annotationNamespaces = new HashMap(); - this.rdfAnnotationNamespaces = new HashMap(); - this.extensions = new HashMap(); - this.nonRDFannotation = null; - this.history = null; - } - - /** - * Creates a new Annotation instance by cloning the given Annotation. - * - * @param annotation the annotation to be cloned. - */ - public Annotation(Annotation annotation) { - super(annotation); - this.annotationNamespaces = new HashMap(); - this.rdfAnnotationNamespaces = new HashMap(); - this.extensions = new HashMap(); - copy(annotation.getAnnotationNamespaces(), this.annotationNamespaces); - copy(annotation.getRDFAnnotationNamespaces(), this.rdfAnnotationNamespaces); - for (Map.Entry entry : annotation.extensions.entrySet()) { - this.extensions.put(new String(entry.getKey()), entry.getValue().clone()); - } - if (annotation.nonRDFannotation != null) { - this.nonRDFannotation = new StringBuilder(annotation.nonRDFannotation - .toString()); - } - for (CVTerm term : annotation.getListOfCVTerms()) { - getListOfCVTerms().add(term.clone()); - } - if (annotation.isSetHistory()) { - this.history = annotation.getHistory().clone(); - } - } - - /** - * Creates an {@link Annotation} instance from a list of {@link CVTerm} - * objects. By default, the {@link History} and otherAnnotation {@link String}s are - * null. The {@link Map}s annotationNamespaces, rdfAnnotationNamespaces and - * extensions are empty. - * - * @param cvTerms - * the list of {@link CVTerm}. - */ - public Annotation(List cvTerms) { - this(); - this.listOfCVTerms = cvTerms; - } - - /** - * Creates an {@link Annotation} instance from a given {@link Map} of - * annotations. By default, the {@link History} and otherAnnotation {@link String}s - * are null. The list of {@link CVTerm}s, rdfAnnotationNamespaces and - * extensions are empty. - * - * @param annotations - * a map containing an XML name space and a {@link String} - * containing all the annotation elements of this name space. - */ - public Annotation(Map annotations) { - this(); - this.annotationNamespaces = annotations; - } - - /** - * Creates an {@link Annotation} instance from a {@link String} containing non RDF - * annotation. By default, the {@link History} is null, the list of {@link CVTerm}s - * is empty. The {@link Map}s annotationNamespaces, rdfAnnotationNamespaces - * and extensions are empty. - * - * @param annotation - * a {@link String} containing non RDF annotation, it will be parsed to - * create a {@link Map} containing an XML name space associated with a - * {@link String} representing all the annotation elements of - * this name space. - * - */ - public Annotation(String annotation) { - this(); - this.nonRDFannotation = new StringBuilder(annotation); - } - - /** - * Creates an {@link Annotation} instance from a {@link String} containing - * non RDF annotation and a list of {@link CVTerm}. By default, the - * {@link History} is null. The {@link Map}s annotationNamespaces, - * rdfAnnotationNamespaces and extensions are empty. - * - * @param annotation - * a {@link String} containing non RDF annotation, it will be - * parsed to create a {@link Map} containing an XML name space - * associated with a {@link String} representing all the - * annotation elements of this name space. - * @param cvTerms - * the {@link List} of {@link CVTerm}. - */ - public Annotation(String annotation, List cvTerms) { - this(); - this.nonRDFannotation = new StringBuilder(annotation); - this.listOfCVTerms = cvTerms; - } - - /** - * Adds a namespace to the map annotationNamespace of this object. - * - * @param namespaceName an XML namespace name. - * @param prefix an optional prefix for the namespace. - * @param URI the URI of the namespace - */ - public void addAnnotationNamespace(String namespaceName, String prefix, - String URI) { - String key = (prefix.length() > 0) ? prefix + ":" + namespaceName - : namespaceName; - - this.annotationNamespaces.put(key, URI); - //TreeNodeAdapter adapter = new TreeNodeAdapter(URI, this); - //adapter.fireNodeAddedEvent(); - this.firePropertyChange(TreeNodeChangeEvent.annotationNameSpaces, null, URI); - } - - /** - * Adds a {@link CVTerm} and checks whether the required name spaces have - * already been added to the {@link #rdfAnnotationNamespaces}. If name - * spaces are missing, these are added automatically. - * - * @param cvTerm - * the {@link CVTerm} to add. - * @return true if the 'cvTerm' element has been added to the {@link List} - * of {@link Qualifier}s. - */ - public boolean addCVTerm(CVTerm cvTerm) { - if (listOfCVTerms == null) { - listOfCVTerms = new LinkedList(); - } - if (!rdfAnnotationNamespaces.containsKey(URI_RDF_SYNTAX_NS)) { - addRDFAnnotationNamespace("rdf", "", URI_RDF_SYNTAX_NS); - } - Type type = cvTerm.getQualifierType(); - if ((type != null) && (type != Type.UNKNOWN_QUALIFIER) - && !rdfAnnotationNamespaces.containsKey(type.getNamespaceURI())) { - addRDFAnnotationNamespace(type.getElementNameEquivalent(), "", type - .getNamespaceURI()); - } - cvTerm.parent = this; - boolean success = listOfCVTerms.add(cvTerm); - firePropertyChange(TreeNodeChangeEvent.addCVTerm, null, cvTerm); - return success; - } - - /** - * Adds an Annotation extension object to the extensions map of this object. - * - * @param namespace the name space. - * @param annotation the annotation extension object. - */ - public void addExtension(String namespace, Annotation annotation) { - this.extensions.put(namespace, annotation); - firePropertyChange(TreeNodeChangeEvent.addExtension, null, annotation); - } - - /** - * Adds a name space to the rdfAnnotationNamespaces {@link Map} of this - * object. - * - * @param namespaceName - * the name space name - * @param prefix - * the name space prefix - * @param URI - * the name space URI - */ - public void addRDFAnnotationNamespace(String namespaceName, String prefix, - String URI) { - // TODO : prefix is ignored, is it normal ?? - this.rdfAnnotationNamespaces.put(URI, namespaceName); - firePropertyChange(TreeNodeChangeEvent.rdfAnnotationNamespaces, null, URI); - } - - /** - * Appends some'annotation' to the non RDF annotation StringBuilder of this object. - * - * @param annotation some non RDF annotations. - */ - public void appendNoRDFAnnotation(String annotation) { - StringBuilder oldNonRDFAnnotation = null; - - if (this.nonRDFannotation == null) { - this.nonRDFannotation = new StringBuilder(annotation); - } else { - oldNonRDFAnnotation = nonRDFannotation; - this.nonRDFannotation.append(annotation); - } - - firePropertyChange(TreeNodeChangeEvent.nonRDFAnnotation, - oldNonRDFAnnotation, nonRDFannotation); - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - public Annotation clone() { - return new Annotation(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Annotation annotation = (Annotation) object; - // TODO: As soon as NonRDFannotation is also represented in form of XMLNodes, we won't have to check this here because this will also be done in the super class. - equals &= isSetNonRDFannotation() == annotation - .isSetNonRDFannotation(); - if (equals && isSetNonRDFannotation()) { - equals = nonRDFannotation.equals(annotation - .getNonRDFannotation()); - } - equals &= isSetAbout() == annotation.isSetAbout(); - if (equals && isSetAbout()) { - equals &= getAbout().equals(annotation.getAbout()); - } - } - return equals; - } - - /** - * Returns a list of CVTerm having the given qualifier. - * - * @param qualifier the qualifier - * @return a list of CVTerm having the given qualifier, an empty - * list is returned if no CVTerm are found. - */ - public List filterCVTerms(Qualifier qualifier) { - LinkedList l = new LinkedList(); - CVTermFilter filter = new CVTermFilter(qualifier); - for (CVTerm term : getListOfCVTerms()) { - if (filter.accepts(term)) { - l.add(term); - } - } - return l; - } - - /** - * Returns a list of CVTerm having the given qualifier and - * where the URI contains the given pattern. The pattern can only be plain text. - * - * @param qualifier the qualifier. - * @param pattern a plain text pattern. - * @return a list of CVTerm having the given qualifier and - * where the URI matches the given pattern. - */ - public List filterCVTerms(Qualifier qualifier, String pattern) { - List l = new LinkedList(); - for (CVTerm c : filterCVTerms(qualifier)) { - l.addAll(c.filterResources(pattern)); - } - return l; - } - - /** - * Returns the about String of this object. - * - * @return the about String of this object. - */ - public String getAbout() { - return about == null ? "" : about; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return true; - } - - /** - * Returns the StringBuilder representing non RDF annotations. - * - * @return the StringBuilder representing non RDF annotations. - */ - public StringBuilder getAnnotationBuilder() { - return this.nonRDFannotation; - } - - /** - * Returns the annotationNamespace map of this object. - * - * @return the annotationNamespace map of this object. - */ - public Map getAnnotationNamespaces() { - return annotationNamespaces; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - if (childIndex < 0) { - throw new IndexOutOfBoundsException(childIndex + " < 0"); - } - int pos = 0; - if (isSetHistory()) { - if (childIndex == pos) { - return getHistory(); - } - pos++; - } - if (isSetListOfCVTerms()) { - if (childIndex == pos) { - return new TreeNodeAdapter(getListOfCVTerms(), this); - } - pos++; - } - if (extensions.size() > 0) { - if (childIndex == pos) { - return new TreeNodeAdapter(extensions, this); - } - pos++; - } -// if (isSetNonRDFannotation()) { -// if (childIndex == pos) { -// return new TreeNodeAdapter(getNonRDFannotation()); -// } -// pos++; -// } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - childIndex, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - int count = 0; - if (isSetHistory()) { - count++; - } - if (isSetListOfCVTerms()) { - count++; - } - if (extensions.size() > 0) { - count++; - } -// if (isSetNonRDFannotation()) { -// count++; -// } - return count; - } - - /** - * Returns the CVTerm at the ith position in the list of CVTerms. - * - * @param i the index of the CVTerm to retrieve. - * @return the CVTerm at the ith position in the list of CVTerms. - */ - public CVTerm getCVTerm(int i) { - return listOfCVTerms.get(i); - } - - /** - * Returns the Annotation extension object matching 'namespace'. Return null - * if there is no matching object. - * - * @param namespace the namespace - * @return the Annotation extension object matching 'namespace'. Return null - * if there is no matching object. - */ - // TODO : we need to clear things up in this class to be sure that we use namespace url or some name/prefix only - public Annotation getExtension(String namespace) { - return this.extensions.get(namespace); - } - - /** - * Returns the {@link History} of the Annotation. - * - * @return the {@link History} of the Annotation. - */ - public History getHistory() { - if (!isSetHistory()) { - createHistory(); - } - return history; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBase#getHistory() - */ - private History createHistory() { - history = new History(); - history.parent = this; - history.addAllChangeListeners(getListOfTreeNodeChangeListeners()); - - return history; - } - - /** - * Returns the list of CVTerms. If they are no CVTerm, an empty list is returned. - * - * @return the list of CVTerms. - */ - public List getListOfCVTerms() { - if (listOfCVTerms == null) { - listOfCVTerms = new LinkedList(); // Should never happen, to remove ? - } - return listOfCVTerms; - } - - /** - * Returns the list of all the namespaces of all the packages which extend - * this object. - * - * @return the list of all the namespaces of all the packages which extend - * this object. - */ - public Set getNamespaces() { - return this.extensions.keySet(); - } - - /** - * Returns the String containing annotations other than RDF - * annotation. - * - * @return the String containing annotations other than RDF - * annotation. Return null if there are none. - */ - public String getNonRDFannotation() { - if (nonRDFannotation != null) { - return nonRDFannotation.toString(); - } - return null; - } - - /** - * Gives the number of {@link CVTerm}s in this {@link Annotation}. - * - * @return the number of controlled vocabulary terms in this {@link Annotation}. - * @deprecated use {@link #getCVTermCount()} - */ - @Deprecated - public int getNumCVTerms() { - return getCVTermCount(); - } - - /** - * Gives the number of {@link CVTerm}s in this {@link Annotation}. - * - * @return the number of controlled vocabulary terms in this {@link Annotation}. - */ - public int getCVTermCount() { - return isSetListOfCVTerms() ? listOfCVTerms.size() : 0; - } - - /** - * Returns the rdfAnnotationNamespaces {@link Map} of this object. - * - * @return the rdfAnnotationNamespaces {@link Map} of this object. - */ - public Map getRDFAnnotationNamespaces() { - if (rdfAnnotationNamespaces == null) { - rdfAnnotationNamespaces = new HashMap(); - } - return rdfAnnotationNamespaces; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 809; - int hashCode = super.hashCode(); - if (isSetNonRDFannotation()) { - hashCode += prime * getNonRDFannotation().hashCode(); - } - if (isSetAbout()) { - hashCode += prime * about.hashCode(); - } - return hashCode; - } - - /** - * Inserts 'annotation' to the non RDF annotation StringBuilder - * at position 'offset'. - * - * @param annotation the piece of annotation to add. - * @param offset the position where to add it in the StringBuilder. - */ - // TODO : check if this method is used and needed. Could also be used to insert the missing namespaces - // before creating the DOM tree. - public void insertNoRDFAnnotation(String annotation, int offset) { - String oldNonRDFAnnotation = null; - - if (this.nonRDFannotation == null) { - this.nonRDFannotation = new StringBuilder(annotation); - } else { - oldNonRDFAnnotation = nonRDFannotation.toString(); - this.nonRDFannotation.insert(offset, annotation); - } - - firePropertyChange(TreeNodeChangeEvent.nonRDFAnnotation, - oldNonRDFAnnotation, nonRDFannotation.toString()); - } - - /** - * - * @return - */ - public boolean isEmpty() { - return (!isSetHistory() || history.isEmpty()) - && (getNumCVTerms() == 0) - && (!isSetOtherAnnotationThanRDF() || (nonRDFannotation.length() == 0)); - } - - /** - * Checks whether the 'about' element has been initialized. - * - * @return true if the 'about' element has been initialized. - */ - public boolean isSetAbout() { - return about != null; - } - - /** - * Checks if the Annotation is initialised. - * - *

An Annotation is initialised if - * at least one of the following is true : - *

  • there is some non RDF annotation - *
  • one or more CVTerm are defined - *
  • there is an history defined. - *

    - * - * @return true if the Annotation is initialised - */ - public boolean isSetAnnotation() { - if ((getNonRDFannotation() == null) && getListOfCVTerms().isEmpty() - && (!isSetHistory())) - { - return false; - - } else if ((getNonRDFannotation() == null) && (!isSetHistory()) - && !getListOfCVTerms().isEmpty()) - { - - for (int i = 0; i < getListOfCVTerms().size(); i++) { - if (getCVTerm(i) != null) { - return true; - } - } - } - return true; - } - - /** - * Checks if the {@link History} is initialised - * - * @return true if the {@link History} is initialised - */ - public boolean isSetHistory() { - return history != null; - } - - - /** - * Checks if the list of {@link CVTerm} is not empty. - * - * @return true if there is one or more {@link CVTerm} defined. - */ - public boolean isSetListOfCVTerms() { - return (listOfCVTerms != null) && (listOfCVTerms.size() > 0); - } - - /** - * Checks if the non RDF part of the Annotation is initialised. - * - *

    An Annotation is initialised if - * there is some non RDF annotation - *

    - * - * @return true if the non RDF part of the Annotation is initialised. - */ - public boolean isSetNonRDFannotation() { - if ((getNonRDFannotation() == null)) { - return false; - } - - return true; - } - - /** - * Returns true if there is some non RDF annotation. - *

    Same as {@link #isSetNonRDFannotation()} - * - * @return true if there is some non RDF annotation. - * @see #isSetNonRDFannotation() - * @deprecated please use {@link #isSetNonRDFannotation()} - */ - @Deprecated - public boolean isSetOtherAnnotationThanRDF() { - return isSetNonRDFannotation(); - } - - /** - * Checks if the RDF part of the Annotation is initialised. - * - *

    An Annotation is initialised if - * at least one of the following is true : - *

  • one or more CVTerm are defined - *
  • there is an history defined. - *

    - * - * @return true if the RDF part of the Annotation is initialised - */ - public boolean isSetRDFannotation() { - if (getListOfCVTerms().isEmpty() && (!isSetHistory())) { - return false; - } else if ((!isSetHistory()) && !getListOfCVTerms().isEmpty()) { - - for (int i = 0; i < getListOfCVTerms().size(); i++) { - if (getCVTerm(i) != null) { - return true; - } - } - } - return true; - } - - /** - * Sets the about instance of this object if the attributeName is equal to - * 'about'. - * - * @param attributeName the attribute name. - * @param prefix the attribute prefix. - * @param value the attribute value. - * @return true if an about XML attribute has been read - */ - public boolean readAttribute(String attributeName, String prefix, - String value) { - if (attributeName.equals("about")) { - setAbout(value); - return true; - } - return false; - } - - /** - * Sets the value of the about String of this object. - * - * @param about the about String to set. - */ - public void setAbout(String about) { - String oldAbout = this.about; - this.about = about; - firePropertyChange(TreeNodeChangeEvent.about, oldAbout, this.about); - } - - /** - * Sets the annotationNamespaces. - * - * @param annotationNamespaces the annotationNamespaces to set - */ - // TODO : we need to find better names for these class attributes and methods for 1.0 release - public void setAnnotationAttributes(NamedNodeMap annotationNamespaces) { - if (annotationNamespaces != null) { - for (int i = 0; i < annotationNamespaces.getLength(); i++) { - Node attribute = annotationNamespaces.item(i); - String oldValue = this.getAnnotationNamespaces().get(attribute.getNodeName()); - getAnnotationNamespaces().put(attribute.getNodeName(), - attribute.getNodeValue()); - firePropertyChange(TreeNodeChangeEvent.annotationNameSpaces, oldValue, attribute.getNodeValue()); - } - } - } - - /** - * Sets the annotationNamespaces. - * - * @param annotationNamespaces the annotationNamespaces to set - */ - public void setAnnotationNamespaces(Map annotationNamespaces) { - Map oldAnnotationNameSpaces = this.annotationNamespaces; - this.annotationNamespaces = annotationNamespaces; - firePropertyChange(TreeNodeChangeEvent.annotationNameSpaces, - oldAnnotationNameSpaces, this.annotationNamespaces); - } - - - /** - * Changes the {@link History} instance to 'history' - * - * @param history the history to set. - */ - public void setHistory(History history) { - History oldHistory = this.history; - this.history = history; - this.history.parent = this; - this.history.addAllChangeListeners(getListOfTreeNodeChangeListeners()); - firePropertyChange(TreeNodeChangeEvent.history, oldHistory, this.history); - } - - /** - * Sets the value of the non RDF annotations - * - * @param nonRDFAnnotation - */ - public void setNonRDFAnnotation(String nonRDFAnnotation) { - String oldNonRDFAnnotation = null; - if (nonRDFannotation != null) { - oldNonRDFAnnotation = nonRDFannotation.toString(); - } - nonRDFannotation = new StringBuilder(nonRDFAnnotation); - firePropertyChange(TreeNodeChangeEvent.nonRDFAnnotation, - oldNonRDFAnnotation, nonRDFannotation.toString()); - } - - /** - * Sets the rdfAnnotationNamespace map to 'rdfAnnotationNamespaces'. - * - * @param rdfAnnotationNamespaces the rdfAnnotationNamespace {@link Map} to set. - */ - public void setRdfAnnotationNamespaces(Map rdfAnnotationNamespaces) { - Map oldRdfAnnotationNameSpaces = this.rdfAnnotationNamespaces; - this.rdfAnnotationNamespaces = rdfAnnotationNamespaces; - firePropertyChange(TreeNodeChangeEvent.rdfAnnotationNamespaces, - oldRdfAnnotationNameSpaces, this.rdfAnnotationNamespaces); - } - - /** - * Clears the {@link List} of {@link CVTerm}s and removes unnecessary - * entries from the {@link #rdfAnnotationNamespaces}. - */ - public void unsetCVTerms() { - if (listOfCVTerms != null) { - List oldListOfCVTerms = this.listOfCVTerms; - listOfCVTerms.clear(); - for (Type type : CVTerm.Type.values()) { - if (rdfAnnotationNamespaces.containsKey(type.getNamespaceURI())) { - rdfAnnotationNamespaces.remove(type.getNamespaceURI()); - } - } - listOfCVTerms = null; - firePropertyChange(TreeNodeChangeEvent.unsetCVTerms, - oldListOfCVTerms, listOfCVTerms); - } - } - - /** - * Sets the {@link History} instance of this object to null. - */ - public void unsetHistory() { - History oldHistory = null; - if (history != null) { - oldHistory = history; - } - this.history = null; - firePropertyChange(TreeNodeChangeEvent.history, oldHistory, history); - } - - /** - * Sets the non RDF annotation String to null. - */ - public void unsetNonRDFannotation() { - String oldNonRDFAnnotation = null; - if (nonRDFannotation != null) { - oldNonRDFAnnotation = nonRDFannotation.toString(); - } - if (isSetNonRDFannotation()) { - nonRDFannotation = null; - firePropertyChange(TreeNodeChangeEvent.nonRDFAnnotation, - oldNonRDFAnnotation, nonRDFannotation.toString()); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AnnotationElement.java b/IPK_lib/src/org/sbml/jsbml/AnnotationElement.java deleted file mode 100644 index ec491709b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AnnotationElement.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * $Id: AnnotationElement.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AnnotationElement.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * A common super class for all those elements that can be part of an {@link Annotation}. - * - * @author Andreas Dräger - * @version $Rev: 1212 $ - * @since 0.8 - * @date 08.07.2011 - */ -public abstract class AnnotationElement extends AbstractTreeNode { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 495755171215798027L; - - /** - * Creates a new empty {@link AnnotationElement} without any children, an - * empty list of {@link TreeNodeChangeListener}s, and a parent that is - * null. - */ - public AnnotationElement() { - super(); - } - - /** - * Clone constructor. - * - * @param annotation - */ - public AnnotationElement(AnnotationElement annotation) { - super(annotation); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Assignment.java b/IPK_lib/src/org/sbml/jsbml/Assignment.java deleted file mode 100644 index 9d8e7de3d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Assignment.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * $Id: Assignment.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Assignment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * An {@link Assignment} can be seen as a mathematical equation with a - * {@link Variable} on the left hand side and an equation on the right hand side - * that assigns a value to the {@link Variable}. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public interface Assignment extends MathContainer { - - /** - * Error message to indicate that a {@link SpeciesReference} cannot be used - * as the {@link Variable} in this {@link Assignment} because the SBML Level - * < 3. - */ - public static final String ILLEGAL_VARIABLE_EXCEPTION_MSG = "Cannot set SpeciesReference %s as the Variable in %s for SBML Level < 3"; - - /** - * Error message to be displayed in case that a {@link Variable} with - * constant property set to true is to be assigned to this - * {@link Assignment}. - */ - public static final String ILLEGAL_CONSTANT_VARIABLE_MSG = "Cannot set the constant variable %s as the target of this %s."; - - /** - * Message to be displayed if no {@link Variable} can be found in the - * associated {@link Model} that would have the desired identifier. - */ - public static final String NO_SUCH_VARIABLE_EXCEPTION_MSG = "Model %s does not contain any variable with identifier %s."; - - /** - * Returns the variableID of this {@link Assignment}. Returns an empty - * {@link String} if it is not set. - * - * @return the variableID of this {@link Assignment}. Returns an empty - * {@link String} if it is not set. - */ - public String getVariable(); - - /** - * Returns the {@link Variable} instance which has the variableID of this - * {@link Assignment} as id. Return null if it doesn't exist. - * - * @return the {@link Variable} instance which has the variableID of this - * {@link Assignment} as id. Return null if it doesn't exist. - */ - public Variable getVariableInstance(); - - /** - * Returns true if the variableID of this {@link Assignment} is not null. - * - * @return true if the variableID of this {@link Assignment} is not null. - */ - public boolean isSetVariable(); - - /** - * Returns true if the {@link Variable} instance which has the variableID of - * this {@link Assignment} as id is not null. - * - * @return true if the {@link Variable} instance which has the variableID of - * this {@link Assignment} as id is not null. - */ - public boolean isSetVariableInstance(); - - /** - * Sets the variableID of this {@link Assignment} to the given value. Listeners - * are notified about this change. - * - * @param variableID - * : the variable to set - */ - public void setVariable(String variableID); - - /** - * Sets the variableID of this {@link Assignment} to the id of the - * {@link Variable} 'variable'.Listeners are notified about this change. - * - * @param variable - * : the variable to set - */ - public void setVariable(Variable variable); - - /** - * Removes the reference from this InitialAssignment to its {@link Variable} - * if there was any, i.e., the {@link Variable} is set to null. Listeners - * are notified about this change. - */ - public void unsetVariable(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/AssignmentRule.java b/IPK_lib/src/org/sbml/jsbml/AssignmentRule.java deleted file mode 100644 index 8817db9f7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/AssignmentRule.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * $Id: AssignmentRule.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/AssignmentRule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * - * Represents the assignmentRule XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class AssignmentRule extends ExplicitRule { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 683172080347613789L; - - /** - * Creates an AssignmentRule instance. By default, the variableID is null. - */ - public AssignmentRule() { - super(); - } - - /** - * Creates a cloned AssignmentRule instance from a given AssignmentRule. - * - * @param ar the AssignmentRule to clone. - */ - public AssignmentRule(AssignmentRule ar) { - super(ar); - } - - /** - * Creates a cloned AssignmentRule instance from a given {@link ExplicitRule}. - * - * @param rule the AssignmentRule to clone. - */ - public AssignmentRule(ExplicitRule rule) { - super(rule); - } - - /** - * Creates an AssignmentRule instance from a given math, level and version. - * - * @param math the math - * @param level the SBML level - * @param version the SBML version - */ - public AssignmentRule(ASTNode math, int level, int version) { - super(math, level, version); - } - - /** - * Creates an AssignmentRule instance from a given math and Parameter. - * - * @param math the math - * @param parameter the parameter - */ - public AssignmentRule(ASTNode math, Parameter parameter) { - this(parameter, math); - } - - /** - * Creates an AssignmentRule instance from a given math and {@link Variable}. - * - * @param math the math - * @param variable the variable - */ - public AssignmentRule(ASTNode math, Variable variable) { - this(variable, math); - } - - /** - * Creates an AssignmentRule instance with the given level and version. - * - * @param level - * the SBML level - * @param version - * the SBML version - */ - public AssignmentRule(int level, int version) { - super(level, version); - } - - /** - * Creates an AssignmentRule instance from a given Parameter. - * - * @param parameter the parameter - */ - public AssignmentRule(Parameter parameter) { - super(parameter); - } - - /** - * Creates an AssignmentRule instance from a given math and Parameter. - * - * @param parameter the parameter - * @param math the math - */ - public AssignmentRule(Parameter parameter, ASTNode math) { - super(parameter, math); - } - - /** - * Creates an AssignmentRule instance from a given variable. Takes level and - * version from the variable. - * - * @param variable the {@link Variable} - */ - public AssignmentRule(Variable variable) { - super(variable); - } - - /** - * Creates an AssignmentRule instance from a given variable and math. Takes - * level and version from the variable. - * - * @param variable the {@link Variable} - * @param math the math - */ - public AssignmentRule(Variable variable, ASTNode math) { - super(variable, math); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#clone() - */ - public AssignmentRule clone() { - return new AssignmentRule(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - if (getLevel() == 1) { - if (isSpeciesConcentration()) { - switch (getVersion()) { - case 1: - return "specieConcentrationRule"; - case 2: - return "speciesConcentrationRule"; - default: - break; - } - } else if (isCompartmentVolume()) { - return "compartmentVolumeRule"; - } else if (isParameter()) { - return "parameterRule"; - } - } - return super.getElementName(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#isScalar() - */ - public boolean isScalar() { - return true; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/CVTerm.java b/IPK_lib/src/org/sbml/jsbml/CVTerm.java deleted file mode 100644 index 1f7212f69..000000000 --- a/IPK_lib/src/org/sbml/jsbml/CVTerm.java +++ /dev/null @@ -1,873 +0,0 @@ -/* - * $Id: CVTerm.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/CVTerm.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeAdapter; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Contains all the MIRIAM URIs for a MIRIAM qualifier in the annotation element - * of a SBML component. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class CVTerm extends AnnotationElement { - - /** - * The Uniform Resource Identifier pointing to http://biomodels.net/model-qualifiers/ - */ - public static final String URI_BIOMODELS_NET_MODEL_QUALIFIERS = "http://biomodels.net/model-qualifiers/"; - /** - * The Uniform Resource Identifier pointing to http://biomodels.net/biology-qualifiers/ - */ - public static final String URI_BIOMODELS_NET_BIOLOGY_QUALIFIERS = "http://biomodels.net/biology-qualifiers/"; - - - // TODO : it would be probably safer to try to load the list a qualifier - // from the web at http://www.ebi.ac.uk/miriam/main/qualifiers/xml/ - // We can have a copy of the file in the jar in case the web access fail but - // the online one would be better as you can have new qualifiers defined at - // any time. - - /** - * This enum list all the possible MIRIAM qualifiers. - * - */ - public static enum Qualifier { - /** - * Represents the MIRIAM biological qualifier 'encodes'. - */ - BQB_ENCODES, - /** - * Represents the MIRIAM biological qualifier 'hasPart'. - */ - BQB_HAS_PART, - /** - * Represents the MIRIAM biological qualifier 'hasProperty'. - */ - BQB_HAS_PROPERTY, - /** - * Represents the MIRIAM biological qualifier 'hasVersion'. - */ - BQB_HAS_VERSION, - /** - * Represents the MIRIAM biological qualifier 'is'. - */ - BQB_IS, - /** - * Represents the MIRIAM biological qualifier 'isDescribedBy'. - */ - BQB_IS_DESCRIBED_BY, - /** - * Represents the MIRIAM biological qualifier 'isEncodedBy'. - */ - BQB_IS_ENCODED_BY, - /** - * Represents the MIRIAM biological qualifier 'isHomologTo'. - */ - BQB_IS_HOMOLOG_TO, - /** - * Represents the MIRIAM biological qualifier 'isPartOf'. - */ - BQB_IS_PART_OF, - /** - * Represents the MIRIAM biological qualifier 'isPropertyOf'. - */ - BQB_IS_PROPERTY_OF, - /** - * Represents the MIRIAM biological qualifier 'isVersionOf'. - */ - BQB_IS_VERSION_OF, - /** - * Represents the MIRIAM biological qualifier 'occursIn'. - */ - BQB_OCCURS_IN, - /** - * Represents an unknown MIRIAM biological qualifier. - */ - BQB_UNKNOWN, - /** - * Represents the MIRIAM model qualifier 'is'. - */ - BQM_IS, - /** - * Represents the MIRIAM model qualifier 'isDerivedFrom'. - */ - BQM_IS_DERIVED_FROM, - /** - * Represents the MIRIAM model qualifier 'isDescribedBy'. - */ - BQM_IS_DESCRIBED_BY, - /** - * Represents an unknown MIRIAM model qualifier. - */ - BQM_UNKNOWN; - - /** - * Returns a name corresponding to this Qualifier Object. - * - * @return a name corresponding to this Qualifier Object. - */ - public String getElementNameEquivalent() { - switch (this) { - case BQB_ENCODES: - return "encodes"; - case BQB_HAS_PART: - return "hasPart"; - case BQB_HAS_VERSION: - return "hasVersion"; - case BQB_HAS_PROPERTY: - return "hasProperty"; - case BQB_IS_PROPERTY_OF: - return "isPropertyOf"; - case BQB_IS: - return "is"; - case BQB_IS_DESCRIBED_BY: - return "isDescribedBy"; - case BQB_IS_ENCODED_BY: - return "isEncodedBy"; - case BQB_IS_HOMOLOG_TO: - return "isHomologTo"; - case BQB_IS_PART_OF: - return "isPartOf"; - case BQB_IS_VERSION_OF: - return "isVersionOf"; - case BQB_OCCURS_IN: - return "occursIn"; - case BQM_IS: - return "is"; - case BQM_IS_DESCRIBED_BY: - return "isDescribedBy"; - case BQM_IS_DERIVED_FROM: - return "isDerivedFrom"; - default: - return "unknownQualifier"; - } - } - - /** - * Returns true if this qualifier is a biological qualifier. - * - * @return true if this qualifier is a biological qualifier, - * false otherwise. - */ - public boolean isBiologicalQualifier() { - return !isModelQualifier(); - } - - /** - * Returns true if this qualifier is a model qualifier. - * - * @return true if this qualifier is a model qualifier, - * false otherwise. - */ - public boolean isModelQualifier() { - return toString().startsWith("BQM_"); - } - } - - /** - * This enum list all the possible MIRIAM qualifiers type. - * - */ - public static enum Type { - /** - * If the MIRIAM qualifier is a biological qualifier. - */ - BIOLOGICAL_QUALIFIER, - /** - * If the MIRIAM qualifier is a model qualifier. - */ - MODEL_QUALIFIER, - /** - * If the MIRIAM qualifier is unknown. - */ - UNKNOWN_QUALIFIER; - - - /** - * Returns a name corresponding to this Type of qualifier Object. - * - * @return a name corresponding to this Type of qualifier Object. - */ - public String getElementNameEquivalent() { - switch (this) { - case BIOLOGICAL_QUALIFIER: - return "bqbiol"; - case MODEL_QUALIFIER: - return "bqmodel"; - case UNKNOWN_QUALIFIER: - return "unknown"; - default: - return null; - } - } - - /** - * Returns the name space associated to this {@link Type}. - * @return - */ - public String getNamespaceURI() { - switch (this) { - case BIOLOGICAL_QUALIFIER: - return URI_BIOMODELS_NET_BIOLOGY_QUALIFIERS; - case MODEL_QUALIFIER: - return URI_BIOMODELS_NET_MODEL_QUALIFIERS; - default: - return null; - } - } - } - - /** - * Message to indicate an illegal combination of a {@link Type} and a - * {@link Qualifier} attribute. - */ - private static final String INVALID_TYPE_AND_QUALIFIER_COMBINATION_MSG = "Invalid combination of type %s with qualifier %s."; - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -3648054739091227113L; - - /** - * Represents the MIRIAM qualifier node in the annotation node of a SBML - * component. - */ - private Qualifier qualifier; - - /** - * Contains all the MIRIAM URI associated with the qualifier of this {@link CVTerm} - * instance. - */ - private List resourceURIs; - - /** - * Represents the type of MIRIAM qualifier for this {@link CVTerm}. It - * depends on the name space in the SBML file, it can be a model qualifier - * or a biological qualifier. - */ - private Type type; - - /** - * Creates a {@link CVTerm} instance. By default, the type and qualifier of - * this {@link CVTerm} are null. The list of resourceURIS is empty. - */ - public CVTerm() { - super(); - type = Type.UNKNOWN_QUALIFIER; - qualifier = null; - resourceURIs = new LinkedList(); - } - - /** - * Creates a {@link CVTerm} instance from a given {@link CVTerm}. - * - * @param term the {@link CVTerm} to clone - */ - public CVTerm(CVTerm term) { - super(term); - this.type = term.getQualifierType(); - switch (type) { - case MODEL_QUALIFIER: - qualifier = term.getModelQualifierType(); - break; - case BIOLOGICAL_QUALIFIER: - qualifier = term.getBiologicalQualifierType(); - break; - default: // UNKNOWN - qualifier = null; - break; - } - resourceURIs = new LinkedList(); - for (int i = 0; i < term.getNumResources(); i++) { - String resource = term.getResourceURI(i); - if (resource != null) { - resourceURIs.add(new String(term.getResourceURI(i))); - } - } - } - - /** - * Guesses the {@link Type} argument and sets the {@link Qualifier} - * attribute appropriately. Then it adds all the given resources. - * - * @param qualifier - * @param resources - */ - public CVTerm(Qualifier qualifier, String... resources) { - this(); - if (qualifier.isBiologicalQualifier()) { - setQualifierType(Type.BIOLOGICAL_QUALIFIER); - setBiologicalQualifierType(qualifier); - } else { - setQualifierType(Type.MODEL_QUALIFIER); - setModelQualifierType(qualifier); - } - addResources(resources); - } - - /** - * Creates a new {@link CVTerm} with the given {@link Type} and - * {@link Qualifier} pointing to all given resources. - * - * @param type - * @param qualifier - * @param resources - * @throws IllegalArgumentException - * if the combination of the given type and qualifier is not - * possible or if the given resources are invalid. - */ - public CVTerm(Type type, Qualifier qualifier, String... resources) { - this(); - setQualifierType(type); - if (isBiologicalQualifier()) { - setBiologicalQualifierType(qualifier); - } else if (isModelQualifier()) { - setModelQualifierType(qualifier); - } else { - throw new IllegalArgumentException(String - .format(INVALID_TYPE_AND_QUALIFIER_COMBINATION_MSG, type, - qualifier)); - } - for (String resource : resources) { - addResource(resource); - } - } - - /** - * Adds a resource to the {@link CVTerm}. - * - *

    Same method a {@link #addResourceURI(String)} - * - * @param urn - * string representing the resource; e.g., - * 'urn:miriam:kegg.reaction:R00351' - * @return true as specified in {@link Collection#add(Object)} - */ - public boolean addResource(String urn) { - boolean contains = resourceURIs.contains(urn); - boolean success = resourceURIs.add(urn); - if (success && !contains) { - (new TreeNodeAdapter(urn, this)).fireNodeAddedEvent(); - } - return success; - } - - /** - * Adds list of resources to the {@link CVTerm}. - * - * @param resources a list of strings representing the resources; e.g., - * 'urn:miriam:kegg.reaction:R00351' - * @return true if all the resources have been added properly. - */ - public boolean addResources(String... resources) { - boolean success = true; - for (String resource : resources) { - success &= addResource(resource); - } - return success; - } - - /** - * Adds a resource to the {@link CVTerm}. - * - *

    Same method a {@link #addResource(String)} - * - * @param uri - * string representing the resource; e.g., - * 'urn:miriam:kegg.reaction:R00351' - * - * @return true if 'uri' has been added to the list of resourceURI of this - * CVTerm. - */ - public boolean addResourceURI(String uri) { - return addResource(uri); - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - public CVTerm clone() { - return new CVTerm(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - CVTerm t = (CVTerm) object; - equals &= t.getQualifierType() == getQualifierType(); - equals &= (t.getBiologicalQualifierType() == qualifier) - || (t.getModelQualifierType() == qualifier); - } - return equals; - } - - /** - * Returns a list of resources that contain the given pattern. This is - * useful to obtain, e.g., all KEGG resources this term points to. - * - * @param pattern - * e.g., "urn:miriam:kegg.reaction:R" or just "kegg". - * @return A list of all resources that contain the given pattern. This list - * can be empty. - */ - public List filterResources(String pattern) { - LinkedList selectedResources = new LinkedList(); - for (String resource : resourceURIs) { - if (resource.contains(pattern)) { - selectedResources.add(resource); - } - } - return selectedResources; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return true; - } - - /** - * Returns the Biological QualifierType code for this CVTerm. - * - * @return the Biological QualifierType code for this CVTerm. - */ - public Qualifier getBiologicalQualifierType() { - if (type == Type.BIOLOGICAL_QUALIFIER) { - return qualifier; - } - return null; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - return new TreeNodeAdapter(getResourceURI(childIndex), this); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - return getResources().size(); - } - - /** - * Returns the Model QualifierType code for this CVTerm. - * - * @return the Model QualifierType code for this CVTerm. - */ - public Qualifier getModelQualifierType() { - if (type == Type.MODEL_QUALIFIER) { - return qualifier; - } - return null; - } - - /** - * Returns the number of resources for this {@link CVTerm}. - * - * @return the number of resources for this {@link CVTerm}. - * @use {@link #getResourceCount()} - */ - @Deprecated - public int getNumResources() { - return getResourceCount(); - } - - /** - * Returns the number of resources for this {@link CVTerm}. - * - * @return the number of resources for this {@link CVTerm}. - */ - public int getResourceCount() { - return resourceURIs.size(); - } - - /** - * Returns the Qualifier Type code for this CVTerm. - * - * @return the Qualifier Type code for this CVTerm. - */ - public Type getQualifierType() { - return type; - } - - /** - * Returns the resources for this CVTerm. - * - * @return the list of urns that store the resources of this CVTerm. - */ - public List getResources() { - return resourceURIs; - } - - /** - * Returns the value of the nth resource for this CVTerm. - * - * @param i - * : index of the resourceURI in the list of the resourceURI. - * @return the value of the nth resource for this CVTerm. - */ - public String getResourceURI(int i) { - return resourceURIs.get(i); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 821; - int hashCode = super.hashCode(); - if (isSetQualifierType()) { - hashCode += prime * getQualifierType().hashCode(); - } - if (isSetBiologicalQualifierType()) { - hashCode += prime * getBiologicalQualifierType().hashCode(); - } - return hashCode; - } - - /** - * Returns true if this qualifier is a biological qualifier. - * - * @return true if this qualifier is a biological qualifier, - * false otherwise. - */ - public boolean isBiologicalQualifier() { - return type.equals(Type.BIOLOGICAL_QUALIFIER); - } - - /** - * Returns true if this qualifier is a model qualifier. - * - * @return true if this qualifier is a model qualifier, - * false otherwise. - */ - public boolean isModelQualifier() { - return type.equals(Type.MODEL_QUALIFIER); - } - - /** - * @return - */ - public boolean isSetBiologicalQualifierType() { - return getBiologicalQualifierType() != null; - } - - /** - * Checks whether or not the {@link Qualifier} has been set for this - * {@link CVTerm}. - * - * @return - */ - public boolean isSetQualifierType() { - return getQualifierType() != null; - } - - /** - * Returns true if the Type of this CVTerm is set. - * - * @return true if the Type of this CVTerm is set. - */ - public boolean isSetType() { - return (type != null) && !type.equals(Type.UNKNOWN_QUALIFIER); - } - - /** - * Returns true if the {@link Qualifier} of this {@link CVTerm} - * is set. - * - * @return true if the {@link Qualifier} of this {@link CVTerm} - * is set. - */ - public boolean isSetTypeQualifier() { - return qualifier != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String elementName, String attributeName, String prefix, String value) - */ - public boolean readAttribute(String elementName, String attributeName, - String prefix, String value) { - - if (elementName.equals("li")) { - if (attributeName.equals("resource")) { - addResourceURI(value); - return true; - } - } - return false; - } - - /** - * Removes a resource from the {@link CVTerm}. - * - * @param resource - */ - public void removeResource(String resource) { - for (int i = resourceURIs.size(); i >= 0; i--) { - if (resourceURIs.get(i).equals(resource)) { - String urn = resourceURIs.remove(i); - (new TreeNodeAdapter(urn, this)).fireNodeRemovedEvent(); - } - } - } - - /** - * Removes the ith resource from the {@link CVTerm}. - * - * @param resource - */ - public void removeResource(int index) { - resourceURIs.remove(index); - } - - /** - * Sets the biological qualifier type. - * - * @param specificQualifierType - */ - public void setBiologicalQualifierType(int specificQualifierType) { - setBiologicalQualifierType(Qualifier.values()[specificQualifierType]); - } - - /** - * Sets the biological qualifier type of this {@link CVTerm}. - * - * @param qualifier - */ - public void setBiologicalQualifierType(Qualifier qualifier) { - if (qualifier != null) { - if (qualifier.toString().startsWith("BQB")) { - if (this.type == Type.BIOLOGICAL_QUALIFIER) { - Qualifier oldValue = this.qualifier; - this.qualifier = qualifier; - this.firePropertyChange(TreeNodeChangeEvent.qualifier, oldValue, qualifier); - } else { - throw new IllegalArgumentException(String.format( - INVALID_TYPE_AND_QUALIFIER_COMBINATION_MSG, type, - qualifier)); - } - } else { - throw new IllegalArgumentException(String.format( - "%s is not a valid Biological Qualifier.", qualifier - .toString())); - } - } - } - - /** - * Sets the model qualifier type of this {@link CVTerm}. - * - * @param specificQualifierType - */ - public void setModelQualifierType(int specificQualifierType) { - final int NUM_BIOLOGICAL_QUALIFIER_TYPES = 11; - setBiologicalQualifierType(Qualifier.values()[specificQualifierType - - NUM_BIOLOGICAL_QUALIFIER_TYPES]); - } - - /** - * Sets the model qualifier type of this {@link CVTerm}. - * - * @param qualifier - */ - public void setModelQualifierType(Qualifier qualifier) { - if (qualifier != null) { - if (qualifier.toString().startsWith("BQM")) { - if (this.type == Type.MODEL_QUALIFIER) { - Qualifier oldValue = this.qualifier; - this.qualifier = qualifier; - this.firePropertyChange(TreeNodeChangeEvent.qualifier, oldValue, qualifier); - } else { - throw new IllegalArgumentException( - "Model qualifier types can only be applyed if the type is set to Model Qualifier."); - } - } else { - throw new IllegalArgumentException(String.format( - "%s is not a valid Model !ualifier.", qualifier - .toString())); - } - } - } - - // TODO : check that this 3 functions are doing the good things and - // selecting the proper qualifier - /** - * Sets the type of this {@link CVTerm} to the {@link Type} represented by - * 'qualifierType'. - * - * @param qualifierType - * the Type to set as an integer. - */ - public void setQualifierType(int qualifierType) { - setQualifierType(Type.values()[qualifierType]); - } - - /** - * Sets the type of this {@link CVTerm} to 'type' - * - * @param type - */ - public void setQualifierType(Type type) { - if ((type == Type.MODEL_QUALIFIER) - || (type == Type.BIOLOGICAL_QUALIFIER) - || (type == Type.UNKNOWN_QUALIFIER)) { - Qualifier oldQualifier = this.qualifier; - Type oldType = this.type; - this.type = type; - - this.qualifier = type == Type.MODEL_QUALIFIER ? Qualifier.BQM_UNKNOWN - : Qualifier.BQB_UNKNOWN; - this.firePropertyChange(TreeNodeChangeEvent.type, oldType, this.type); - this.firePropertyChange(TreeNodeChangeEvent.qualifier, oldQualifier, this.qualifier); - } else { - throw new IllegalArgumentException(String.format( - "%s is not a valid qualifier.", type.toString())); - } - } - - /** - * Returns a {@link String} containing the qualifier and all the resource - * URIs of this {@link CVTerm}. - * - * @return a {@link String} containing the qualifier and all the resource - * URIs of this {@link CVTerm}. - */ - @Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - switch (getQualifierType()) { - case MODEL_QUALIFIER: - buffer.append("model "); - switch (getModelQualifierType()) { - case BQM_IS: - buffer.append("is"); - break; - case BQM_IS_DESCRIBED_BY: - buffer.append("is described by"); - break; - case BQM_IS_DERIVED_FROM: - buffer.append("is derived from"); - break; - default: // unknown - buffer.append("has something to do with"); - break; - } - break; - case BIOLOGICAL_QUALIFIER: - buffer.append("biological entity "); - switch (getBiologicalQualifierType()) { - case BQB_ENCODES: - buffer.append("encodes"); - break; - case BQB_HAS_PART: - buffer.append("has "); - buffer.append(resourceURIs.size() == 1 ? "a part" : "parts"); - break; - case BQB_HAS_VERSION: - buffer.append("has the version"); - break; - case BQB_HAS_PROPERTY: - buffer.append("has the property"); - break; - case BQB_IS: - buffer.append("is"); - break; - case BQB_IS_DESCRIBED_BY: - buffer.append("is described by"); - break; - case BQB_IS_ENCODED_BY: - buffer.append("is encoded by"); - break; - case BQB_IS_HOMOLOG_TO: - buffer.append("is homolog to"); - break; - case BQB_IS_PART_OF: - buffer.append("is a part of"); - break; - case BQB_IS_VERSION_OF: - buffer.append("is a version of"); - break; - case BQB_OCCURS_IN: - buffer.append("occurs in"); - break; - default: // unknown - buffer.append("has something to do with"); - break; - } - break; - default: // UNKNOWN_QUALIFIER - buffer.append("element has something to do with"); - break; - } - int i = 0; - if (resourceURIs.size() > 0) { - buffer.append(' '); - } - String uri; - for (i = 0; i < resourceURIs.size(); i++) { - uri = resourceURIs.get(i); - if (i > 0) { - buffer.append(", "); - } - buffer.append(uri); - } - return buffer.toString(); - } - - /** - * Writes all the MIRIAM annotations of the {@link CVTerm} in 'buffer' - * - * @param indent - * @param buffer - */ - public void toXML(String indent, StringBuffer buffer) { - if (resourceURIs != null) { - for (int i = 0; i < getResourceCount(); i++) { - String resourceURI = getResourceURI(i); - StringTools.append(buffer, "\n"); - } - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/CallableSBase.java b/IPK_lib/src/org/sbml/jsbml/CallableSBase.java deleted file mode 100644 index 5176a9c85..000000000 --- a/IPK_lib/src/org/sbml/jsbml/CallableSBase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * $Id: CallableSBase.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/CallableSBase.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -/** - * The interface {@link CallableSBase} represents an {@link SBase} that can be - * called in mathematical expressions, i.e., {@link ASTNode}, via its - * identifier. In terms of serialized SBML files, the identifiers of instances - * of {@link CallableSBase} can be used in ci elements within - * MathML expressions. All these elements can be found in the specification of - * SBML Level 3 Version 1 Core, Table 1 on page 21. Furthermore, - * {@link LocalParameter} also belongs to these elements. - * - * @author Andreas Dräger - * @date 2011-02-15 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface CallableSBase extends NamedSBaseWithDerivedUnit { - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Compartment.java b/IPK_lib/src/org/sbml/jsbml/Compartment.java deleted file mode 100644 index 19ba8e871..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Compartment.java +++ /dev/null @@ -1,948 +0,0 @@ -/* - * $Id: Compartment.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Compartment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.Locale; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the compartment in a model, i.e., a variable element with name, - * identifier, unit, and value that may change during a simulation. This is the - * container for reacting species. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class Compartment extends Symbol { - - /** - * This message will be displayed if the user tries to set the spatial - * dimensions of this element to a value other than 0, 1, 2, or 3. - */ - private static final String ERROR_MESSAGE_INVALID_DIM = "Spatial dimensions must be within {0, 3}, but %f was given."; - - /** - * This is the error message to be displayed if an application tries to set - * units or size attribute for this compartment but the spatial dimensions - * have been set to zero. - */ - private static final String ERROR_MESSAGE_ZERO_DIM = "Cannot set %s for compartment %s if the spatial dimensions are zero."; - - /** - * A {@link Logger} for this class. - */ - private static final transient Logger logger = Logger.getLogger(Compartment.class); - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1117854029388326636L; - /** - * Represents the compartmentType XML attribute of a compartment element. It - * matches a compartmentType id in the model. - */ - @Deprecated - private String compartmentTypeID; - /** - * Helper variable to check if spatial dimensions has been set by the user. - */ - private boolean isSetSpatialDimensions = false; - /** - * Represents the outside XML attribute of a compartment element. It matches - * a compartment id in the model instance. - */ - @Deprecated - private String outsideID; - /** - * Represents the spatialDimensions XML attribute of a compartment element. - */ - private Double spatialDimensions; - - /** - * Creates a Compartment instance. By default, if the level is set and is - * superior or equal to 3, sets the compartmentType, outsideID and - * spatialDimension to null. - */ - public Compartment() { - super(); - initDefaults(); - } - - /** - * Creates a Compartment instance from a given compartment. - * - * @param compartment the compartment object to clone. - */ - public Compartment(Compartment compartment) { - super(compartment); - - if (compartment.isSetCompartmentType()) { - this.compartmentTypeID = new String(compartment - .getCompartmentType()); - } else { - compartmentTypeID = compartment.compartmentTypeID == null ? null : new String(compartment.compartmentTypeID); - } - - if (compartment.isSetSpatialDimensions()) { - setSpatialDimensions(Double.valueOf(compartment - .getSpatialDimensions())); - } else { - spatialDimensions = compartment.spatialDimensions == null ? null : new Double(compartment.spatialDimensions); - } - - if (compartment.isSetOutside()) { - setOutside(new String(compartment.getOutside())); - } else { - outsideID = compartment.outsideID == null ? null : new String(compartment.outsideID); - } - - // size is set in the super clone constructor - } - - /** - * Creates a Compartment instance from a level and version. By default, if - * the level is set and is superior or equal to 3, sets the compartmentType, - * outsideID and spatialDimension to null. - * - * @param level the SBML level - * @param version the SBML level - */ - public Compartment(int level, int version) { - this(null, null, level, version); - } - - /** - * Creates a Compartment instance with the given id. - * - * @param id the compartment id. - */ - public Compartment(String id) { - this(); - setId(id); - } - - /** - * Creates a Compartment instance from an id, level and version. By default, - * sets the compartmentType, outsideID and spatialDimension to null. - * - * @param id the compartment id. - * @param level the SBML level - * @param version the SBML level - */ - public Compartment(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * Creates a Compartment instance from an id, name, level and version. By - * default, if the level is set and is superior or equal to 3, sets the - * compartmentType, outsideID and spatialDimension to null. - * - * @param id the compartment id. - * @param name the compartment name. - * @param level the SBML level - * @param version the SBML level - */ - public Compartment(String id, String name, int level, int version) { - super(id, name, level, version); - initDefaults(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#clone() - */ - public Compartment clone() { - return new Compartment(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Compartment c = (Compartment) object; - equals &= c.isSetOutside() == isSetOutside(); - if (equals && isSetOutside()) { - equals &= c.getOutside().equals(getOutside()); - } - equals &= c.isSetCompartmentType() == isSetCompartmentType(); - if (equals && isSetCompartmentType()) { - equals &= c.getCompartmentType().equals(getCompartmentType()); - } - // already checked by super class: - // equals &= c.getSize() == getSize(); - equals &= Double.valueOf(c.getSpatialDimensions()).equals(getSpatialDimensions()); - } - return equals; - } - - /** - * Returns the compartmentType id of this compartment. Return an empty - * String if it is not set. - * - * @return the compartmentType id of this compartment. Return an empty - * String if it is not set. - * @deprecated Only defined in SBML Level 2 Versions 2 through 4. - */ - @Deprecated - public String getCompartmentType() { - return isSetCompartmentType() ? this.compartmentTypeID : ""; - } - - /** - * Returns the compartmentType instance in Model for this compartment - * compartmentTypeID. Return null if there is no compartmentType - * instance which matches this compartmentTypeID. - * - * @return the compartmentType instance in Model for this compartment - * compartmentTypeID. Return null if there is no compartmentType - * instance which matches this compartmentTypeID. - */ - @Deprecated - public CompartmentType getCompartmentTypeInstance() { - Model m = getModel(); - return m != null ? m.getCompartmentType(this.compartmentTypeID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnitDefinition() - */ - @Override - public UnitDefinition getDerivedUnitDefinition() { - if ((getLevel() < 3) || isSetUnitsInstance()) { - return super.getDerivedUnitDefinition(); - } else if (isSetSpatialDimensions()) { - double dim = getSpatialDimensions(); - if ((dim - ((short) dim) == 0d)) { - Model model = getModel(); - if (model != null) { - // Look into the model for inherited units - switch ((short) dim) { - case 1: - return model.isSetLengthUnitsInstance() ? model.getLengthUnitsInstance() : null; - case 2: - return model.isSetAreaUnitsInstance() ? model.getAreaUnitsInstance() : null; - case 3: - return model.isSetVolumeUnitsInstance() ? model.getVolumeUnitsInstance() : null; - default: - break; - } - } - } - } - return null; - } - - /** - * Returns the outside id of this compartment. Return "" if it is not set. - * - * @return the outside id of this compartment. Return "" if it is not set. - */ - public String getOutside() { - return isSetOutside() ? outsideID : ""; - } - - /** - * Returns the compartment instance which matches the outside id in Model. - * Return null if no compartment instance matches the outside id. - * - * @return the compartment instance which matches the outside id in Model. - * Return null if no compartment instance matches the outside id. - */ - public Compartment getOutsideInstance() { - Model m = getModel(); - return m != null ? m.getCompartment(outsideID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getPredefinedUnitID() - */ - public String getPredefinedUnitID() { - if (getLevel() < 3) { - if (getLevel() < 2) { - return "volume"; - } - switch ((short) getSpatialDimensions()) { - case 3: - return "volume"; - case 2: - return "area"; - case 1: - return "length"; - default: - break; - } - } - return null; - } - - /** - * Returns the size of this compartment. - * - * @return the size of this compartment. - */ - public double getSize() { - return getValue(); - } - - /** - * Returns the {@link #spatialDimensions} of this {@link Compartment}. If it - * is not set and the level of this {@link Compartment} is either one or two - * it returns the default SBML Level 2 value, which is 3. In all other - * cases, {@link Double#NaN} will be returned. - * - * @return the {@link #spatialDimensions} of this {@link Compartment} or 3 - * if {@link #spatialDimensions} is not set and level is 1 or 2. - */ - public double getSpatialDimensions() { - if (isSetSpatialDimensions() && (spatialDimensions != null)) { - return spatialDimensions.doubleValue(); - } - if (getLevel() < 3) { - // Although in Level 1, no spatial dimensions are defined, but - // these are implicitly 3 due to the volume attribute. - return 3d; - } - return Double.NaN; - } - - /** - * - * @return - * @deprecated use {@link #getSpatialDimensions()} - */ - @Deprecated - public double getSpatialDimensionsAsDouble() { - return getSpatialDimensions(); - } - - /** - * Gets the volume of this Compartment - * - * This method is identical to getSize(). In SBML Level 1, compartments are - * always three-dimensional constructs and only have volumes, whereas in - * SBML Level 2, compartments may be other than three-dimensional and - * therefore the 'volume' attribute is named 'size' in Level 2. LibSBML - * provides both getSize() and getVolume() for easier compatibility between - * SBML Levels. - * - * @return the volume of this {@link Compartment} - * @deprecated The volume attribute is only defined in SBML Level 1. Please - * use {@link #getSize()}. - */ - @Deprecated - public double getVolume() { - return getSize(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#hashCode() - */ - @Override - public int hashCode() { - final int prime = 991; - int hashCode = super.hashCode(); - if (isSetOutside()) { - hashCode += prime * getOutside().hashCode(); - } - if (isSetCompartmentType()) { - hashCode += prime * getCompartmentType().hashCode(); - } - if (isSetSpatialDimensions()) { - hashCode += prime * spatialDimensions.hashCode(); - } - return hashCode; - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default values using the current Level/Version configuration. - * - * @param level - * @param version - */ - public void initDefaults(int level, int version) { - compartmentTypeID = null; - outsideID = null; - unitsID = null; - if (level < 3) { - spatialDimensions = Double.valueOf(3d); - if (level >= 2) { - constant = new Boolean(true); - } - else { - constant = null; - } - } else { - spatialDimensions = null; - constant = null; - } - - if (level == 1) { - value = Double.valueOf(1d); - } - } - - /** - * Returns true if the compartmentID of this compartment is not null. - * - * @return true if the compartmentID of this compartment is not null. - */ - public boolean isSetCompartmentType() { - return compartmentTypeID != null; - } - - /** - * Returns true if the compartmentType instance which matches the - * compartmentTypeID of this compartment is not null. - * - * @return true if the compartmentType instance which matches the - * compartmentTypeID of this compartment is not null. - */ - @Deprecated - public boolean isSetCompartmentTypeInstance() { - Model m = getModel(); - return m != null ? m.getCompartmentType(this.compartmentTypeID) != null - : false; - } - - /** - * Returns true if the outsideID of this compartment is not null. - * - * @return true if the outsideID of this compartment is not null. - */ - public boolean isSetOutside() { - return outsideID != null; - } - - /** - * Returns true if the compartment instance which matches the outsideID of - * this compartment is not null. - * - * @return true if the compartment instance which matches the outsideID of - * this compartment is not null. - */ - public boolean isSetOutsideInstance() { - Model m = getModel(); - return m != null ? m.getCompartment(this.outsideID) != null : false; - } - - /** - * Returns true if the size of this compartment has been set by a user. - * - * @return true if the size of this compartment has been set by a user. - */ - public boolean isSetSize() { - return isSetValue(); - } - - /** - * Returns true if the spatialDimensions of this compartment has been set by a user. - * - * @return true if the spatialDimensions of this compartment has been set by a user. - */ - public boolean isSetSpatialDimensions() { - return isSetSpatialDimensions; - } - - /** - *

    - * Returns true or false depending on whether this Compartment's 'volume' - * attribute has been set. - *

    - *

    - * Some words of explanation about the set/unset/isSet methods: SBML Levels - * 1 and 2 define certain attributes on some classes of objects as optional. - * This requires an application to be careful about the distinction between - * two cases: (1) a given attribute has never been set to a value, and - * therefore should be assumed to have the SBML-defined default value, and - * (2) a given attribute has been set to a value, but the value happens to - * be an empty string. LibSBML supports these distinctions by providing - * methods to set, unset, and query the status of attributes that are - * optional. The methods have names of the form setAttribute(...), - * unsetAttribute(), and isSetAttribute(), where Attribute is the the name - * of the optional attribute in question. - *

    - *

    - * This method is similar but not identical to {@link #isSetSize()}. The - * latter should not be used in the context of SBML Level 1 models because - * this method (isSetVolume()) performs extra processing to take into - * account the difference in default values between SBML Levels 1 and 2. - *

    - * - * @return true if the 'volume' attribute ('size' in L2) of this Compartment - * has been set, false otherwise. - * @see #isSetSize() - * @jsbml.note In SBML Level 1, a compartment's volume has a default value ( - * 1.0) and therefore this method will always return true. In - * Level 2, a compartment's size (the equivalent of SBML Level - * 1's 'volume') is optional and has no default value, and - * therefore may or may not be set. - * @deprecated The volume attribute is only defined in SBML Level 1. Please - * use {@link #isSetSize()} - */ - @Deprecated - public boolean isSetVolume() { - return isSetSize(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - isAttributeRead = true; - if (attributeName.equals("spatialDimensions")) { - setSpatialDimensions(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("units")) { - setUnits(value); - } else if (attributeName.equals("size")) { - setSize(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("volume")) { - setVolume(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("compartmentType")) { - setCompartmentType(value); - } else if (attributeName.equals("outside")) { - setOutside(value); - } else if (attributeName.equals("constant")) { - setConstant(StringTools.parseSBMLBoolean(value)); - } else { - isAttributeRead = false; - } - } - - return isAttributeRead; - } - - /** - * Sets the compartmentTypeID value of this compartment to the id of - * 'compartmentType' - * - * @param compartmentType - * @sbml.deprecated Level 3 Version 1 - */ - @Deprecated - public void setCompartmentType(CompartmentType compartmentType) { - setCompartmentType(compartmentType != null ? compartmentType - .getId() : null); - } - - /** - * Sets the compartmentTypeID of this compartment to 'compartmentTypeID' - * - * @param compartmentTypeID - * @deprecated Only valid in Level 2. - * @throws PropertyNotAvailableException if Level is not 2. - */ - @Deprecated - public void setCompartmentType(String compartmentTypeID) { - if (getLevel() != 2) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.compartmentType, - this); - } - String oldCompartmentTypeID = this.compartmentTypeID; - this.compartmentTypeID = compartmentTypeID; - firePropertyChange(TreeNodeChangeEvent.compartmentType, - oldCompartmentTypeID, this.compartmentTypeID); - } - - /** - * Sets the outsideID of this compartment to the id of 'outside'. - * - * @param outside - * @sbml.deprecated Level 3 Version 1 - */ - @Deprecated - public void setOutside(Compartment outside) { - setOutside(outside != null ? outside.getId() : null); - } - - /** - * Sets the outsideID of this compartment to 'outside'. - * - * @param outside - * @deprecated since Level 3 Version 1 - * @throws PropertyNotAvailableException if Level greater than 2. - */ - @Deprecated - public void setOutside(String outside) { - if (getLevel() > 2) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.outside, this); - } - String oldOutside = outsideID; - if ((outside != null) && (outside.trim().length() == 0)) { - this.outsideID = null; - } else { - this.outsideID = outside; - } - firePropertyChange(TreeNodeChangeEvent.outside, oldOutside, this.outsideID); - } - - /** - * Sets the size of this compartment to 'size'. - * - * @param size - * @throws PropertyNotAvailableException - * in case of Level < 2. - */ - public void setSize(double size) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.size, this); - } - setValue(size); - } - - /** - * Sets the spatialDimensions of this compartment to 'i'. - * - * @param spatialDimension - * @throws IllegalArgumentException - * if spatialDimension < 0 or if spatialDimension > 3 - * @throws PropertyNotAvailableException if Level < 2. - */ - public void setSpatialDimensions(double spatialDimension) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.spatialDimensions, this); - } - if (((0d <= spatialDimension) && (spatialDimension <= 3d) - && (((int) spatialDimension) - spatialDimension == 0d)) - || (getLevel() > 2)) - { - isSetSpatialDimensions = true; - Double oldSpatialDimensions = this.spatialDimensions; - this.spatialDimensions = Double.valueOf(spatialDimension); - firePropertyChange(TreeNodeChangeEvent.spatialDimensions, - oldSpatialDimensions, this.spatialDimensions); - } else { - throw new IllegalArgumentException(String.format( - ERROR_MESSAGE_INVALID_DIM, spatialDimension)); - } - } - - /** - * - * @param spatialDimensions - */ - public void setSpatialDimensions(int spatialDimensions) { - setSpatialDimensions((double) spatialDimensions); - } - - /** - * Sets the spatialDimensions of this compartment to 'spatialDimensiosn'. - * - * @param spatialDimensions - * @throws IllegalArgumentException - * if spatialDimension < 0 or if spatialDimension > 3 - */ - public void setSpatialDimensions(short spatialDimensions) { - setSpatialDimensions((int) spatialDimensions); - } - - /** - * Sets the unitsID of this {@link QuantityWithUnit}. Only valid unit - * kind names or identifiers of already existing {@link UnitDefinition}s are - * allowed arguments of this function. - * - * @param units - * the identifier of an already existing {@link UnitDefinition} - * or an {@link Unit.Kind} identifier for the current - * level/version combination of this unit. Passing a null value - * to this method is equivalent to calling {@link #unsetUnits()}. - * - * @throws IllegalArgumentException - * if the unit is not valid or if spatialDimensions = 0. - */ - @Override - public void setUnits(String units) { - if ((units != null) && (units.trim().length() == 0)) { - unsetUnits(); - return; - } - double specDim = getSpatialDimensions(); - if (Double.isNaN(specDim) || (0 < specDim)) { - super.setUnits(units); - } else { - throw new IllegalArgumentException(String.format( - ERROR_MESSAGE_ZERO_DIM, "units", getId())); - } - } - - /** - * Sets the {@link Unit} of this {@link Compartment}. - * - * @param unit - * - * @throws IllegalArgumentException - * if spatialDimensions = 0. - */ - @Override - public void setUnits(Unit unit) { - if (0 < getSpatialDimensions()) { - super.setUnits(unit); - } else { - throw new IllegalArgumentException(String.format( - ERROR_MESSAGE_ZERO_DIM, "unit", getId())); - } - } - - /** - * Sets the unit of this Compartment. - * - * A new Unit object will be created base on this kind. - * - * @param unitKind - * - * @throws IllegalArgumentException - * if spatialDimensions = 0. - * - */ - @Override - public void setUnits(Unit.Kind unitKind) { - if (0 < getSpatialDimensions()) { - super.setUnits(unitKind); - } else { - throw new IllegalArgumentException(String.format( - ERROR_MESSAGE_ZERO_DIM, "unit kind", getId())); - } - } - - /** - * Set the unit attribute of this Compartment to the given unit definition. - * - * @param unitDefinition - * - * @throws IllegalArgumentException - * if spatialDimensions <= 0. - * - */ - @Override - public void setUnits(UnitDefinition unitDefinition) { - /* - * No test for spatial dimensions is necessary here because the super - * method will finally refer to the other setUnits method in this class - * in which we will check the spatial dimensions. - */ - super.setUnits(unitDefinition); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#setValue(double) - */ - @Override - public void setValue(double value) { - double dim = getSpatialDimensions(); - if ((dim > 0d) || Double.isNaN(dim)) { - super.setValue(value); - } else { - throw new IllegalArgumentException(String.format( - ERROR_MESSAGE_ZERO_DIM, "size", getId())); - } - } - - /** - *

    - * Sets the 'volume' attribute (or 'size' in SBML Level 2) of this - * Compartment. - *

    - *

    - * Some words of explanation about the set/unset/isSet methods: SBML Levels - * 1 and 2 define certain attributes on some classes of objects as optional. - * This requires an application to be careful about the distinction between - * two cases: (1) a given attribute has never been set to a value, and - * therefore should be assumed to have the SBML-defined default value, and - * (2) a given attribute has been set to a value, but the value happens to - * be an empty string. LibSBML supports these distinctions by providing - * methods to set, unset, and query the status of attributes that are - * optional. The methods have names of the form setAttribute(...), - * unsetAttribute(), and isSetAttribute(), where Attribute is the the name - * of the optional attribute in question. - *

    - *

    - * This method is identical to {@link #setSize(double)} and is provided for - * compatibility between SBML Level 1 and Level 2. - *

    - * - * @param value - * a double representing the volume of this compartment instance - * in whatever units are in effect for the compartment. - * @deprecated This method is only available for SBML Level 1. You should - * either use {@link #setSize(double)} or - * {@link #setValue(double)}. - * @throws PropertyNotAvailableException if Level is not 1. - */ - @Deprecated - public void setVolume(double value) { - if (getLevel() != 1) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.volume, this); - } - setValue(value); - } - - /** - * Sets the compartmentTypeID of this {@link Compartment} to null. - */ - public void unsetCompartmentType() { - setCompartmentType((String) null); - } - - /** - * Sets the outsideID of this compartment to null. - * - * @deprecated since Level 3 Version 1 - */ - @Deprecated - public void unsetOutside() { - setOutside((String) null); - } - - /** - *

    - * Unsets the value of the 'size' attribute of this Compartment. - *

    - *

    - * Some words of explanation about the set/unset/isSet methods: SBML Levels - * 1 and 2 define certain attributes on some classes of objects as optional. - * This requires an application to be careful about the distinction between - * two cases: (1) a given attribute has never been set to a value, and - * therefore should be assumed to have the SBML-defined default value, and - * (2) a given attribute has been set to a value, but the value happens to - * be an empty string. LibSBML supports these distinctions by providing - * methods to set, unset, and query the status of attributes that are - * optional. The methods have names of the form setAttribute(...), - * unsetAttribute(), and isSetAttribute(), where Attribute is the the name - * of the optional attribute in question. - *

    - */ - public void unsetSize() { - unsetValue(); - } - - /** - * Sets the spatialDimensions of this compartment to null. - */ - public void unsetSpatialDimensions() { - Double oldSpatialDim = this.spatialDimensions; - this.spatialDimensions = null; - isSetSpatialDimensions = false; - firePropertyChange(TreeNodeChangeEvent.spatialDimensions, oldSpatialDim, - this.spatialDimensions); - } - - /** - *

    - * Unsets the value of the 'volume' attribute of this Compartment. - *

    - *

    - * Some words of explanation about the set/unset/isSet methods: SBML Levels - * 1 and 2 define certain attributes on some classes of objects as optional. - * This requires an application to be careful about the distinction between - * two cases: (1) a given attribute has never been set to a value, and - * therefore should be assumed to have the SBML-defined default value, and - * (2) a given attribute has been set to a value, but the value happens to - * be an empty string. LibSBML supports these distinctions by providing - * methods to set, unset, and query the status of attributes that are - * optional. The methods have names of the form setAttribute(...), - * unsetAttribute(), and isSetAttribute(), where Attribute is the the name - * of the optional attribute in question. - *

    - *

    - * In SBML Level 1, a Compartment volume has a default value (1.0) and - * therefore should always be set. In Level 2, 'size' is optional with no - * default value and as such may or may not be set. - *

    - * - * @deprecated The volume attribute is only defined in SBML Level 1. Please - * use {@link #unsetSize()} - */ - @Deprecated - public void unsetVolume() { - unsetSize(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - int level = getLevel(); - Locale en = Locale.ENGLISH; - if (level == 1) { - if (isSetVolume()) { - attributes.put("volume", StringTools.toString(en, getVolume())); - } - } else if (1 < level) { - if (isSetSpatialDimensions()) { - attributes.put("spatialDimensions", level < 3 ? Short - .toString((short) getSpatialDimensions()) : StringTools - .toString(en, getSpatialDimensions())); - if ((level < 3) - && (((short) getSpatialDimensions()) - - getSpatialDimensions() != 0d)) { - logger.warn(MessageFormat.format( - "Illegal non-integer spatial dimensions {0,number}.", - getSpatialDimensions())); - } - } - if (isSetSize()) { - attributes.put("size", StringTools.toString(en, getSize())); - } - if (isSetConstant()) { - attributes.put("constant", Boolean.toString(getConstant())); - } - if (isSetUnits()) { - attributes.put("units", getUnits()); - } - } - if (level == 2) { - if (isSetCompartmentType()) { - attributes.put("compartmentType", getCompartmentType()); - } - } - if (level < 3) { - if (isSetOutside()) { - attributes.put("outside", outsideID); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/CompartmentType.java b/IPK_lib/src/org/sbml/jsbml/CompartmentType.java deleted file mode 100644 index 59e96e17a..000000000 --- a/IPK_lib/src/org/sbml/jsbml/CompartmentType.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * $Id: CompartmentType.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/CompartmentType.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - - -/** - * Represents the compartmentType XML element of a SBML file. It is deprecated - * since level 3 and not defined in SBML before Level 2 Version 2. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ -@Deprecated -public class CompartmentType extends AbstractNamedSBase implements - UniqueNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -2894837299868213399L; - - /** - * Creates a CompartmentType instance. - */ - @Deprecated - public CompartmentType() { - super(); - } - - /** - * Creates a CompartmentType instance from a given CompartmentType. - * - * @param nsb - */ - @Deprecated - public CompartmentType(CompartmentType nsb) { - super(nsb); - } - - /** - * Creates a CompartmentType instance from a level and version. - * - * @param level - * @param version - */ - @Deprecated - public CompartmentType(int level, int version) { - super(level, version); - } - - /** - * Creates a CompartmentType instance from an id. - * - * @param id - * @deprecated - */ - @Deprecated - public CompartmentType(String id) { - super(id); - } - - /** - * Creates a CompartmentType instance from an id, level and version. - * - * @param id - * @param level - * @param version - */ - @Deprecated - public CompartmentType(String id, int level, int version) { - super(id, level, version); - } - - /** - * Creates a CompartmentType instance from an id, name, level and version. - * - * @param id - * @param name - * @param level - * @param version - */ - @Deprecated - public CompartmentType(String id, String name, int level, int version) { - super(id, name, level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.AbstractSBase#clone() - */ - @Deprecated - public CompartmentType clone() { - return new CompartmentType(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - @Deprecated - public boolean isIdMandatory() { - return true; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Constraint.java b/IPK_lib/src/org/sbml/jsbml/Constraint.java deleted file mode 100644 index 1a71656e7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Constraint.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * $Id: Constraint.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Constraint.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.xml.XMLNode; - - -/** - * Represents the constraint XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Constraint extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7396734926596485200L; - - /** - * Represents the subnode message of a constraint element. - */ - private XMLNode message; - - /** - * Creates a {@link Constraint} instance. By default, the message is null. - */ - public Constraint() { - super(); - this.message = null; - } - - /** - * Creates a {@link Constraint} instance from an {@link ASTNode}, a level and a version. By - * default, the message is null. - * - * @param math - * @param level - * @param version - */ - public Constraint(ASTNode math, int level, int version) { - super(math, level, version); - message = null; - } - - /** - * Creates a {@link Constraint} instance from a given {@link Constraint}. - * - * @param sb - */ - public Constraint(Constraint sb) { - super(sb); - if (sb.isSetMessage()) { - this.message = new XMLNode(sb.getMessage()); - } - } - - /** - * Creates a {@link Constraint} instance from a level and a version. By default, the - * message is null. - * - * @param level - * @param version - */ - public Constraint(int level, int version) { - super(level, version); - this.message = null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public Constraint clone() { - return new Constraint(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetMessage()) { - if (index == pos) { - return getMessage(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetMessage()) { - count++; - } - return count; - } - - /** - * Returns the message of this {@link Constraint}. Returns null if the - * message is not set. - * - * @return the message of this {@link Constraint}. Returns null if the - * message is not set. - */ - public XMLNode getMessage() { - return isSetMessage() ? message : null; - } - - /** - * Returns the message of this {@link Constraint} as an XML {@link String}. - * - * @return the message of this {@link Constraint} as an XML {@link String}. - */ - public String getMessageString() { - return message.toXMLString(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * Returns true if the message of this {@link Constraint} is not null. - * - * @return true if the message of this {@link Constraint} is not null. - */ - public boolean isSetMessage() { - return message != null; - } - - /** - * Sets the message of this {@link Constraint} to 'message'. - * - * @param message - * : the message to set - */ - public void setMessage(String message) { - XMLNode oldMessage = this.message; - this.message = XMLNode.convertStringToXMLNode(message); - firePropertyChange(TreeNodeChangeEvent.message, oldMessage, message); - } - - /** - * Sets the message of this {@link Constraint} to 'message'. - * - * @param message - * : the message to set - */ - public void setMessage(XMLNode message) { - XMLNode oldMessage = this.message; - this.message = message; - firePropertyChange(TreeNodeChangeEvent.message, oldMessage, message); - } - - /** - * Sets the message of this {@link Constraint} to null. - */ - public void unsetMessage() { - setMessage((XMLNode) null); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/Creator.java b/IPK_lib/src/org/sbml/jsbml/Creator.java deleted file mode 100644 index 1de2a4e61..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Creator.java +++ /dev/null @@ -1,556 +0,0 @@ -/* - * $Id: Creator.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Creator.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.regex.Pattern; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Contains all the information about a creator of a {@link Model} (or other {@link SBase} in level - * 3). - * - * @author marine3 - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Creator extends AnnotationElement { - - /** - * A {@link Logger} for this class. - */ - private static final transient Logger logger = Logger.getLogger(Creator.class); - - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -3403463908044292946L; - - /** - * URI for the RDF syntax name space definition for VCards. - */ - public static final transient String URI_RDF_VCARD_NS = "http://www.w3.org/2001/vcard-rdf/3.0#"; - - /** - * email of the creator - */ - private String email; - /** - * Family name of the creator - */ - private String familyName; - /** - * Given name of the creator - */ - private String givenName; - - /** - * Organisation name of the creator. - */ - private String organisation; - - /** - * Holding any additional vCard elements. - * This is a quick and dirty solution as the vCard can contain - * many elements that have sub-elements. - * - * TODO : use an XMLNode to hold all the additional informations - * - */ - private Map otherAttributes; - - /** - * Creates a {@link Creator} instance. By default, the email, familyName, - * givenName, organisation are null. - */ - public Creator() { - super(); - this.givenName = null; - this.familyName = null; - this.organisation = null; - this.email = null; - this.otherAttributes = null; - } - - /** - * Creates a {@link Creator} instance from a given {@link Creator}. - * - * @param creator - */ - public Creator(Creator creator) { - super(creator); - this.email = creator.isSetEmail() ? new String(creator.getEmail()) : null; - this.familyName = creator.isSetFamilyName() ? new String(creator.getFamilyName()) : null; - this.givenName = creator.isSetGivenName() ? new String(creator.getGivenName()) : null; - this.organisation = creator.isSetOrganisation() ? new String(creator.getOrganisation()) : null; - - if (creator.isSetOtherAttributes()) { - this.otherAttributes = new LinkedHashMap(); - - for (String key : creator.getOtherAttributes().keySet()) { - this.otherAttributes.put(new String(key), new String(creator.getOtherAttribute(key))); - } - } else { - this.otherAttributes = null; - } - } - - /** - * Creates a {@link Creator} instance. - * - * @param givenName - * @param familyName - * @param organization - * @param email - */ - public Creator(String givenName, String familyName, String organization, - String email) { - this(); - setGivenName(givenName); - setFamilyName(familyName); - setOrganization(organization); - setEmail(email); - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - public Creator clone() { - return new Creator(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Creator m = (Creator) object; - equals &= isSetEmail() == m.isSetEmail(); - if (equals && isSetEmail()) { - equals &= getEmail().equals(m.getEmail()); - } - equals &= isSetFamilyName() == m.isSetFamilyName(); - if (equals && isSetFamilyName()) { - equals &= getFamilyName().equals(m.getFamilyName()); - } - equals &= isSetGivenName() == m.isSetGivenName(); - if (equals && isSetGivenName()) { - equals &= getGivenName().equals(m.getGivenName()); - } - equals &= isSetOrganisation() == m.isSetOrganisation(); - if (equals && isSetOrganisation()) { - equals &= getOrganisation().equals(m.getOrganisation()); - } - equals &= isSetOtherAttributes() == m.isSetOtherAttributes(); - if (equals && isSetOtherAttributes()) { - equals &= getOtherAttributes().equals(m.getOtherAttributes()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return false; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - throw new IndexOutOfBoundsException(Integer.toString(childIndex)); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - return 0; - } - - /** - * Returns the email from the {@link Creator}. Returns an empty String if it is - * not set. - * - * @return the email from the {@link Creator}. Returns an empty String if it is - * not set. - */ - public String getEmail() { - return isSetEmail() ? email : ""; - } - - /** - * Returns the familyName from the {@link Creator}. Returns an empty String if - * it is not set. - * - * @return the familyName from the {@link Creator}. Returns an empty String if - * it is not set. - */ - public String getFamilyName() { - return isSetFamilyName() ? familyName : ""; - } - - /** - * Returns the givenName from the {@link Creator}. Returns an empty String if - * it is not set. - * - * @return the givenName from the {@link Creator}. Returns an empty String if - * it is not set. - */ - public String getGivenName() { - return isSetGivenName() ? givenName : ""; - } - - /** - * Returns the organisation from the {@link Creator}. Returns an empty String - * if it is not set. - * - * @return the organisation from the {@link Creator}. Returns an empty String - * if it is not set. - */ - public String getOrganisation() { - return isSetOrganisation() ? organisation : ""; - } - - /** - * Returns the organisation from the {@link Creator}. Returns an empty String - * if it is not set. - *

    - * Equal to {@link #getOrganisation()} - * - * @return the organisation from the {@link Creator}. Returns an empty String - * if it is not set. - */ - public String getOrganization() { - return getOrganisation(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 797; - int hashCode = super.hashCode(); - if (isSetEmail()) { - hashCode += prime * getEmail().hashCode(); - } - if (isSetFamilyName()) { - hashCode += prime * getFamilyName().hashCode(); - } - if (isSetGivenName()) { - hashCode += prime * getGivenName().hashCode(); - } - if (isSetOrganization()) { - hashCode += prime * getOrganization().hashCode(); - } - if (isSetOtherAttributes()) { - hashCode += prime * getOtherAttributes().hashCode(); - } - return hashCode; - } - - /** - * Returns true or false depending on whether this - * {@link Creator}'s email has been set. - * - * @return true if the email of this {@link Creator} is not null. - */ - public boolean isSetEmail() { - return email != null; - } - - /** - * Returns true or false depending on whether this - * {@link Creator}'s familyName has been set. - * - * @return true if the familyName of this {@link Creator} is not null. - */ - public boolean isSetFamilyName() { - return familyName != null; - } - - /** - * Returns true or false depending on whether this - * {@link Creator}'s givenName has been set. - * - * @return true if the givenName of this {@link Creator} is not null. - */ - public boolean isSetGivenName() { - return givenName != null; - } - - /** - * Returns true or false depending on whether this - * {@link Creator}'s organisation has been set. - * - * @return true if the organisation of this {@link Creator} is not null. - */ - public boolean isSetOrganisation() { - return organisation != null; - } - - /** - * Returns true or false depending on whether this - * {@link Creator}'s organisation has been set. - *

    Equal to {@link #isSetOrganisation()} - * - * @return true or false depending on whether this - * {@link Creator}'s organisation has been set. - */ - public boolean isSetOrganization() { - return isSetOrganisation(); - } - - /** - * Returns true if the XML attribute is known by this {@link Creator}. - * - * @return true if the XML attribute is known by this {@link Creator}. - */ - public boolean readAttribute(String elementName, String attributeName, - String prefix, String value) { - if (elementName.equals("li") || elementName.equals("N") - || elementName.equals("ORG")) { - if (attributeName.equals("parseType") && value.equals("Resource")) { - return true; - } - } - return false; - } - - /** - * Sets the email if it follows the syntax rules of valid e-mail addresses - * according to - * http://en.wikipedia.org/wiki/E-mail_address. - * - * @param email - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int setEmail(String email) { - /* - * ^ # start of the line - * [_A-Za-z0-9-]+ # must start with string in the bracket [ ], must contains one or more (+) - * ( # start of group #1 - * \\.[_A-Za-z0-9-]+ # follow by a dot "." and string in the bracket [ ], must contains one or more (+) - * )* # end of group #1, this group is optional (*) - * @ # must contains a "@" symbol - * [A-Za-z0-9-]+ # follow by string in the bracket [ ], must contains one or more (+) - * ( # start of group #2 - first level TLD checking - * \\.[A-Za-z0-9-]+ # follow by a dot "." and string in the bracket [ ], must contains one or more (+) - * )* # end of group #2, this group is optional (*) - * ( # start of group #3 - second level TLD checking - * \\.[A-Za-z]{2,} # follow by a dot "." and string in the bracket [ ], with minimum length of 2 - * ) # end of group #3 - *$ # end of the line - */ - final String emailPattern = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"; - if ((email != null) && !Pattern.matches(emailPattern, email)) { - logger.warn(String.format("Invalid e-mail address %s", email)); - throw new IllegalArgumentException(String.format("Invalid e-mail address %s", email)); - } - String oldValue = this.email; - this.email = email; - this.firePropertyChange(TreeNodeChangeEvent.email, oldValue, email); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Sets the family name - * - * @param familyName - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int setFamilyName(String familyName) { - String oldValue = this.familyName; - this.familyName = familyName; - this.firePropertyChange(TreeNodeChangeEvent.familyName, oldValue, familyName); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Sets the given name - * - * @param givenName - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int setGivenName(String givenName) { - String oldValue = this.givenName; - this.givenName = givenName; - this.firePropertyChange(TreeNodeChangeEvent.givenName, oldValue, givenName); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Sets the organisation - * - * @param organisation - */ - public void setOrganisation(String organisation) { - String oldValue = this.organisation; - this.organisation = organisation; - this.firePropertyChange(TreeNodeChangeEvent.organisation, oldValue, organisation); - } - - /** - * Sets the organisation - *

    Equal to {@link #setOrganisation(String)}. - * - * @param organization - */ - public void setOrganization(String organization) { - setOrganisation(organization); - } - - /** - * - * @param attributeName - * @param attributeValue - */ - public void setOtherAttribute(String attributeName, String attributeValue) { - if (attributeName == null) { - return; - } - getOtherAttributes().put(attributeName, attributeValue); - } - - /** - * - * @return - */ - public Map getOtherAttributes() { - - if (!isSetOtherAttributes()) { - otherAttributes = new LinkedHashMap(); - } - return otherAttributes; - } - - /** - * - * @return - */ - public boolean isSetOtherAttributes() { - return otherAttributes != null; - } - - /** - * - * @param attributeName - * @return - */ - public String getOtherAttribute(String attributeName) { - if (attributeName == null) { - return null; - } - return getOtherAttributes().get(attributeName); - } - - /** - * Returns the information about the {@link Creator} as a {@link String}. - * - * @return the information about the {@link Creator} as a {@link String}. - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (isSetGivenName()) { - sb.append(getGivenName()); - if (isSetFamilyName() || isSetEmail() || isSetOrganisation()) { - sb.append(' '); - } - } - if (isSetFamilyName()) { - sb.append(getFamilyName()); - if (isSetEmail() || isSetOrganisation()) { - sb.append(", "); - } - } - if (isSetEmail()) { - sb.append(getEmail()); - if (isSetOrganisation()) { - sb.append(", "); - } - } - if (isSetOrganisation()) { - sb.append(getOrganisation()); - } - - return sb.toString(); - } - - /** - * Unsets the email of this {@link Creator}. - * - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int unsetEmail() { - String oldValue = this.email; - email = null; - this.firePropertyChange(TreeNodeChangeEvent.email, oldValue, email); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Unsets the familyName of this {@link Creator}. - * - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int unsetFamilyName() { - String oldValue = this.familyName; - this.familyName = null; - this.firePropertyChange(TreeNodeChangeEvent.familyName, oldValue, familyName); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Unsets the givenName of this {@link Creator}. - * - * @return {@link JSBML#OPERATION_SUCCESS} - */ - public int unsetGivenName() { - String oldValue = this.givenName; - this.givenName = null; - this.firePropertyChange(TreeNodeChangeEvent.givenName, oldValue, givenName); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Unsets the organisation of this {@link Creator}. - * - */ - public void unsetOrganization() { - String oldValue = this.organisation; - this.organisation = null; - this.firePropertyChange(TreeNodeChangeEvent.organisation, oldValue, organisation); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Delay.java b/IPK_lib/src/org/sbml/jsbml/Delay.java deleted file mode 100644 index 4d2b8cea2..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Delay.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * $Id: Delay.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Delay.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - - -/** - * Represents the delay subnode of an event element. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Delay extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1578051749680028593L; - - /** - * Creates a Delay instance. - */ - public Delay() { - super(); - } - - /** - * Creates a Delay instance from an ASTNode, level and version. - * - * @param math - */ - public Delay(ASTNode math, int level, int version) { - super(math, level, version); - } - - /** - * Creates a Delay instance from a given Delay. - * - * @param sb - */ - public Delay(Delay sb) { - super(sb); - } - - /** - * Creates a Delay instance from a level and version. - * - * @param level - * @param version - */ - public Delay(int level, int version) { - super(level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public Delay clone() { - return new Delay(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - public Event getParent() { - return (Event) super.getParent(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Event.java b/IPK_lib/src/org/sbml/jsbml/Event.java deleted file mode 100644 index c5ad7e370..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Event.java +++ /dev/null @@ -1,1015 +0,0 @@ -/* - * $Id: Event.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Event.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * Represents the event XML element of a SBML file. Since {@link Event}s were - * introduced to SBML in Level 2, this class must not be used for models in - * Level 1. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Event extends AbstractNamedSBaseWithUnit implements - UniqueNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 5282750820355199194L; - /** - * Represents the delay sub-element of an event element. - */ - private Delay delay; - private boolean isSetUseValuesFromTriggerTime; - - /** - * Represents the listOfEventAssignments sub-element of an event element. - */ - private ListOf listOfEventAssignments; - - /** - * Represents the priority sub-element of an event. - */ - private Priority priority; - - /** - * Represents the trigger sub-element of an event element. - */ - private Trigger trigger; - - /** - * Represents the 'useValuesFromTriggerTime' XML attribute of an event - * element. - */ - private Boolean useValuesFromTriggerTime; - - /** - * Creates an Event instance. By default, if the level is set and is - * superior or equal to 3, the trigger, delay, listOfEventAssignemnts and - * timeUnitsID are null. - */ - public Event() { - super(); - initDefaults(); - } - - /** - * Creates an Event instance from a given event. - * - * @param event - */ - public Event(Event event) { - super(event); - - if (event.isSetTrigger()) { - setTrigger(event.getTrigger().clone()); - } - if (event.isSetUseValuesFromTriggerTime()) { - setUseValuesFromTriggerTime(event.getUseValuesFromTriggerTime()); - } else { - useValuesFromTriggerTime = event.useValuesFromTriggerTime == null ? null : new Boolean(event.useValuesFromTriggerTime); - } - if (event.isSetDelay()) { - setDelay(event.getDelay().clone()); - } - if (event.isSetListOfEventAssignments()) { - setListOfEventAssignments((ListOf) event - .getListOfEventAssignments().clone()); - } - if (event.isSetPriority()) { - setPriority(event.getPriority().clone()); - } - } - - /** - * Creates an Event from a level and version. By default, if the level is - * set and is superior or equal to 3, the trigger, delay, - * listOfEventAssignemnts and timeUnitsID are null. - * - * @param level - * @param version - */ - public Event(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * - * @param id - */ - public Event(String id) { - super(id); - initDefaults(); - } - - /** - * Creates an Event instance from an id, level and version. By default, if - * the level is set and is superior or equal to 3, the trigger, delay, - * listOfEventAssignemnts and timeUnitsID are null. - * - * @param id - * @param level - * @param version - */ - public Event(String id, int level, int version) { - super(id, level, version); - initDefaults(); - } - - /** - * Creates an Event instance from an id, name, level and version. By - * default, if the level is set and is superior or equal to 3, the trigger, - * delay, listOfEventAssignemnts and timeUnitsID are null. - * - * @param id - * @param name - * @param level - * @param version - */ - public Event(String id, String name, int level, int version) { - super(id, name, level, version); - initDefaults(); - } - - /** - * Adds an EventAssignment instance to the list of EventAssignments of this - * Event. - * - * @param eventass - * @return true if the {@link #listOfEventAssignments} was - * changed as a result of this call. - */ - public boolean addEventAssignment(EventAssignment eventass) { - return getListOfEventAssignments().add(eventass); - } - - /** - * Remove all the EventAssignments of the listOfEventAssignments of this - * Event. - */ - public void clearListOfEventAssignments() { - if (isSetListOfEventAssignments()) { - listOfEventAssignments.clear(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#clone() - */ - public Event clone() { - return new Event(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#containsUndeclaredUnits() - */ - @Override - @Deprecated - public boolean containsUndeclaredUnits() { - return super.containsUndeclaredUnits(); - } - - /** - * - * @return - */ - public Delay createDelay() { - Delay d = new Delay(getLevel(), getVersion()); - d.addAllChangeListeners(getListOfTreeNodeChangeListeners()); - setDelay(d); - return d; - } - - /** - * - * @param math - * @return - */ - public Delay createDelay(ASTNode math) { - Delay d = createDelay(); - d.setMath(math); - return d; - } - - /** - * - * @return the new EventAssignment instance. - */ - public EventAssignment createEventAssignment() { - EventAssignment ea = new EventAssignment(getLevel(), getVersion()); - addEventAssignment(ea); - return ea; - } - - /** - * - * @param variable - * @param math - * @return - */ - public EventAssignment createEventAssignment(String variable, ASTNode math) { - EventAssignment ea = createEventAssignment(); - ea.setVariable(variable); - ea.setMath(math); - return ea; - } - - /** - * - * @param variable - * @param math - * @return - */ - public EventAssignment createEventAssignment(Variable variable, ASTNode math) { - return createEventAssignment(variable.getId(), math); - } - - /** - * Creates a new, empty {@link Priority}, adds it to this {@link Event} and - * returns the {@link Priority}. - * - * @return the newly created {@link Priority} object instance - */ - public Priority createPriority() { - Priority p = new Priority(getLevel(), getVersion()); - setPriority(p); - return p; - } - - /** - * - * @param math - * @return - */ - public Priority createPriority(ASTNode math) { - Priority p = createPriority(); - p.setMath(math); - return p; - } - - /** - * - * @return - */ - public Trigger createTrigger() { - Trigger t = new Trigger(getLevel(), getVersion()); - setTrigger(t); - return t; - } - - /** - * - * @param initialValue - * @param persistent - * @return - */ - public Trigger createTrigger(boolean initialValue, boolean persistent) { - Trigger t = createTrigger(); - t.setInitialValue(initialValue); - t.setPersistent(persistent); - return t; - } - - /** - * - * @param initialValue - * @param persistent - * @param math - * @return - */ - public Trigger createTrigger(boolean initialValue, boolean persistent, - ASTNode math) { - Trigger t = createTrigger(initialValue, persistent); - t.setMath(math); - return t; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Event e = (Event) object; - equals &= e.getUseValuesFromTriggerTime() == getUseValuesFromTriggerTime(); - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetTrigger()) { - if (pos == index) { - return getTrigger(); - } - pos++; - } - if (isSetPriority()) { - if (pos == index) { - return getPriority(); - } - pos++; - } - if (isSetDelay()) { - if (pos == index) { - return getDelay(); - } - pos++; - } - if (isSetListOfEventAssignments()) { - if (pos == index) { - return getListOfEventAssignments(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int children = super.getChildCount(); - if (isSetTrigger()) { - children++; - } - if (isSetPriority()) { - children++; - } - if (isSetDelay()) { - children++; - } - if (isSetListOfEventAssignments()) { - children++; - } - return children; - } - - /** - * - * @return the Delay instance of this Event. - */ - public Delay getDelay() { - return this.delay; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnitDefinition() - */ - @Override - @Deprecated - public UnitDefinition getDerivedUnitDefinition() { - return super.getDerivedUnitDefinition(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnits() - */ - @Override - @Deprecated - public String getDerivedUnits() { - return super.getDerivedUnits(); - } - - /** - * - * @param n - * @return the nth EventAssignment instance of the list of EventAssignments - * for this Event. - */ - public EventAssignment getEventAssignment(int n) { - if (isSetListOfEventAssignments()) { - return listOfEventAssignments.get(n); - } - throw new IndexOutOfBoundsException(Integer.toString(n)); - } - - /** - * - * @return the list of eventAssignments of this Event. - */ - public ListOf getListOfEventAssignments() { - if (listOfEventAssignments == null) { - listOfEventAssignments = ListOf.newInstance(this, EventAssignment.class); - } - return listOfEventAssignments; - } - - /** - * @return the number of EventAssignments in the list of EventAssignements - * of this Event. - * @deprecated use {@link #getEventAssignmentCount()} - */ - @Deprecated - public int getNumEventAssignments() { - return getEventAssignmentCount(); - } - - /** - * @return the number of EventAssignments in the list of EventAssignements - * of this Event. - */ - public int getEventAssignmentCount() { - return listOfEventAssignments == null ? 0 : listOfEventAssignments.size(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getPredefinedUnitID() - */ - public String getPredefinedUnitID() { - return null; - } - - /** - * @return the priority - */ - public Priority getPriority() { - return this.priority; - } - - /** - * - * @return The timeUnitsID of this Event. Return an empty String if it is - * not set. - * @deprecated - */ - @Deprecated - public String getTimeUnits() { - return getUnits(); - } - - /** - * @return the timeUnitsID - * @deprecated - */ - @Deprecated - public String getTimeUnitsID() { - return getUnits(); - } - - /** - * - * @return the {@link UnitDefinition} instance of the model which matches - * the timesUnitsID of this {@link Event}. Returns null if there is - * no {@link UnitDefinition} id which matches the - * {@link #timeUnitsID} of this {@link Event}. - * @deprecated - */ - @Deprecated - public UnitDefinition getTimeUnitsInstance() { - return getUnitsInstance(); - } - - /** - * - * @return the Trigger instance of this Event. - */ - public Trigger getTrigger() { - return trigger; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getUnits() - */ - @Override - @Deprecated - public String getUnits() { - return super.getUnits(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getUnitsInstance() - */ - @Override - @Deprecated - public UnitDefinition getUnitsInstance() { - return super.getUnitsInstance(); - } - - /** - * - * @return the useValuesFromTriggerTime instance of this Event. it is null - * if it has not been set. - */ - public boolean getUseValuesFromTriggerTime() { - return isUseValuesFromTriggerTime(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#hashCode() - */ - @Override - public int hashCode() { - final int prime = 911; - int hashCode = super.hashCode(); - if (isSetUseValuesFromTriggerTime()) { - hashCode += prime * useValuesFromTriggerTime.hashCode(); - } - return hashCode; - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default values of this {@link Event}. - */ - public void initDefaults(int level, int version) { - this.trigger = null; - this.delay = null; - this.priority = null; - this.listOfEventAssignments = null; - if ((0 < level) && (level < 3)) { - useValuesFromTriggerTime = new Boolean(true); - } else { - useValuesFromTriggerTime = null; - } - if ((0 < level) && (level < 2)) { - throw new IllegalAccessError("Cannot create an Event with Level < 2."); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * - * @return true if the delay of this Event is not null. - */ - public boolean isSetDelay() { - return delay != null; - } - - /** - * - * @return true if the listOfEventAssignments of this Event is not null and - * not empty; - */ - public boolean isSetListOfEventAssignments() { - return (listOfEventAssignments != null) - && (listOfEventAssignments.size() > 0); - } - - /** - * - * @return - */ - public boolean isSetPriority() { - return this.priority != null; - } - - /** - * - * @return true if the timeUnitsID of this {@link Event} is not null. - * @deprecated - */ - @Deprecated - public boolean isSetTimeUnits() { - return isSetUnits(); - } - - /** - * - * @return true if the UnitDefinition which has the timeUnitsID of this - * Event as id is not null. - * @deprecated - */ - @Deprecated - public boolean isSetTimeUnitsInstance() { - return isSetUnitsInstance(); - } - - /** - * - * @return true if the trigger of this Event is not null. - */ - public boolean isSetTrigger() { - return this.trigger != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#isSetUnits() - */ - @Override - @Deprecated - public boolean isSetUnits() { - return super.isSetUnits(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#isSetUnitsInstance() - */ - @Override - @Deprecated - public boolean isSetUnitsInstance() { - return super.isSetUnitsInstance(); - } - - /** - * - * @return true is the useValuesFromTriggerTime of this Event is not null. - */ - public boolean isSetUseValuesFromTriggerTime() { - return isSetUseValuesFromTriggerTime; - } - - /** - * - * @return the boolean value of the useValuesFromTriggerTime of this {@link Event} - * if it has been set, false otherwise. - */ - public boolean isUseValuesFromTriggerTime() { - return isSetUseValuesFromTriggerTime() ? useValuesFromTriggerTime - : true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName - .equals(TreeNodeChangeEvent.useValuesFromTriggerTime)) { - setUseValuesFromTriggerTime(StringTools.parseSBMLBoolean(value)); - return true; - } else if (attributeName.equals(TreeNodeChangeEvent.timeUnits)) { - setTimeUnits(value); - return true; - } - } - return isAttributeRead; - } - - /** - * - * @param i - * @return the removed ith EventAssignment instance. - */ - public EventAssignment removeEventAssignment(int i) { - if ((i >= getNumEventAssignments()) || (i < 0)) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - return listOfEventAssignments.remove(i); - } - - /** - * - * @param id - * @return the removed EventAssignment instance which has 'id' as id. - */ - public EventAssignment removeEventAssignment(String id) { - EventAssignment deletedEventAssignment = null; - int index = 0; - - for (EventAssignment reactant : getListOfEventAssignments()) { - if (reactant.getVariable().equals(id)) { - deletedEventAssignment = reactant; - break; - } - index++; - } - - if (deletedEventAssignment != null) { - listOfEventAssignments.remove(index); - } - - return deletedEventAssignment; - // return listOfEventAssignments.remove(id); - } - - /** - * Sets the delay of this Event to 'delay'. It automatically sets the Delay - * parentSBML object to this Event instance. - * - * @param delay - */ - public void setDelay(Delay delay) { - unsetDelay(); - this.delay = delay; - registerChild(this.delay); - } - - /** - * Sets the {@link #listOfEventAssignments} of this {@link Event} to - * 'listOfEventAssignments'. It automatically sets the SBMLParent object of - * the listOfEventAssignments and all the {@link EventAssignment}s in this list to - * this {@link Event} instance. - * - * @param listOfEventAssignments - */ - public void setListOfEventAssignments( - ListOf listOfEventAssignments) { - unsetListOfEventAssignments(); - this.listOfEventAssignments = listOfEventAssignments; - if ((this.listOfEventAssignments != null) && (this.listOfEventAssignments.getSBaseListType() != ListOf.Type.listOfEventAssignments)) { - this.listOfEventAssignments.setSBaseListType(ListOf.Type.listOfEventAssignments); - registerChild(this.listOfEventAssignments); - } - } - - /** - * @param priority - * the priority to set - * @throws PropertyNotAvailableException if Level < 3. - */ - public void setPriority(Priority priority) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.priority, - this); - } - unsetPriority(); - this.priority = priority; - registerChild(this.priority); - } - - /** - * Sets the timeUnitsID of this {@link Event} to 'timeUnits'. - * - * @param timeUnits - * @deprecated This is only applicable for SBML Level 2, Versions 1 and 2. - */ - @Deprecated - public void setTimeUnits(String timeUnits) { - setUnits(timeUnits); - } - - /** - * Sets the timeUnitsID of this {@link Event} to the id of the {@link UnitDefinition} - * 'timeUnits'. - * - * @param timeUnits - */ - @Deprecated - public void setTimeUnits(UnitDefinition timeUnits) { - setTimeUnits(timeUnits != null ? timeUnits.getId() : null); - } - - /** - * @param timeUnitsID - * the timeUnitsID to set - * @deprecated - */ - @Deprecated - public void setTimeUnitsID(String timeUnitsID) { - setTimeUnits(timeUnitsID); - } - - /** - * Sets the trigger of this Event to 'trigger'. It automatically sets the - * {@link Trigger} parentSBML object to this Event instance. - * - * @param trigger - */ - public void setTrigger(Trigger trigger) { - unsetTrigger(); - this.trigger = trigger; - registerChild(this.trigger); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#setUnits(org.sbml.jsbml.Unit.Kind) - */ - @Override - @Deprecated - public void setUnits(Kind timeUnitKind) { - if (!((getLevel() == 2) && ((getVersion() == 1) || (getVersion() == 2)))) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.timeUnits, - this); - } - super.setUnits(timeUnitKind); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#setUnits(java.lang.String) - */ - @Override - @Deprecated - public void setUnits(String timeUnits) { - if (!((getLevel() == 2) && ((getVersion() == 1) || (getVersion() == 2)))) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.timeUnits, - this); - } - super.setUnits(timeUnits); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#setUnits(org.sbml.jsbml.Unit) - */ - @Override - @Deprecated - public void setUnits(Unit timeUnit) { - if (!((getLevel() == 2) && ((getVersion() == 1) || (getVersion() == 2)))) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.timeUnits, - this); - } - super.setUnits(timeUnit); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#setUnits(org.sbml.jsbml.UnitDefinition) - */ - @Override - @Deprecated - public void setUnits(UnitDefinition timeUnits) { - if (!((getLevel() == 2) && ((getVersion() == 1) || (getVersion() == 2)))) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.timeUnits, - this); - } - super.setUnits(timeUnits); - } - - /** - * Sets the useValuesFromTriggerTime of this {@link Event} to - * 'useValuesFromTriggerTime'. - * - * @param useValuesFromTriggerTime - * @throws PropertyNotAvailableException if the Level/Version combination is lower than 2.4. - */ - public void setUseValuesFromTriggerTime(boolean useValuesFromTriggerTime) { - if (getLevelAndVersion().compareTo(Integer.valueOf(2), - Integer.valueOf(4)) < 0) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.useValuesFromTriggerTime, this); - } - Boolean oldUsesValuesFromTriggerTime = this.useValuesFromTriggerTime; - this.useValuesFromTriggerTime = useValuesFromTriggerTime; - isSetUseValuesFromTriggerTime = true; - firePropertyChange(TreeNodeChangeEvent.useValuesFromTriggerTime, - oldUsesValuesFromTriggerTime, useValuesFromTriggerTime); - } - - /** - * Sets the delay of this {@link Event} to null. - */ - public boolean unsetDelay() { - if (this.delay != null) { - Delay oldDelay = this.delay; - this.delay = null; - oldDelay.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfEventAssignments} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfEventAssignments() { - if (this.listOfEventAssignments != null) { - ListOf oldListOfEventAssignments = this.listOfEventAssignments; - this.listOfEventAssignments = null; - oldListOfEventAssignments.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Sets the {@link Priority} of this {@link Event} to null and notifies - * {@link TreeNodeChangeListener}s. - */ - public boolean unsetPriority() { - if (this.priority != null) { - Priority oldPriority = this.priority; - this.priority = null; - oldPriority.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Sets the timeUnitsID of this {@link Event} to null. - */ - public void unsetTimeUnits() { - setTimeUnitsID(null); - } - - /** - * Sets the trigger of this {@link Event} to null and notifies - * {@link TreeNodeChangeListener}s. - */ - public boolean unsetTrigger() { - if (this.trigger != null) { - Trigger oldTrigger = this.trigger; - this.trigger = null; - oldTrigger.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Sets the useValuesFromTriggerTime of this Event to null. - */ - public void unsetUseValuesFromTriggerTime() { - if(this.useValuesFromTriggerTime != null){ - Boolean oldUseValuesFromTriggerTime = useValuesFromTriggerTime; - this.useValuesFromTriggerTime = null; - isSetUseValuesFromTriggerTime = false; - firePropertyChange(TreeNodeChangeEvent.useValuesFromTriggerTime, - oldUseValuesFromTriggerTime, null); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetUseValuesFromTriggerTime() - && (((getLevel() == 2) && (getVersion() == 4)) || (getLevel() >= 3))) { - attributes.put(TreeNodeChangeEvent.useValuesFromTriggerTime, Boolean - .toString(getUseValuesFromTriggerTime())); - } - - if (isSetTimeUnits() - && ((getLevel() == 1) || ((getLevel() == 2) && ((getVersion() == 1) || (getVersion() == 2))))) { - attributes.put(TreeNodeChangeEvent.timeUnits, getTimeUnits()); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/EventAssignment.java b/IPK_lib/src/org/sbml/jsbml/EventAssignment.java deleted file mode 100644 index d5fa40a8d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/EventAssignment.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * $Id: EventAssignment.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/EventAssignment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the eventAssignment XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class EventAssignment extends AbstractMathContainer implements Assignment { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -263409745456083049L; - - /** - * Represents the 'variable' XML attribute of an eventAssignment element. - */ - private String variableID; - - /** - * Creates an EventAssignment instance. By default, the variableID is null. - */ - public EventAssignment() { - super(); - this.variableID = null; - } - - /** - * Creates an EventAssignment instance from a given EventAssignment. - * - * @param eventAssignment - */ - public EventAssignment(EventAssignment eventAssignment) { - super(eventAssignment); - if (eventAssignment.isSetVariable()) { - this.variableID = new String(eventAssignment.getVariable()); - } - } - - /** - * Creates an EventAssignment instance from a level and version. By default, - * the variableID is null. - */ - public EventAssignment(int level, int version) { - super(level, version); - this.variableID = null; - if (isSetLevel() && (getLevel() < 2)) { - throw new IllegalAccessError("Cannot create an EventAssignment with Level < 2."); - } - } - - /** - * Sets the variableID of this EventAssignment to 'variable'. If 'variable' - * doesn't match any id of Compartment , Species, SpeciesReference or - * Parameter in Model, an {@link IllegalArgumentException} is thrown. - * - * @param variable - * @throws IllegalArgumentException - */ - public void checkAndSetVariable(String variable) { - Model m = getModel(); - if (m != null) { - Variable nsb = getModel().findVariable(variable); - if (nsb == null) { - throw new IllegalArgumentException(String.format( - NO_SUCH_VARIABLE_EXCEPTION_MSG, - m.getId(), variable)); - } - setVariable(nsb); - } else { - throw new NullPointerException(JSBML.UNDEFINED_MODEL_MSG); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public EventAssignment clone() { - return new EventAssignment(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - EventAssignment ea = (EventAssignment) object; - equals &= ea.isSetVariable() == isSetVariable(); - if (equals && isSetVariable()) { - equals &= ea.getVariable().equals(getVariable()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariable() - */ - public String getVariable() { - return isSetVariable() ? this.variableID : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariableInstance() - */ - public Variable getVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 839; - int hashCode = super.hashCode(); - if (isSetVariable()) { - hashCode += prime * getVariable().hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariable() - */ - public boolean isSetVariable() { - return variableID != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariableInstance() - */ - public boolean isSetVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) != null : false; - } - - /* (non-Javadoc) - * @see readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName.equals("variable")) { - setVariable(value); - return true; - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(java.lang.String) - */ - public void setVariable(String variable) { - String oldVariable = this.variableID; - this.variableID = variable; - firePropertyChange(TreeNodeChangeEvent.variable, oldVariable, variable); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(org.sbml.jsbml.Variable) - */ - public void setVariable(Variable variable) { - if (!variable.isConstant()) { - if ((getLevel() < 3) && (variable instanceof SpeciesReference)) { - throw new IllegalArgumentException(String.format( - ILLEGAL_VARIABLE_EXCEPTION_MSG, variable.getId(), - getElementName())); - } - if (variable.isSetId()) { - setVariable(variable.getId()); - } else { - unsetVariable(); - } - } else { - throw new IllegalArgumentException(String.format( - ILLEGAL_CONSTANT_VARIABLE_MSG, variable.getId(), - getElementName())); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#toString() - */ - @Override - public String toString() { - if (getMath() != null && getVariable() != null) { - return getVariable() + " = " + getMath().toString(); - } else if (isSetMath()) { - return getMath().toString(); - } else if (isSetVariable()) { - return getVariable() + " = 0"; - } - return getElementName(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#unsetVariable() - */ - public void unsetVariable() { - setVariable((String) null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetVariable() && getLevel() >= 2) { - attributes.put("variable", getVariable()); - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ExplicitRule.java b/IPK_lib/src/org/sbml/jsbml/ExplicitRule.java deleted file mode 100644 index 23fff1e20..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ExplicitRule.java +++ /dev/null @@ -1,564 +0,0 @@ -/* - * $Id: ExplicitRule.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ExplicitRule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * An explicit {@link Rule} is a rule that explicitly declares its variable - * element. Hence, this class provides methods to access and manipulate the - * variable field of the underlying {@link Rule}. - * - * @author Andreas Dräger - * @date 2010-08-05 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public abstract class ExplicitRule extends Rule implements Assignment, - SBaseWithUnit { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7458241628289830621L; - - /** - * Represents the 'units' XML attribute of a ParameterRule. - * - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - protected String unitsID; - - /** - * Represents the id of a {@link Variable}. Matches the variable XML - * attribute of an assignmentRule or rateRule element. - */ - String variableID; - - /** - * Creates a new {@link ExplicitRule}. - */ - public ExplicitRule() { - super(); - initDefaults(); - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param math - * @param level - * @param version - */ - public ExplicitRule(ASTNode math, int level, int version) { - super(math, level, version); - initDefaults(); - } - - /** - * Creates a new {@link ExplicitRule} with the given {@link ASTNode} element - * for the assignment to the given {@link Variable} or the derivative of the - * {@link Variable}. - * - * @param math - * An assignment - * @param variable - * Either the variable itself or its derivative is to be modified - * with the given. - */ - public ExplicitRule(ASTNode math, Variable variable) { - this(variable, math); - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param rule - */ - public ExplicitRule(ExplicitRule rule) { - super(rule); - initDefaults(); - if (rule.isSetVariable()) { - setVariable(new String(rule.getVariable())); - } - if (rule.isSetUnits()) { - setUnits(new String(rule.getUnits())); - } - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param level - * @param version - */ - public ExplicitRule(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param parameter - */ - public ExplicitRule(Parameter parameter) { - this((Variable) parameter); - UnitDefinition ud = parameter.getDerivedUnitDefinition(); - if ((ud != null) && ud.isSetId()) { - this.unitsID = new String(ud.getId()); - } else { - this.unitsID = null; - } - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param parameter - * @param math - */ - public ExplicitRule(Parameter parameter, ASTNode math) { - this((Variable) parameter, math); - if (parameter.isSetUnits()) { - this.unitsID = new String(parameter.getUnits()); - } else { - this.unitsID = null; - } - } - - /** - * Creates an {@link ExplicitRule} instance from a given {@link Variable}. - * Takes level and version from the variable. - * - * @param variable - */ - public ExplicitRule(Variable variable) { - this(variable.getLevel(), variable.getVersion()); - setVariable(variable); - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param variable - * @param math - */ - public ExplicitRule(Variable variable, ASTNode math) { - super(math, variable.getLevel(), variable.getVersion()); - initDefaults(); - if (variable.isSetId()) { - this.variableID = new String(variable.getId()); - } else { - this.variableID = null; - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Rule#clone() - */ - public abstract ExplicitRule clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - ExplicitRule r = (ExplicitRule) object; - equals &= isSetVariable() == r.isSetVariable(); - if (equals && isSetVariable()) { - equals &= getVariable().equals(r.getVariable()); - } - equals &= isSetUnits() == r.isSetUnits(); - if (equals && isSetUnits()) { - equals &= getUnits().equals(r.getUnits()); - } - } - return equals; - } - - /** - * Returns the unitsID of this object. - * - * @return the unitsID of this object. - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public String getUnits() { - return isSetUnits() ? unitsID : ""; - } - - /** - * - * @return the UnitDefinition instance which matches the unitsID of this - * object. - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public UnitDefinition getUnitsInstance() { - Model model = getModel(); - return model != null ? model.getUnitDefinition(this.unitsID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariable() - */ - public String getVariable() { - return isSetVariable() ? this.variableID : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariableInstance() - */ - public Variable getVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 919; - int hashCode = super.hashCode(); - if (isSetVariable()) { - hashCode += prime * getVariable().hashCode(); - } - if (isSetUnits()) { - hashCode += prime * getUnits().hashCode(); - } - return hashCode; - } - - /** - * - */ - public void initDefaults() { - variableID = null; - unitsID = null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isCompartmentVolume() - */ - @Override - public boolean isCompartmentVolume() { - return isSetVariable() - && (getVariableInstance() instanceof Compartment); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isParameter() - */ - @Override - public boolean isParameter() { - return isSetVariableInstance() - && (getVariableInstance() instanceof Parameter); - } - - /** - * Predicate returning true or false depending on whether this Rule is an - * AssignmentRule (SBML Level 2) or has a 'type' attribute value of 'scalar' - * (SBML Level 1). - * - * @return true if this Rule is an AssignmentRule (Level 2) or has type - * 'scalar' (Level 1), false otherwise. - */ - public abstract boolean isScalar(); - - /** - * - * @return true if the unitsID of this object is not null. - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public boolean isSetUnits() { - return unitsID != null; - } - - /** - * - * @return true if the UnitsID of this object matches a no null - * UniDefinition of the model instance. - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public boolean isSetUnitsInstance() { - Model model = getModel(); - return model != null ? model.getUnitDefinition(this.unitsID) != null - : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariable() - */ - public boolean isSetVariable() { - return variableID != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariableInstance() - */ - public boolean isSetVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) != null : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.Rule#isSpeciesConcentration() - */ - @Override - public boolean isSpeciesConcentration() { - return isSetVariableInstance() - && (getVariableInstance() instanceof Species); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (getLevel() == 1) { - if ((attributeName.equals("compartment") - || attributeName.equals("name") || attributeName - .equals((getVersion() == 1) ? "specie" : "species"))) - { - setVariable(value); - return true; - } else if (attributeName.equals("units")) { - setUnits(value); - return true; - } - - } else if (attributeName.equals("variable")) { - setVariable(value); - return true; - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit.Kind) - */ - @Deprecated - public void setUnits(Kind unitKind) { - setUnits(new Unit(unitKind, getLevel(), getVersion())); - } - - /** - * Sets the unitsID to 'unitsID'. - * - * @param unitsID - * A valid identifier of a {@link UnitDefinition} in the - * {@link Model} or the name of one of the {@link Unit.Kind} base - * types. - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - * @throws PropertyNotAvailableException if Level is not 1. - */ - @Deprecated - public void setUnits(String unitsID) { - if (getLevel() != 1) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.units, this); - } - if (isSetVariable() && !isParameter()) { - throw new IllegalArgumentException(String.format( - "Cannot set unit %s for a variable other than parameter", unitsID)); - } - String oldUnitsID = this.unitsID; - this.unitsID = unitsID; - firePropertyChange(TreeNodeChangeEvent.units, oldUnitsID, unitsID); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit) - */ - @Deprecated - public void setUnits(Unit unit) { - UnitDefinition ud = new UnitDefinition(unit.getKind().toString(), - getLevel(), getVersion()); - ud.addUnit(unit); - if ((unit.getExponent() != 1) || (unit.getScale() != 0) - || (unit.getMultiplier() != 1d) || (unit.getOffset() != 0d)) { - StringBuilder sb = new StringBuilder(); - sb.append(unit.getMultiplier()); - sb.append('_'); - sb.append(unit.getScale()); - sb.append('_'); - sb.append(unit.getKind().toString()); - sb.append('_'); - sb.append(unit.getExponent()); - ud.setId(sb.toString()); - Model m = getModel(); - if (m != null) { - m.addUnitDefinition(ud); - } - } - setUnits(ud); - } - - /** - * Sets the unitsID of this object with the id of 'units'. - * - * @param variable - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link AssignmentRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public void setUnits(UnitDefinition units) { - if (units != null) { - setUnits(units.getId()); - } else { - unsetUnits(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(java.lang.String) - */ - public void setVariable(String variable) { - // checkAndSetVariable(variable); // We cannot use that as the Object might not be defined yet in L3. - - if (variable != null && variable.trim().length() == 0) { - variable = null; - } - - String oldVariable = variableID; - variableID = variable; - firePropertyChange(TreeNodeChangeEvent.variable, oldVariable, variableID); - - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(org.sbml.jsbml.Variable) - */ - public void setVariable(Variable variable) { - if (variable != null) { - if (variable.isConstant()) { - throw new IllegalArgumentException( - String.format(ILLEGAL_CONSTANT_VARIABLE_MSG, - variable.getId(), getElementName())); - } - if (isSetUnits() && !(variable instanceof Parameter)) { - throw new IllegalArgumentException(String.format( - "Variable expected to be an instance of Parameter because a Unit attribute is set already, but given is an %s.", - variable.getElementName())); - } - if ((getLevel() < 3) && (variable instanceof SpeciesReference)) { - throw new IllegalArgumentException(String.format( - ILLEGAL_VARIABLE_EXCEPTION_MSG, variable.getId(), - getElementName())); - } - if (variable.isSetId()) { - String oldVariable = this.variableID; - variableID = variable.getId(); - firePropertyChange(TreeNodeChangeEvent.variable, oldVariable, variableID); - } else { - unsetVariable(); - } - } else { - unsetVariable(); - } - } - - /** - * Unsets the unitsID of this {@link ExplicitRule}. - * - * @deprecated This is a requirement for Level 1 Version 1 and Version 2, - * but can only be used in conjunction with {@link Parameter}s. - * In this case this {@link ExplicitRule} represents the SBML - * element ParameterRule. - */ - @Deprecated - public void unsetUnits() { - String oldUnitsID = this.unitsID; - this.unitsID = null; - firePropertyChange(TreeNodeChangeEvent.variable, oldUnitsID, unitsID); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#unsetVariable() - */ - public void unsetVariable() { - String oldVariableID = this.variableID; - variableID = null; - firePropertyChange(TreeNodeChangeEvent.variable, oldVariableID, - variableID); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetVariable()) { - if (getLevel() > 1) { - attributes.put("variable", getVariable()); - } else if (getLevel() == 1) { - if (isSpeciesConcentration()) { - attributes.put((getVersion() == 1) ? "specie" : "species", - getVariable()); - } else if (isCompartmentVolume()) { - attributes.put("compartment", getVariable()); - } else if (isParameter()) { - attributes.put("name", getVariable()); - } - if (isSetUnits()) { - attributes.put("units", getUnits()); - } - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/FunctionDefinition.java b/IPK_lib/src/org/sbml/jsbml/FunctionDefinition.java deleted file mode 100644 index eb7ec545e..000000000 --- a/IPK_lib/src/org/sbml/jsbml/FunctionDefinition.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * $Id: FunctionDefinition.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/FunctionDefinition.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the functionDefinition XML element of a SBML file. Since - * {@link FunctionDefinition}s were introduced to SBML in Level 2, this - * class must not be used for models in Level 1. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class FunctionDefinition extends AbstractMathContainer implements - CallableSBase, UniqueNamedSBase { - - /** - * Error message to indicate that an incorrect {@link ASTNode#Type} has been passed - * to a method. - */ - private static final String ILLEGAL_ASTNODE_TYPE_MSG = "Math element is expected to be of type %s, but given is %s."; - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 5103621145642898899L; - /** - * Represents the "id" attribute of a functionDefinition element. - */ - private String id; - /** - * Represents the "name" attribute of a functionDefinition element. - */ - private String name; - - /** - * Creates a FunctionDefinition instance. By default, id and name are null. - */ - public FunctionDefinition() { - super(); - this.id = null; - this.name = null; - } - - /** - * Creates a FunctionDefinition instance from a given FunctionDefinition. - * - * @param sb - */ - public FunctionDefinition(FunctionDefinition sb) { - super(sb); - if (sb.isSetId()) { - this.id = new String(sb.getId()); - } else { - this.id = null; - } - if (sb.isSetName()) { - this.name = new String(sb.getName()); - } else { - this.name = null; - } - } - - /** - * Creates a FunctionDefinition instance from a level and version. By - * default, name is null. - * - * @param level - * @param version - */ - public FunctionDefinition(int level, int version) { - super(level, version); - if (getLevel() < 2) { - throw new IllegalArgumentException(String.format( - "Cannot create a %s with Level = %s.", getElementName(), - getLevel())); - } - } - - /** - * Creates a FunctionDefinition instance from an id, ASTNode, level and - * version. By default, name is null. If the ASTNode is not of type lambda, - * an IllegalArgumentException is thrown. - * - * @param id - * @param lambda - * @param level - * @param version - */ - public FunctionDefinition(String id, ASTNode lambda, int level, int version) { - super(lambda, level, version); - if (!lambda.isLambda()) { - throw new IllegalArgumentException(String.format( - ILLEGAL_ASTNODE_TYPE_MSG, - ASTNode.Type.LAMBDA, lambda.getType())); - } - if (id != null) { - this.id = new String(id); - } else { - this.id = null; - } - this.name = null; - } - - /** - * Creates a FunctionDefinition instance from an id, level and version. - * - * @param id - * @param level - * @param version - */ - public FunctionDefinition(String id, int level, int version) { - super(level, version); - if (id != null) { - this.id = new String(id); - } else { - this.id = null; - } - this.name = null; - } - - /** - * Checks if the sID is a valid identifier. - * - * @param sID - * the identifier to be checked. If null or an invalid - * identifier, an exception will be thrown. - * @return true only if the sID is a valid identifier. - * Otherwise this method throws an {@link IllegalArgumentException}. - * This is an intended behavior. - * @throws IllegalArgumentException - * if the given id is not valid in this model. - */ - boolean checkIdentifier(String sID) { - if ((sID == null) - || !AbstractNamedSBase.isValidId(sID, getLevel(), getVersion())) { - throw new IllegalArgumentException(String.format( - "\"%s\" is not a valid identifier.", sID)); - } - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public FunctionDefinition clone() { - return new FunctionDefinition(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - FunctionDefinition fd = (FunctionDefinition) object; - equals &= fd.isSetId() == isSetId(); - if (equals && isSetId()) { - equals &= fd.getId().equals(getId()); - } - equals &= fd.isSetName() == isSetName(); - if (equals && isSetName()) { - equals &= fd.getName().equals(getName()); - } - } - return equals; - } - - /** - * Get the nth argument to this function. - * - * Callers should first find out the number of arguments to the function by - * calling {@link #getArgumentCount()}. - * - * @param n - * an integer index for the argument sought. - * @return the nth argument (bound variable) passed to this - * {@link FunctionDefinition}. - */ - public ASTNode getArgument(int n) { - if (getArgumentCount() < n) { - throw new IndexOutOfBoundsException(String.format( - "No such argument with index %d.", n)); - } - return getMath().getChild(n); - } - - /** - * Get the argument named name to this {@link FunctionDefinition}. - * - * @param name - * the exact name (case-sensitive) of the sought-after argument - * @return the argument (bound variable) having the given name, or null if - * no such argument exists. - */ - public ASTNode getArgument(String name) { - ASTNode arg = null; - for (int i = 0; i < getArgumentCount(); i++) { - arg = getArgument(i); - if (arg.getName().equals(name)) { - return arg; - } - } - return null; - } - - /** - * Get the mathematical expression that is the body of this - * {@link FunctionDefinition} object. - * - * @return the body of this {@link FunctionDefinition} as an Abstract Syntax - * Tree, or null if no body is defined. - */ - public ASTNode getBody() { - return isSetMath() ? getMath().getRightChild() : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#getId() - */ - public String getId() { - return isSetId() ? this.id : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#getName() - */ - public String getName() { - return isSetName() ? name : ""; - } - - /** - * Get the number of arguments (bound variables) taken by this - * {@link FunctionDefinition}. - * - * @return the number of arguments (bound variables) that must be passed to - * this {@link FunctionDefinition}. - * @deprecated use {@link #getArgumentCount()} - */ - @Deprecated - public int getNumArguments() { - return getArgumentCount(); - } - - /** - * Get the number of arguments (bound variables) taken by this - * {@link FunctionDefinition}. - * - * @return the number of arguments (bound variables) that must be passed to - * this {@link FunctionDefinition}. - */ - public int getArgumentCount() { - return isSetMath() && (getMath().getChildCount() > 1) - ? getMath().getChildCount() - 1 : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 877; - int hashCode = super.hashCode(); - if (isSetId()) { - hashCode += prime * getId().hashCode(); - } - if (isSetName()) { - hashCode += prime * getName().hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isSetId() - */ - public boolean isSetId() { - return id != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isSetName() - */ - public boolean isSetName() { - return name != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName.equals("id")) { - setId(value); - return true; - } else if (attributeName.equals("name")) { - setName(value); - return true; - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#setId(java.lang.String) - */ - public void setId(String id) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.id, this); - } - String oldId = this.id; - Model model = getModel(); - if ((oldId != null) && (model != null)) { - // Delete previous identifier only if defined. - model.registerId(this, false); - } - if ((id == null) || (id.trim().length() == 0)) { - this.id = null; - } else if ((getLevel() == 3) || checkIdentifier(id)) { - this.id = id; - } - if ((model != null) && !model.registerId(this, true)) { - IdentifierException exc = new IdentifierException(this, this.id); - this.id = oldId; // restore the previous setting! - throw new IllegalArgumentException(exc); - } - firePropertyChange(TreeNodeChangeEvent.id, oldId, this.id); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#setMath(org.sbml.jsbml.ASTNode) - */ - @Override - public void setMath(ASTNode math) { - if (getLevel() < 2) { - // throw new PropertyNotAvailableError(SBaseChangedEvent.id, this); - // We can use internally ASTNode even if working on level 1 model !! - } - - if (!math.isLambda()) { - throw new IllegalArgumentException(String.format( - ILLEGAL_ASTNODE_TYPE_MSG, ASTNode.Type.LAMBDA, math - .getType())); - } - super.setMath(math); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#setName(java.lang.String) - */ - public void setName(String name) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.id, this); - } - String oldName = this.name; - if ((name == null) || (name.length() == 0)) { - this.name = null; - } else { - this.name = name; - } - firePropertyChange(TreeNodeChangeEvent.name, oldName, name); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#toString() - */ - @Override - public String toString() { - if (isSetName() && getName().length() > 0) { - return name; - } - if (isSetId()) { - return id; - } - String name = getClass().getName(); - return name.substring(name.lastIndexOf('.') + 1); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#unsetId() - */ - public void unsetId() { - setId(null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#unsetName() - */ - public void unsetName() { - setName(null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId() && (getLevel() > 1)) { - attributes.put("id", getId()); - } - if (isSetName() && (getLevel() > 1)) { - attributes.put("name", getName()); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/History.java b/IPK_lib/src/org/sbml/jsbml/History.java deleted file mode 100644 index 836d86913..000000000 --- a/IPK_lib/src/org/sbml/jsbml/History.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * $Id: History.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/History.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Calendar; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.TreeNodeAdapter; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Contains all the history information about a {@link Model} (or other - * {@link SBase} if level >= 3). - * - * @author Marine Dumousseau - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class History extends AnnotationElement { - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1699117162462037149L; - /** - * Date of creation - */ - private Date creation; - /** - * Contains all the {@link Creator} instances of this {@link History}. - */ - private List listOfCreators; - /** - * Contains all the modified date instances of this {@link History}. - */ - private List listOfModification; - /** - * Last date of modification - */ - private Date modified; - - /** - * Creates a {@link History} instance. By default, the creation and modified - * are null. The {@link #listOfModification} and {@link #listOfCreators} are empty. - */ - public History() { - super(); - listOfCreators = new LinkedList(); - listOfModification = new LinkedList(); - creation = null; - modified = null; - } - - /** - * Creates a {@link History} instance from a given {@link History}. - * - * @param history - */ - public History(History history) { - super(history); - listOfCreators = new LinkedList(); - for (Creator c : history.getListOfCreators()) { - listOfCreators.add(c.clone()); - } - listOfModification = new LinkedList(); - for (Date d : history.getListOfModifiedDates()) { - listOfModification.add((Date) d.clone()); - } - Calendar calendar = Calendar.getInstance(); - if (history.isSetCreatedDate()) { - calendar.setTime(history.getCreatedDate()); - creation = calendar.getTime(); - } - if (history.isSetModifiedDate()) { - calendar.setTime(history.getModifiedDate()); - modified = calendar.getTime(); - } - } - - /** - * Adds a {@link Creator} instance to this {@link History}. - * - * @param mc - */ - public void addCreator(Creator mc) { - boolean success = listOfCreators.add(mc); - mc.parent = this; - if (success) { - firePropertyChange(TreeNodeChangeEvent.created, null, mc); - } - } - - /** - * Adds a {@link Date} of modification to this {@link History}. - * - * @param date - */ - public void addModifiedDate(Date date) { - setModifiedDate(date); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public History clone() { - return new History(this); - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - // Check all child elements recursively in super class first: - boolean equals = super.equals(object); - if (equals) { - // Cast is possible because super class checks the class attributes - History mh = (History) object; - equals &= listOfCreators.size() == mh.getListOfCreators().size(); - equals &= isSetModifiedDate() == mh.isSetModifiedDate(); - if (equals && isSetModifiedDate()) { - equals &= getModifiedDate().equals(mh.getModifiedDate()); - } - equals &= isSetCreatedDate() == mh.isSetCreatedDate(); - // isSetCreatedDate() may still be null. - if (equals && isSetCreatedDate()) { - equals &= getCreatedDate().equals(mh.getCreatedDate()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - int pos = 0; - if (isSetListOfCreators()) { - if (pos == childIndex) { - return new TreeNodeAdapter(getListOfCreators(), this); - } - pos++; - } - if (isSetListOfModification()) { - if (pos == childIndex) { - return new TreeNodeAdapter(getListOfModifiedDates(), this); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - childIndex, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - int count = 0; - if (isSetListOfCreators()) { - count ++; - } - if (isSetListOfModification()) { - count++; - } - return count; - } - - /** - * Returns the createdDate from the {@link History}. - * - * @return {@link Date} object representing the createdDate from the {@link History}. - * Can be null if it is not set. - */ - public Date getCreatedDate() { - return creation; - } - - /** - * Get the nth {@link Creator} object in this {@link History}. - * - * @param i - * @return the nth {@link Creator} of this {@link History}. Can be null. - */ - public Creator getCreator(int i) { - return listOfCreators.get(i); - } - - /** - * Get the list of {@link Creator} objects in this {@link History}. - * - * @return the list of {@link Creator}s for this {@link History}. - */ - public List getListOfCreators() { - return listOfCreators; - } - - /** - * Get the list of ModifiedDate objects in this {@link History}. - * - * @return the list of ModifiedDates for this {@link History}. - */ - public List getListOfModifiedDates() { - return listOfModification; - } - - /** - * Returns the modifiedDate from the {@link History}. - * - * @return Date object representing the modifiedDate from the {@link History}. - * Can be null if it is not set. - */ - public Date getModifiedDate() { - return modified; - } - - /** - * Get the nth {@link Date} object in the list of ModifiedDates in this - * {@link History}. - * - * @param n - * the nth {@link Date} in the list of ModifiedDates of this - * {@link History}. - * @return the nth {@link Date} object in the list of ModifiedDates in this - * {@link History}. Can be null if it is not set. - */ - public Date getModifiedDate(int n) { - return listOfModification.get(n); - } - - /** - * Get the number of {@link Creator} objects in this {@link History}. - * - * @return the number of {@link Creator}s in this {@link History}. - * @deprecated use {@link #getCreatorCount()} - */ - @Deprecated - public int getNumCreators() { - return getCreatorCount(); - } - - /** - * Get the number of {@link Creator} objects in this {@link History}. - * - * @return the number of {@link Creator}s in this {@link History}. - */ - public int getCreatorCount() { - return isSetListOfCreators() ? listOfCreators.size() : 0; - } - - /** - * Get the number of ModifiedDate objects in this {@link History}. - * - * @return the number of ModifiedDates in this {@link History}. - * @deprecated use {@link #getModifiedDateCount()} - */ - @Deprecated - public int getNumModifiedDates() { - return getModifiedDateCount(); - } - - /** - * Get the number of ModifiedDate objects in this {@link History}. - * - * @return the number of ModifiedDates in this {@link History}. - */ - public int getModifiedDateCount() { - return isSetListOfModification() ? listOfModification.size() : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 811; - int hashCode = super.hashCode(); - if (isSetModifiedDate()) { - hashCode += prime * getModifiedDate().hashCode(); - } - if (isSetCreatedDate()) { - hashCode += prime * getCreatedDate().hashCode(); - } - return hashCode; - } - - /** - * Checks whether at least one attribute has been set for this - * {@link History}. - * - * @return true if at least one of the possible attributes is set, i.e., not - * null: - *

      - *
    • {@link #creation} date
    • - *
    • {@link #listOfCreators} is not null and contains at least one - * element
    • - *
    • - * {@link #listOfModification} is not null and contains at least one - * element.
    • - *
    • {@link #modified} is not null.
    • - *
    - */ - public boolean isEmpty() { - return !isSetCreatedDate() && (getCreatorCount() == 0) - && (getModifiedDateCount() == 0) && !isSetModifiedDate(); - } - - /** - * Predicate returning true or false depending on whether this - * {@link History}'s createdDate has been set. - * - * @return true if the createdDate of this {@link History} has been set, false - * otherwise. - */ - public boolean isSetCreatedDate() { - return creation != null; - } - - /** - * - * @return - */ - public boolean isSetListOfCreators() { - return listOfCreators != null; - } - - /** - * - * @return - */ - public boolean isSetListOfModification() { - return listOfModification != null; - } - - /** - * Predicate returning true or false depending on whether this - * {@link History}'s modifiedDate has been set. - * - * @return true if the modifiedDate of this {@link History} has been set, false - * otherwise. - */ - public boolean isSetModifiedDate() { - return modified != null; - } - - /** - * - * @param nodeName - * @param attributeName - * @param prefix - * @param value - * @return true if the XML attribute is known by this {@link History}. - */ - public boolean readAttribute(String nodeName, String attributeName, - String prefix, String value) { - if (nodeName.equals("creator") || nodeName.equals("created") - || nodeName.equals("modified")) { - if (attributeName.equals("parseType") && value.equals("Resource")) { - return true; - } - } - return false; - } - - /** - *If there is no ith {@link Creator}, it returns null. - * - * @param i - * @return the {@link Creator} removed from the {@link #listOfCreators}. - */ - public Creator removeCreator(int i) { - Creator c = listOfCreators.remove(i); - if(c != null){ - firePropertyChange(TreeNodeChangeEvent.creator, c, null); - } - return c; - } - - /** - * If there is no ith modified {@link Date}, it returns null. - * - * @param i - * @return the modified {@link Date} removed from the listOfModification. - */ - public Date removeModifiedDate(int i) { - if (i < listOfModification.size()) { - if (i == listOfModification.size() - 1) { - if (i - 2 >= 0) { - this.modified = listOfModification.get(i - 2); - } else { - this.modified = null; - } - } - Date d = listOfModification.remove(i); - if(d != null){ - firePropertyChange(TreeNodeChangeEvent.modified, d, null); - } - return d; - } - throw new IndexOutOfBoundsException(String.format("No modified date %d available.", i)); - } - - /** - * Sets the createdDate. - * - * @param date - * a {@link Date} object representing the date the {@link History} was - * created. - */ - public void setCreatedDate(Date date) { - Date oldValue = creation; - creation = date; - firePropertyChange(TreeNodeChangeEvent.created, oldValue, date); - } - - /** - * Sets the modifiedDate. - * - * @param date - * a {@link Date} object representing the date the {@link History} was - * modified. - */ - public void setModifiedDate(Date date) { - Date oldValue = modified; - boolean success = listOfModification.add(date); - modified = date; - if (success) { - firePropertyChange(TreeNodeChangeEvent.modified, oldValue, modified); - } - } - - /** - * Sets the created of this {@link History} to null. - */ - public void unsetCreatedDate() { - if(this.creation != null){ - Date oldValue = this.creation; - creation = null; - firePropertyChange(TreeNodeChangeEvent.created, oldValue, creation); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/IdentifierException.java b/IPK_lib/src/org/sbml/jsbml/IdentifierException.java deleted file mode 100644 index ac95acca8..000000000 --- a/IPK_lib/src/org/sbml/jsbml/IdentifierException.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * $Id: IdentifierException.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/IdentifierException.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -import org.apache.log4j.Logger; - -/** - * This exception is thrown when trying to set or add an identifier to an - * instance of {@link NamedSBase} but if the given identifier is already - * registered in the containing {@link Model}. - * - * @author Andreas Dräger - * @version $Rev: 1169 $ - * @since 0.8 - * @date 19.09.2011 - */ -public class IdentifierException extends SBMLException { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 3203848126194894206L; - /** - * - */ - private static transient final Logger logger = Logger.getLogger(IdentifierException.class); - /** - * - */ - public static final String DUPLICATE_IDENTIFIER_MSG = "Cannot set duplicate %sidentifier '%s' for %s."; - - /** - * - * @param sb - * @param id - */ - public IdentifierException(NamedSBase sb, String id) { - super(String.format(DUPLICATE_IDENTIFIER_MSG, "", id, sb.getElementName())); - logger.error(String.format( - "An element with the id '%s' is already present in the SBML model. The identifier of %s will not be set to this value.", - id, sb.getElementName())); - } - - /** - * @param abstractSBase - * @param metaId - */ - public IdentifierException(SBase sb, String metaId) { - super(String.format(DUPLICATE_IDENTIFIER_MSG, "meta ", metaId, sb.getElementName())); - logger.error(String.format( - "An element with the metaid '%s' is already present in the SBML document. The element %s will not be annotated with it.", - metaId, sb.getElementName())); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/InitialAssignment.java b/IPK_lib/src/org/sbml/jsbml/InitialAssignment.java deleted file mode 100644 index 561edfeb6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/InitialAssignment.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * $Id: InitialAssignment.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/InitialAssignment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the initialAssignment XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class InitialAssignment extends AbstractMathContainer implements Assignment { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 2798071640186792089L; - /** - * Represents the 'symbol' XML attribute of an initialAssignmnent element. - */ - private String variableID; - - /** - * Creates an InitialAssignment instance. By default, variableID is null. - */ - public InitialAssignment() { - super(); - this.variableID = null; - } - - /** - * Creates an InitialAssignment instance from a given InitialAssignment. - * - * @param sb - */ - public InitialAssignment(InitialAssignment sb) { - super(sb); - if (sb.isSetVariable()) { - this.variableID = new String(sb.getVariable()); - } else { - this.variableID = null; - } - } - - /** - * Creates an InitialAssignment from level and version. - * - * @param level - * @param version - */ - public InitialAssignment(int level, int version) { - super(level, version); - if (getLevelAndVersion().compareTo(Integer.valueOf(2), - Integer.valueOf(2)) < 0) { - throw new IllegalArgumentException(String.format( - "Cannot create a %s with Level = %s and Version = &s.", - getElementName(), getLevel(), getVersion())); - } - } - - /** - * Creates an InitialAssignment instance from a {@link Variable}. Takes - * level and version from the given variable. - * - * @param variable - */ - public InitialAssignment(Variable variable) { - super(variable.getLevel(), variable.getVersion()); - if (variable.isSetId()) { - this.variableID = new String(variable.getId()); - } else { - this.variableID = null; - } - } - - /** - * Creates an InitialAssignment from a {@link Variable}, {@link ASTNode}, - * level and version. - * - * @param variable - * @param math - * @param level - * @param version - */ - public InitialAssignment(Variable variable, ASTNode math, int level, - int version) { - super(math, level, version); - if (variable.isSetId()) { - this.variableID = new String(variable.getId()); - } else { - this.variableID = null; - } - } - - /** - * Sets the variableID of this {@link InitialAssignment} to 'variable'. If this - * variableID doesn't match any {@link Variable} id in {@link Model} ( - * {@link Compartment}, {@link Species}, {@link SpeciesReference}, or - * {@link Parameter}), an {@link IllegalArgumentException} is thrown. - * - * @param variable - * : the symbol to set - */ - public void checkAndSetVariable(String variable) { - Variable nsb = null; - Model m = getModel(); - if (m != null) { - nsb = m.findVariable(variable); - } - if (nsb == null) { - throw new IllegalArgumentException(String.format( - NO_SUCH_VARIABLE_EXCEPTION_MSG, m.getId(), variable)); - } - setVariable(nsb.getId()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public InitialAssignment clone() { - return new InitialAssignment(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - InitialAssignment in = (InitialAssignment) object; - equals &= in.isSetVariable() == isSetVariable(); - if (equals && isSetVariable()) { - equals &= in.getVariable().equals(getVariable()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * This method is for compatibility with libSBML only. - * - * @return the variableID of this {@link InitialAssignment}. Return an empty - * {@link String} if it is not set. - * @deprecated use {@link #getVariable()} - */ - @Deprecated - public String getSymbol() { - return getVariable(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariable() - */ - public String getVariable() { - return isSetVariable() ? variableID : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#getVariableInstance() - */ - public Variable getVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 853; - int hashCode = super.hashCode(); - if (isSetVariable()) { - hashCode += prime * getVariable().hashCode(); - } - return hashCode; - } - - /** - * - * @return true if the variableID of this InitialAssignment is not null. - */ - public boolean isSetSymbol() { - return isSetVariable(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariable() - */ - public boolean isSetVariable() { - return variableID != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#isSetVariableInstance() - */ - public boolean isSetVariableInstance() { - Model m = getModel(); - return m != null ? m.findVariable(this.variableID) != null : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName.equals("symbol")) { - this.setVariable(value); - return true; - } - } - return isAttributeRead; - } - - /** - * This method is provided for compatibility with libSBML and also to - * reflect what is written in the SBML specifications until L3V1, but for - * consistency, JSBML uses the term {@link Variable} to refer to elements - * that satisfy the properties of this interface. - * - * @param symbol - * @deprecated use {@link #setVariable(String)}. - */ - @Deprecated - public void setSymbol(String symbol) { - setVariable(symbol); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(java.lang.String) - */ - public void setVariable(String variable) { - if (getLevelAndVersion().compareTo(Integer.valueOf(2), Integer.valueOf(2)) < 0) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.variable, this); - } - String oldVariableID = this.variableID; - this.variableID = variable; - firePropertyChange(TreeNodeChangeEvent.variable, oldVariableID, variable); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#setVariable(org.sbml.jsbml.Variable) - */ - public void setVariable(Variable variable) { - if ((getLevel() < 3) && (variable instanceof SpeciesReference)) { - throw new IllegalArgumentException(String.format( - Assignment.ILLEGAL_VARIABLE_EXCEPTION_MSG, - variable.getId(), getElementName())); - } - setVariable(this.variableID = variable != null ? variable.getId() : null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Assignment#unsetVariable() - */ - public void unsetVariable() { - setVariable((String) null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes( - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetVariable()) { - attributes.put("symbol", getVariable()); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/JSBML.java b/IPK_lib/src/org/sbml/jsbml/JSBML.java deleted file mode 100644 index 8e8ade903..000000000 --- a/IPK_lib/src/org/sbml/jsbml/JSBML.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * $Id: JSBML.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/JSBML.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.InvalidPropertiesFormatException; -import java.util.Map; -import java.util.Properties; - -import javax.xml.stream.XMLStreamException; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.resources.Resource; -import org.sbml.jsbml.text.parser.ParseException; - -/** - * Wrapper class for global methods and constants defined by JSBML. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class JSBML { - - public static final int DUPLICATE_OBJECT_ID = -6; - - /** - * Error message for the case that an invalid unit identifier is to be added - * to this object. - */ - public static final String ILLEGAL_UNIT_EXCEPTION_MSG = "Cannot identify unit %s in the model. Only a valid unit kind or the identifier of an existing unit definition are allowed."; - public static final int INDEX_EXCEEDS_SIZE = -1; - public static final int INVALID_ATTRIBUTE_VALUE = -4; - public static final int INVALID_OBJECT = -5; - public static final int INVALID_XML_OPERATION = -9; - /** - * The current version number of JSBML. - */ - private static final String jsbmlVersion = "0.8-rc1"; // TODO : replace automatically this version number with [BUILD.NUMBER] - - public static final int LEVEL_MISMATCH = -7; - public static final int OPERATION_FAILED = -3; - public static final int OPERATION_SUCCESS = 0; - /** - * This indicates that the {@link Model} has not been set properly or that - * an element tries to access its containing model but this is not possible. - */ - public static final String UNDEFINED_MODEL_MSG = "Cannot access containing model."; - - /** - * This message indicates that a problem occurred but the current class - * cannot give any more precise information about the reasons. - */ - public static final String UNDEFINED_PARSE_ERROR_MSG = "An error occur while creating a parser: %s."; - /** - * This message indicates that a problem occurred but the current class - * cannot give any more precise information about the reasons. - */ - public static final String UNDEFINED_PARSING_ERROR_MSG = "An error occur while parsing the file : %s."; - public static final int UNEXPECTED_ATTRIBUTE = -2; - - public static final int VERSION_MISMATCH = -8; - - /** - * URI for purl terms. - */ - public static final transient String URI_PURL_TERMS = "http://purl.org/dc/terms/"; - /** - * URI for the definition of purl elements - */ - public static final transient String URI_PURL_ELEMENTS = "http://purl.org/dc/elements/1.1/"; - /** - * URI for the definition of XHTML. - */ - public static final transient String URI_XHTML_DEFINITION = "http://www.w3.org/1999/xhtml"; - - - /** - * Adds the given {@link UnitDefinition} to the given model or returns the - * identifier of an equivalent {@link UnitDefinition} that is already part - * of the model. In case that the given model is null, the return value of - * this method will also be null. - * - * @param model - * The model where to add the given {@link UnitDefinition} - * @param units - * The {@link UnitDefinition} to be checked and possibly added to - * the given {@link Model} - * @return The identifier of the given {@link UnitDefinition} if this one - * has been added to the given model, the identifier of an - * equivalent {@link UnitDefinition} that is already part of the - * given model, or null. - */ - public static String addUnitDefinitionIfNotContained(Model model, - UnitDefinition units) { - if (model != null) { - return model.addUnitDefinitionOrReturnIdenticalUnit(units); - } - return null; - } - - /** - * Converts an {@link ASTNode} formula to a text string using a specific - * syntax for mathematical formulas. - *

    - * The text-string form of mathematical formulas produced by - * libsbml.formulaToString() and read by - * libsbml.parseFormula() are simple C-inspired infix notation taken from SBML - * Level 1. A formula in this text-string form therefore can be handed - * to a program that understands SBML Level 1 mathematical expressions, - * or used as part of a formula translation system. The syntax is described - * in detail in the libsbml documentation for ASTNode. - *

    - * - * @param tree - * the root of the {@link ASTNode} formula expression tree - *

    - * @return the formula from the given AST as an SBML Level 1 text-string - * mathematical formula. NULL is returned if the given argument is - * NULL. - *

    - * @throws SBMLException - * In case the given {@link ASTNode} tree contains invalid - * nodes. - */ - public static String formulaToString(ASTNode node) throws SBMLException { - return node.toFormula(); - } - - /** - * Returns the JSBML version as a string of the form '1.2.3'. - * - * @return the JSBML version as a string of the form '1.2.3'. - */ - public static String getJSBMLDottedVersion() { - return jsbmlVersion; - } - - /** - * Returns the JSBML version as an integer: version 1.2.3 becomes 123. - * - * @return the JSBML version as an integer: version 1.2.3 becomes 123. - */ - public static int getJSBMLVersion() { - String jsbmlVersionString = getJSBMLVersionString(); - int indexOfDash = jsbmlVersionString.indexOf("-"); - - if (indexOfDash != -1) { - jsbmlVersionString = jsbmlVersionString.substring(0, indexOfDash); - } - - return Integer.parseInt(jsbmlVersionString); - } - - - /** - * Returns the JSBML version as a string: version 1.2.3 becomes '123'. - * - * @return the JSBML version as a string: version 1.2.3 becomes '123'. - */ - public static String getJSBMLVersionString() { - StringBuilder number = new StringBuilder(); - for (String num : jsbmlVersion.split("\\.")) { - number.append(num); - } - return number.toString(); - } - - /** - * Loads {@link Properties} from a configuration file with the given path - * assuming that all values represent class names. - * @param - * @param path - * @param whereToPutProperties - */ - @SuppressWarnings("unchecked") - public static void loadClasses(String path, - Map> whereToPutProperties) { - Logger logger = Logger.getLogger(JSBML.class); - Properties p = new Properties(); - try { - p.loadFromXML(Resource.getInstance().getStreamFromResourceLocation(path)); - for (Map.Entry entry : p.entrySet()) { - try { - whereToPutProperties.put(entry.getKey().toString(), - (Class) Class.forName(entry.getValue().toString())); - } catch (ClassNotFoundException e) { - logger.debug(MessageFormat.format("Could not load class {0}.", e.getLocalizedMessage())); - } - } - } catch (InvalidPropertiesFormatException e) { - throw new IllegalArgumentException(MessageFormat.format( - "The format of the file {0} is incorrect.", path)); - } catch (IOException e) { - throw new IllegalArgumentException(MessageFormat.format( - "There was a problem opening the file {0}. Please make sure the resources directory is included in the Java class path.", - path)); - } - } - - /** - * Parses a text-string mathematical formula and returns a representation as - * an Abstract Syntax Tree. - * - * @param formula - * a text-string mathematical formula. - * @return an ASTNode representing the formula. - * @throws ParseException - * If the given formula is not of valid format or cannot be - * parsed for other reasons. - */ - public static ASTNode parseFormula(String formula) throws ParseException { - return ASTNode.parseFormula(formula); - } - - /** - * Reads the MathML from the given XML string, constructs a corresponding - * abstract syntax tree, and returns a pointer to the root of the tree. - * - * @param xml - * the MathML XML string. - * @return an ASTNode - */ - public static ASTNode readMathMLFromString(String xml) { - return ASTNode.readMathMLFromString(xml); - } - - /** - * Reads an SBML document from the given file. - * - * @param filename - * the file name. - * @return an SBMLDocument object. - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws IOException if the file does not exist or cannot be read. - */ - public static SBMLDocument readSBML(String fileName) - throws XMLStreamException, IOException { - SBMLReader reader = new SBMLReader(); - - return reader.readSBML(fileName); - } - - /** - * Reads an SBML document from the given file. - * - * @param fileName - * the file name. - * @return an SBMLDocument object. - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws IOException if the file does not exist or cannot be read. - */ - public static SBMLDocument readSBMLFromFile(String fileName) - throws XMLStreamException, IOException { - SBMLReader reader = new SBMLReader(); - - return reader.readSBML(fileName); - } - - - /** - * Reads an SBML document from a string assumed to be in XML format. - * - * @param xml - * the SBMLDocument as XML. - * @return an SBMLDocument object. - * @throws XMLStreamException - * if any error occur while creating the XML document. - */ - public static SBMLDocument readSBMLFromString(String xml) - throws XMLStreamException { - SBMLReader reader = new SBMLReader(); - - return reader.readSBMLFromString(xml); - } - - /** - * Writes the given ASTNode (and its children) to a string as MathML, and - * returns the string. - * - * @param node - * the ASTNode - * @return the MathML string representing the given ASTNode - * @throws XMLStreamException - * @throws SBMLException - */ - public static String writeMathMLToString(ASTNode node) - throws XMLStreamException, SBMLException { - return node.toMathML(); - } - - /** - * Writes the XML representation of an SBML document to a file. - * - * @param d - * the SBMLdocument - * @param filename - * the file name - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws FileNotFoundException - * if the file name is invalid - * @throws SBMLException - */ - public static void writeSBML(SBMLDocument d, String filename) - throws XMLStreamException, FileNotFoundException, SBMLException - { - SBMLWriter writer = new SBMLWriter(); - writer.write(d, filename); - } - - /** - * Writes the given SBML document to an in-memory string. - * - * @param d - * the SBMLdocument - * @return the XML representation of the SBMLdocument as a - * String. - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws SBMLException - */ - public static String writeSBMLToString(SBMLDocument d) - throws XMLStreamException, SBMLException - { - SBMLWriter writer = new SBMLWriter(); - return writer.writeSBMLToString(d); - } - - /** - * - * @param level - * @param version - * @return the name space matching the level and version. - */ - public static String getNamespaceFrom(int level, int version) { - if (level == 3) { - if (version == 1) { - return SBMLDocument.URI_NAMESPACE_L3V1Core; - } - } else if (level == 2) { - if (version == 4) { - return SBMLDocument.URI_NAMESPACE_L2V4; - } else if (version == 3) { - return SBMLDocument.URI_NAMESPACE_L2V3; - } else if (version == 2) { - return SBMLDocument.URI_NAMESPACE_L2V2; - } else if (version == 1) { - return SBMLDocument.URI_NAMESPACE_L2V1; - } - } else if (level == 1) { - if ((version == 1) || (version == 2)) { - return SBMLDocument.URI_NAMESPACE_L1; - } - } - return null; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/KineticLaw.java b/IPK_lib/src/org/sbml/jsbml/KineticLaw.java deleted file mode 100644 index 53b5be054..000000000 --- a/IPK_lib/src/org/sbml/jsbml/KineticLaw.java +++ /dev/null @@ -1,1051 +0,0 @@ -/* - * $Id: KineticLaw.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/KineticLaw.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.HashMap; -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * Represents the kineticLaw XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1212 $ - */ -public class KineticLaw extends AbstractMathContainer implements SBaseWithUnit { - - /** - * Exception to be displayed in case that an illegal variant of unit is to - * be set for this {@link SBaseWithUnit}. - */ - private static final String ILLEGAL_UNIT_KIND_EXCEPTION_MSG = "Cannot set unit %s because only variants of substance or time units are acceptable."; - /** - * A logger for this class. - */ - private static final transient Logger logger = Logger.getLogger(KineticLaw.class); - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7528194464711501708L; - /** - * Represents the listOfLocalParameters or listOfParameters sub-element of a - * kineticLaw element. - */ - private ListOf listOfLocalParameters; - /** - * For internal computation: a mapping between their identifiers and - * the {@link LocalParameter}s in {@link KineticLaw}s themselves: - */ - private Map mapOfLocalParameters; - /** - * Represents the 'substanceUnits' XML attribute of this KineticLaw. - * - * @deprecated - */ - @Deprecated - private String substanceUnitsID; - /** - * Represents the 'timeUnits' XML attribute of this KineticLaw. - * - * @deprecated - */ - @Deprecated - private String timeUnitsID; - /** - * In case that a variant of substance per time is set, this will memorize - * the identifier of the corresponding element in the {@link Model}. - * - * @deprecated - */ - @Deprecated - private String unitsID; - - /** - * Creates a KineticLaw instance. By default, this listOfParameters, the - * timeUnitsID and substanceUnitsID are null. - */ - public KineticLaw() { - super(); - initDefaults(); - } - - /** - * Creates a KineticLaw instance from a level and version. By default, this - * listOfParameters, the timeUnitsID and substanceUnitsID are null. - * - * @param level - * @param version - */ - public KineticLaw(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * Creates a KineticLaw instance from a given KineticLaw. - * - * @param kineticLaw - */ - public KineticLaw(KineticLaw kineticLaw) { - super(kineticLaw); - - if (kineticLaw.isSetListOfLocalParameters()) { - setListOfLocalParameters((ListOf) kineticLaw - .getListOfLocalParameters().clone()); - } - if (kineticLaw.isSetTimeUnits()) { - this.timeUnitsID = new String(kineticLaw.getTimeUnits()); - } else { - timeUnitsID = null; - } - if (kineticLaw.isSetSubstanceUnits()) { - this.substanceUnitsID = new String(kineticLaw.getSubstanceUnits()); - } else { - substanceUnitsID = null; - } - } - - /** - * Creates a KineticLaw instance from a given Reaction. - * - * @param parentReaction - */ - public KineticLaw(Reaction parentReaction) { - this(parentReaction.getLevel(), parentReaction.getVersion()); - parentReaction.setKineticLaw(this); - } - - /** - * Adds a copy of the given Parameter object to the list of local parameters - * in this KineticLaw. - * - * @param parameter - * @return true if the {@link #listOfLocalParameters} was - * changed as a result of this call. - */ - public boolean addLocalParameter(LocalParameter parameter) { - if (getListOfLocalParameters().add(parameter)) { - if (parameter.isSetId() && isSetMath()) { - getMath().updateVariables(); - } - return true; - } - return false; - } - - /** - * Adds a copy of the given Parameter object to the list of local parameters - * in this KineticLaw. - * - * @param p - * @return true if the {@link #listOfLocalParameters} was - * changed as a result of this call. - * @deprecated use {@link #addLocalParameter(LocalParameter)}. - */ - @Deprecated - public boolean addParameter(LocalParameter parameter) { - return addLocalParameter(parameter); - } - - /** - * This method creates a new {@link LocalParameter} with identical - * properties as the given {@link Parameter} and adds this new - * {@link LocalParameter} to this {@link KineticLaw}'s - * {@link #listOfLocalParameter}s. - * - * @param p - * @deprecated A {@link KineticLaw} can only contain instances of - * {@link LocalParameter}s. Please use - * {@link #addLocalParameter(LocalParameter)} and create an - * instance of {@link LocalParameter} for your purposes. - */ - @Deprecated - public void addParameter(Parameter p) { - addParameter(new LocalParameter(p)); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public KineticLaw clone() { - return new KineticLaw(this); - } - - /** - * @return - */ - public LocalParameter createLocalParameter() { - return createLocalParameter(null); - } - - /** - * @param string - * @return - */ - public LocalParameter createLocalParameter(String id) { - LocalParameter parameter = new LocalParameter(id, getLevel(), getVersion()); - addLocalParameter(parameter); - return parameter; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.MathContainer#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - KineticLaw kl = (KineticLaw) object; - equals &= kl.isSetTimeUnits() == isSetTimeUnits(); - if (equals && isSetTimeUnits()) { - equals &= kl.getTimeUnits().equals(getTimeUnits()); - } - equals &= kl.isSetSubstanceUnits() == isSetSubstanceUnits(); - if (equals && isSetSubstanceUnits()) { - equals &= kl.getSubstanceUnits().equals(getSubstanceUnits()); - } - equals &= kl.isSetUnits() == isSetUnits(); - if (equals && isSetUnits()) { - equals &= kl.getUnits().equals(getUnits()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetListOfLocalParameters()) { - if (pos == index) { - return getListOfLocalParameters(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#getChildCount() - */ - @Override - public int getChildCount() { - int children = super.getChildCount(); - if (isSetListOfLocalParameters()) { - children++; - } - return children; - } - - /** - * - * @return the {@link #listOfLocalParameters} of this {@link KineticLaw}. - * Returns null if it is not set. - */ - public ListOf getListOfLocalParameters() { - if (listOfLocalParameters == null) { - listOfLocalParameters = ListOf.newInstance(this, LocalParameter.class); - } - return listOfLocalParameters; - } - - /** - * - * @return the {@link #listOfLocalParameters} of this {@link KineticLaw}. - * Returns null if it is not set. - * @deprecated use {@link #getListOfLocalParameters()} - */ - @Deprecated - public ListOf getListOfParameters() { - return getListOfLocalParameters(); - } - - /** - * - * @param i - * @return the ith {@link LocalParameter} object in the - * {@link #listOfLocalParameters} in this {@link KineticLaw} - * instance. - */ - public LocalParameter getLocalParameter(int i) { - return getListOfParameters().get(i); - } - - /** - * - * @param id - * @return a {@link LocalParameter} based on its identifier. - */ - public LocalParameter getLocalParameter(String id) { - return mapOfLocalParameters != null ? mapOfLocalParameters.get(id) : null; - } - - /** - * @return the number of {@link LocalParameter} instances in this - * {@link KineticLaw} instance. - */ - public int getLocalParameterCount() { - return isSetListOfLocalParameters() ? listOfLocalParameters.size() : 0; - } - - /** - * - * @return the number of {@link LocalParameter} instances in this - * {@link KineticLaw} instance. - * @deprecated use {@link #getLocalParameterCount()} - */ - @Deprecated - public int getNumLocalParameters() { - return getLocalParameterCount(); - } - - /** - * - * @return the number of {@link LocalParameter} instances in this - * {@link KineticLaw} instance. - * @deprecated use {@link #getLocalParameterCount()} - */ - @Deprecated - public int getNumParameters() { - return getNumLocalParameters(); - } - - /** - * - * @param i - * @return the ith {@link LocalParameter} object in the - * {@link #listOfLocalParameters} in this {@link KineticLaw} - * instance. - * @deprecated use {@link #getLocalParameter(int)} - */ - @Deprecated - public LocalParameter getParameter(int i) { - return getLocalParameter(i); - } - - /** - * - * @param id - * @return a {@link LocalParameter} based on its identifier. - * @deprecated use {@link #getLocalParameter(String)} - */ - @Deprecated - public LocalParameter getParameter(String id) { - return getLocalParameter(id); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - public Reaction getParent() { - return getParentSBMLObject(); - } - - /** - * This method is convenient when holding an object nested inside other - * objects in an SBML model. It allows direct access to the <model> - * - * element containing it. - * - * @return Returns the parent SBML object. - */ - @Override - public Reaction getParentSBMLObject() { - return (Reaction) parent; - } - - /** - * - * @return the substanceUnitsID of this {@link KineticLaw}. Return the empty {@link String} - * if it is not set. - */ - @Deprecated - public String getSubstanceUnits() { - return isSetSubstanceUnits() ? this.substanceUnitsID : ""; - } - - /** - * - * @return the UnitDefinition instance which has the substanceUnistID of - * this KineticLaw as id. Return null if it doesn't exist. - */ - @Deprecated - public UnitDefinition getSubstanceUnitsInstance() { - Model m = getModel(); - if ((m != null) && isSetSubstanceUnits()) { - return m.getUnitDefinition(substanceUnitsID); - } - if (unitsID != null) { - UnitDefinition def = new UnitDefinition("substance", getLevel(), - getVersion()); - for (Unit unit : getUnitsInstance().getListOfUnits()) { - if (unit.isVariantOfSubstance()) { - def.addUnit(unit); - } - } - return def; - } - return null; - } - - /** - * - * @return the timeUnitsID of this {@link KineticLaw}. Return the empty {@link String} if it - * is not set. - */ - @Deprecated - public String getTimeUnits() { - return isSetTimeUnits() ? this.timeUnitsID : ""; - } - - /** - * - * @return the UnitDefinition instance which has the timeUnistID of this - * KineticLaw as id. Return null if it doesn't exist. - */ - @Deprecated - public UnitDefinition getTimeUnitsInstance() { - Model m = getModel(); - if ((m != null) && isSetTimeUnits()) { - return m.getUnitDefinition(timeUnitsID); - } - if (unitsID != null) { - UnitDefinition def = new UnitDefinition("time", getLevel(), getVersion()); - Unit time; - for (Unit unit : getUnitsInstance().getListOfUnits()) { - time = unit.clone(); - time.setExponent(-unit.getExponent()); - if (unit.isVariantOfTime()) { - def.addUnit(time); - } - } - return def; - } - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#getUnits() - */ - @Deprecated - public String getUnits() { - return isSetUnits() ? unitsID : ""; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#getUnitsInstance() - */ - @Deprecated - public UnitDefinition getUnitsInstance() { - if (unitsID != null) { - if (Unit.isUnitKind(unitsID, getLevel(), getVersion())) { - UnitDefinition ud = new UnitDefinition(unitsID, getLevel(), - getVersion()); - ud.addUnit(Unit.Kind.valueOf(unitsID.toUpperCase())); - return ud; - } - Model model = getModel(); - return model == null ? null : model.getUnitDefinition(unitsID); - } - UnitDefinition substancePerTimeUnits = getSubstanceUnitsInstance(); - UnitDefinition timeUnits = getTimeUnitsInstance(); - substancePerTimeUnits = (substancePerTimeUnits == null) ? new UnitDefinition( - getLevel(), getVersion()) : substancePerTimeUnits.clone(); - if (timeUnits != null) { - substancePerTimeUnits.divideBy(timeUnits); - substancePerTimeUnits.setId(getSubstanceUnits() + "_per_" - + getTimeUnits()); - } else if (!substancePerTimeUnits.isSetId()) { - substancePerTimeUnits.setId(getSubstanceUnits()); - } - return substancePerTimeUnits; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 857; - int hashCode = super.hashCode(); - if (isSetSubstanceUnits()) { - hashCode += prime * getSubstanceUnits().hashCode(); - } - if (isSetTimeUnits()) { - hashCode += prime * getTimeUnits().hashCode(); - } - if (isSetUnits()) { - hashCode += prime * getUnits().hashCode(); - } - return hashCode; - } - - /** - * - */ - public void initDefaults() { - this.timeUnitsID = null; - this.substanceUnitsID = null; - } - - /** - * - * @return - */ - public boolean isSetListOfLocalParameters() { - return (listOfLocalParameters != null) - && (listOfLocalParameters.size() > 0); - } - - /** - * - * @return true if the listOfParameters of this KineticLaw is not null and - * not empty. - * @deprecated use {@link #isSetListOfLocalParameters()} - */ - @Deprecated - public boolean isSetListOfParameters() { - return isSetListOfLocalParameters(); - } - - /** - * - * @return true if the substanceUnitsID of this KineticLaw is not null. - */ - @Deprecated - public boolean isSetSubstanceUnits() { - return this.substanceUnitsID != null; - } - - /** - * - * @return true if the UnistDefinition instance which has the - * substanceUnitsID of this KineticLaw as id is not null. - * @deprecated - */ - @Deprecated - public boolean isSetSubstanceUnitsInstance() { - Model m = getModel(); - return m != null ? m.getUnitDefinition(this.substanceUnitsID) != null - : false; - } - - /** - * - * @return true if the timeUnitsID of this KineticLaw is not null. - * @deprecated - */ - @Deprecated - public boolean isSetTimeUnits() { - return this.timeUnitsID != null; - } - - /** - * - * @return true if the UnistDefinition instance which has the timeUnitsID of - * this KineticLaw as id is not null. - * @deprecated - */ - @Deprecated - public boolean isSetTimeUnitsInstance() { - Model m = getModel(); - return m != null ? m.getUnitDefinition(this.timeUnitsID) != null - : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#isSetUnits() - */ - @Deprecated - public boolean isSetUnits() { - return (isSetSubstanceUnits() && isSetTimeUnits()) || (unitsID != null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#isSetUnitsInstance() - */ - @Deprecated - public boolean isSetUnitsInstance() { - if (isSetSubstanceUnitsInstance() && isSetTimeUnitsInstance()) { - return true; - } - if (unitsID != null) { - if (Unit.isUnitKind(this.unitsID, getLevel(), getVersion())) { - return true; - } - Model model = getModel(); - return model == null ? false - : model.getUnitDefinition(this.unitsID) != null; - } - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName.equals("timeUnits")) { - setTimeUnits(value); - return true; - } else if (attributeName.equals("substanceUnits")) { - setSubstanceUnits(value); - return true; - } - } - return isAttributeRead; - } - - /** - * @param parameter - * @param delete - * @return - */ - boolean registerLocalParameter(LocalParameter parameter, boolean delete) { - boolean success = false; - if (parameter.isSetId()) { - String id = parameter.getId(); - if (delete) { - if (mapOfLocalParameters != null) { - success = mapOfLocalParameters.remove(id) != null; - logger.debug(String.format("removed id=%s from %s", id, toString())); - } - } else { - if (mapOfLocalParameters == null) { - mapOfLocalParameters = new HashMap(); - } - if (mapOfLocalParameters.containsKey(id)) { - logger.error(String.format( - "A local parameter with the id '%s' is already present in the %s. The new element will not be added to the list.", - id, getListOfLocalParameters().getElementName())); - throw new IllegalArgumentException(String.format( - "Cannot set duplicate identifier '%s'.", id)); - } - mapOfLocalParameters.put(id, parameter); - success = true; - logger.debug(String.format("registered id=%s in %s", id, toString())); - } - } - return success; - } - - /** - * Removes the ith {@link LocalParameter} from this object. - * - * @param i - * @return the {@link LocalParameter} that has been removed or null. - */ - public LocalParameter removeLocalParameter(int i) { - if (!isSetListOfLocalParameters()) { - throw new IndexOutOfBoundsException(Integer.toString(i)); - } - return listOfLocalParameters.remove(i); - } - - /** - * Removes the {@link LocalParameter} 'p' from the - * {@link #listOfLocalParameters} of this {@link KineticLaw} according to - * its 'id'. - * - * @param p - * @return true if the operation was performed successfully. - */ - public boolean removeLocalParameter(LocalParameter p) { - if (isSetListOfLocalParameters()) { - return listOfLocalParameters.remove(p); - } - return false; - } - - /** - * Removes a {@link LocalParameter} from this object based on its 'id'. - * - * @param i - * @return true if the operation was performed successfully. - */ - public boolean removeLocalParameter(String id) { - if (isSetListOfLocalParameters()) { - return getListOfLocalParameters().remove(getLocalParameter(id)); - } - return false; - } - - /** - * Removes the ith {@link LocalParameter} from this object. - * - * @param i - * @deprecated use {@link #removeLocalParameter(int)} - */ - @Deprecated - public void removeParameter(int i) { - removeLocalParameter(i); - } - - /** - * Removes the {@link Parameter} 'p' from the {@link #listOfLocalParameters} - * of this {@link KineticLaw}. - * - * @param p - * @return true if the operation was performed successfully. - * @deprecated use {@link #removeLocalParameter(LocalParameter)} - */ - @Deprecated - public boolean removeParameter(Parameter p) { - return removeLocalParameter(p.getId()); - } - - /** - * Removes a {@link LocalParameter} from this object based on its 'id'. - * - * @param i - * @return true if the operation was performed successfully. - * @deprecated use {@link #removeLocalParameter(String)} - */ - @Deprecated - public boolean removeParameter(String id) { - return removeLocalParameter(id); - } - - /** - * Sets the listOfParameters of this {@link KineticLaw} to 'list'. It automatically - * sets this as parentSBML object of the listOfParameters as well as the - * Parameter instances in the list. - * - * @param listOfLocalParameters - */ - public void setListOfLocalParameters(ListOf listOfLocalParameters) { - unsetListOfLocalParameters(); - this.listOfLocalParameters = listOfLocalParameters; - if (this.listOfLocalParameters != null) { - if (this.listOfLocalParameters.getSBaseListType() != ListOf.Type.listOfLocalParameters) { - this.listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters); - } - registerChild(this.listOfLocalParameters); - } - if (isSetMath()) { - getMath().updateVariables(); - } - } - - /** - * Sets the substanceUnitsID of this {@link KineticLaw}. - * - * @param substanceUnits - * @deprecated Only defined for SBML Level 1 and Level 2 Version 1 and 2. - * @throws PropertyNotAvailableException - * for inappropriate Level/Version combinations. - */ - @Deprecated - public void setSubstanceUnits(String substanceUnits) { - if (((getLevel() == 2) && (getVersion() == 1)) || (getLevel() == 1)) { - String oldSubstanceUnits = this.substanceUnitsID; - this.substanceUnitsID = substanceUnits; - firePropertyChange(TreeNodeChangeEvent.substanceUnits, - oldSubstanceUnits, substanceUnitsID); - } else { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.substanceUnits, this); - } - } - - /** - * - * @param substanceUnit - * @deprecated - */ - @Deprecated - public void setSubstanceUnits(Unit substanceUnit) { - setUnits(substanceUnit); - } - - /** - * Sets the timeUnitsID of this {@link KineticLaw}. - * - * @param timeUnits - * @deprecated Only defined for Level 1 and Level 2 Version 1. - * @throws PropertyNotAvailableException - * for inappropriate Level/Version combinations. - */ - @Deprecated - public void setTimeUnits(String timeUnits) { - if (((getLevel() == 2) && (getVersion() == 1)) || (getLevel() == 1)) { - String oldTimeUnits = this.timeUnitsID; - this.timeUnitsID = timeUnits; - firePropertyChange(TreeNodeChangeEvent.timeUnits, oldTimeUnits, - timeUnitsID); - } else { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.timeUnits, - this); - } - } - - /** - * - * @param timeUnit - * @deprecated - */ - @Deprecated - public void setTimeUnits(Unit timeUnit) { - setUnits(timeUnit); - } - - /** - * Sets the timeUnitsID of this KineticLaw. - * - * @param timeUnits - * @deprecated Only defined for Level 1 and Level 2 Version 1. - */ - @Deprecated - public void setTimeUnits(UnitDefinition timeUnits) { - setTimeUnits(timeUnits.isSetId() ? timeUnits.getId() : null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit.Kind) - */ - @Deprecated - public void setUnits(Kind unitKind) { - setUnits(new Unit(unitKind, getLevel(), getVersion())); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(java.lang.String) - */ - @Deprecated - public void setUnits(String units) { - String oldUnits = this.unitsID; - if (units == null) { - unitsID = null; - } else { - units = units.trim(); - boolean illegalArgument = false; - if (units.length() == 0) { - illegalArgument = true; - } else { - Model model = getModel(); - if (((model == null) || Kind.isValidUnitKindString(units, - getLevel(), getVersion())) - || (((model != null) && (model.getUnitDefinition(units) != null)))) { - unitsID = units; - } else { - illegalArgument = true; - } - } - if (illegalArgument) { - throw new IllegalArgumentException(String.format( - JSBML.ILLEGAL_UNIT_EXCEPTION_MSG, units)); - } - } - if (oldUnits != unitsID) { - firePropertyChange(TreeNodeChangeEvent.units, oldUnits, unitsID); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.Unit) - */ - @Deprecated - public void setUnits(Unit unit) { - if (!unit.isVariantOfSubstance() && !unit.isVariantOfTime()) { - throw new IllegalArgumentException(String.format( - ILLEGAL_UNIT_KIND_EXCEPTION_MSG, unit.toString())); - } - if ((unit.getExponent() != 1) || (unit.getScale() != 0) - || (unit.getMultiplier() != 1d) || (unit.getOffset() != 0d)) { - StringBuilder sb = new StringBuilder(); - sb.append(unit.getMultiplier()); - sb.append('_'); - sb.append(unit.getScale()); - sb.append('_'); - sb.append(unit.getKind().toString()); - sb.append('_'); - sb.append(unit.getExponent()); - UnitDefinition ud = new UnitDefinition(sb.toString(), getLevel(), - getVersion()); - ud.addUnit(unit); - Model m = getModel(); - if (m != null) { - m.addUnitDefinition(ud); - } - setUnits(ud.getId()); - } else { - setUnits(unit.getKind().toString()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#setUnits(org.sbml.jsbml.UnitDefinition) - */ - @Deprecated - public void setUnits(UnitDefinition units) { - if (units != null) { - units = units.simplify(); - if (units.isVariantOfSubstance()) { - setSubstanceUnits(units.getUnit(0)); - } else if (units.isVariantOfTime()) { - setTimeUnits(units.getUnit(0)); - } else if (units.isVariantOfSubstancePerTime()) { - for (Unit unit : units.getListOfUnits()) { - if (unit.isVariantOfSubstance()) { - setSubstanceUnits(unit); - } else { - // must be variant of time^-1 - Unit u = unit.clone(); - u.setExponent(-unit.getExponent()); - setTimeUnits(u); - } - } - } else { - throw new IllegalArgumentException(String.format( - ILLEGAL_UNIT_KIND_EXCEPTION_MSG, UnitDefinition - .printUnits(units, true))); - } - } else { - unsetUnits(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#toString() - */ - @Override - public String toString() { - - String parentId = ""; - - if (getParent() != null) { - // Can happen in the clone constructor when using the SimpleSBaseChangeListener - // The super constructor is called before parent is initialized and - // it is using the toString() method - parentId = getParent().getId(); - } - - return String.format("%s(%s)", getElementName(), parentId); - } - - /** - * Removes the {@link #listOfLocalParameters} from this {@link KineticLaw} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfLocalParameters() { - if (this.listOfLocalParameters != null) { - ListOf oldListOfLocalParameters = this.listOfLocalParameters; - this.listOfLocalParameters = null; - oldListOfLocalParameters.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * @deprecated use {@link #unsetListOfLocalParameters()} - */ - @Deprecated - public void unsetListOfParameters() { - unsetListOfLocalParameters(); - } - - /** - * Unsets the sunbstanceUnistID of this KineticLaw. - * - * @deprecated - */ - @Deprecated - public void unsetSubstanceUnits() { - String oldSubstanceUnitsID = substanceUnitsID; - substanceUnitsID = null; - firePropertyChange(TreeNodeChangeEvent.substanceUnits, - oldSubstanceUnitsID, substanceUnitsID); - } - - /** - * Unsets the timeUnitsID of this KineticLaw. - * - * @deprecated - */ - @Deprecated - public void unsetTimeUnits() { - String oldTimeUnitsID = timeUnitsID; - timeUnitsID = null; - firePropertyChange(TreeNodeChangeEvent.timeUnits, oldTimeUnitsID, - timeUnitsID); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithUnit#unsetUnits() - */ - @Deprecated - public void unsetUnits() { - unsetSubstanceUnits(); - unsetTimeUnits(); - if (unitsID != null) { - String oldUnitID = unitsID; - unitsID = null; - firePropertyChange(TreeNodeChangeEvent.units, oldUnitID, unitsID); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.MathContainer#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if ((getLevel() == 1) || ((getLevel() == 2) && (getVersion() == 1))) { - if (isSetTimeUnits()) { - attributes.put(TreeNodeChangeEvent.timeUnits, getTimeUnits()); - } - if (isSetSubstanceUnits()) { - attributes.put(TreeNodeChangeEvent.substanceUnits, - getSubstanceUnits()); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/LevelVersionError.java b/IPK_lib/src/org/sbml/jsbml/LevelVersionError.java deleted file mode 100644 index 7fd239b64..000000000 --- a/IPK_lib/src/org/sbml/jsbml/LevelVersionError.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * $Id: LevelVersionError.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/LevelVersionError.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.util.Message; - -/** - * An {@link SBMLError} that indicates that associated instances of - * {@link SBase} cannot be combined within the same model due to their - * differently set Level or Version attribute. - * - * @author Andreas Dräger - * @date 2010-11-21 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class LevelVersionError extends SBMLError { - - /** - * Message to display in cases that two objects do not have identical level - * attributes. Requires the following replacement arguments: Class name of - * first element, version in first element, class name of second element and - * level in second argument. - */ - public static final String LEVEL_MISMATCH_MSG = "Level mismatch between %s in L %d and %s in L %d"; - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5549251465153191735L; - /** - * Message to indicate that an invalid combination of the level and version - * attribute has been set. - */ - public static final String UNDEFINED_LEVEL_VERSION_COMBINATION_MSG = "Undefined combination of Level %d and Version %d."; - /** - * Message to display in cases that two objects do not have identical - * version attributes. Requires the following replacement arguments: Class - * name of first element, version in first element, class name of second - * element and version in second argument. - */ - public static final String VERSION_MISMATCH_MSG = "Version mismatch between %s in V %d and %s in V %d."; - - /** - * Creates an error message if the level fields of both elements are not - * identical, or an empty {@link String} otherwise. - * - * @param element1 - * @param element2 - * @return - */ - public static String levelMismatchMessage(SBase element1, SBase element2) { - if (element1.getLevel() != element2.getLevel()) { - return String.format(VERSION_MISMATCH_MSG, element1 - .getElementName(), element1.getLevel(), element2 - .getElementName(), element2.getLevel()); - } - return ""; - } - - /** - * Creates an error message if the version fields of both elements are not - * identical, or an empty {@link String} otherwise. - * - * @param element1 - * @param element2 - * @return - */ - public static String versionMismatchMessage(SBase element1, SBase element2) { - if (element1.getVersion() != element2.getVersion()) { - return String.format(VERSION_MISMATCH_MSG, element1 - .getElementName(), element1.getVersion(), element2 - .getElementName(), element2.getVersion()); - } - return ""; - } - - /** - * - * @param sbase - */ - public LevelVersionError(SBase sbase) { - this(sbase.getElementName(), sbase.getLevel(), sbase.getVersion()); - } - - /** - * - * @param level - * @param version - */ - public LevelVersionError(int level, int version) { - this(null, level, version); - } - - /** - * - * @param elementName - * @param level - * @param version - */ - public LevelVersionError(String elementName, int level, int version) { - super(); - Message message = new Message(); - if (!AbstractSBase.isValidLevelAndVersionCombination(level, version)) { - message.setMessage(String.format( - UNDEFINED_LEVEL_VERSION_COMBINATION_MSG, level, version)); - if (elementName != null) { - message.setMessage(String.format("%s for element %s.", message.getMessage().substring(0, - message.getMessage().length() - 1), elementName)); - } - setMessage(message); - } - } - - /** - * - * @param element1 - * @param element2 - */ - public LevelVersionError(SBase element1, SBase element2) { - super(); - Message message = new Message(); - if (element1.getLevel() != element2.getLevel()) { - message.setMessage(levelMismatchMessage(element1, element2)); - } else if (element1.getVersion() != element2.getVersion()) { - message.setMessage(versionMismatchMessage(element1, element2)); - } - setMessage(message); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBMLError#toString() - */ - public String toString() { - return getMessage(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ListOf.java b/IPK_lib/src/org/sbml/jsbml/ListOf.java deleted file mode 100644 index 08d5f7282..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ListOf.java +++ /dev/null @@ -1,947 +0,0 @@ -/* - * $Id: ListOf.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ListOf.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeWithChangeSupport; -import org.sbml.jsbml.util.filters.Filter; - -/** - * This list implementation is a Java {@link List} that extends - * {@link AbstractSBase}. It represents the listOfxxx XML elements in a SBML - * file. Unfortunately, there is no way for multiple inheritance in Java. - * - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1240 $ - */ -public class ListOf extends AbstractSBase implements List { - - /** - * This enum lists all the possible names of the listXXX components. If the - * listXXX is a SBML package extension, the SBaseListType value to set would - * be 'other'. - * - * @author marine - * - */ - public static enum Type { - /** - * - */ - listOfCompartments, - /** - * - */ - listOfCompartmentTypes, - /** - * - */ - listOfConstraints, - /** - * - */ - listOfEventAssignments, - /** - * - */ - listOfEvents, - /** - * - */ - listOfFunctionDefinitions, - /** - * - */ - listOfInitialAssignments, - /** - * - */ - listOfLocalParameters, - /** - * - */ - listOfModifiers, - /** - * - */ - listOfParameters, - /** - * - */ - listOfProducts, - /** - * - */ - listOfReactants, - /** - * - */ - listOfReactions, - /** - * - */ - listOfRules, - /** - * - */ - listOfSpecies, - /** - * - */ - listOfSpeciesTypes, - /** - * - */ - listOfUnitDefinitions, - /** - * - */ - listOfUnits, - /** - * Indicates that the {@link Type} is not known yet or has not been - * configured so far. - */ - none, - /** - * For instance, it is not possible to decide between reactants and products - * because both elements are of the same type. Also in the extension packages - * this type is required. - */ - other; - - /** - * Gives the corresponding {@link Type} for the given {@link Class} - * object. However, in the case of {@link #listOfReactants} and - * {@link #listOfProducts} it is not possible to make a distinction - * because both types refer to the same {@link Class} object. Therefore, - * in this case this method will return the type {@link #other}, which - * is to be clearly distinguished from {@link #none}. - * - * @param type - * @return - */ - @SuppressWarnings("deprecation") - public static Type valueOf(Class type) { - if (type.equals(Compartment.class)) { - return listOfCompartments; - } else if(type.equals(CompartmentType.class)) { - return listOfCompartmentTypes; - } else if (type.equals(Constraint.class)) { - return listOfConstraints; - } else if (type.equals(Event.class)) { - return listOfEvents; - } else if (type.equals(EventAssignment.class)) { - return listOfEventAssignments; - } else if (type.equals(FunctionDefinition.class)) { - return listOfFunctionDefinitions; - } else if (type.equals(InitialAssignment.class)) { - return listOfInitialAssignments; - } else if (type.equals(LocalParameter.class)) { - return listOfLocalParameters; - } else if (type.equals(ModifierSpeciesReference.class)) { - return listOfModifiers; - } else if (type.equals(Parameter.class)) { - return listOfParameters; - } else if (type.equals(SpeciesReference.class)) { - // Can be reactant or product! - return other; - } else if (type.equals(Reaction.class)) { - return listOfReactions; - } else if (type.equals(Rule.class)) { - return listOfRules; - } else if (type.equals(Species.class)) { - return listOfSpecies; - } else if (type.equals(SpeciesType.class)) { - return listOfSpeciesTypes; - } else if (type.equals(UnitDefinition.class)) { - return listOfUnitDefinitions; - } else if (type.equals(Unit.class)) { - return listOfUnits; - } - return none; - } - - /** - * Gives the corresponding {@link Class} object for this {@link Type}. - * However, in case of {@link #listOfReactants} and - * {@link #listOfProducts} the same {@link Class} object is returned. - * - * @return - */ - @SuppressWarnings("deprecation") - public Class toClass() { - switch (this) { - case listOfCompartments: - return Compartment.class; - case listOfCompartmentTypes: - return CompartmentType.class; - case listOfConstraints: - return Constraint.class; - case listOfEventAssignments: - return EventAssignment.class; - case listOfEvents: - return Event.class; - case listOfFunctionDefinitions: - return FunctionDefinition.class; - case listOfInitialAssignments: - return InitialAssignment.class; - case listOfLocalParameters: - return LocalParameter.class; - case listOfModifiers: - return ModifierSpeciesReference.class; - case listOfParameters: - return Parameter.class; - case listOfProducts: - return SpeciesReference.class; - case listOfReactants: - return SpeciesReference.class; - case listOfReactions: - return Reaction.class; - case listOfRules: - return Rule.class; - case listOfSpecies: - return Species.class; - case listOfSpeciesTypes: - return SpeciesType.class; - case listOfUnitDefinitions: - return UnitDefinition.class; - case listOfUnits: - return Unit.class; - case none: - return null; - default: - return SBase.class; - } - } - } - - /** - * Switches the behavior of the {@link #toString()} method from displaying - * the {@link Type} (default) to the complete content of all instances of - * {@link ListOf} - */ - private static boolean DEBUG_MODE; - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 5757549697766609627L; - - /** - * Helper method to initialize newly created lists. - * - * @param list - * @param type - */ - public static ListOf initListOf(SBase parent, - ListOf list, ListOf.Type type) { - if (parent.isSetLevel()) { - list.setLevel(parent.getLevel()); - } - if (parent.isSetVersion()) { - list.setVersion(parent.getVersion()); - } - list.setSBaseListType(type); - if (parent instanceof AbstractSBase) { - ((AbstractSBase) parent).registerChild(list); - } - return list; - } - - /** - * If this method returns true, the {@link #toString()} method of this - * {@link ListOf} displays the whole content of the list. Otherwise, only - * the {@link Type} is shown. - * - * @return the debugMode - */ - public static boolean isDebugMode() { - return DEBUG_MODE; - } - - /** - * Helper method to initialize a new {@link ListOf} object for the given - * parent SBML object and with the given {@link Class} as the type of the - * list. - * - * @param - * @param parent - * @param clazz - * @return - */ - public static ListOf newInstance(SBase parent, - Class clazz) { - return initListOf(parent, new ListOf(), ListOf.Type.valueOf(clazz)); - } - - /** - * Allows you to influence the behavior of the {@link #toString()} method. - * If set to true, the whole content of this {@link ListOf} is - * displayed by the {@link #toString()} method, just like it is done in - * other {@link List} implementations. The default for JSBML, however, is, - * to only display the {@link Type} of this list. - * - * @param debugMode - * the debugMode to set - */ - public static void setDebugMode(boolean debugMode) { - DEBUG_MODE = debugMode; - } - - /** - * list containing all the SBase elements of this object. - */ - protected List listOf = new ArrayList(); - - /** - * name of the list at it appears in the SBMLFile. By default, it is - * SBaseListType.none. - */ - protected Type listType = Type.none; - - /** - * Creates a ListOf instance. By default, the list containing the SBase - * elements is empty. - */ - public ListOf() { - super(); - } - - /** - * Creates a ListOf instance from a level and version. By default, the list - * containing the SBase elements is empty. - */ - public ListOf(int level, int version) { - super(level, version); - } - - /** - * creates a ListOf instance from a given ListOf. - * - * @param listOf - */ - @SuppressWarnings("unchecked") - public ListOf(ListOf listOf) { - super(listOf); - setSBaseListType(listOf.getSBaseListType()); - - for (SBase base : listOf) { - if (base != null) { - add((T) base.clone()); - } - } - } - - /* (non-Javadoc) - * @see java.util.List#add(int, java.lang.Object) - */ - public void add(int index, T element) { - listOf.add(index, element); - registerChild(element); - } - - /* (non-Javadoc) @see java.util.List#add(java.lang.Object) - */ - public boolean add(T e) { - /* - * Calling the method registerChild before adding the object to the list - * as it can throw an Exception if the metaid or id is not unique in the - * model; it also checks if the given element has the same Level/Version - * configuration as this listOf* element and will throw an exception if - * this is not the case. - */ - registerChild(e); - return listOf.add(e); - } - - /* (non-Javadoc) - * @see java.util.List#addAll(java.util.Collection) - */ - public boolean addAll(Collection c) { - if (listOf.addAll(c)) { - for (T element : c) { - registerChild(element); - } - return true; - } - return false; - } - - /* (non-Javadoc) - * @see java.util.List#addAll(int, java.util.Collection) - */ - public boolean addAll(int index, Collection c) { - if (listOf.addAll(index, c)) { - for (T element : c) { - registerChild(element); - } - return true; - } - return false; - } - - /** - * Adds item to the end of this ListOf. - * - * This variant of the method makes a clone of the item handed to it. This - * means that when the {@link ListOf} is destroyed, the original items will not be - * destroyed. - * - * @param e - * the item to be added to the list. - * @return true if this could be successfully appended. - * @see #add(T) - */ - @SuppressWarnings("unchecked") - public boolean append(T e) { - return add((T) e.clone()); - } - - /* (non-Javadoc) - * @see java.util.List#clear() - */ - public void clear() { - List removedElements = listOf; - listOf.clear(); - for( T element : removedElements){ - ((AbstractTreeNode) element).fireNodeRemovedEvent(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - public ListOf clone() { - return new ListOf(this); - } - - /* (non-Javadoc) - * @see java.util.List#contains(java.lang.Object) - */ - public boolean contains(Object o) { - return listOf.contains(o); - } - - /* (non-Javadoc) - * @see java.util.List#containsAll(java.util.Collection) - */ - public boolean containsAll(Collection c) { - return listOf.containsAll(c); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - boolean equals = super.equals(o); - if (equals) { - ListOf listOf = (ListOf) o; - equals &= getSBaseListType() == listOf.getSBaseListType(); - } - return equals; - } - - /** - * Returns a new {@link ListOf} that contains only those elements that - * satisfy a certain filter criterion. - * - * @param f - * A filter that defines the criterion for elements to be put - * into the list to be returned. - * @return A new list that can be empty if no element fulfills the filter - * criterion. - */ - public ListOf filterList(Filter f) { - /* - * The new list should not be linked to the model or SBMLDocument - * as otherwise, it will try to register elements that are - * already registered and send an exception instead doing any - * filtering - */ - ListOf list = new ListOf(getLevel(), getVersion()); - list.setSBaseListType(getSBaseListType()); - - for (T sbase : this) { - if (f.accepts(sbase)) { - list.add(sbase); - } - } - list.parent = parent; - return list; - } - - /** - * Returns the first element in this list that satisfies a certain filter - * criterion. - * - * @param f - * A filter defining the criterion for which to be filter. - * @return The first element of this list that satisfies the criterion or - * null if no such element exists in this list. - */ - public T firstHit(Filter f) { - for (T sbase : this) { - if (f.accepts(sbase)) { - return sbase; - } - } - return null; - } - - /** - * Returns the element at the specified position in this list or null if the index is negative or too big. - * - * @param index index of the element to return. - * @return the element at the specified position in this list or null if the index is negative or too big. - * - * @see java.util.List#get(int) - */ - public T get(int index) { - if ((index < 0) || (index >= listOf.size())) { - return null; - } - - return listOf.get(index); - } - - /** - * Gets the list element which has the id 'id'. - * - *

    The elements of the list have to implement {@link NamedSBase}, if they are not - * or if the id is not found, null is returned. - * - * @param id the id to search for. - * @return the list element which has the id 'id'. - */ - public T get(String id) { - - T foundElement = null; - - for (T element : listOf) { - if (element instanceof NamedSBase) { - if (((NamedSBase) element).getId().equals(id)) { - foundElement = element; - break; - } - } - if (element instanceof ExplicitRule) { - if (((ExplicitRule) element).getVariable().equals(id)) { - foundElement = element; - break; - } - } - } - - return foundElement; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(); - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - return get(index); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - return super.getChildCount() + size(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - if ((getLevel() < 3) - && (getSBaseListType() == ListOf.Type.listOfLocalParameters)) { - return "listOfParameters"; - } - return (getSBaseListType() != null ? getSBaseListType().toString() - : Type.none.toString()); - } - - /** - * The first element in this list. - * - * @return - */ - public T getFirst() { - return listOf.get(0); - } - - /** - * Returns the last element in this list. - * - * @return - */ - public T getLast() { - return listOf.get(listOf.size() - 1); - } - - /** - * - * @return the SBaseListType of this ListOf instance - */ - public Type getSBaseListType() { - return listType; - } - - /* (non-Javadoc) - * @see java.util.List#indexOf(java.lang.Object) - */ - public int indexOf(Object o) { - return listOf.indexOf(o); - } - - /* (non-Javadoc) - * @see java.util.List#isEmpty() - */ - public boolean isEmpty() { - return listOf.isEmpty(); - } - - /* (non-Javadoc) - * @see java.util.List#iterator() - */ - public Iterator iterator() { - return listOf.iterator(); - } - - /* (non-Javadoc) - * @see java.util.List#lastIndexOf(java.lang.Object) - */ - public int lastIndexOf(Object o) { - return listOf.lastIndexOf(o); - } - - /* (non-Javadoc) - * @see java.util.List#listIterator() - */ - public ListIterator listIterator() { - return listOf.listIterator(); - } - - /* (non-Javadoc) - * @see java.util.List#listIterator(int) - */ - public ListIterator listIterator(int index) { - return listOf.listIterator(index); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) - { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - // no special attributes for ListOf - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see java.util.List#remove(int) - */ - public T remove(int index) { - T t = listOf.remove(index); - ((AbstractTreeNode) t).fireNodeRemovedEvent(); - return t; - } - - /** - * Removes a {@link NamedSBase} according to its unique id. - * - * @param nsb - * the object to be removed. - * @return success or failure. - */ - public boolean remove(NamedSBase nsb) { - if (!listOf.remove(nsb)) { - if (nsb.isSetId()) { - int pos = -1; - for (int i = 0; (i < size()) && (pos < 0); i++) { - NamedSBase sb = (NamedSBase) get(i); - if (sb.isSetId() && nsb.isSetId() - && sb.getId().equals(nsb.getId())) { - pos = i; - } - } - if (pos >= 0) { - T t = listOf.remove(pos); - ((TreeNodeWithChangeSupport) t).fireNodeRemovedEvent(); - return true; - } - } - } else { - ((TreeNodeWithChangeSupport) nsb).fireNodeRemovedEvent(); - return true; - } - return false; - } - - /* (non-Javadoc) - * @see java.util.List#remove(java.lang.Object) - */ - public boolean remove(Object o) { - if (!(o instanceof SBase)) { - return false; - } - SBase sbase = (SBase) o; - if (listOf.remove(sbase)) { - ((AbstractTreeNode) o).fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Specialized method to remove a named SBase according to its unique id. - * - * @param id - * the id of the object to be removed. - * @return success or failure. - */ - @SuppressWarnings("unchecked") - public T remove(String removeId) { - if (removeId != null && removeId.trim().length() > 0) { - int pos = -1; - SBase sbase = null; - for (int i = 0; i < size() && pos < 0; i++) { - NamedSBase sb = (NamedSBase) get(i); - if (sb.isSetId() && sb.getId().equals(removeId)) { - pos = i; - sbase = sb; - break; - } - } - if (pos >= 0) { - T element = listOf.remove(pos); - ((AbstractTreeNode) element).fireNodeRemovedEvent(); - return (T) sbase; - } - } - return null; - } - - /* (non-Javadoc) - * @see java.util.List#removeAll(java.util.Collection) - */ - public boolean removeAll(Collection c) { - boolean success = listOf.removeAll(c); - if(success){ - for(Iterator i = c.iterator(); i.hasNext();){ - AbstractTreeNode element = (AbstractTreeNode) i.next(); - element.fireNodeRemovedEvent(); - } - } - return success; - } - - /** - * Removes all elements from this list that fulfill the filter property of - * the given filter. - * - * @param f - * @return - */ - public boolean removeAll(Filter f) { - return removeAll(filterList(f)); - } - - /** - * Removes the first element from this list that fulfills the filter - * property of the given filter. - * - * @param f - * @return - */ - public T removeFirst(Filter f) { - T t = firstHit(f); - if (remove(t)) - return t; - return null; - } - - /* (non-Javadoc) - * @see java.util.List#retainAll(java.util.Collection) - */ - public boolean retainAll(Collection c) { - boolean modified = false; - for(T element : listOf){ - if (!c.contains(element)) { - listOf.remove(element); - ((AbstractTreeNode) element).fireNodeRemovedEvent(); - modified = true; - } - } - return modified; - } - - /* (non-Javadoc) - * @see java.util.List#set(int, java.lang.Object) - */ - public T set(int index, T element) { - T prevElem = listOf.set(index, element); - // TODO: this should rather be a firePropertyChangedEvent, as the - // element is first removed and then added again. But the method - // registerChild fires a NodeAddedEvent - ((AbstractTreeNode) element).fireNodeRemovedEvent(); - registerChild(element); - return prevElem; - } - - /** - * Clears this {@link ListOf} if not empty and then adds all elements in - * the given {@link List} to this {@link ListOf}. - * - * @param listOf - */ - public void setListOf(List listOf) { - if (!this.listOf.isEmpty()) { - this.clear(); - } - if ((listOf != null) && (listOf.size() > 0)) { - this.addAll(listOf); - } - } - - /** - * Sets the {@link Type} of this {@link ListOf} instance to the {@link Type} - * defined by the given {@link Class}. - * - * @param type - */ - public void setSBaseListType(Class type) { - setSBaseListType(Type.valueOf(type)); - } - - /** - * Sets the {@link Type} of this {@link ListOf} instance to 'listType'. - * - * @param listType - */ - public void setSBaseListType(Type currentList) { - Type oldType = this.listType; - this.listType = currentList; - firePropertyChange(TreeNodeChangeEvent.baseListType, oldType, listType); - } - - /* (non-Javadoc) - * @see java.util.List#size() - */ - public int size() { - return listOf.size(); - } - - /* (non-Javadoc) - * @see java.util.List#subList(int, int) - */ - public List subList(int fromIndex, int toIndex) { - return listOf.subList(fromIndex, toIndex); - } - - /* (non-Javadoc) - * @see java.util.List#toArray() - */ - public Object[] toArray() { - return listOf.toArray(); - } - - /* (non-Javadoc) - * @see java.util.List#toArray(T[]) - */ - @SuppressWarnings("hiding") - public T[] toArray(T[] a) { - return listOf.toArray(a); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#toString() - */ - @Override - public String toString() { - if (DEBUG_MODE) { - return listOf.toString(); - } - - if (listType == null) { - // Can happen in the clone constructor when using the SimpleSBaseChangeListener - // The super constructor is called before listType is initialized and - // it is using the toString() method - return Type.none.toString(); - } - - if (listType.equals(Type.other) && size() > 0) { - String className = get(0).getClass().getSimpleName(); - - return "listOf" + className + (className.endsWith("s") ? "" : "s"); - } - - return listType.toString(); - } - - /** - * Sets the SBaseListType of this ListOf to SBaseListType.none. - */ - public void unsetSBaseListType() { - Type oldType = this.listType; - this.listType = Type.none; - firePropertyChange(TreeNodeChangeEvent.baseListType, oldType, listType); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/LocalParameter.java b/IPK_lib/src/org/sbml/jsbml/LocalParameter.java deleted file mode 100644 index 0f638683b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/LocalParameter.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * $Id: LocalParameter.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/LocalParameter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Locale; -import java.util.Map; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * A local parameter can only be used to specify a constant within a - * {@link KineticLaw}. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @date 2010-04-20 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class LocalParameter extends QuantityWithUnit { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 57994535283502018L; - - /** - * This field memorizes whether this {@link LocalParameter} has been - * explicitly set to be constant. All instances of {@link LocalParameter} - * are constant by definition, however, in earlier versions of SBML (before - * Level 3) it was possible to explicitly state that a - * {@link LocalParameter} is constant. Therefore, a special field has become - * necessary to reflect this property. - */ - private boolean isExplicitlySetConstant = false; - - /** - * Creates a new instance of {@link LocalParameter}. - */ - public LocalParameter() { - super(); - } - - /** - * @param level - * @param version - */ - public LocalParameter(int level, int version) { - super(level, version); - } - - /** - * @param lp - */ - public LocalParameter(LocalParameter lp) { - super(lp); - } - - /** - * Creates a new local parameter that will have the same properties than the - * given global parameter. However, the value of the constant attribute will - * be ignored because a local parameter can only be a constant quantity. - * - * @param parameter - */ - public LocalParameter(Parameter parameter) { - super(parameter); - } - - /** - * Creates a new instance of {@link LocalParameter} with the given - * identifier. - * - * @param id - */ - public LocalParameter(String id) { - super(id); - } - - /** - * @param id - * @param level - * @param version - */ - public LocalParameter(String id, int level, int version) { - super(id, level, version); - } - - /** - * @param id - * @param name - * @param level - * @param version - */ - public LocalParameter(String id, String name, int level, int version) { - super(id, name, level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#clone() - */ - public LocalParameter clone() { - return new LocalParameter(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - LocalParameter lp = (LocalParameter) object; - equals &= isExplicitlySetConstant() == lp.isExplicitlySetConstant(); - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - return (getLevel() < 3) ? "parameter" : super.getElementName(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParentSBMLObject() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParentSBMLObject() { - return (ListOf) super.getParentSBMLObject(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getPredefinedUnitID() - */ - public String getPredefinedUnitID() { - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int hashCode = super.hashCode(); - hashCode += prime * Boolean.valueOf(isExplicitlySetConstant()).hashCode(); - return hashCode; - } - - /** - * In SBML prior to Level 3 it was possible to explicitly state that a local - * parameter represents a constant {@link Quantity}. However, per - * definition, each local parameter has always been constant no matter if - * its XML representation contains the constant attribute or - * not. Hence, this attribute could set to true only. This - * method checks if for this {@link LocalParameter} an explicit - * constant flag has been set. - * - * @return the isExplicitlySetConstant true if this - * {@link LocalParameter} contains an explicit constant - * flag, false otherwise. - */ - public boolean isExplicitlySetConstant() { - return isExplicitlySetConstant; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (attributeName.equals("value")) { - this.setValue(StringTools.parseSBMLDouble(value)); - return true; - } else if (attributeName.equals("units")) { - this.setUnits(value); - return true; - } else if ((getLevel() < 3) && attributeName.equals("constant") - && value.equals("true")) - { - isExplicitlySetConstant = true; - // do nothing because this is always constant. - return true; - } - - return isAttributeRead; - } - - /** - * This method allows users to explicitly manipulate the - * constant attribute of this {@link LocalParameter}. This - * attribute can set to true only. Therefore, this method does - * just decide whether or not the constant attribute should - * occur in generated SBML code when serializing this {@link LocalParameter} - * . Since this object always represents a constant {@link Quantity} this - * method does only decide whether or not the resulting SBML code should - * contain the attribute/value pair constant = true, it does - * not decide on whether or not this object should be constant. - * - * @param isExplicitlySetConstant - * the isExplicitlySetConstant to set - * @deprecated Since SBML Level 3 it is no longer possible to explicitly set - * a {@link LocalParameter} to constant = true - * because {@link LocalParameter} instances always represent - * constant a {@link Quantity}. - */ - @Deprecated - public void setExplicitlyConstant(boolean isExplicitlySetConstant) { - if(this.isExplicitlySetConstant != isExplicitlySetConstant){ - Boolean oldValue = this.isExplicitlySetConstant; - this.isExplicitlySetConstant = Boolean.valueOf(isExplicitlySetConstant); - firePropertyChange(TreeNodeChangeEvent.isExplicitlySetConstant, - oldValue, this.isExplicitlySetConstant); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetValue()) { - attributes.put("value", StringTools.toString(Locale.ENGLISH, - getValue())); - } - if (isSetUnits()) { - attributes.put("units", getUnits()); - } - // Put back the constant attribute if it was set in the original file. - // The methods #readAttribute take care of doing all the needed tests. - if (isExplicitlySetConstant) { - attributes.put("constant", "true"); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/MathContainer.java b/IPK_lib/src/org/sbml/jsbml/MathContainer.java deleted file mode 100644 index 7dfda84f6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/MathContainer.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * $Id: MathContainer.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/MathContainer.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.text.parser.ParseException; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * Base interface for all the SBML components which contain MathML nodes. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public interface MathContainer extends SBaseWithDerivedUnit { - - /** - * Converts this {@link MathContainer}'s internal {@link ASTNode} to a - * C-like {@link String} according to the SBML Level 1 specifications and - * returns it. - * - * @return the math {@link ASTNode} of this object as a String. It returns - * the empty String if the math {@link ASTNode} is not set. - * @deprecated As this is part of SBML Level 1, it is strongly recommended - * not to work with the {@link String} representation of a - * formula, but to deal with a more flexible {@link ASTNode}. - * @see #getMath() - */ - @Deprecated - public String getFormula(); - - /** - * If {@link #isSetMath()} returns true, this method returns the - * {@link ASTNode} belonging to this {@link MathContainer}. - * - * @return the math {@link ASTNode} of this object. It return null if the - * math {@link ASTNode} is not set. - */ - public ASTNode getMath(); - - /** - * If {@link #isSetMath()} returns true, this method returns the - * corresponding MathML {@link String}, otherwise an empty {@link String} - * will be returned. - * - * @return the MathML representation of this {@link MathContainer}'s math - * element. - */ - public String getMathMLString(); - - /** - * Checks if an {@link ASTNode} has been set for this {@link MathContainer}. - * - * @return true if the math {@link ASTNode} of this object is not null. - */ - public boolean isSetMath(); - - /** - * Sets the mathematical expression of this {@link MathContainer} instance - * to the given formula. This method parses the given {@link String} and - * stores the result in an {@link ASTNode} object. - * - * @param formula - * a C-like {@link String} according to the definition in the - * SBML Level 1 specifications. - * @deprecated As this is part of SBML Level 1, it is strongly recommended - * not to work with the {@link String} representation of a - * formula, but to deal with a more flexible {@link ASTNode}. - * Please use {@link ASTNode#parseFormula(String)} to create an - * {@link ASTNode} object from your formula {@link String}. - * @throws ParseException - * If the given formula is invalid or cannot be parsed properly. - * @throws PropertyNotAvailableException - * When trying to set this attribute and the Level is set to a - * value other than 1, this will throw an error. - */ - @Deprecated - public void setFormula(String formula) throws ParseException; - - /** - * Sets the math {@link ASTNode} of this {@link MathContainer} to the given - * value. - * - * @param math - * an abstract syntax tree. - */ - public void setMath(ASTNode math); - - /** - * @deprecated use {@link #unsetMath()} - */ - @Deprecated - public void unsetFormula(); - - /** - * Sets the current {@link ASTNode} math element of this - * {@link MathContainer} to null and notifies all - * {@link TreeNodeChangeListener}s assigned to this object about this - * change. - */ - public void unsetMath(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Model.java b/IPK_lib/src/org/sbml/jsbml/Model.java deleted file mode 100644 index cc1742ed8..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Model.java +++ /dev/null @@ -1,4954 +0,0 @@ -/* - * $Id: Model.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ $URL: - * https://jsbml - * .svn.sourceforge.net/svnroot/jsbml/trunk/src/org/sbml/jsbml/Model.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit for - * the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: 1. The - * University of Tuebingen, Germany 2. EMBL European Bioinformatics Institute - * (EBML-EBI), Hinxton, UK 3. The California Institute of Technology, Pasadena, - * CA, USA - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation. A copy of the license agreement is provided in the file - * named "LICENSE.txt" included with this software distribution and also - * available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.filters.AssignmentVariableFilter; -import org.sbml.jsbml.util.filters.BoundaryConditionFilter; -import org.sbml.jsbml.util.filters.IdenticalUnitDefinitionFilter; -import org.sbml.jsbml.util.filters.NameFilter; - -/** - *

    - * JSBML implementation of SBML's {@link Model} construct. - *

    - *

    - * In an SBML model definition, a single object of class {@link Model} serves as - * the overall container for the lists of the various model components. All of - * the lists are optional, but if a given list container is present within the - * model, the list must not be empty; that is, it must have length one or more. - *

    - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1238 $ - */ -public class Model extends AbstractNamedSBase implements UniqueNamedSBase { - - /** - * Error message to indicate that an element could not be created. - */ - private static final String COULD_NOT_CREATE_ELEMENT_MSG = "Could not create %s because no %s have been defined yet."; - - /** - * A {@link Logger} for this class. - */ - private static final transient Logger logger = Logger.getLogger(Model.class); - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 5256379371231860049L; - /** - * Represents the 'areaUnits' XML attribute of a model element. - */ - private String areaUnitsID; - /** - * Represents the 'conversionFactor' XML attribute of a model element. - */ - private String conversionFactorID; - /** - * Represents the 'extentUnits' XML attribute of a model element. - */ - private String extentUnitsID; - /** - * Represents the 'lengthUnits' XML attribute of a model element. - */ - private String lengthUnitsID; - /** - * Represents the listOfCompartments subnode of a model element. - */ - private ListOf listOfCompartments; - /** - * Represents the listOfCompartmentTypes subnode of a model element. - * @deprecated only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - private ListOf listOfCompartmentTypes; - /** - * Represents the listOfConstraints subnode of a model element. - */ - private ListOf listOfConstraints; - - /** - * Represents the listOfEvents subnode of a model element. - */ - private ListOf listOfEvents; - - /** - * Represents the listOfFunctionDefinitions subnode of a model element. - */ - private ListOf listOfFunctionDefinitions; - - /** - * Represents the listOfInitialAssignments subnode of a model element. - */ - private ListOf listOfInitialAssignments; - - /** - * Represents the listOfParameters subnode of a model element. - */ - private ListOf listOfParameters; - - /** - * Represents the list of predefined UnitDefinitions for a given SBML level - * and version. - */ - private List listOfPredefinedUnitDefinitions; - - /** - * Represents the listOfReactions subnode of a model element. - */ - private ListOf listOfReactions; - - /** - * Represents the listOfRules subnode of a model element. - */ - private ListOf listOfRules; - - /** - * Represents the listOfSpecies subnode of a model element. - */ - private ListOf listOfSpecies; - - /** - * Represents the listOfSpeciesTypes subnode of a model element. - * @deprecated only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - private ListOf listOfSpeciesTypes; - - /** - * Represents the listOfUnitDefinitions subnode of a model element. - */ - private ListOf listOfUnitDefinitions; - - /** - * A mapping between the identifiers of {@link LocalParameter}s and the - * identifiers of containing {@link Reaction} objects. - */ - private Map> mapOfLocalParameters; - - /** - * For internal computation: a mapping between their identifiers and - * the {@link UniqueNamedSBase}s in {@link Model}s themself: - */ - private Map mapOfUniqueNamedSBases; - - /** - * A mapping between their identifiers and associated {@link UnitDefinition} objects. - */ - private Map mapOfUnitDefinitions; - - /** - * Represents the 'substanceUnits' XML attribute of a model element. - */ - private String substanceUnitsID; - - /** - * Represents the 'timeUnits' XML attribute of a model element. - */ - private String timeUnitsID; - - /** - * Represents the 'volumeUnits' XML attribute of a model element. - */ - private String volumeUnitsID; - - /** - * Creates a Model instance. By default, all the listOfxxx and xxxUnitsID are - * null. - */ - public Model() { - super(); - initDefaults(); - } - - /** - * Creates a Model instance. - * - * @param level - * @param version - */ - public Model(int level, int version) { - this(null, level, version); - initDefaults(); - } - - /** - * Creates a Model instance from a Model. - * - * @param model - */ - @SuppressWarnings("deprecation") - public Model(Model model) { - super(model); - initDefaults(); - if (model.isSetListOfFunctionDefinitions()) { - setListOfFunctionDefinitions((ListOf) model - .getListOfFunctionDefinitions().clone()); - } - if (model.isSetListOfUnitDefinitions()) { - setListOfUnitDefinitions((ListOf) model - .getListOfUnitDefinitions().clone()); - } - if (model.isSetListOfCompartmentTypes()) { - setListOfCompartmentTypes((ListOf) model - .getListOfCompartmentTypes().clone()); - } - if (model.isSetListOfSpeciesTypes()) { - setListOfSpeciesTypes((ListOf) model.getListOfSpeciesTypes() - .clone()); - } - if (model.isSetListOfCompartments()) { - setListOfCompartments((ListOf) model.getListOfCompartments() - .clone()); - } - if (model.isSetListOfSpecies()) { - setListOfSpecies((ListOf) model.getListOfSpecies().clone()); - } - if (model.isSetListOfParameters()) { - setListOfParameters((ListOf) model.getListOfParameters() - .clone()); - } - if (model.isSetListOfInitialAssignments()) { - setListOfInitialAssignments((ListOf) model - .getListOfInitialAssignments().clone()); - } - if (model.isSetListOfRules()) { - setListOfRules((ListOf) model.getListOfRules().clone()); - } - if (model.isSetListOfConstraints()) { - setListOfConstraints((ListOf) model.getListOfConstraints() - .clone()); - } - if (model.isSetListOfReactions()) { - setListOfReactions((ListOf) model.getListOfReactions().clone()); - } - if (model.isSetListOfEvents()) { - setListOfEvents((ListOf) model.getListOfEvents().clone()); - } - } - - /** - * Creates a Model instance from an id. - * - * @param id - */ - public Model(String id) { - super(id); - initDefaults(); - } - - /** - * Creates a Model instance from an id, level and version. By default, all the - * listOfxxx and xxxUnitsID are null. - * - * @param id - * @param level - * @param version - */ - public Model(String id, int level, int version) { - super(id, level, version); - initDefaults(); - } - - /** - * Adds a Compartment instance to the listOfCompartments of this Model. - * - * @param compartment - * @return true if the {@link #listOfCompartments} was changed as - * a result of this call. - */ - public boolean addCompartment(Compartment compartment) { - return getListOfCompartments().add(compartment); - } - - /** - * Adds a CompartmentType instance to the listOfCompartmentTypes of this - * Model. - * - * @param compartmentType - * @return true if the {@link #listOfCompartmentTypes} was - * changed as a result of this call. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean addCompartmentType(CompartmentType compartmentType) { - return getListOfCompartmentTypes().add(compartmentType); - } - - /** - * Adds a {@link Constraint} instance to the listOfConstraints of this - * {@link Model}. - * - * @param constraint - * @return true if the {@link #listOfConstraints} was changed as - * a result of this call. - */ - public boolean addConstraint(Constraint constraint) { - return getListOfConstraints().add(constraint); - } - - /** - * Adds an {@link Event} instance to the listOfEvents of this Model. - * - * @param event - * @return true if the {@link #listOfEvents} was changed as a - * result of this call. - * @throws PropertyNotAvailableException - * for inappropriate Level/Version combinations. - */ - public boolean addEvent(Event event) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException("event", this); - } - return getListOfEvents().add(event); - } - - /** - * Adds a {@link FunctionDefinition} instance to the listOfFunctionDefinitions - * of this {@link Model}. - * - * @param functionDefinition - * @return true if the {@link #listOfFunctionDefinitions} was - * changed as a result of this call. - */ - public boolean addFunctionDefinition(FunctionDefinition functionDefinition) { - return getListOfFunctionDefinitions().add(functionDefinition); - } - - /** - * Adds an InitialAssignment instance to the listOfInitialAssignments of this - * Model. - * - * @param initialAssignment - * @return true if the {@link #listOfInitialAssignments} was - * changed as a result of this call. - */ - public boolean addInitialAssignment(InitialAssignment initialAssignment) { - return getListOfInitialAssignments().add(initialAssignment); - } - - /** - * Adds a Parameter instance to the listOfParameters of this Model. - * - * @param parameter - * @return true if the {@link #listOfParameters} was changed as a - * result of this call. - */ - public boolean addParameter(Parameter parameter) { - return getListOfParameters().add(parameter); - } - - /** - * Adds all the possible unit kinds as {@link UnitDefinition}, so that the - * method {@link Model#getUnitDefinition(String)} would be able to return a - * valid {@link UnitDefinition} even if one of these kinds is passed as - * parameter. - * - */ - private void addPredefinedUnits() { - - List oldValue = new ArrayList( - this.listOfPredefinedUnitDefinitions); - - if ((getLevel() == -1) || (getVersion() == -1)) { - return; - } - - // ampere farad joule lux radian volt - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "ampere", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "farad", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "joule", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit("lux", - getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "radian", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "volt", getLevel(), getVersion())); - - // avogadro gram katal metre second watt - if (getLevel() >= 3) { - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "avogadro", getLevel(), getVersion())); - } - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "gram", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "katal", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "metre", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "second", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "watt", getLevel(), getVersion())); - - // becquerel gray kelvin mole siemens weber - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "becquerel", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "gray", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "kelvin", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "mole", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "siemens", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "weber", getLevel(), getVersion())); - - // candela henry kilogram newton sievert - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "candela", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "henry", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "kilogram", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "newton", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "sievert", getLevel(), getVersion())); - - // coulomb hertz litre ohm steradian - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "coulomb", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "hertz", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "litre", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit("ohm", - getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "steradian", getLevel(), getVersion())); - - // dimensionless item lumen pascal tesla - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "dimensionless", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "item", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "lumen", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "pascal", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "tesla", getLevel(), getVersion())); - - // meter liter celsius - if (getLevel() == 1) { - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "meter", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "liter", getLevel(), getVersion())); - listOfPredefinedUnitDefinitions.add(UnitDefinition.getPredefinedUnit( - "celsius", getLevel(), getVersion())); - } - this.firePropertyChange(TreeNodeChangeEvent.units, oldValue, - listOfPredefinedUnitDefinitions); - } - - /** - * Adds a Reaction instance to the listOfReactions of this Model. - * - * @param reaction - * @return true if the {@link #listOfReactions} was changed as a - * result of this call. - */ - public boolean addReaction(Reaction reaction) { - return getListOfReactions().add(reaction); - } - - /** - * Adds a Rule instance to the listOfRules of this Model. - * - * @param rule - * @return true if the {@link #listOfRules} was changed as a - * result of this call. - */ - public boolean addRule(Rule rule) { - return getListOfRules().add(rule); - } - - /** - * Adds a Species instance to the listOfSpecies of this Model. - * - * @param spec - * @return true if the {@link #listOfSpecies} was changed as a - * result of this call. - */ - public boolean addSpecies(Species spec) { - return getListOfSpecies().add(spec); - } - - /** - * Adds a SpeciesType instance to the listOfSpeciesTypes of this Model. - * - * @param speciesType - * @return true if the {@link #listOfSpeciesTypes} was changed as - * a result of this call. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean addSpeciesType(SpeciesType speciesType) { - return getListOfSpeciesTypes().add(speciesType); - } - - /** - * Adds an UnitDefinition instance to the listOfUnitDefinitions of this Model. - * - * @param unitDefinition - * @return true if the {@link #listOfUnitDefinitions} was changed - * as a result of this call. - */ - public boolean addUnitDefinition(UnitDefinition unitDefinition) { - return getListOfUnitDefinitions().add(unitDefinition); - } - - /** - * Checks whether an identical {@link UnitDefinition} like the given - * {@link UnitDefinition} is already in this {@link Model}'s - * {@link #listOfUnitDefinitions}. If yes, the identifier of the identical - * {@link UnitDefinition} will be returned. Otherwise, the given unit is added - * to the {@link #listOfUnitDefinitions} and its identifier will be returned. - * In any case, this method returns the identifier of a {@link UnitDefinition} - * that is part of this {@link Model} at least after calling this method. - * - * @param units - * The unit to be checked and added if no identical - * {@link UnitDefinition} can be found. - * @return - */ - public String addUnitDefinitionOrReturnIdenticalUnit(UnitDefinition units) { - boolean contains = false; - for (UnitDefinition ud : getListOfUnitDefinitions()) { - if (UnitDefinition.areIdentical(ud, units)) { - units = ud; - contains = true; - break; - } - } - if (!contains) { - addUnitDefinition(units); - } - return units.getId(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#clone() - */ - public Model clone() { - return new Model(this); - } - - /** - * Returns true if this model contains a reference to a {@link Compartment} - * with the given identifier. - * - * @param id - * @return true if this model contains a reference to a {@link Compartment} - * with the given identifier. - */ - public boolean containsCompartment(String id) { - return getCompartment(id) != null; - } - - /** - * Returns true if this model contains a reference to a - * {@link FunctionDefinition} with the given identifier. - * - * @param id - * @return true if this model contains a reference to a - * {@link FunctionDefinition} with the given identifier. - */ - public boolean containsFunctionDefinition(String id) { - return getFunctionDefinition(id) != null; - } - - /** - * Returns true if this model contains a reference to a {@link Parameter} with - * the given identifier. - * - * @param id - * @return true if this model contains a reference to a {@link Parameter} with - * the given identifier. - */ - public boolean containsParameter(String id) { - return getParameter(id) != null; - } - - /** - * Returns true if this {@link Model} contains a reference to the given - * {@link Quantity}. - * - * @param quantity - * @return true if this {@link Model} contains a reference to the given - * {@link Quantity}. - */ - public boolean containsQuantity(Quantity quantity) { - Model model = quantity.getModel(); - if (!quantity.isSetId() || (model == null) || (this != model)) { - return false; - } - return findQuantity(quantity.getId()) != null; - } - - /** - * Returns true if this {@link Model} contains a reference to the given - * {@link Species}. - * - * @param id - * @return true if this {@link Model} contains a reference to the given - * {@link Species}. - */ - public boolean containsSpecies(String id) { - return getSpecies(id) != null; - } - - /** - * Returns true if this {@link Model} contains a reference to the given - * {@link UniqueNamedSBase}. - * - * @param units - * @return true if this {@link Model} contains a reference to the given - * {@link UniqueNamedSBase}. - */ - public boolean containsUniqueNamedSBase(String id) { - return mapOfUniqueNamedSBases.containsKey(id); - } - - /** - * Returns true if this {@link Model} contains a reference to the given - * {@link UnitDefinition}. - * - * @param units - * @return true if this {@link Model} contains a reference to the given - * {@link UnitDefinition}. - */ - public boolean containsUnitDefinition(String units) { - return getUnitDefinition(units) != null; - } - - /** - * Creates a new {@link AlgebraicRule} inside this {@link Model} and returns - * it. - *

    - * - * @return the {@link AlgebraicRule} object created - *

    - * @see #addRule(Rule r) - */ - public AlgebraicRule createAlgebraicRule() { - AlgebraicRule rule = new AlgebraicRule(getLevel(), getVersion()); - addRule(rule); - return rule; - } - - /** - * Creates a new {@link AssignmentRule} inside this {@link Model} and returns - * it. - *

    - * - * @return the {@link AssignmentRule} object created - *

    - * @see #addRule(Rule r) - */ - public AssignmentRule createAssignmentRule() { - AssignmentRule rule = new AssignmentRule(getLevel(), getVersion()); - addRule(rule); - return rule; - } - - /** - * Creates a new {@link Compartment} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Compartment} object created - *

    - * @see #addCompartment(Compartment c) - */ - public Compartment createCompartment() { - return createCompartment(null); - } - - /** - * Creates a new {@link Compartment} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link Compartment} object created - */ - public Compartment createCompartment(String id) { - Compartment compartment = new Compartment(id, getLevel(), getVersion()); - addCompartment(compartment); - return compartment; - } - - /** - * Creates a new {@link CompartmentType} inside this {@link Model} and returns - * it. - *

    - * - * @return the {@link CompartmentType} object created - *

    - * @see #addCompartmentType(CompartmentType ct) - * @deprecated {@link CompartmentType}s should no longer be used, because this - * data structure is only valid in SBML Level 2 for Versions 2 - * through 4. - */ - @Deprecated - public CompartmentType createCompartmentType() { - return createCompartmentType(null); - } - - /** - * Creates a new {@link CompartmentType} inside this {@link Model} and returns - * it. - * - * @param id - * the id of the new element to create - * @return the {@link CompartmentType} object created - * @deprecated {@link CompartmentType}s should no longer be used, because this - * data structure is only valid in SBML Level 2 for Versions 2 - * through 4. - */ - @Deprecated - public CompartmentType createCompartmentType(String id) { - CompartmentType compartmentType = new CompartmentType(id, getLevel(), - getVersion()); - addCompartmentType(compartmentType); - - return compartmentType; - } - - /** - * Creates a new {@link Constraint} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Constraint} object created - *

    - * @see #addConstraint(Constraint c) - */ - public Constraint createConstraint() { - Constraint constraint = new Constraint(getLevel(), getVersion()); - addConstraint(constraint); - - return constraint; - } - - /** - * Creates a new {@link Delay} inside the last {@link Event} object created in - * this {@link Model}, and returns a pointer to it. - *

    - * The mechanism by which the last {@link Event} object in this model was - * created is not significant. It could have been created in a variety of - * ways, for example by using createEvent(). If no {@link Event} object exists - * in this {@link Model} object, a new {@link Delay} is not created - * and NULL is returned instead. - *

    - * - * @return the {@link Delay} object created - */ - public Delay createDelay() { - return getLastElementOf(getListOfEvents()).createDelay(); - } - - /** - * Creates a new {@link Event} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Event} object created - */ - public Event createEvent() { - return createEvent(null); - } - - /** - * Creates a new {@link Event} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link Event} object created - */ - public Event createEvent(String id) { - Event event = new Event(id, getLevel(), getVersion()); - addEvent(event); - return event; - } - - /** - * Creates a new {@link EventAssignment} inside the last {@link Event} object - * created in this {@link Model}, and returns a pointer to it. - *

    - * The mechanism by which the last {@link Event} object in this model was - * created is not significant. It could have been created in a variety of - * ways, for example by using createEvent(). If no {@link Event} object exists - * in this {@link Model} object, a new {@link EventAssignment} is not - * created and NULL is returned instead. - *

    - * - * @return the {@link EventAssignment} object created - */ - public EventAssignment createEventAssignment() { - - int numEvent = getNumEvents(); - Event lastEvent = null; - - if (numEvent == 0) { - return null; - } else { - lastEvent = getEvent(numEvent - 1); - } - - EventAssignment eventAssgnt = new EventAssignment(getLevel(), getVersion()); - lastEvent.addEventAssignment(eventAssgnt); - - return eventAssgnt; - } - - /** - * Creates a new {@link FunctionDefinition} inside this {@link Model} and - * returns it. - *

    - * - * @return the {@link FunctionDefinition} object created - *

    - * @see #addFunctionDefinition(FunctionDefinition fd) - */ - public FunctionDefinition createFunctionDefinition() { - return createFunctionDefinition(null); - } - - /** - * Creates a new {@link FunctionDefinition} inside this {@link Model} and - * returns it. - * - * @param id - * the id of the new element to create - * @return the {@link FunctionDefinition} object created - */ - public FunctionDefinition createFunctionDefinition(String id) { - FunctionDefinition functionDef = new FunctionDefinition(id, getLevel(), - getVersion()); - addFunctionDefinition(functionDef); - - return functionDef; - } - - /** - * Creates a new {@link InitialAssignment} inside this {@link Model} and - * returns it. - *

    - * - * @return the {@link InitialAssignment} object created - *

    - * @see #addInitialAssignment(InitialAssignment ia) - */ - public InitialAssignment createInitialAssignment() { - InitialAssignment initAssgmt = new InitialAssignment(getLevel(), - getVersion()); - addInitialAssignment(initAssgmt); - - return initAssgmt; - } - - /** - * Creates a new {@link KineticLaw} inside the last {@link Reaction} object - * created in this {@link Model}, and returns a pointer to it. - *

    - * The mechanism by which the last {@link Reaction} object was created and - * added to this {@link Model} is not significant. It could have been created - * in a variety of ways, for example using createReaction(). If a - * {@link Reaction} does not exist for this model, or a {@link Reaction} - * exists but already has a {@link KineticLaw}, a new {@link KineticLaw} is - * not created and NULL is returned instead. - *

    - * - * @return the {@link KineticLaw} object created - */ - public KineticLaw createKineticLaw() { - Reaction lastReaction = (Reaction) getLastElementOf(listOfReactions); - - if (lastReaction == null) { - logger.warn(String.format(COULD_NOT_CREATE_ELEMENT_MSG, "KineticLaw", - "reactions")); - return null; - } - - KineticLaw kineticLaw = new KineticLaw(getLevel(), getVersion()); - lastReaction.setKineticLaw(kineticLaw); - - return kineticLaw; - } - - /** - * Creates a new local {@link LocalParameter} inside the {@link KineticLaw} - * object of the last {@link Reaction} created inside this {@link Model}, and - * returns a pointer to it. - *

    - * The last {@link KineticLaw} object in this {@link Model} could have been - * created in a variety of ways. For example, it could have been added using - * createKineticLaw(), or it could be the result of using - * Reaction.createKineticLaw() on the {@link Reaction} object created by a - * createReaction(). If a {@link Reaction} does not exist for this model, or - * the last {@link Reaction} does not contain a {@link KineticLaw} object, a - * new {@link LocalParameter} is not created and NULL is returned - * instead. - *

    - * - * @return the {@link LocalParameter} object created - */ - public LocalParameter createKineticLawParameter() { - return createKineticParameter(null); - } - - /** - * Creates a new local {@link LocalParameter} inside the {@link KineticLaw} - * object of the last {@link Reaction} created inside this {@link Model}, and - * returns a pointer to it. - * - * @param id - * the id of the new element to create - * @return the {@link LocalParameter} object created - */ - public LocalParameter createKineticParameter(String id) { - Reaction lastReaction = (Reaction) getLastElementOf(listOfReactions); - KineticLaw lastKineticLaw = null; - - if (lastReaction == null) { - logger.warn(String.format(COULD_NOT_CREATE_ELEMENT_MSG, - "LocalParameter for KineticLaw", "reactions")); - return null; - } else { - lastKineticLaw = lastReaction.getKineticLaw(); - if (lastKineticLaw == null) { - return null; - } - } - - LocalParameter parameter = new LocalParameter(id, getLevel(), getVersion()); - lastKineticLaw.addLocalParameter(parameter); - - return parameter; - } - - /** - * Creates a new {@link ModifierSpeciesReference} object for a modifier - * species inside the last {@link Reaction} object in this {@link Model}, and - * returns a pointer to it. - *

    - * The mechanism by which the last {@link Reaction} object was created and - * added to this {@link Model} is not significant. It could have been created - * in a variety of ways, for example using createReaction(). If a - * {@link Reaction} does not exist for this model, a new - * {@link ModifierSpeciesReference} is not created and NULL is - * returned instead. - *

    - * - * @return the {@link SpeciesReference} object created - */ - public ModifierSpeciesReference createModifier() { - return createModifier(null); - } - - /** - * Creates a new {@link ModifierSpeciesReference} with the specified 'id'. - * - * @param id - * the id of the new element to create - * @return the {@link SpeciesReference} object created - */ - public ModifierSpeciesReference createModifier(String id) { - Reaction lastReaction = (Reaction) getLastElementOf(listOfReactions); - - if (lastReaction == null) { return null; } - - ModifierSpeciesReference modifier = lastReaction.createModifier(id); - - return modifier; - } - - /** - * Creates a new {@link Parameter} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Parameter} object created - *

    - * @see #addParameter(Parameter p) - */ - public Parameter createParameter() { - return createParameter(null); - } - - /** - * Creates a new {@link Parameter}. - * - * @param id - * the id of the new element to create - * @return the {@link Parameter} object created - */ - public Parameter createParameter(String id) { - Parameter parameter = new Parameter(id, getLevel(), getVersion()); - addParameter(parameter); - return parameter; - } - - /** - * Creates a new {@link SpeciesReference} object for a product inside the last - * {@link Reaction} object in this {@link Model}, and returns a pointer to it. - *

    - * The mechanism by which the last {@link Reaction} object was created and - * added to this {@link Model} is not significant. It could have been created - * in a variety of ways, for example using createReaction(). If a - * {@link Reaction} does not exist for this model, a new - * {@link SpeciesReference} is not created and NULL is returned - * instead. - *

    - * - * @return the {@link SpeciesReference} object created - */ - public SpeciesReference createProduct() { - return createProduct(null); - } - - /** - * Creates an instance of {@link SpeciesReference} and adds it to the last - * {@link Reaction} element that has been added to this {@link Model}. - * - * @param id - * @return - */ - public SpeciesReference createProduct(String id) { - Reaction lastReaction = (Reaction) getLastElementOf(listOfReactions); - - if (lastReaction == null) { - logger.warn(String.format(COULD_NOT_CREATE_ELEMENT_MSG, "Product", - "reactions")); - return null; - } - - SpeciesReference product = lastReaction.createProduct(id); - - return product; - } - - /** - * Creates a new {@link RateRule} inside this {@link Model} and returns it. - *

    - * - * @return the {@link RateRule} object created - *

    - * @see #addRule(Rule r) - */ - public RateRule createRateRule() { - RateRule rule = new RateRule(getLevel(), getVersion()); - addRule(rule); - - return rule; - } - - /** - * Creates a new {@link SpeciesReference} object for a reactant inside the - * last {@link Reaction} object in this {@link Model}, and returns a pointer - * to it. - *

    - * The mechanism by which the last {@link Reaction} object was created and - * added to this {@link Model} is not significant. It could have been created - * in a variety of ways, for example using createReaction(). If a - * {@link Reaction} does not exist for this model, a new - * {@link SpeciesReference} is not created and NULL is returned - * instead. - *

    - * - * @return the {@link SpeciesReference} object created - */ - public SpeciesReference createReactant() { - return createReactant(null); - } - - /** - * Creates a new {@link SpeciesReference} object, with the specified 'id', for - * a reactant inside the last {@link Reaction} object in this {@link Model}, - * and returns a pointer to it. - * - * @param id - * the id of the new element to create - * @return the {@link SpeciesReference} object created. - */ - public SpeciesReference createReactant(String id) { - Reaction lastReaction = (Reaction) getLastElementOf(listOfReactions); - if (lastReaction == null) { - logger.warn(String.format(COULD_NOT_CREATE_ELEMENT_MSG, "Reactant", - "reactions")); - return null; - } - SpeciesReference reactant = lastReaction.createReactant(id); - - return reactant; - } - - /** - * Creates a new {@link Reaction} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Reaction} object created - *

    - * @see #addReaction(Reaction r) - */ - public Reaction createReaction() { - return createReaction(null); - } - - /** - * Creates a new {@link Reaction} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link Reaction} object created - */ - public Reaction createReaction(String id) { - Reaction reaction = new Reaction(id, getLevel(), getVersion()); - addReaction(reaction); - - return reaction; - } - - /** - * Creates a new {@link Species} inside this {@link Model} and returns it. - *

    - * - * @return the {@link Species} object created - *

    - * @see #addSpecies(Species s) - */ - public Species createSpecies() { - return createSpecies(null); - } - - /** - * Creates a new {@link Species} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link Species} object created - */ - public Species createSpecies(String id) { - Species species = new Species(id, getLevel(), getVersion()); - addSpecies(species); - return species; - } - - /** - * Creates a new {@link Species} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @param c - * the Compartment of the new {@link Species} - * @return the {@link Species} object created - */ - public Species createSpecies(String id, Compartment c) { - Species s = createSpecies(id); - s.setCompartment(c); - return s; - } - - /** - * Creates a new {@link Species} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @param name - * the name of the new element to create - * @param c - * the Compartment of the new {@link Species} - * @return the {@link Species} object created - */ - public Species createSpecies(String id, String name, Compartment c) { - Species s = createSpecies(id, c); - s.setName(name); - return s; - } - - /** - * Creates a new {@link SpeciesType} inside this {@link Model} and returns it. - *

    - * - * @return the {@link SpeciesType} object created - *

    - * @see #addSpeciesType(SpeciesType st) - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType createSpeciesType() { - return createSpeciesType(null); - } - - /** - * Creates a new {@link SpeciesType} inside this {@link Model} and returns it. - * - * @param id - * the id of the new element to create - * @return the {@link SpeciesType} object created - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType createSpeciesType(String id) { - SpeciesType speciesType = new SpeciesType(id, getLevel(), getVersion()); - addSpeciesType(speciesType); - - return speciesType; - } - - /** - * Creates a new {@link Trigger} inside the last {@link Event} object created - * in this {@link Model}, and returns a pointer to it. - *

    - * The mechanism by which the last {@link Event} object in this model was - * created is not significant. It could have been created in a variety of - * ways, for example by using createEvent(). If no {@link Event} object exists - * in this {@link Model} object, a new {@link Trigger} is not created - * and NULL is returned instead. - *

    - * - * @return the {@link Trigger} object created - */ - public Trigger createTrigger() { - return getLastElementOf(getListOfEvents()).createTrigger(); - } - - /** - * Creates a new {@link Unit} object within the last {@link UnitDefinition} - * object created in this model and returns a pointer to it. - *

    - * The mechanism by which the {@link UnitDefinition} was created is not - * significant. If a {@link UnitDefinition} object does not exist in this - * model, a new {@link Unit} is not created and NULL is returned - * instead. - *

    - * - * @return the {@link Unit} object created - *

    - * @see #addUnitDefinition(UnitDefinition ud) - */ - public Unit createUnit() { - return createUnit(null); - } - - /** - * Creates a new {@link Unit} object within the last {@link UnitDefinition} - * object created in this model and returns a pointer to it. - * - * @param kind - * the kind of the new unit. - * @return the {@link Unit} object created - */ - public Unit createUnit(Unit.Kind kind) { - int numUnitDef = getNumUnitDefinitions(); - UnitDefinition lastUnitDef = null; - - if (numUnitDef == 0) { - return null; - } else { - lastUnitDef = getUnitDefinition(numUnitDef - 1); - } - - Unit unit = lastUnitDef.createUnit(kind); - - return unit; - } - - /** - * Creates a new {@link UnitDefinition} inside this {@link Model} and returns - * it. - *

    - * - * @return the {@link UnitDefinition} object created - *

    - * @see #addUnitDefinition(UnitDefinition ud) - */ - public UnitDefinition createUnitDefinition() { - return createUnitDefinition(null); - } - - /** - * Creates a new {@link UnitDefinition} inside this {@link Model} and returns - * it. - * - * @param id - * the id of the new element to create - * @return the {@link UnitDefinition} object created - */ - public UnitDefinition createUnitDefinition(String id) { - UnitDefinition unitDefinition = new UnitDefinition(id, getLevel(), - getVersion()); - addUnitDefinition(unitDefinition); - - return unitDefinition; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Model m = (Model) object; - equals &= m.isSetTimeUnits() == isSetTimeUnits(); - if (equals && isSetTimeUnits()) { - equals &= getTimeUnits().equals(m.getTimeUnits()); - } - equals &= m.isSetAreaUnits() == isSetAreaUnits(); - if (equals && isSetAreaUnits()) { - equals &= getAreaUnits().equals(m.getAreaUnits()); - } - equals &= m.isSetConversionFactor() == isSetConversionFactor(); - if (equals && isSetConversionFactor()) { - equals &= getConversionFactor().equals(m.getConversionFactor()); - } - equals &= m.isSetExtentUnits() == isSetExtentUnits(); - if (equals && isSetExtentUnits()) { - equals &= getExtentUnits().equals(m.getExtentUnits()); - } - equals &= m.isSetLengthUnits() == isSetLengthUnits(); - if (equals && isSetLengthUnits()) { - equals &= getLengthUnits().equals(m.getLengthUnits()); - } - equals &= m.isSetSubstanceUnits() == isSetSubstanceUnits(); - if (equals && m.isSetSubstanceUnits()) { - equals &= getSubstanceUnits().equals(m.getSubstanceUnits()); - } - equals &= m.isSetVolumeUnits() == isSetVolumeUnits(); - if (equals && isSetVolumeUnits()) { - equals &= getVolumeUnits().equals(m.getVolumeUnits()); - } - } - return equals; - } - - /** - * Returns a {@link CallableSBase} element of the {@link Model} that has the - * given 'id' as identifier or null if no element is found. - * - * @param id - * an identifier indicating an element of the {@link Model}. - * @return a {@link CallableSBase} element of the {@link Model} that has the - * given 'id' as id or null if no element is found. - */ - public CallableSBase findCallableSBase(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof CallableSBase)) { - return (CallableSBase) found; - } - return null; - } - - /** - * Searches the first {@link UnitDefinition} within this {@link Model}'s - * {@link #listOfUnitDefinitions} that - * is identical to the given {@link UnitDefinition}. If no element can be - * found that satisfies the method - * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)}, - * null will be returned. - * - * @param unitDefinition - * @return A {@link UnitDefinition} object that is already part of this - * {@link Model}'s {@link #listOfUnitDefinitions} and satisfies the - * condition of - * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)} - * in comparison to the given {@link UnitDefinition}, or - * null if no such element can be found. - */ - public UnitDefinition findIdentical(UnitDefinition unitDefinition) { - return getListOfUnitDefinitions().firstHit(new IdenticalUnitDefinitionFilter(unitDefinition)); - } - - /** - * Finds all instances of {@link LocalParameter} in this {@link Model} and - * adds them to a {@link List}. - * - * @param id - * @return A {@link List} of all {@link LocalParameter} instances with the - * given name or identifier. This {@link List} can be empty, but never - * null. - */ - public List findLocalParameters(String id) { - List list = new LinkedList(); - SortedSet rList = findReactionsForLocalParameter(id); - if ((rList == null) || rList.isEmpty()) { - return list; - } - LocalParameter p; - Reaction r; - for (String rId : rList) { - r = getReaction(rId); - // This must always be true, otherwise there is an error elsewhere: - if (r.isSetKineticLaw()) { - p = r.getKineticLaw().getLocalParameter(id); - if (p != null) { - list.add(p); - } - } - } - return list; - } - - /** - * Returns the {@link ModifierSpeciesReference} with all {@link Reaction}s - * of this {@link Model} that has 'id' as id. - * - * @param id - * the identifier of the {@link ModifierSpeciesReference} of interest. - * Note that this is not the identifier of the {@link Species} instance - * referred to by the {@link ModifierSpeciesReference}. - * @return the {@link ModifierSpeciesReference} out of all {@link Reaction}s - * which has 'id' as id (or name depending on level and version). - * null if it doesn't exist. - */ - public ModifierSpeciesReference findModifierSpeciesReference(String id) { - SimpleSpeciesReference ssr = findSimpleSpeciesReference(id); - if ((ssr != null) && (ssr instanceof ModifierSpeciesReference)) { - return (ModifierSpeciesReference) ssr; - } - return null; - } - - /** - * Returns a {@link NamedSBase} element of the model that has the given 'id' - * as id or null if no element is found. - * - * @param id - * an id indicating an element of the model. - * @return a {@link NamedSBase} element of the model that has the given 'id' - * as id or null if no element is found. - */ - public NamedSBase findNamedSBase(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof NamedSBase)) { - return (NamedSBase) found; - } - return null; - } - - /** - * Returns a {@link NamedSBaseWithDerivedUnit} element of the {@link Model} - * that has the given 'id' as id or null if no element is found. It first - * tries to find a {@link CallableSBase} with the given identifier and, if - * this is not successful, it searches for an instance of {@link Event} with - * the given id. - * - * @param id - * an id indicating an element of the {@link Model}. - * @return a {@link NamedSBaseWithDerivedUnit} element of the {@link Model} - * that has the given 'id' as id or null if no element is found. - * @see #findCallableSBase(String) - */ - public NamedSBaseWithDerivedUnit findNamedSBaseWithDerivedUnit(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof NamedSBaseWithDerivedUnit)) { - return (NamedSBaseWithDerivedUnit) found; - } - return null; - } - - /** - * Searches for an instance of {@link Quantity} within all of this - * {@link Model}'s components that has the given identifier or name attribute - * and returns it. There might be multiple instances of {@link LocalParameter} - * with the same identifier or name, each located in different - * {@link Reaction}s. In this case, the first match will be returned. Note - * that also global {@link Parameter} instances have a higher priority and are - * returned first. - * - * @param id - * @return the {@link Compartment}, {@link Species}, {@link SpeciesReference} - * or {@link Parameter}, or the first {@link LocalParameter} which has - * 'id' as id. - * @see #findLocalParameters(String) - */ - public Quantity findQuantity(String id) { - Quantity nsb = findVariable(id); - if (nsb == null) { - List list = findLocalParameters(id); - if (!list.isEmpty()) { - return list.get(0); - } - } - return nsb; - } - - /** - * Searches for an instance of {@link QuantityWithUnit} within all of this - * {@link Model}'s components that has the given identifier or name attribute - * and returns it. There might be multiple instances of {@link LocalParameter} - * with the same identifier or name, each located in different - * {@link Reaction}s. In this case, the first match will be returned. Note - * that also global {@link Parameter} instances have a higher priority and are - * returned first. - * - * @param idOrName - * @return - * @see #findLocalParameters(String) - */ - public QuantityWithUnit findQuantityWithUnit(String idOrName) { - QuantityWithUnit q = findSymbol(idOrName); - if (q == null) { - List list = findLocalParameters(idOrName); - if (!list.isEmpty()) { - return list.get(0); - } - } - return q; - } - - /** - * Returns a {@link SortedSet} of identifiers of all {@link Reaction} elements - * within - * this {@link Model} whose {@link KineticLaw}s contain a - * {@link LocalParameter} that has the given 'id' or null if no - * element cannot be found. - * - * @param id - * an id indicating an {@link LocalParameter} element of the - * {@link Model}. - * @return a {@link SortedSet} of the identifiers of all {@link Reaction} - * elements within this {@link Model} whose {@link KineticLaw} - * contains a {@link LocalParameter} that has the given 'id' as id - * or null if no such element with this 'id' can be - * found. - */ - public SortedSet findReactionsForLocalParameter(String id) { - return mapOfLocalParameters == null ? null : mapOfLocalParameters.get(id); - } - - /** - * Returns the {@link SimpleSpeciesReference} within all {@link Reaction}s of - * this {@link Model} that has 'id' as id. - * - * @param id - * the identifier of the {@link SimpleSpeciesReference} of interest. - * Note that this is not the identifier of the {@link Species} instance - * referred to by the {@link SimpleSpeciesReference}. - * @return the {@link SimpleSpeciesReference} out of all {@link Reaction}s - * which has 'id' as id (or name depending on level and version). - * null if it doesn't exist. - */ - public SimpleSpeciesReference findSimpleSpeciesReference(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof SimpleSpeciesReference)) { - return (SimpleSpeciesReference) found; - } - return null; - } - - /** - * Returns the {@link SpeciesReference} with all {@link Reaction}s - * of this {@link Model} that has 'id' as id. - * - * @param id - * the identifier of the {@link SpeciesReference} of interest. - * Note that this is not the identifier of the {@link Species} instance - * referred to by the {@link SpeciesReference}. - * @return the {@link SpeciesReference} out of all {@link Reaction}s - * which has 'id' as id (or name depending on level and version). - * null if it doesn't exist. - */ - public SpeciesReference findSpeciesReference(String id) { - SimpleSpeciesReference ssr = findSimpleSpeciesReference(id); - if ((ssr != null) && (ssr instanceof SpeciesReference)) { - return (SpeciesReference) ssr; - } - return null; - } - - /** - * Searches in the list of {@link Compartment}s, {@link Species}, and - * {@link Parameter}s for the element with the given identifier. - * - * @param id - * @return a {@link Symbol} element with the given identifier or null if there - * is no such element. - */ - public Symbol findSymbol(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Symbol)) { - return (Symbol) found; - } - return null; - } - - /** - * Returns a {@link UniqueNamedSBase} element that has the given 'id' within - * this {@link Model} or null if no such element can be found. - * - * @param id - * an id indicating an {@link UniqueNamedSBase} element of the - * {@link Model}. - * @return a {@link UniqueNamedSBase} element of the {@link Model} that has - * the given 'id' as id or null if no element with this - * 'id' can be found. - */ - public UniqueNamedSBase findUniqueNamedSBase(String id) { - return mapOfUniqueNamedSBases == null ? null : mapOfUniqueNamedSBases.get(id); - } - - /** - * Returns a {@link UnitDefinition} element that has the given 'id' within - * this {@link Model} or null if no such element can be found. - * - * @param id - * an id indicating an {@link UnitDefinition} element of the - * {@link Model}. - * @return a {@link UniqueNamedSBase} element of the {@link Model} that has - * the given 'id' as id or null if no such element with - * this 'id' can be found. - */ - public UnitDefinition findUnitDefinition(String id) { - return mapOfUnitDefinitions == null ? null : mapOfUnitDefinitions.get(id); - } - - /** - * Searches the {@link Variable} with the given identifier in this model. - * - * @param id - * The identifier of the {@link Variable} of interest. - * @return the {@link Compartment}, {@link Species}, {@link SpeciesReference}, - * or {@link Parameter}, which has 'variable' as id. - */ - public Variable findVariable(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Variable)) { - return (Variable) found; - } - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /** - * Returns the area units ID of this {@link Model}. - * - * @return the area units ID of this {@link Model}. Returns an empty - * {@link String} if it is not set. - */ - public String getAreaUnits() { - if (isSetAreaUnits()) { - return areaUnitsID; - } else if (getLevel() == 2) { - return UnitDefinition.AREA; - } - return ""; - } - - /** - * Returns the {@link UnitDefinition} instance which has the {@link #areaUnitsID} of - * this {@link Model} as id. - * - * @return the {@link UnitDefinition} instance which has the {@link #areaUnitsID} of - * this {@link Model} as id. null if it doesn't exist. - */ - public UnitDefinition getAreaUnitsInstance() { - return getUnitDefinition(getAreaUnits()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetListOfFunctionDefinitions()) { - if (pos == index) { - return getListOfFunctionDefinitions(); - } - pos++; - } - if (isSetListOfUnitDefinitions()) { - if (pos == index) { - return getListOfUnitDefinitions(); - } - pos++; - } - if (isSetListOfCompartmentTypes()) { - if (pos == index) { - return getListOfCompartmentTypes(); - } - pos++; - } - if (isSetListOfSpeciesTypes()) { - if (pos == index) { - return getListOfSpeciesTypes(); - } - pos++; - } - if (isSetListOfCompartments()) { - if (pos == index) { - return getListOfCompartments(); - } - pos++; - } - if (isSetListOfSpecies()) { - if (pos == index) { - return getListOfSpecies(); - } - pos++; - } - if (isSetListOfParameters()) { - if (pos == index) { - return getListOfParameters(); - } - pos++; - } - if (isSetListOfInitialAssignments()) { - if (pos == index) { - return getListOfInitialAssignments(); - } - pos++; - } - if (isSetListOfRules()) { - if (pos == index) { - return getListOfRules(); - } - pos++; - } - if (isSetListOfConstraints()) { - if (pos == index) { - return getListOfConstraints(); - } - pos++; - } - if (isSetListOfReactions()) { - if (pos == index) { - return getListOfReactions(); - } - pos++; - } - if (isSetListOfEvents()) { - if (pos == index) { - return getListOfEvents(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", index, - +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int children = super.getChildCount(); - if (isSetListOfFunctionDefinitions()) { - children++; - } - if (isSetListOfUnitDefinitions()) { - children++; - } - if (isSetListOfCompartmentTypes()) { - children++; - } - if (isSetListOfSpeciesTypes()) { - children++; - } - if (isSetListOfCompartments()) { - children++; - } - if (isSetListOfSpecies()) { - children++; - } - if (isSetListOfParameters()) { - children++; - } - if (isSetListOfInitialAssignments()) { - children++; - } - if (isSetListOfRules()) { - children++; - } - if (isSetListOfConstraints()) { - children++; - } - if (isSetListOfReactions()) { - children++; - } - if (isSetListOfEvents()) { - children++; - } - return children; - } - - /** - * Gets the nth {@link Compartment} instance of the listOfCompartments. - * - * @param n - * @return the nth {@link Compartment} instance of the listOfCompartments. - * Null if if the listOfCompartments is not set. - */ - public Compartment getCompartment(int n) { - return getListOfCompartments().get(n); - } - - /** - * Gets the {@link Compartment} of the listOfCompartments which has 'id' as - * id. - * - * @param id - * @return the {@link Compartment} of the listOfCompartments which has 'id' as - * id (or name depending on the version and level). Null if if the - * listOfCompartments is not set. - */ - public Compartment getCompartment(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Compartment)) { - return (Compartment) found; - } - return null; - } - - /** - * Returns the number of {@link Compartment}s of this {@link Model}. - * - * @return the number of {@link Compartment}s of this {@link Model}. - */ - public int getCompartmentCount() { - return isSetListOfCompartments() ? listOfCompartments.size() : 0; - } - - /** - * Gets the nth CompartmentType object in this Model. - * - * @param n - * index - * @return the nth CompartmentType of this Model. Returns null if there are no - * compartmentType defined or if the index n is too big or lower than - * zero. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public CompartmentType getCompartmentType(int n) { - return getListOfCompartmentTypes().get(n); - } - - /** - * Gets the {@link CompartmentType} with the given id. - * - * @param id - * @return the CompartmentType of the {@link #listOfCompartmentTypes} which has 'id' as - * id (or name depending on the level and version). Null if the - * {@link #listOfCompartmentTypes} is not set or the id is not found. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public CompartmentType getCompartmentType(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof CompartmentType)) { - return (CompartmentType) found; - } - return null; - } - - /** - * Returns the number of {@link CompartmentType}s of this {@link Model}. - * - * @return the number of {@link CompartmentType}s of this {@link Model}. - * @deprecated using {@link CompartmentType} is not recommended, because this - * data structure is only valid in SBML Level 2 for Versions 2 - * through 4. - */ - @Deprecated - public int getCompartmentTypeCount() { - return isSetListOfCompartmentTypes() ? listOfCompartmentTypes.size() : 0; - } - - /** - * Gets the nth Constraint object in this Model. - * - * @param n - * @return the nth Constraint of this Model. Returns null if there are no - * constraint defined or if the index n is too big or lower than zero. - */ - public Constraint getConstraint(int n) { - return getListOfConstraints().get(n); - } - - /** - * Returns the number of {@link Constraint}s of this {@link Model}. - * - * @return the number of {@link Constraint}s of this {@link Model}. - */ - public int getConstraintCount() { - return isSetListOfConstraints() ? listOfConstraints.size() : 0; - } - - /** - * Returns the conversionFactor ID of this {@link Model}. - * - * @return the conversionFactorID of this {@link Model}. Returns an empty - * {@link String} if it is not set. - */ - public String getConversionFactor() { - return isSetConversionFactor() ? conversionFactorID : ""; - } - - /** - * Returns the Parameter instance which has the conversionFactorID of this - * Model as id. - * - * @return the Parameter instance which has the conversionFactorID of this - * Model as id. Null if it doesn't exist - */ - public Parameter getConversionFactorInstance() { - return getParameter(this.conversionFactorID); - } - - /** - * Returns the number of {@link Delay}s of this {@link Model}. - * - * @return the number of {@link Delay}s of this {@link Model}. - */ - public int getDelayCount() { - int count = 0; - for (Event e : getListOfEvents()) { - if (e.isSetDelay()) { - count++; - } - } - return count; - } - - /** - * Gets the nth Event object in this Model. - * - * @param n - * @return the nth Event of this Model. Returns null if there are no event - * defined or if the index n is too big or lower than zero. - */ - public Event getEvent(int n) { - return getListOfEvents().get(n); - } - - /** - * Gets the {@link Event} which as the given id as id. - * - * @param id - * @return the {@link Event} of the {@link #listOfEvents} which has 'id' as id - * (or name depending on the level and version). Null if if the - * {@link #listOfEvents} is not set. - */ - public Event getEvent(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Event)) { - return (Event) found; - } - return null; - } - - /** - * Returns the number of {@link EventAssignment}s of this {@link Model}. - * - * @return return the number of {@link EventAssignment}s of this {@link Model}. - */ - public int getEventAssignmentCount() { - int count = 0; - for (Event e : getListOfEvents()) { - count += e.getEventAssignmentCount(); - } - return count; - } - - /** - * Returns the number of {@link Event}s of this {@link Model}. - * - * @return the number of {@link Event}s of this {@link Model}. - */ - public int getEventCount() { - return isSetListOfEvents() ? listOfEvents.size() : 0; - } - - /** - * Returns the extent units ID of this {@link Model}. - * - * @return the extent units ID of this {@link Model}. Returns an empty - * {@link String} if it is not set. - */ - public String getExtentUnits() { - return isSetExtentUnits() ? extentUnitsID : ""; - } - - /** - * Returns the {@link UnitDefinition} instance which has the extent units ID - * of this Model as id. - * - * @return the {@link UnitDefinition} instance which has the extent units ID - * of this Model as id. Null if it doesn't exist - */ - public UnitDefinition getExtentUnitsInstance() { - return getUnitDefinition(getExtentUnits()); - } - - /** - * Gets the nth {@link FunctionDefinition} instance of the - * listOfFunstionDefinitions. - * - * @param n - * @return the nth {@link FunctionDefinition} instance of the - * listOfFunstionDefinitions. Null if if the listOfFunctionDefinitions - * is not set. - */ - public FunctionDefinition getFunctionDefinition(int n) { - return getListOfFunctionDefinitions().get(n); - } - - /** - * Returns the {@link FunctionDefinition} of the {@link #listOfFunctionDefinitions} - * which has 'id' as id. - * - * @param id - * @return the {@link FunctionDefinition} of the {@link #listOfFunctionDefinitions} - * which has 'id' as id (or name depending on the level and version). - * Null if if the {@link #listOfFunctionDefinitions} is not set. - */ - public FunctionDefinition getFunctionDefinition(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof FunctionDefinition)) { - return (FunctionDefinition) found; - } - return null; - } - - /** - * Returns the number of {@link FunctionDefinition}s of this {@link Model}. - * - * @return the number of {@link FunctionDefinition}s of this {@link Model}. - */ - public int getFunctionDefinitionCount() { - return isSetListOfFunctionDefinitions() ? listOfFunctionDefinitions.size() - : 0; - } - - /** - * Gets the nth {@link InitialAssignment} object in this {@link Model}. - * - * @param n - * @return the nth {@link InitialAssignment} of this {@link Model}. Null if - * the listOfInitialAssignments is not set. - */ - public InitialAssignment getInitialAssignment(int n) { - return getListOfInitialAssignments().get(n); - } - - /** - * Returns the {@link InitialAssignment} of the - * {@link #listOfInitialAssignments} whose symbol attribute, - * i.e., whose {@link Variable} has the given variable as - * identifier. - * - * @param variable - * The identifier of a variable, for which a corresponding - * {@link InitialAssignment} is requested. - * @return the first {@link InitialAssignment} of the - * {@link #listOfInitialAssignments}, whose {@link Variable} has the - * variable as identifier (or name depending on the level - * and version). Null if it doesn't exist. - */ - public InitialAssignment getInitialAssignment(String variable) { - return getListOfInitialAssignments().firstHit( - new AssignmentVariableFilter(variable)); - } - - /** - * Returns the number of {@link InitialAssignment}s of this {@link Model}. - * - * @return the number of {@link InitialAssignment}s of this {@link Model}. - */ - public int getInitialAssignmentCount() { - return isSetListOfInitialAssignments() ? listOfInitialAssignments.size() - : 0; - } - - /** - * Returns the number of {@link KineticLaw}s of this {@link Model}. - * - * @return the number of {@link KineticLaw}s of this {@link Model}. - */ - public int getKineticLawCount() { - int count = 0; - for (Reaction r : getListOfReactions()) { - if (r.isSetKineticLaw()) { - count++; - } - } - return count; - } - - /** - * Returns the last element added in the given list. - * - * @return the last element added in the model, corresponding to the last - * element of the list of these elements, or null is no element exist - * for this type. - */ - private T getLastElementOf(ListOf listOf) { - // added casting and parenthesis because there was a compilation error - // when using the ant script - return ((listOf == null) || (listOf.size() == 0)) ? (T) null : (T) listOf - .getLast(); - } - - /** - * Returns the length units ID of this {@link Model}. - * - * @return the length units ID of this {@link Model}. Returns an empty - * {@link String} if it is not set. - */ - public String getLengthUnits() { - if (isSetLengthUnits()) { - return lengthUnitsID; - } else if (getLevel() == 2) { return UnitDefinition.LENGTH; } - return ""; - } - - /** - * Returns the length units of this {@link Model} as a {@link UnitDefinition}. - * - * @return the {@link UnitDefinition} instance which has the {@link #lengthUnitsID} of this - * {@link Model} as id. null if it doesn't exist. - */ - public UnitDefinition getLengthUnitsInstance() { - return getUnitDefinition(getLengthUnits()); - } - - /** - * Returns the listOfCompartments of this {@link Model}. - * - * @return the listOfCompartments of this {@link Model}. - */ - public ListOf getListOfCompartments() { - if (listOfCompartments == null) { - listOfCompartments = ListOf.newInstance(this, Compartment.class); - } - return listOfCompartments; - } - - /** - * Returns the listOfCompartmentTypes of this {@link Model}. - * - * @return the listOfCompartmentTypes of this {@link Model}. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public ListOf getListOfCompartmentTypes() { - if (listOfCompartmentTypes == null) { - listOfCompartmentTypes = ListOf.newInstance(this, CompartmentType.class); - } - return listOfCompartmentTypes; - } - - /** - * Returns the listOfConstraints of this {@link Model}. - * - * @return the listOfConstraints of this {@link Model}. set. - */ - public ListOf getListOfConstraints() { - if (listOfConstraints == null) { - listOfConstraints = ListOf.newInstance(this, Constraint.class); - } - return listOfConstraints; - } - - /** - * Returns the number of {@link ListOf}s of this {@link Model}. - * - * @return the number of {@link ListOf}s of this {@link Model}. - */ - public int getListOfCount() { - return getChildCount(); - } - - /** - * Returns the listOfEvents of this {@link Model}. - * - * @return the listOfEvents of this {@link Model}. - */ - public ListOf getListOfEvents() { - if (listOfEvents == null) { - listOfEvents = ListOf.newInstance(this, Event.class); - } - return listOfEvents; - } - - /** - * Returns the listOfFunctionDefinitions of this {@link Model}. - * - * @return the listOfFunctionDefinitions of this {@link Model}. - */ - public ListOf getListOfFunctionDefinitions() { - if (listOfFunctionDefinitions == null) { - listOfFunctionDefinitions = ListOf.newInstance(this, - FunctionDefinition.class); - } - return listOfFunctionDefinitions; - } - - /** - * Returns the listOfInitialAssignments of this {@link Model}. - * - * @return the listOfInitialAssignments of this {@link Model}. - */ - public ListOf getListOfInitialAssignments() { - if (listOfInitialAssignments == null) { - listOfInitialAssignments = ListOf.newInstance(this, - InitialAssignment.class); - } - return listOfInitialAssignments; - } - - /** - * Returns the listOfParameters of this {@link Model}. - * - * @return the listOfParameters of this {@link Model}. - */ - public ListOf getListOfParameters() { - if (listOfParameters == null) { - listOfParameters = ListOf.newInstance(this, Parameter.class); - } - return listOfParameters; - } - - /** - * - * @return - */ - public List getListOfPredefinedUnitDefinitions() { - return (listOfPredefinedUnitDefinitions != null) ? listOfPredefinedUnitDefinitions - : new ArrayList(0); - } - - /** - * Returns the listOfReactions of this {@link Model}. - * - * @return the listOfReactions of this {@link Model}. - */ - public ListOf getListOfReactions() { - if (listOfReactions == null) { - listOfReactions = ListOf.newInstance(this, Reaction.class); - } - return listOfReactions; - } - - /** - * Returns the listOfRules of this {@link Model}. - * - * @return the listOfRules of this {@link Model}. - */ - public ListOf getListOfRules() { - if (listOfRules == null) { - listOfRules = ListOf.newInstance(this, Rule.class); - } - return listOfRules; - } - - /** - * Returns the listOfSpecies of this {@link Model}. - * - * @return the listOfSpecies of this {@link Model}. - */ - public ListOf getListOfSpecies() { - if (listOfSpecies == null) { - listOfSpecies = ListOf.newInstance(this, Species.class); - } - return listOfSpecies; - } - - /** - * Returns the listOfSpeciesTypes of this {@link Model}. - * - * @return the listOfSpeciesTypes of this {@link Model}. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public ListOf getListOfSpeciesTypes() { - if (listOfSpeciesTypes == null) { - listOfSpeciesTypes = ListOf.newInstance(this, SpeciesType.class); - } - return listOfSpeciesTypes; - } - - /** - * Returns the listOfUnitDefinitions of this {@link Model}. - * - * @return the listOfUnitDefinitions of this {@link Model}. - */ - public ListOf getListOfUnitDefinitions() { - if (listOfUnitDefinitions == null) { - listOfUnitDefinitions = ListOf.newInstance(this, UnitDefinition.class); - } - return listOfUnitDefinitions; - } - - /** - * Returns the number of parameters that are contained within kineticLaws in - * the reactions of this model. - * - * @return the number of parameters that are contained within kineticLaws in - * the reactions of this model. - */ - public int getLocalParameterCount() { - int count = 0; - if (isSetListOfReactions()) { - for (Reaction reaction : getListOfReactions()) { - if (reaction.isSetKineticLaw()) { - count += reaction.getKineticLaw().getLocalParameterCount(); - } - } - } - return count; - } - - /** - * Returns the number of elements that can contain math in the {@link Model} . - * - * @return the number of elements that can contain math in the {@link Model} . - * @see MathContainer - */ - public int getMathContainerCount() { - return getFunctionDefinitionCount() + getInitialAssignmentCount() - + getEventAssignmentCount() + getDelayCount() + getConstraintCount() - + getRuleCount() + getTriggerCount() + getStoichiometryMathCount() - + getKineticLawCount(); - } - - /** - * Returns {@link History} of this model. - * - * @return the {@link History} of this model. - * - * @see SBase#getHistory - * @deprecated use {@link SBase#getHistory()} - */ - @Deprecated - public History getModelHistory() { - return getHistory(); - } - - /** - * Returns the number of {@link ModifierSpeciesReference}s in the - * {@link Model}. - * - * @return the number of {@link ModifierSpeciesReference}s in the - * {@link Model}. - */ - public int getModifierSpeciesReferenceCount() { - int count = 0; - for (Reaction r : getListOfReactions()) { - count += r.getModifierCount(); - } - return count; - } - - /** - * Returns all {@link ModifierSpeciesReference}s, registered in - * any {@link Reaction}. - * @return - * @return all {@link ModifierSpeciesReference} contained in this {@link Model}. - */ - public Set getModifierSpeciesReferences() { - Set listOfModifiers = new HashSet(); - for (Reaction r : getListOfReactions()) { - if (r.isSetListOfModifiers()) { - listOfModifiers.addAll( r.getListOfModifiers() ); - } - } - return listOfModifiers; - } - - /** - * Returns the number of {@link NamedSBase}s in the {@link Model}, so elements - * that can have a name. - * - * @return the number of {@link NamedSBase}s in the {@link Model}, so elements - * that can have a name. - */ - public int getNamedSBaseCount() { - return getNamedSBaseWithDerivedUnitCount() + 1 /* this model */ - + getSpeciesTypeCount() + getCompartmentTypeCount() - + getUnitDefinitionCount() + getEventCount() - + getModifierSpeciesReferenceCount(); - } - - public int getNamedSBaseWithDerivedUnitCount() { - return getQuantityCount() + getFunctionDefinitionCount() + getReactionCount(); - } - - /** - * Returns the number of {@link Compartment}s of this {@link Model}. - * - * @return the number of {@link Compartment}s of this {@link Model}. - * @deprecated use {@link #getCompartmentCount()} - */ - @Deprecated - public int getNumCompartments() { - return getCompartmentCount(); - } - - /** - * Returns the number of {@link CompartmentType}s of this {@link Model}. - * - * @return the number of {@link CompartmentType}s of this {@link Model}. - * @deprecated use {@link #getCompartmentTypeCount()} - */ - @Deprecated - public int getNumCompartmentTypes() { - return getCompartmentTypeCount(); - } - - /** - * Returns the number of {@link Constraint}s of this {@link Model}. - * - * @return the number of {@link Constraint}s of this {@link Model}. - * @deprecated use {@link #getConstraintCount()} - */ - @Deprecated - public int getNumConstraints() { - return getConstraintCount(); - } - - /** - * Returns the number of {@link Delay}s of this {@link Model}. - * - * @return the number of {@link Delay}s of this {@link Model}. - * @deprecated use {@link #getDelayCount()} - */ - @Deprecated - public int getNumDelays() { - return getDelayCount(); - } - - /** - * Returns the number of {@link EventAssignment}s of this {@link Model}. - * - * @return return the number of {@link EventAssignment}s of this {@link Model}. - * @deprecated use {@link #getEventAssignmentCount()} - */ - @Deprecated - public int getNumEventAssignments() { - return getEventAssignmentCount(); - } - - /** - * Returns the number of {@link Event}s of this {@link Model}. - * - * @return the number of {@link Event}s of this {@link Model}. - * @deprecated use {@link #getEventCount()} - */ - @Deprecated - public int getNumEvents() { - return getEventCount(); - } - - /** - * Returns the number of {@link FunctionDefinition}s of this {@link Model}. - * - * @return the number of {@link FunctionDefinition}s of this {@link Model}. - * @deprecated use {@link #getFunctionDefinitionCount()} - */ - @Deprecated - public int getNumFunctionDefinitions() { - return getFunctionDefinitionCount(); - } - - /** - * Returns the number of {@link InitialAssignment}s of this {@link Model}. - * - * @return the number of {@link InitialAssignment}s of this {@link Model}. - * @deprecated use {@link #getInitialAssignmentCount()} - */ - @Deprecated - public int getNumInitialAssignments() { - return getInitialAssignmentCount(); - } - - /** - * Returns the number of {@link KineticLaw}s of this {@link Model}. - * - * @return the number of {@link KineticLaw}s of this {@link Model}. - * @deprecated use {@link #getKineticLawCount()} - */ - @Deprecated - public int getNumKineticLaws() { - return getKineticLawCount(); - } - - /** - * Returns the number of {@link ListOf}s of this {@link Model}. - * - * @return the number of {@link ListOf}s of this {@link Model}. - * @deprecated use {@link #getListOfCount()} - */ - @Deprecated - public int getNumListsOf() { - return getListOfCount(); - } - - /** - * Returns the number of parameters that are contained within kineticLaws in - * the reactions of this model. - * - * @return the number of parameters that are contained within kineticLaws in - * the reactions of this model. - * @deprecated use {@link #getLocalParameterCount()} - */ - @Deprecated - public int getNumLocalParameters() { - return getLocalParameterCount(); - } - - /** - * Returns the number of elements that can contain math in the {@link Model} . - * - * @return the number of elements that can contain math in the {@link Model} . - * @see MathContainer - * @deprecated use {@link #getMathContainerCount()} - */ - @Deprecated - public int getNumMathContainers() { - return getMathContainerCount(); - } - - /** - * Returns the number of {@link ModifierSpeciesReference}s in the - * {@link Model}. - * - * @return the number of {@link ModifierSpeciesReference}s in the - * {@link Model}. - * @deprecated use {@link #getModifierSpeciesReferenceCount()} - */ - @Deprecated - public int getNumModifierSpeciesReferences() { - return getModifierSpeciesReferenceCount(); - } - - /** - * Returns the number of {@link NamedSBase}s in the {@link Model}, so elements - * that can have a name. - * - * @return the number of {@link NamedSBase}s in the {@link Model}, so elements - * that can have a name. - * @deprecated use {@link #getNamedSBaseCount()} - */ - @Deprecated - public int getNumNamedSBases() { - return getNamedSBaseCount(); - } - - /** - * Returns the number of {@link NamedSBaseWithDerivedUnit}s in the - * {@link Model}, so elements that can have a name and a unit that can be - * derived. - * - * @return the number of {@link NamedSBaseWithDerivedUnit}s in the - * {@link Model}, so elements that can have a name and a unit that can - * be derived. - * @deprecated use {@link #getNamedSBaseWithDerivedUnitCount()} - */ - @Deprecated - public int getNumNamedSBasesWithDerivedUnit() { - return getNamedSBaseWithDerivedUnitCount(); - } - - /** - * Returns the number of {@link Parameter}s of this {@link Model}. - * - * @return the number of {@link Parameter}s of this {@link Model}. - * @deprecated use {@link #getParameterCount()} - */ - @Deprecated - public int getNumParameters() { - return getParameterCount(); - } - - /** - * Returns the number of {@link Quantity}s of this {@link Model}. - * - * @return the number of {@link Quantity}s of this {@link Model}. - * @deprecated use {@link #getQuantityCount()} - */ - @Deprecated - public int getNumQuantities() { - return getQuantityCount(); - } - - /** - * Returns the number of {@link QuantityWithUnit}s of this {@link Model}. - * - * @return the number of {@link QuantityWithUnit}s of this {@link Model}. - * @deprecated use {@link #getQuantityWithUnitCount()} - */ - @Deprecated - public int getNumQuantitiesWithUnit() { - return getQuantityWithUnitCount(); - } - - /** - * Returns the number of {@link Reaction}s of this {@link Model}. - * - * @return the number of {@link Reaction}s of this {@link Model}. - * @deprecated use {@link #getReactionCount()} - */ - @Deprecated - public int getNumReactions() { - return getReactionCount(); - } - - /** - * Returns the number of {@link Rule}s of this {@link Model}. - * - * @return the number of {@link Rule}s of this {@link Model}. - * @deprecated use {@link #getRuleCount()} - */ - @Deprecated - public int getNumRules() { - return getRuleCount(); - } - - /** - * Returns the number of {@link SBase}s of this {@link Model}. - * - * @return the number of {@link SBase}s of this {@link Model}. - * @deprecated use {@link #getSBaseCount()} - */ - @Deprecated - public int getNumSBases() { - return getSBaseCount(); - } - - /** - * Returns the number of {@link SBaseWithDerivedUnit}s of this {@link Model}. - * - * @return the number of {@link SBaseWithDerivedUnit}s of this {@link Model}. - * @deprecated use {@link #getSBaseWithDerivedUnitCount()} - */ - @Deprecated - public int getNumSBasesWithDerivedUnit() { - return getSBaseWithDerivedUnitCount(); - } - - /** - * Returns the number of {@link Species} of this {@link Model}. - * - * @return the number of {@link Species} of this {@link Model}. - * @deprecated use {@link #getSpeciesCount()} - */ - @Deprecated - public int getNumSpecies() { - return getSpeciesCount(); - } - - /** - * Returns the number of {@link SpeciesReferences}s of this {@link Model}. - * - * @return the number of {@link SpeciesReferences}s of this {@link Model}. - * @deprecated use {@link #getSpeciesReferenceCount()} - */ - @Deprecated - public int getNumSpeciesReferences() { - return getSpeciesReferenceCount(); - } - - /** - * Returns the number of {@link SpeciesType}s of this {@link Model}. - * - * @return the number of {@link SpeciesType}s of this {@link Model}. - * @deprecated use {@link #getSpeciesTypeCount()} - */ - @Deprecated - public int getNumSpeciesTypes() { - return getSpeciesTypeCount(); - } - - /** - * Returns the number of {@link Species} whose boundary condition is set to - * true. - * - * @return the number of {@link Species} whose boundary condition is set to - * true. - * @deprecated use {@link #getSpeciesWithBoundaryConditionCount()} - */ - @Deprecated - public int getNumSpeciesWithBoundaryCondition() { - return getSpeciesWithBoundaryConditionCount(); - } - - /** - * Returns the number of {@link StoichiometryMath} in the {@link Model}. - * - * @return the number of {@link StoichiometryMath} in the {@link Model}. - * @deprecated use {@link #getStoichiometryMathCount()} - */ - @Deprecated - public int getNumStoichiometryMath() { - return getStoichiometryMathCount(); - } - - /** - * Returns the number of all instances of {@link Symbol} referenced within the - * model. There is no dedicated list for {@link Symbol}s. This is a convenient - * method to support working with the model data structure. - * - * @return The number of {@link Compartment}s, {@link Species}, and - * {@link Parameter}s in the model. - * @deprecated use {@link #getSymbolCount()} - */ - @Deprecated - public int getNumSymbols() { - return getSymbolCount(); - } - - /** - * Returns the number of {@link Trigger} of this {@link Model}. - * - * @return the number of {@link Trigger} of this {@link Model}. - * @deprecated use {@link #getTriggerCount()} - */ - @Deprecated - public int getNumTriggers() { - return getTriggerCount(); - } - - /** - * Returns the number of {@link UnitDefinition}s of this {@link Model}. - * - * @return the number of {@link UnitDefinition}s of this {@link Model}. - * @deprecated use {@link #getUnitDefinitionCount()} - */ - @Deprecated - public int getNumUnitDefinitions() { - return getUnitDefinitionCount(); - } - - /** - * Returns the number of {@link Unit}s of this {@link Model}. - * - * @return the number of {@link Unit}s of this {@link Model}. - * @deprecated use {@link #getUnitCount()} - */ - @Deprecated - public int getNumUnits() { - return getUnitCount(); - } - - /** - * Returns the number of {@link Variable}s of this {@link Model}. - * - * @return the number of {@link Variable}s of this {@link Model}. - * @deprecated use {@link #getVariableCount()} - */ - @Deprecated - public int getNumVariables() { - return getVariableCount(); - } - - /** - * Gets the nth {@link Parameter} object in this {@link Model}. - * - * @param n - * index - * @return the nth {@link Parameter} of this {@link Model}. - */ - public Parameter getParameter(int n) { - return getListOfParameters().get(n); - } - - /** - * Returns the {@link Parameter} of the listOfParameters which has 'id' as id - * - * @param id - * @return the {@link Parameter} of the listOfParameters which has 'id' as id - * (or name depending on the level and version). Null if it doesn't - * exist. - */ - public Parameter getParameter(String id) { - return getListOfParameters().firstHit(new NameFilter(id)); - } - - /** - * Returns the number of {@link Parameter}s of this {@link Model}. - * - * @return the number of {@link Parameter}s of this {@link Model}. - */ - public int getParameterCount() { - return isSetListOfParameters() ? listOfParameters.size() : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - public SBMLDocument getParent() { - return (SBMLDocument) super.getParent(); - } - - /** - * Returns a UnitDefinition representing one of the predefined units of SBML, - * returns null if the given unit kind is not a valid one for the SBML level - * and version of this {@link Model}. - * - * @param unitKind - * a unit kind for one of the predefined units from the SBML - * Specifications - * @return a UnitDefinition representing one of the predefined units of SBML, - * null if the unitKind is invalid. - */ - public UnitDefinition getPredefinedUnitDefinition(String unitKind) { - // TODO: This might be more efficient than ALWAYS storing ALL base units in the listOfPredefinedUnits: -// if ((unitKind != null) && !unitKind.isEmpty()) { -// int level = getLevel(), version = getVersion(); -// if (Unit.isUnitKind(unitKind, level, version)) { -// UnitDefinition ud = new UnitDefinition(unitKind + "_base", level, version); -// ud.addUnit(Unit.Kind.valueOf(unitKind.toUpperCase())); -// return ud; -// } -// } - if (listOfPredefinedUnitDefinitions != null) { - for (UnitDefinition unitDefinition : listOfPredefinedUnitDefinitions) { - // TODO: It can never happen that a unitDef has the id that is a unit kind. - if (unitDefinition.getId().equals(unitKind) - || unitDefinition.getId().equals(unitKind + "_base")) - { - return unitDefinition; - } - } - } - return null; - } - - /** - * Returns the number of {@link Quantity}s of this {@link Model}. - * - * @return the number of {@link Quantity}s of this {@link Model}. - */ - public int getQuantityCount() { - return getNumVariables() + getLocalParameterCount(); - } - - /** - * Returns the number of {@link QuantityWithUnit}s of this {@link Model}. - * - * @return the number of {@link QuantityWithUnit}s of this {@link Model}. - */ - public int getQuantityWithUnitCount() { - return getNumSymbols() + getLocalParameterCount(); - } - - /** - * Gets the n-th {@link Reaction} object in this Model. - * - * @param reactionIndex - * @return the n-th {@link Reaction} of this Model. - */ - public Reaction getReaction(int n) { - return getListOfReactions().get(n); - } - - /** - * Returns the {@link Reaction} of the {@link #listOfReactions} which has 'id' as id. - * - * @param id - * @return the {@link Reaction} of the {@link #listOfReactions} which has 'id' as id - * (or name depending on the level and version). null if it doesn't - * exist. - */ - public Reaction getReaction(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Reaction)) { - return (Reaction) found; - } - return null; - } - - /** - * Returns the number of {@link Reaction}s of this {@link Model}. - * - * @return the number of {@link Reaction}s of this {@link Model}. - */ - public int getReactionCount() { - return isSetListOfReactions() ? listOfReactions.size() : 0; - } - - /** - * Gets the nth {@link Rule} of the listOfRules. - * - * @param n - * an index - * @return the nth {@link Rule} of the listOfRules. Null if it doesn't exist. - */ - public Rule getRule(int n) { - return getListOfRules().get(n); - } - - /** - * Searches for the first instance of {@link ExplicitRule} within this - * {@link Model}'s {@link #listOfRules}, whose variable attribute is set to - * the value passed to this method. - * - * @param variable - * @return Null if no element with the required property exists. - */ - public ExplicitRule getRule(String variable) { - Rule rule = listOfRules.firstHit(new AssignmentVariableFilter(variable)); - return (rule != null) && (rule instanceof ExplicitRule) ? (ExplicitRule) rule - : null; - } - - /** - * Returns the number of {@link Rule}s of this {@link Model}. - * - * @return the number of {@link Rule}s of this {@link Model}. - */ - public int getRuleCount() { - return isSetListOfRules() ? listOfRules.size() : 0; - } - - /** - * Returns the number of {@link SBase}s of this {@link Model}. - * - * @return the number of {@link SBase}s of this {@link Model}. - */ - public int getSBaseCount() { - int count = getNamedSBaseCount() - getFunctionDefinitionCount() - + getMathContainerCount() + getListOfCount() + getUnitCount() + 1; - // one for this model - if (getParent() != null) { - count++; // the owning SBML document. - } - return count; - } - - /** - * Returns the number of {@link SBaseWithDerivedUnit}s of this {@link Model}. - * - * @return the number of {@link SBaseWithDerivedUnit}s of this {@link Model}. - */ - public int getSBaseWithDerivedUnitCount() { - return getNamedSBaseWithDerivedUnitCount() + getMathContainerCount() - - getFunctionDefinitionCount(); - } - - /** - * Gets the n-th {@link Species} object in this Model. - * - * @param n - * an index - * @return the {@link Species} with the given index if it exists, - * null otherwise. - */ - public Species getSpecies(int n) { - return getListOfSpecies().get(n); - } - - /** - * Gets the {@link Species} of the {@link #listOfSpecies} which has 'id' as - * id. - * - * @param id - * @return the {@link Species} of the listOfSpecies which has 'id' as id (or - * name depending on the level and version). null if - * it doesn't exist. - */ - public Species getSpecies(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof Species)) { - return (Species) found; - } - return null; - } - - /** - * Returns the number of {@link Species} of this {@link Model}. - * - * @return the number of {@link Species} of this {@link Model}. - */ - public int getSpeciesCount() { - return isSetListOfSpecies() ? listOfSpecies.size() : 0; - } - - /** - * Returns the number of {@link SpeciesReferences}s of this {@link Model}. - * - * @return the number of {@link SpeciesReferences}s of this {@link Model}. - */ - public int getSpeciesReferenceCount() { - int count = 0; - for (Reaction r : getListOfReactions()) { - count += r.getReactantCount() + r.getProductCount(); - } - return count; - } - - /** - * Gets the nth {@link SpeciesType} object in this Model. - * - * @param n - * index - * @return the nth {@link SpeciesType} of this Model. Returns null if there - * are no speciesType defined or if the index n is too big or lower - * than zero. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType getSpeciesType(int n) { - return getListOfSpeciesTypes().get(n); - } - - /** - * Returns the {@link SpeciesType} of the {@link #listOfSpeciesTypes} which has 'id' as - * id. - * - * @param id - * @return the {@link SpeciesType} of the {@link #listOfSpeciesTypes} which has 'id' as - * id (or name depending on the level and version). null if it doesn't - * exist. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType getSpeciesType(String id) { - UniqueNamedSBase found = findUniqueNamedSBase(id); - if ((found != null) && (found instanceof SpeciesType)) { - return (SpeciesType) found; - } - return null; - } - - /** - * Returns the number of {@link SpeciesType}s of this {@link Model}. - * - * @return the number of {@link SpeciesType}s of this {@link Model}. - * @deprecated the use of {@link SpeciesType} is not recommended, because this - * data structure is only valid in SBML Level 2 for Versions 2 - * through 4. - */ - @Deprecated - public int getSpeciesTypeCount() { - return isSetListOfSpeciesTypes() ? listOfSpeciesTypes.size() : 0; - } - - /** - * Returns the number of {@link Species} whose boundary condition is set to - * true. - * - * @return the number of {@link Species} whose boundary condition is set to - * true. - */ - public int getSpeciesWithBoundaryConditionCount() { - return getListOfSpecies().filterList(new BoundaryConditionFilter()).size(); - } - - /** - * Returns the number of {@link StoichiometryMath} in the {@link Model}. - * - * @return the number of {@link StoichiometryMath} in the {@link Model}. - */ - public int getStoichiometryMathCount() { - int count = 0; - for (Reaction r : getListOfReactions()) { - for (SpeciesReference sr : r.getListOfReactants()) { - if (sr.isSetStoichiometryMath()) { - count++; - } - } - for (SpeciesReference sr : r.getListOfProducts()) { - if (sr.isSetStoichiometryMath()) { - count++; - } - } - } - return count; - } - - /** - * Returns the substance units ID of this model. - * - * @return the substance units ID of this model. Returns the empty - * {@link String} if it is not set. - */ - public String getSubstanceUnits() { - if (isSetSubstanceUnits()) { - return substanceUnitsID; - } else if (getLevel() < 3) { - return UnitDefinition.SUBSTANCE; - } - return ""; - } - - /** - * Returns the {@link UnitDefinition} which has the {@link #substanceUnitsID} of this - * {@link Model} as id. - * - * @return the {@link UnitDefinition} which has the {@link #substanceUnitsID} of this - * {@link Model} as id. null if it doesn't exist. - */ - public UnitDefinition getSubstanceUnitsInstance() { - return getUnitDefinition(getSubstanceUnits()); - } - - /** - * Returns the number of all instances of {@link Symbol} referenced within the - * model. There is no dedicated list for {@link Symbol}s. This is a convenient - * method to support working with the model data structure. - * - * @return The number of {@link Compartment}s, {@link Species}, and - * {@link Parameter}s in the model. - */ - public int getSymbolCount() { - return getParameterCount() + getSpeciesCount() + getCompartmentCount(); - } - - /** - * Returns the time units ID of this {@link Model}. - * - * @return the time units ID of this {@link Model} or an empty {@link String} - * if it is not set. - */ - public String getTimeUnits() { - if (isSetTimeUnits()) { - return timeUnitsID; - } else if (getLevel() < 3) { - return UnitDefinition.TIME; - } - return ""; - } - - /** - * Gets the {@link UnitDefinition} representing the time units of this - * {@link Model}. - * - * @return the {@link UnitDefinition} representing the time units of this - * {@link Model}, null if it is not defined in this {@link Model} - */ - public UnitDefinition getTimeUnitsInstance() { - return getUnitDefinition(getTimeUnits()); - } - - /** - * Returns the number of {@link Trigger} of this {@link Model}. - * - * @return the number of {@link Trigger} of this {@link Model}. - */ - public int getTriggerCount() { - int count = 0; - for (Event e : getListOfEvents()) { - if (e.isSetTrigger()) { - count++; - } - } - return count; - } - - /** - * Returns the number of {@link Unit}s of this {@link Model}. - * - * @return the number of {@link Unit}s of this {@link Model}. - */ - public int getUnitCount() { - int count = 0; - for (UnitDefinition ud : getListOfUnitDefinitions()) { - count += ud.getUnitCount(); - } - return count; - } - - /** - * Gets the nth {@link UnitDefinition} object in this {@link Model}. - * - * @param n - * @return the nth {@link UnitDefinition} of this {@link Model}. Returns - * null if there are no {@link UnitDefinition}s defined - * or if the index n is too big or lower than zero. - */ - public UnitDefinition getUnitDefinition(int n) { - return getListOfUnitDefinitions().get(n); - } - - /** - * Returns the {@link UnitDefinition} of the {@link #listOfUnitDefinitions} - * which has 'id' as id. If no {@link UnitDefinition} are found, we check in the - * {@link #listOfPredefinedUnitDefinitions}. If we still did not find a - * {@link UnitDefinition}, null is returned. - * - * @param id - * @return the {@link UnitDefinition} of the {@link #listOfUnitDefinitions}s - * which has 'id' as id (or name depending on the level and version). - * Null if it doesn't exist. - */ - public UnitDefinition getUnitDefinition(String id) { - UnitDefinition unitDefinition = mapOfUnitDefinitions != null ? mapOfUnitDefinitions.get(id) : null; - // Checking if it is not one of the predefined default units. - if (unitDefinition == null) { - unitDefinition = getPredefinedUnitDefinition(id); - } - return unitDefinition; - } - - /** - * Returns the number of {@link UnitDefinition}s of this {@link Model}. - * - * @return the number of {@link UnitDefinition}s of this {@link Model}. - */ - public int getUnitDefinitionCount() { - return isSetListOfUnitDefinitions() ? listOfUnitDefinitions.size() : 0; - } - - /** - * Returns the number of {@link Variable}s of this {@link Model}. - * - * @return the number of {@link Variable}s of this {@link Model}. - */ - public int getVariableCount() { - return getSymbolCount() + getSpeciesReferenceCount(); - } - - /** - * Returns the volume units ID of this {@link Model}. - * - * @return the volume nits ID of this {@link Model}. Returns an empty String - * if it is not set. - */ - public String getVolumeUnits() { - if (isSetVolumeUnits()) { - return volumeUnitsID; - } else if (getLevel() < 3) { - return UnitDefinition.VOLUME; - } - return ""; - } - - /** - * Returns the {@link UnitDefinition} instance which has the {@link #volumeUnitsID} - * of this {@link Model} as id. - * - * @return the {@link UnitDefinition} instance which has the {@link #volumeUnitsID} - * of this {@link Model} as id. null if it doesn't exist. - */ - public UnitDefinition getVolumeUnitsInstance() { - return getUnitDefinition(getVolumeUnits()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 887; - int hashCode = super.hashCode(); - if (isSetTimeUnits()) { - hashCode += prime * getTimeUnits().hashCode(); - } - if (isSetAreaUnits()) { - hashCode += prime * getAreaUnits().hashCode(); - } - if (isSetConversionFactor()) { - hashCode += prime * getConversionFactor().hashCode(); - } - if (isSetExtentUnits()) { - hashCode += prime * getExtentUnits().hashCode(); - } - if (isSetLengthUnits()) { - hashCode += prime * getLengthUnits().hashCode(); - } - if (isSetSubstanceUnits()) { - hashCode += prime * getSubstanceUnits().hashCode(); - } - if (isSetVolumeUnits()) { - hashCode += prime * getVolumeUnits().hashCode(); - } - return hashCode; - } - - /** - * Returns true if this model has a reference to the unit with the given - * identifier. - * - * @param id - * @return true if this model has a reference to the unit with the given - * identifier, false otherwise. - */ - public boolean hasUnit(String id) { - return getUnitDefinition(id) != null; - } - - /** - * Initializes the default values using the current Level/Version - * configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default values of the attributes of the {@link Model} - */ - public void initDefaults(int level, int version) { - listOfCompartments = null; - listOfCompartmentTypes = null; - listOfConstraints = null; - listOfEvents = null; - listOfFunctionDefinitions = null; - listOfInitialAssignments = null; - listOfParameters = null; - listOfReactions = null; - listOfRules = null; - listOfSpecies = null; - listOfSpeciesTypes = null; - UnitDefinition ud; - listOfPredefinedUnitDefinitions = new ArrayList(); - addPredefinedUnits(); - - switch (level) { - case 1: - // substance - ud = UnitDefinition.substance(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // time - ud = UnitDefinition.time(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // volume - ud = UnitDefinition.volume(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - areaUnitsID = null; - lengthUnitsID = null; - extentUnitsID = null; - conversionFactorID = null; - break; - case 2: - // substance - ud = UnitDefinition.substance(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // volume - ud = UnitDefinition.volume(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // area - ud = UnitDefinition.area(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // length - ud = UnitDefinition.length(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - // time - ud = UnitDefinition.time(getLevel(), getVersion()); - listOfPredefinedUnitDefinitions.add(ud); - - extentUnitsID = null; - conversionFactorID = null; - break; - default: // undefined or level 3 - substanceUnitsID = null; - timeUnitsID = null; - volumeUnitsID = null; - areaUnitsID = null; - lengthUnitsID = null; - extentUnitsID = null; - conversionFactorID = null; - break; - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * Returns true if the area units ID of this Model is not null. - * - * @return true if the area units ID of this Model is not null. - */ - public boolean isSetAreaUnits() { - return this.areaUnitsID != null; - } - - /** - * Returns true if the UnitDefinition which has the area units ID of this - * Model as id is not null. - * - * @return true if the UnitDefinition which has the area units ID of this - * Model as id is not null. - */ - public boolean isSetAreaUnitsInstance() { - return getAreaUnitsInstance() != null; - } - - /** - * Returns true if the conversionFactorID of this Model is not null. - * - * @return true if the conversionFactorID of this Model is not null. - */ - public boolean isSetConversionFactor() { - return this.conversionFactorID != null; - } - - /** - * Returns true if the Parameter which has the conversionFactorID of this - * Model as id is not null. - * - * @return true if the Parameter which has the conversionFactorID of this - * Model as id is not null. - */ - public boolean isSetConversionFactorInstance() { - return getParameter(this.conversionFactorID) != null; - } - - /** - * Returns true if the extentUnitsID of this Model is not null. - * - * @return true if the extentUnitsID of this Model is not null. - */ - public boolean isSetExtentUnits() { - return this.extentUnitsID != null; - } - - /** - * Returns true if the UnitDefinition which has the extentUnitsID of this - * Model as id is not null. - * - * @return true if the UnitDefinition which has the extentUnitsID of this - * Model as id is not null. - */ - public boolean isSetExtentUnitsInstance() { - return getExtentUnitsInstance() != null; - } - - /** - * Returns true if the lengthUnitsID of this Model is not null. - * - * @return true if the lengthUnitsID of this Model is not null. - */ - public boolean isSetLengthUnits() { - return this.lengthUnitsID != null; - } - - /** - * Returns true if the UnitDefinition which has the lengthUnitsID of this - * Model as id is not null. - * - * @return true if the UnitDefinition which has the lengthUnitsID of this - * Model as id is not null. - */ - public boolean isSetLengthUnitsInstance() { - return getLengthUnitsInstance() != null; - } - - /** - * Returns true if the listOfCompartments of this Model is not null and not - * empty. - * - * @return true if the listOfCompartments of this Model is not null and not - * empty. - */ - public boolean isSetListOfCompartments() { - return (listOfCompartments != null) && (listOfCompartments.size() > 0); - } - - /** - * Returns true if the listOfCompartmentTypes of this Model is not null and - * not empty. - * - * @return true if the listOfCompartmentTypes of this Model is not null and - * not empty. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean isSetListOfCompartmentTypes() { - return (listOfCompartmentTypes != null) - && (listOfCompartmentTypes.size() > 0); - } - - /** - * Returns true if the listOfConstraints of this Model is not null and not - * empty. - * - * @return true if the listOfConstraints of this Model is not null and not - * empty. - */ - public boolean isSetListOfConstraints() { - return (listOfConstraints != null) && (listOfConstraints.size() > 0); - } - - /** - * Returns true if the listOfEvents of this Model is not null and not empty. - * - * @return true if the listOfEvents of this Model is not null and not empty. - */ - public boolean isSetListOfEvents() { - return (listOfEvents != null) && (listOfEvents.size() > 0); - } - - /** - * Returns true if the listOfFunctionDefinitions of this Model is not null and - * not empty. - * - * @return true if the listOfFunctionDefinitions of this Model is not null and - * not empty. - */ - public boolean isSetListOfFunctionDefinitions() { - return (listOfFunctionDefinitions != null) - && (listOfFunctionDefinitions.size() > 0); - } - - /** - * Returns true if the listOfInitialAssignments of this Model is not null and - * not empty. - * - * @return true if the listOfInitialAssignments of this Model is not null and - * not empty. - */ - public boolean isSetListOfInitialAssignments() { - return (listOfInitialAssignments != null) - && (listOfInitialAssignments.size() > 0); - } - - /** - * Returns true if the listOfParameters of this Model is not null and not - * empty. - * - * @return true if the listOfParameters of this Model is not null and not - * empty. - */ - public boolean isSetListOfParameters() { - return (listOfParameters != null) && (listOfParameters.size() > 0); - } - - /** - * Returns true if the listOfReactions of this Model is not null and not - * empty. - * - * @return true if the listOfReactions of this Model is not null and not - * empty. - */ - public boolean isSetListOfReactions() { - return (listOfReactions != null) && (listOfReactions.size() > 0); - } - - /** - * Returns true if the listOfRules of this Model is not null and not empty. - * - * @return true if the listOfRules of this Model is not null and not empty. - */ - public boolean isSetListOfRules() { - return (listOfRules != null) && (listOfRules.size() > 0); - } - - /** - * Returns true if the listOfSpecies of this Model is not null and not empty. - * - * @return true if the listOfSpecies of this Model is not null and not empty. - */ - public boolean isSetListOfSpecies() { - return (listOfSpecies != null) && (listOfSpecies.size() > 0); - } - - /** - * Returns true if the listOfSpeciesTypes of this Model is not null and not - * empty. - * - * @return true if the listOfSpeciesTypes of this Model is not null and not - * empty. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean isSetListOfSpeciesTypes() { - return (listOfSpeciesTypes != null) && (listOfSpeciesTypes.size() > 0); - } - - /** - * Returns true if the listOfUnitDefinitions of this Model is not null and not - * empty. - * - * @return true if the listOfUnitDefinitions of this Model is not null and not - * empty. - */ - public boolean isSetListOfUnitDefinitions() { - return (listOfUnitDefinitions != null) - && (listOfUnitDefinitions.size() > 0); - } - - /** - * Returns the {@link History} of the Model. This is equivalent to the call - * {@link SBase#isSetHistory()}. - * - * @return the {@link History} of the Model. - * @deprecated use {@link SBase#isSetHistory()} - */ - @Deprecated - public boolean isSetModelHistory() { - return isSetHistory(); - } - - /** - * Returns true if the substanceUnitsID of this Model is not null. - * - * @return true if the substanceUnitsID of this Model is not null. - */ - public boolean isSetSubstanceUnits() { - return this.substanceUnitsID != null; - } - - /** - * Returns true if the UnitDefinition which has the substanceUnitsID of this - * Model as id is not null. - * - * @return true if the UnitDefinition which has the substanceUnitsID of this - * Model as id is not null. - */ - public boolean isSetSubstanceUnitsInstance() { - return getSubstanceUnitsInstance() != null; - } - - /** - * Returns true if the timeUnitsID of this {@link Model} is not null. - * - * @return true if the timeUnitsID of this {@link Model} is not null. - */ - public boolean isSetTimeUnits() { - return this.timeUnitsID != null; - } - - /** - * Returns true if the UnitsDefinition which has the timeUnistID of this Model - * as id is not null. - * - * @return true if the UnitsDefinition which has the timeUnistID of this Model - * as id is not null. - */ - public boolean isSetTimeUnitsInstance() { - return getTimeUnitsInstance() != null; - } - - /** - * Returns true if the volumeUnitsID of this Model is not null. - * - * @return true if the volumeUnitsID of this Model is not null. - */ - public boolean isSetVolumeUnits() { - return this.volumeUnitsID != null; - } - - /** - * Returns true if the UnitDefinition which has the volumeUnitsID of this - * Model as id is not null. - * - * @return true if the UnitDefinition which has the volumeUnitsID of this - * Model as id is not null. - */ - public boolean isSetVolumeUnitsInstance() { - return getVolumeUnitsInstance() != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); - - if (!isAttributeRead) { - if (attributeName.equals("substanceUnits")) { - setSubstanceUnits(value); - return true; - } else if (attributeName.equals("timeUnits")) { - setTimeUnits(value); - return true; - } else if (attributeName.equals("volumeUnits")) { - setVolumeUnits(value); - return true; - } else if (attributeName.equals("areaUnits")) { - setAreaUnits(value); - return true; - } else if (attributeName.equals("lengthUnits")) { - setLengthUnits(value); - return true; - } else if (attributeName.equals("extentUnits")) { - setExtentUnits(value); - return true; - } else if (attributeName.equals("conversionFactor")) { - setConversionFactor(value); - return true; - } - } - return isAttributeRead; - } - - /** - * Registration of {@link LocalParameter} instances in the {@link Model}. - * - * @param kl - * the {@link KineticLaw} that contains the given - * {@link LocalParameter} - * @param lp - * the {@link LocalParameter} whose identifier is to be registered. - * @param delete - * @return true in case of success, otherwise false. - */ - private boolean registerId(KineticLaw kl, LocalParameter lp, boolean delete) { - // Register local parameter within its kinetic law first. - if (kl.registerLocalParameter(lp, delete)) { - /* - * If this works, register the local parameter and its reaction also - * in the model. This is necessary because of the restriction that the - * ids local parameters may not override the ids of UnitDefinitions. - */ - Reaction r = kl.getParentSBMLObject(); - String pId = lp.getId(); - if ((r != null) && r.isSetId()) { - if (delete) { - if (mapOfLocalParameters != null) { - SortedSet reactionSet = mapOfLocalParameters.get(pId); - if (reactionSet != null) { - reactionSet.remove(r.getId()); - if (reactionSet.isEmpty()) { - mapOfLocalParameters.remove(pId); - } - } - } - return true; - } else { - // add new key or reaction for this local parameter. - if (mapOfLocalParameters == null) { - mapOfLocalParameters = new HashMap>(); - } - if (!mapOfLocalParameters.containsKey(pId)) { - mapOfLocalParameters.put(pId, new TreeSet()); - } - mapOfLocalParameters.get(pId).add(r.getId()); - return true; - } - } - } - return false; - } - - /** - * Registers the identifier of a {@link NamedSBase} and its associated object - * in this {@link Model}. - * - * @param nsb - * the element, whose identifier is to be registered. - * @param add - * If true the identifier of the given {@link NamedSBase} - * will be registered in this {@link Model} Otherwise, the given - * identifier will be removed from this {@link Model}'s hash. - */ - boolean registerId(NamedSBase nsb, boolean add) { - return registerIds(nsb.getParentSBMLObject(), nsb, true, !add); - } - - /** - * - * @param unsb - * @param recursively - * @param delete - * @return - */ - private boolean registerId(UniqueNamedSBase unsb, boolean recursively, boolean delete) { - String id = unsb.getId(); - if (delete && (mapOfUniqueNamedSBases != null)) { - mapOfUniqueNamedSBases.remove(id); - if (logger.isDebugEnabled()) { - logger.debug(String.format("removed id=%s from model%s", - id, (isSetId() ? " " + getId() : ""))); - } - } else if (unsb.isSetId()) { - if (mapOfUniqueNamedSBases == null) { - mapOfUniqueNamedSBases = new HashMap(); - } - /* - * Three reasons for non acceptance: - * (1) another UniqueNamedSBase is already registered with the identical id. - * - * No need to test this case (2) some Reaction refers to a LocalParameter - * with this id, but LV >= 2.3 and the - * overridden element is not an instance of Species, Compartment, or Parameter. - * - || ((0 < unsb.getLevelAndVersion().compareTo(Integer.valueOf(2), Integer.valueOf(2))) - && (mapOfLocalParameters != null) - && mapOfLocalParameters.containsKey(id) && !(unsb instanceof Symbol)) - - * (3) In Level 1 UnitDefinitions and UniqueNamedSBases use the same namespace. - */ - if ((mapOfUniqueNamedSBases.containsKey(id) && - (mapOfUniqueNamedSBases.get(id) != unsb)) - || ((unsb.getLevel() == 1) && (mapOfUnitDefinitions != null) && - (mapOfUnitDefinitions.containsKey(id)))) - { - logger.error(String.format( - "An element with the id '%s' is already present in this model%s. The new element will not be added to the model.", - id, (isSetId() ? " " + getId() : ""))); - return false; - } - mapOfUniqueNamedSBases.put(id, unsb); - - if (logger.isDebugEnabled()) { - logger.debug(String.format("registered id=%s in model%s", - id, (isSetId() ? " " + getId() : ""))); - } - } - boolean success = true; - if (recursively) { - TreeNode child; - for (int i = 0; i < unsb.getChildCount(); i++) { - child = unsb.getChildAt(i); - if (child instanceof SBase) { - success &= registerIds(unsb, (SBase) child, recursively, delete); - } - } - } - return success; - } - - /** - * Registers the identifier and the corresponding {@link UnitDefinition} - * itself - * in this {@link Model}. - * - * @param ud - * the {@link UnitDefinition} to be registered. - * @param add - * @return - */ - private boolean registerId(UnitDefinition ud, boolean add) { - if (mapOfUnitDefinitions == null) { - mapOfUnitDefinitions = new HashMap(); - } - if (add) { - return mapOfUnitDefinitions.put(ud.getId(), ud) == null; - } - return mapOfUnitDefinitions.remove(ud.getId()) != null; - } - - /** - * Registers the given element in this {@link Model}. - * - * @param parent - * @param newElem - * @param recursively - * @param delete - * @return true if this operation was successfully performed, - * false otherwise. - */ - boolean registerIds(SBase parent, SBase newElem, boolean recursively, boolean delete) { - if (newElem instanceof NamedSBase) { - NamedSBase newNsb = (NamedSBase) newElem; - if (newNsb.isSetId()) { - if (newNsb instanceof UniqueNamedSBase) { - return registerId((UniqueNamedSBase) newNsb, recursively, delete); - } else if ((newNsb instanceof LocalParameter) - && (parent.getParent() != null)) { - return registerId((KineticLaw) parent.getParent(), - (LocalParameter) newNsb, delete); - } else if (newNsb instanceof UnitDefinition) { - return registerId((UnitDefinition) newNsb, !delete); - } else { - // in L3 packages we might have different id namespaces - logger.error("registerIds : the object " + newNsb.getClass().getCanonicalName() + " is neither " + - "a UniqueNamedSBase, a LocalParameter or a UnitDefinition so it's id will not be registered in the Model."); - } - } else if (!newNsb.isIdMandatory()) { - return true; - } - } - if (recursively) { - boolean success = true; - for (int i = 0; (i < newElem.getChildCount()) && success; i++) { - TreeNode child = newElem.getChildAt(i); - if (child instanceof SBase) { - if ((parent instanceof KineticLaw) && (child instanceof LocalParameter)) { - success &= registerId((KineticLaw) parent, (LocalParameter) child, delete); - } else { - success &= registerIds(newElem, (SBase) child, recursively, delete); - } - } - } - return success; - } - /* - * the default return value is true to be able to register successfully objects that are - * not NamedSBase when the recursive boolean is set to false (happen with listOf objects for example). - * For these, the AbstractSBase.registerChild(SBase) method was throwing an exception although there was no problem. - */ - return true; - } - - /** - * Removes the i-th {@link Compartment} of the {@link Model}. - * - * @param i - * the index of the {@link Compartment} to remove - * @return the removed {@link Compartment}. - */ - public Compartment removeCompartment(int i) { - return getListOfCompartments().remove(i); - } - - /** - * Removes the {@link Compartment} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed {@link Compartment}. - */ - public Compartment removeCompartment(String id) { - return getListOfCompartments().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link CompartmentType} of the {@link Model}. - * - * @param n - * the index of the {@link Compartment} to remove - * @return the removed {@link CompartmentType}. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public CompartmentType removeCompartmentType(int n) { - return getListOfCompartmentTypes().remove(n); - } - - /** - * Removes the {@link CompartmentType} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public CompartmentType removeCompartmentType(String id) { - return getListOfCompartmentTypes().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link Constraint} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public Constraint removeConstraint(int n) { - return getListOfConstraints().remove(n); - } - - /** - * Removes the n-th {@link Event} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public Event removeEvent(int n) { - return getListOfEvents().remove(n); - } - - /** - * Removes the {@link Event} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - */ - public Event removeEvent(String id) { - return getListOfEvents().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link FunctionDefinition} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public FunctionDefinition removeFunctionDefinition(int n) { - return getListOfFunctionDefinitions().remove(n); - } - - /** - * Removes the {@link FunctionDefinition} of the {@link Model} with 'id' as - * id. - * - * @param id - * @return the removed element. - */ - public FunctionDefinition removeFunctionDefinition(String id) { - return getListOfFunctionDefinitions().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link InitialAssignment} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public InitialAssignment removeInitialAssignment(int n) { - return getListOfInitialAssignments().remove(n); - } - - /** - * Removes the n-th {@link Parameter} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public Parameter removeParameter(int n) { - return getListOfParameters().remove(n); - } - - /** - * Removes the Parameter 'parameter' from this Model. - * - * @param parameter - * @return true if the {@link Parameter} was found and removed. - */ - public boolean removeParameter(Parameter parameter) { - return getListOfParameters().remove(parameter); - } - - /** - * Removes the {@link Parameter} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - */ - public Parameter removeParameter(String id) { - return getListOfParameters().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link Reaction} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public Reaction removeReaction(int n) { - return getListOfReactions().remove(n); - } - - /** - * Removes a reaction from the model. - * - * @param reac - * @return true if the {@link Reaction} was found and removed. - */ - public boolean removeReaction(Reaction reac) { - return getListOfReactions().remove(reac); - } - - /** - * Removes the {@link Reaction} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - */ - public Reaction removeReaction(String id) { - return getListOfReactions().removeFirst(new NameFilter(id)); - } - - /** - * Removes the i-th {@link Rule} of the {@link Model}. - * - * @param i - * @return the removed element. - */ - public Rule removeRule(int i) { - return getListOfRules().remove(i); - } - - /** - * Removes the {@link Rule} of the {@link Model} with 'variableId' as - * variable. - * - * @param variableId - * @return the removed element. - */ - public Rule removeRule(String variableId) { - return getListOfRules().removeFirst( - new AssignmentVariableFilter(variableId)); - } - - /** - * Removes the i-th {@link Species} of the {@link Model}. - * - * @param i - * @return the removed element. - */ - public Species removeSpecies(int i) { - return getListOfSpecies().remove(i); - } - - /** - * Removes a species from the model. - * - * @param spec - * @return true if the {@link Species} was found and removed. - */ - public boolean removeSpecies(Species spec) { - return getListOfSpecies().remove(spec); - } - - /** - * Removes the {@link Species} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - */ - public Species removeSpecies(String id) { - return getListOfSpecies().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link SpeciesType} of the {@link Model}. - * - * @param n - * @return the removed element. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType removeSpeciesType(int n) { - return getListOfSpeciesTypes().remove(n); - } - - /** - * Removes the {@link SpeciesType} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public SpeciesType removeSpeciesType(String id) { - return getListOfSpeciesTypes().removeFirst(new NameFilter(id)); - } - - /** - * Removes the n-th {@link UnitDefinition} of the {@link Model}. - * - * @param n - * @return the removed element. - */ - public UnitDefinition removeUnitDefinition(int n) { - return getListOfUnitDefinitions().remove(n); - } - - /** - * Removes the {@link UnitDefinition} of the {@link Model} with 'id' as id. - * - * @param id - * @return the removed element. - */ - public UnitDefinition removeUnitDefinition(String id) { - return getListOfUnitDefinitions().removeFirst(new NameFilter(id)); - } - - /** - * Removes a {@link UnitDefinition} of the {@link Model}. - * - * @param unitDefininition - * @return true if the UnitDefinition 'unitDefinition' has been removed from - * the Model. - */ - public boolean removeUnitDefinition(UnitDefinition unitDefininition) { - return getListOfUnitDefinitions().remove(unitDefininition); - } - - /** - * Sets the areaUnitsID of this {@link Model} to 'areaUnitsID' - * - * @param areaUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setAreaUnits(String areaUnitsID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.areaUnits, - this); - } - String oldAreaUnitsID = this.areaUnitsID; - this.areaUnitsID = areaUnitsID; - firePropertyChange(TreeNodeChangeEvent.areaUnits, oldAreaUnitsID, - areaUnitsID); - } - - /** - * Sets the areaUnitsID of this {@link Model} to the id of the - * {@link UnitDefinition} 'areaUnits'. - * - * @param areaUnits - */ - public void setAreaUnits(UnitDefinition areaUnits) { - if (!getListOfUnitDefinitions().contains(areaUnits)) { - addUnitDefinition(areaUnits); - } - setAreaUnits(areaUnits != null ? areaUnits.getId() : null); - } - - /** - * Sets the conversionFactorID of this {@link Model} to the id of the - * {@link Parameter} 'conversionFactor'. - * - * @param conversionFactor - */ - public void setConversionFactor(Parameter conversionFactor) { - setConversionFactor(conversionFactor != null ? conversionFactor.getId() - : null); - } - - /** - * Sets the conversionFactorID of this {@link Model} to - * 'conversionFactorID'. - * - * @param conversionFactorID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setConversionFactor(String conversionFactorID) { - if (getLevel() < 3) { throw new PropertyNotAvailableException( - TreeNodeChangeEvent.conversionFactor, this); } - String oldConversionFactorID = this.conversionFactorID; - this.conversionFactorID = conversionFactorID; - firePropertyChange(TreeNodeChangeEvent.conversionFactor, - oldConversionFactorID, conversionFactorID); - } - - /** - * Sets the extendUnitsID of this {@link Model} to 'extentUnitsID'. - * - * @param extentUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setExtentUnits(String extentUnitsID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.extentUnits, this); - } - String oldExtentUnits = this.extentUnitsID; - this.extentUnitsID = extentUnitsID; - firePropertyChange(TreeNodeChangeEvent.extentUnits, oldExtentUnits, - extentUnitsID); - } - - /** - * Sets the extentUnitsID of this {@link Model} to the id of the - * {@link UnitDefinition} 'extentUnits'. - * - * @param extentUnits - */ - public void setExtentUnits(UnitDefinition extentUnits) { - if (!getListOfUnitDefinitions().contains(extentUnits)) { - addUnitDefinition(extentUnits); - } - setExtentUnits(extentUnits != null ? extentUnits.getId() : null); - } - - /** - * Sets the lengthUnitsID of this {@link Model} to 'lengthUnitsID'. - * - * @param lengthUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setLengthUnits(String lengthUnitsID) { - if (getLevel() < 3) { throw new PropertyNotAvailableException( - TreeNodeChangeEvent.lengthUnits, this); } - String oldLengthUnits = this.lengthUnitsID; - this.lengthUnitsID = lengthUnitsID; - firePropertyChange(TreeNodeChangeEvent.lengthUnits, oldLengthUnits, - lengthUnitsID); - } - - /** - * Sets the lengthUnitsID of this {@link Model} to the id of the - * UnitDefinition 'lengthUnits'. - * - * @param lengthUnits - */ - public void setLengthUnits(UnitDefinition lengthUnits) { - if (!getListOfUnitDefinitions().contains(lengthUnits)) { - addUnitDefinition(lengthUnits); - } - setLengthUnits(lengthUnits != null ? lengthUnits.getId() : null); - } - - /** - * Sets the listOfCompartments of this {@link Model} to 'listOfCompartments'. - * Automatically sets the parentSBML objects of 'listOfCompartments' to this - * Model. - * - * @param listOfCompartments - */ - public void setListOfCompartments(ListOf listOfCompartments) { - unsetListOfCompartments(); - this.listOfCompartments = listOfCompartments; - if ((this.listOfCompartments != null) - && (this.listOfCompartments.getSBaseListType() != ListOf.Type.listOfCompartments)) { - this.listOfCompartments.setSBaseListType(ListOf.Type.listOfCompartments); - } - registerChild(this.listOfCompartments); - } - - /** - * Sets the listOfCompartmentTypes of this Model to 'listOfCompartmentTypes'. - * Automatically sets the parentSBML objects of 'listOfCompartmentTypes' to - * this {@link Model}. - * - * @param listOfCompartmentTypes - * the listOfCompartmentTypes to set - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public void setListOfCompartmentTypes( - ListOf listOfCompartmentTypes) { - unsetListOfCompartmentTypes(); - this.listOfCompartmentTypes = listOfCompartmentTypes; - if ((this.listOfCompartmentTypes != null) - && (this.listOfCompartmentTypes.getSBaseListType() != ListOf.Type.listOfCompartmentTypes)) { - this.listOfCompartmentTypes - .setSBaseListType(ListOf.Type.listOfCompartmentTypes); - } - registerChild(this.listOfCompartmentTypes); - } - - /** - * Sets the listOfConstraints of this {@link Model} to 'listOfConstraints'. - * Automatically sets the parentSBML objects of 'listOfCanstraints' to this - * Model. - * - * @param listOfConstraints - * the listOfConstraints to set - */ - public void setListOfConstraints(ListOf listOfConstraints) { - unsetListOfConstraints(); - this.listOfConstraints = listOfConstraints; - if ((this.listOfConstraints != null) - && (this.listOfConstraints.getSBaseListType() != ListOf.Type.listOfConstraints)) { - this.listOfConstraints.setSBaseListType(ListOf.Type.listOfConstraints); - } - registerChild(this.listOfConstraints); - } - - /** - * Sets the listOfEvents of this {@link Model} to 'listOfEvents'. - * Automatically sets the parentSBML objects of 'listOfEvents' to this - * {@link Model}. - * - * @param listOfEvents - */ - public void setListOfEvents(ListOf listOfEvents) { - unsetListOfEvents(); - this.listOfEvents = listOfEvents; - if ((this.listOfEvents != null) - && (this.listOfEvents.getSBaseListType() != ListOf.Type.listOfEvents)) { - this.listOfEvents.setSBaseListType(ListOf.Type.listOfEvents); - } - registerChild(this.listOfEvents); - } - - /** - * Sets the listOfFunctionDefinitions of this {@link Model} to - * 'listOfFunctionDefinitions'. Automatically sets the parentSBML objects of - * 'listOfFunctionDefinitions' to this Model. - * - * @param listOfFunctionDefinitions - * the listOfFunctionDefinitions to set - */ - public void setListOfFunctionDefinitions( - ListOf listOfFunctionDefinitions) { - unsetListOfFunctionDefinitions(); - this.listOfFunctionDefinitions = listOfFunctionDefinitions; - if ((this.listOfFunctionDefinitions != null) - && (this.listOfFunctionDefinitions.getSBaseListType() != ListOf.Type.listOfFunctionDefinitions)) { - this.listOfFunctionDefinitions - .setSBaseListType(ListOf.Type.listOfFunctionDefinitions); - } - registerChild(this.listOfFunctionDefinitions); - } - - /** - * Sets the {@link #listOfInitialAssignments} of this {@link Model} to - * 'listOfInitialAssignments'. Automatically sets the parentSBML objects of - * 'listOfInitialAssignments' to this Model. - * - * @param listOfInitialAssignments - * the listOfInitialAssignments to set - */ - public void setListOfInitialAssignments( - ListOf listOfInitialAssignments) { - unsetListOfInitialAssignments(); - this.listOfInitialAssignments = listOfInitialAssignments; - if ((this.listOfInitialAssignments != null) - && (this.listOfInitialAssignments.getSBaseListType() != ListOf.Type.listOfInitialAssignments)) { - this.listOfInitialAssignments - .setSBaseListType(ListOf.Type.listOfInitialAssignments); - } - registerChild(this.listOfInitialAssignments); - } - - /** - * Sets the {@link #listOfParameters} of this {@link Model} to - * 'listOfParameters'. Automatically sets the parentSBML objects of - * 'listOfParameters' to this Model. - * - * @param listOfParameters - */ - public void setListOfParameters(ListOf listOfParameters) { - unsetListOfParameters(); - this.listOfParameters = listOfParameters; - if ((this.listOfParameters != null) - && (this.listOfParameters.getSBaseListType() != ListOf.Type.listOfParameters)) { - this.listOfParameters.setSBaseListType(ListOf.Type.listOfParameters); - } - registerChild(listOfParameters); - } - - /** - * Sets the {@link #listOfReactions} of this {@link Model} to - * 'listOfReactions'. Automatically sets the parentSBML objects of - * 'listOfReactions' to this Model. - * - * @param listOfReactions - */ - public void setListOfReactions(ListOf listOfReactions) { - unsetListOfReactions(); - this.listOfReactions = listOfReactions; - if ((this.listOfReactions != null) - && (this.listOfReactions.getSBaseListType() != ListOf.Type.listOfReactions)) { - this.listOfReactions.setSBaseListType(ListOf.Type.listOfReactions); - } - registerChild(this.listOfReactions); - } - - /** - * Sets the {@link #listOfRules} of this {@link Model} to 'listOfRules'. - * Automatically sets the parentSBML objects of 'listOfRules' to this Model. - * - * @param listOfRules - */ - public void setListOfRules(ListOf listOfRules) { - unsetListOfRules(); - this.listOfRules = listOfRules; - if ((this.listOfRules != null) - && (this.listOfRules.getSBaseListType() != ListOf.Type.listOfRules)) { - this.listOfRules.setSBaseListType(ListOf.Type.listOfRules); - } - registerChild(this.listOfRules); - } - - /** - * Sets the listOfSpecies of this {@link Model} to 'listOfSpecies'. - * Automatically sets the parentSBML objects of 'listOfSpecies' to this Model. - * - * @param listOfSpecies - */ - public void setListOfSpecies(ListOf listOfSpecies) { - unsetListOfSpecies(); - this.listOfSpecies = listOfSpecies; - if ((this.listOfSpecies != null) - && (this.listOfSpecies.getSBaseListType() != ListOf.Type.listOfSpecies)) { - this.listOfSpecies.setSBaseListType(ListOf.Type.listOfSpecies); - } - registerChild(this.listOfSpecies); - } - - /** - * Sets the listOfSpeciesTypes of this Model to 'listOfSpeciesTypes'. - * Automatically sets the parentSBML objects of 'listOfSpeciesTypes' to this - * Model. - * - * @param listOfSpeciesTypes - * the listOfSpeciesTypes to set - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public void setListOfSpeciesTypes(ListOf listOfSpeciesTypes) { - unsetListOfSpeciesTypes(); - this.listOfSpeciesTypes = listOfSpeciesTypes; - if ((this.listOfSpeciesTypes != null) - && (this.listOfSpeciesTypes.getSBaseListType() != ListOf.Type.listOfSpeciesTypes)) { - this.listOfSpeciesTypes.setSBaseListType(ListOf.Type.listOfSpeciesTypes); - } - registerChild(this.listOfSpeciesTypes); - } - - /** - * Sets the listOfUnitDefinitions of this {@link Model} to - * 'listOfUnitDefinitions'. Automatically sets the parentSBML objects of - * 'listOfUnitDefinitions' to this Model. - * - * @param listOfUnitDefinitions - */ - public void setListOfUnitDefinitions( - ListOf listOfUnitDefinitions) { - unsetListOfUnitDefinitions(); - this.listOfUnitDefinitions = listOfUnitDefinitions; - if ((this.listOfUnitDefinitions != null) - && (this.listOfUnitDefinitions.getSBaseListType() != ListOf.Type.listOfUnitDefinitions)) { - this.listOfUnitDefinitions - .setSBaseListType(ListOf.Type.listOfUnitDefinitions); - } - registerChild(this.listOfUnitDefinitions); - } - - /** - * @see #setHistory(History history) - * @param history - * @deprecated use {@link #setHistory(History)} - */ - @Deprecated - public void setModelHistory(History history) { - setHistory(history); - } - - /** - * Sets the {@link #substanceUnitsID} of this {@link Model} to 'substanceUnitsID' - * - * @param substanceUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setSubstanceUnits(String substanceUnitsID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.substanceUnits, this); - } - String oldSubstanceUnitsID = this.substanceUnitsID; - this.substanceUnitsID = substanceUnitsID; - firePropertyChange(TreeNodeChangeEvent.substanceUnits, oldSubstanceUnitsID, - substanceUnitsID); - } - - /** - * Sets the substanceUnitsID of this {@link Model} to the id of - * 'substanceUnits'. - * - * @param substanceUnits - */ - public void setSubstanceUnits(UnitDefinition substanceUnits) { - if (!getListOfUnitDefinitions().contains(substanceUnits)) { - addUnitDefinition(substanceUnits); - } - setSubstanceUnits(substanceUnits != null ? substanceUnits.getId() : null); - } - - /** - * Sets the timeUnits of this {@link Model} to 'timeUnistID' - * - * @param timeUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setTimeUnits(String timeUnitsID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.timeUnits, this); - } - String oldTimeUnitsID = this.timeUnitsID; - this.timeUnitsID = timeUnitsID; - firePropertyChange(TreeNodeChangeEvent.timeUnits, oldTimeUnitsID, - timeUnitsID); - } - - /** - * Sets the timeUnitsID of this {@link Model} to the id of the - * {@link UnitDefinition} 'timeUnits'. - * - * @param timeUnits - */ - public void setTimeUnits(UnitDefinition timeUnits) { - if (!getListOfUnitDefinitions().contains(timeUnits)) { - addUnitDefinition(timeUnits); - } - setTimeUnits(timeUnits != null ? timeUnits.getId() : null); - } - - /** - * Sets the volumeUnitsID of this {@link Model} to 'volumeUnitsID' - * - * @param volumeUnitsID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setVolumeUnits(String volumeUnitsID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.volumeUnits, - this); - } - String oldVolumeUnitsID = this.volumeUnitsID; - this.volumeUnitsID = volumeUnitsID; - firePropertyChange(TreeNodeChangeEvent.volumeUnits, oldVolumeUnitsID, - this.volumeUnitsID); - } - - /** - * Sets the volumeUnitsID of this {@link Model} to the id of the - * {@link UnitDefinition} 'volumeUnits'. - * - * @param volumeUnits - */ - public void setVolumeUnits(UnitDefinition volumeUnits) { - if (!getListOfUnitDefinitions().contains(volumeUnits)) { - addUnitDefinition(volumeUnits); - } - setVolumeUnits(volumeUnits != null ? volumeUnits.getId() : null); - } - - /** - * Sets the {@link #areaUnitsID} of this {@link Model} to null. - */ - public void unsetAreaUnits() { - setAreaUnits((String) null); - } - - /** - * Sets the {@link #conversionFactorID} of this {@link Model} to null. - */ - public void unsetConversionFactor() { - setConversionFactor((String) null); - } - - /** - * Sets the {@link #extentUnitsID} of this {@link Model} to null. - */ - public void unsetExtentUnits() { - setExtentUnits((String) null); - } - - /** - * Sets the {@link #lengthUnitsID} of this {@link Model} to null. - */ - public void unsetLengthUnits() { - setLengthUnits((String) null); - } - - /** - * Removes the {@link #listOfCompartments} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfCompartments() { - if (this.listOfCompartments != null) { - ListOf oldListOfCompartments = this.listOfCompartments; - this.listOfCompartments = null; - oldListOfCompartments.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfCompartmentTypes} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean unsetListOfCompartmentTypes() { - if (this.listOfCompartmentTypes != null) { - ListOf oldListOfCompartmentTypes = this.listOfCompartmentTypes; - this.listOfCompartmentTypes = null; - oldListOfCompartmentTypes.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfConstraints} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfConstraints() { - if (this.listOfConstraints != null) { - ListOf oldListOfConstraints = this.listOfConstraints; - this.listOfConstraints = null; - oldListOfConstraints.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfEvents} from this {@link Model} and notifies all - * registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfEvents() { - if (this.listOfEvents != null) { - ListOf oldListOfEvents = this.listOfEvents; - this.listOfEvents = null; - oldListOfEvents.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfFunctionDefinitions} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfFunctionDefinitions() { - if (this.listOfFunctionDefinitions != null) { - ListOf oldListOfFunctionDefinitions = this.listOfFunctionDefinitions; - this.listOfFunctionDefinitions = null; - oldListOfFunctionDefinitions.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfInitialAssignments} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfInitialAssignments() { - if (this.listOfInitialAssignments != null) { - ListOf oldListOfInitialAssignments = this.listOfInitialAssignments; - this.listOfInitialAssignments = null; - oldListOfInitialAssignments.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfParameters} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfParameters() { - if (this.listOfParameters != null) { - ListOf oldListOfParameters = this.listOfParameters; - this.listOfParameters = null; - oldListOfParameters.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfReactions} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfReactions() { - if (this.listOfReactions != null) { - ListOf oldListOfReactions = this.listOfReactions; - this.listOfReactions = null; - oldListOfReactions.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfRules} from this {@link Model} and notifies all - * registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfRules() { - if (this.listOfRules != null) { - ListOf oldListOfRules = this.listOfRules; - this.listOfRules = null; - oldListOfRules.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfSpecies} from this {@link Model} and notifies all - * registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfSpecies() { - if (this.listOfSpecies != null) { - ListOf oldListOfSpecies = this.listOfSpecies; - this.listOfSpecies = null; - oldListOfSpecies.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfSpeciesTypes} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ - @Deprecated - public boolean unsetListOfSpeciesTypes() { - if (this.listOfSpeciesTypes != null) { - ListOf oldListOfSpeciesTypes = this.listOfSpeciesTypes; - this.listOfSpeciesTypes = null; - oldListOfSpeciesTypes.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfUnitDefinitions} from this {@link Model} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfUnitDefinitions() { - if (this.listOfUnitDefinitions != null) { - ListOf oldListOfUnitDefinitions = this.listOfUnitDefinitions; - this.listOfUnitDefinitions = null; - oldListOfUnitDefinitions.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * @see #unsetHistory() - * @deprecated use {@link #unsetHistory()}. - */ - @Deprecated - public void unsetModelHistory() { - unsetHistory(); - } - - /** - * Sets the {@link #substanceUnitsID} of this {@link Model} to null. - */ - public void unsetSubstanceUnits() { - setSubstanceUnits((String) null); - } - - /** - * Sets the timeUnitsID of this {@link Model} to null. - */ - public void unsetTimeUnits() { - setTimeUnits((String) null); - } - - /** - * Sets the {@link #volumeUnitsID} of this {@link Model} to null. - */ - public void unsetVolumeUnits() { - setVolumeUnits((String) null); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (getLevel() > 2) { - if (isSetSubstanceUnits()) { - attributes.put("substanceUnits", getSubstanceUnits()); - } - if (isSetTimeUnits()) { - attributes.put("timeUnits", getTimeUnits()); - } - if (isSetVolumeUnits()) { - attributes.put("volumeUnits", getVolumeUnits()); - } - if (isSetAreaUnits()) { - attributes.put("areaUnits", getAreaUnits()); - } - if (isSetLengthUnits()) { - attributes.put("lengthUnits", getLengthUnits()); - } - if (isSetExtentUnits()) { - attributes.put("extentUnits", getExtentUnits()); - } - if (isSetConversionFactor()) { - attributes.put("conversionFactor", getConversionFactor()); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ModifierSpeciesReference.java b/IPK_lib/src/org/sbml/jsbml/ModifierSpeciesReference.java deleted file mode 100644 index b604f9be6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ModifierSpeciesReference.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * $Id: ModifierSpeciesReference.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ModifierSpeciesReference.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * Represents the modifierSpeciesReference XML element of a SBML file. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class ModifierSpeciesReference extends SimpleSpeciesReference { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 6033910247622532704L; - - /** - * Creates a ModifierSpeciesReference instance. - */ - public ModifierSpeciesReference() { - super(); - } - - /** - * - * @param level - * @param version - */ - public ModifierSpeciesReference(int level, int version) { - super(level, version); - } - - /** - * Creates a ModifierSpeciesReference instance from a given - * ModifierSpeciesReference. - * - * @param modifierSpeciesReference - */ - public ModifierSpeciesReference( - ModifierSpeciesReference modifierSpeciesReference) { - super(modifierSpeciesReference); - } - - /** - * Creates a ModifierSpeciesReference instance from a given Species. - * - * @param modifierSpeciesReference - */ - public ModifierSpeciesReference(Species species) { - super(species); - } - - /** - * - * @param id - */ - public ModifierSpeciesReference(String id) { - super(id); - } - - /** - * - * @param id - * @param level - * @param version - */ - public ModifierSpeciesReference(String id, int level, int version) { - super(id, level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#clone() - */ - @Override - public ModifierSpeciesReference clone() { - return new ModifierSpeciesReference(this); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/NamedSBase.java b/IPK_lib/src/org/sbml/jsbml/NamedSBase.java deleted file mode 100644 index cfc912645..000000000 --- a/IPK_lib/src/org/sbml/jsbml/NamedSBase.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * $Id: NamedSBase.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/NamedSBase.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * Base class for all the SBML components with an id and a name (optional or - * not). - * - * @author Andreas Dräger - * @author marine - * @since 0.8 - * @version $Rev: 1169 $ - */ -public interface NamedSBase extends SBase { - - /** - * - * @return the id of the element if it is set, an empty string otherwise. - */ - public String getId(); - - /** - * - * @return the name of the element if it is set, an empty string otherwise. - */ - public String getName(); - - /** - * This method can be used to query if the identifier of this - * {@link NamedSBase} is required to be defined (i.e., not null) - * in the definition of SBML. - * - * @return true if the identifier of this element must be set in - * order to create a valid SBML representation. false - * otherwise, i.e., if the identifier can be understood as an optional - * attribute. - */ - public boolean isIdMandatory(); - - /** - * - * @return true if the id is not null. - */ - public boolean isSetId(); - - /** - * - * @return true if the name is not null. - */ - public boolean isSetName(); - - /** - * sets the id value with 'id' - * - * @param id - */ - public void setId(String id); - - /** - * sets the name value with 'name'. If level is 1, sets automatically the id - * to 'name' - * - * @param name - */ - public void setName(String name); - - /** - * sets the id value to null. - */ - public void unsetId(); - - /** - * sets the name value to null. - */ - public void unsetName(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/NamedSBaseWithDerivedUnit.java b/IPK_lib/src/org/sbml/jsbml/NamedSBaseWithDerivedUnit.java deleted file mode 100644 index df1997dc3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/NamedSBaseWithDerivedUnit.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * $Id: NamedSBaseWithDerivedUnit.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/NamedSBaseWithDerivedUnit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * All objects that implement this interface can be referenced in abstract - * syntax trees as implemented in {@link ASTNode}. The necessary requirement for - * this is that these objects can be accessed with an identifier and are - * associated with some value that can be evaluated to a unit. The value may be - * defined within the class or have to be computed in a simulation. - * - * @author Andreas Dräger - * @date 2010-04-22 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface NamedSBaseWithDerivedUnit extends NamedSBase, - SBaseWithDerivedUnit { - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Parameter.java b/IPK_lib/src/org/sbml/jsbml/Parameter.java deleted file mode 100644 index ee4506398..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Parameter.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * $Id: Parameter.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Parameter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Locale; -import java.util.Map; - -import org.sbml.jsbml.util.StringTools; - -/** - * Represents a globally valid parameter in the model, i.e., a variable that - * may change during a simulation or that provides a constant value. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Parameter extends Symbol { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 3300762892435768291L; - - /** - * Creates a Parameter instance. - */ - public Parameter() { - super(); - initDefaults(); - } - - /** - * Creates a Parameter instance from an id, level and version. - * - * @param id - * @param level - * @param version - */ - public Parameter(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * This constructor allows the creation of a global {@link Parameter} based on a - * {@link LocalParameter}. It creates a new {@link Parameter} object that will have the - * same attributes than the {@link LocalParameter}. Its constant attribute will be - * set to true. - * - * @param localParameter - */ - public Parameter(LocalParameter localParameter) { - super(localParameter); - if (getLevel() != 1) { - // This is necessary because in Level 1 this attribute is not defined. - setConstant(true); - } - } - - /** - * Creates a Parameter instance from a given Parameter. - * - * @param p - */ - public Parameter(Parameter p) { - super(p); - } - - /** - * - * @param id - */ - public Parameter(String id) { - this(); - setId(id); - } - - /** - * - * @param id - */ - public Parameter(String id, int level, int version) { - super(id, level, version); - initDefaults(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#clone() - */ - public Parameter clone() { - return new Parameter(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getPredefinedUnitID() - */ - public String getPredefinedUnitID() { - return null; - } - - /** - * Initializes the default values of this {@link Parameter}, i.e., sets it to a - * constant variable with a NaN value. - */ - public void initDefaults(int level, int version) { - value = Double.NaN; - - if (level > 1) { - constant = true; - } - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("value")) { - setValue(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("units")) { - setUnits(value); - } else if (attributeName.equals("constant")) { - setConstant(StringTools.parseSBMLBoolean(value)); - } else { - isAttributeRead = false; - } - } - - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Symbol#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetValue()) { - attributes.put("value", StringTools.toString(Locale.ENGLISH, - getValue())); - } - if (isSetUnits()) { - attributes.put("units", getUnits()); - } - if (isSetConstant() && (getLevel() > 1)) { - attributes.put("constant", Boolean.toString(getConstant())); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Priority.java b/IPK_lib/src/org/sbml/jsbml/Priority.java deleted file mode 100644 index e6c49b242..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Priority.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * $Id: Priority.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Priority.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * This class represents the priority element in SBML. - * - * @author Andreas Dräger - * @date 2010-10-21 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Priority extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 391689890391156873L; - - /** - * - */ - public Priority() { - super(); - } - - /** - * @param math - * @param level - * @param version - */ - public Priority(ASTNode math, int level, int version) { - super(math, level, version); - if (isSetLevel() && (getLevel() < 3)) { - throw new IllegalArgumentException("Cannot create Priority element with Level < 3."); - } - } - - /** - * @param level - * @param version - */ - public Priority(int level, int version) { - super(level, version); - if (isSetLevel() && (getLevel() < 3)) { - throw new IllegalArgumentException("Cannot create Priority element with Level < 3."); - } - } - - /** - * @param sb - */ - public Priority(Priority sb) { - super(sb); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - public Priority clone() { - return new Priority(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - public Event getParent() { - return (Event) super.getParent(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/PropertyException.java b/IPK_lib/src/org/sbml/jsbml/PropertyException.java deleted file mode 100644 index 43ef0e1e5..000000000 --- a/IPK_lib/src/org/sbml/jsbml/PropertyException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * $Id: PropertyException.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/PropertyException.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -/** - * This is an error of an undefined property or value for a propterty in some - * instance of {@link SBase}. - * - * @author Andreas Dräger - * @version $Rev: 1169 $ - * @since 0.8 - * @date 24.03.2011 - */ -public abstract class PropertyException extends SBMLError { - - /** - * Generated serial version identifier - */ - private static final long serialVersionUID = -3416620362835594659L; - - /** - * - */ - public PropertyException() { - super(); - } - - /** - * @param message - */ - public PropertyException(String message) { - super(message); - } - - /** - * Creates an error message pointing out that the property of the given name is not defined - * in the Level/Version combination of the given {@link SBase}. - * - * @param property - * @param sbase - * @return - */ - static String createMessage(String baseMessage, String property, SBase sbase) { - return String.format(baseMessage, property, sbase - .getElementName(), Integer.valueOf(sbase.getLevel()), Integer - .valueOf(sbase.getVersion())); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBMLError#toString() - */ - @Override - public String toString() { - return getMessage(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/PropertyNotAvailableException.java b/IPK_lib/src/org/sbml/jsbml/PropertyNotAvailableException.java deleted file mode 100644 index 8e1f51e30..000000000 --- a/IPK_lib/src/org/sbml/jsbml/PropertyNotAvailableException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * $Id: PropertyNotAvailableException.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/PropertyNotAvailableException.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * An error that indicates that a property of an {@link SBase} is - * not available for the current SBML Level/Version combination. - * - * @author Andreas Dräger - * @date 2010-11-21 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class PropertyNotAvailableException extends PropertyException { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 3030431702957624218L; - - /** - * Message to indicate that a certain property cannot be set for the current - * level/version combination. - */ - public static final String PROPERTY_UNDEFINED_EXCEPTION_MSG = "Property %s is not defined in %s for Level %d and Version %d."; - - /** - * - * @param property - * @param sbase - */ - public PropertyNotAvailableException(String property, SBase sbase) { - super(createMessage(PROPERTY_UNDEFINED_EXCEPTION_MSG, property, sbase)); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/PropertyUndefinedError.java b/IPK_lib/src/org/sbml/jsbml/PropertyUndefinedError.java deleted file mode 100644 index 6d448ff41..000000000 --- a/IPK_lib/src/org/sbml/jsbml/PropertyUndefinedError.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * $Id: PropertyUndefinedError.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/PropertyUndefinedError.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -/** - * This {@link PropertyException} indicates that the value belonging to a mandatory - * property, for which there is no default value, has not been declared by the - * user. - * - * @author Andreas Dräger - * @version $Rev: 1116 $ - * @since 0.8 - * @date 24.03.2011 - */ -public class PropertyUndefinedError extends PropertyException { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 2990146647017147195L; - - /** - * Message to indicate that a certain property has not been set for the - * current {@link SBase} in its level/version combination. - */ - public static final String PROPERTY_UNDEFINED_EXCEPTION_MSG = "The value for property %s is not defined in %s for Level %d and Version %d."; - - /** - * @param property - * @param sbase - */ - public PropertyUndefinedError(String property, SBase sbase) { - super(createMessage(PROPERTY_UNDEFINED_EXCEPTION_MSG, property, sbase)); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Quantity.java b/IPK_lib/src/org/sbml/jsbml/Quantity.java deleted file mode 100644 index 6b9a3b295..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Quantity.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * $Id: Quantity.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Quantity.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * A quantity is an element that represents a value with an associated unit that - * can be addressed through the identifier or name attribute of this element. - * Both the value and the unit may be directly declared by the quantity or may - * have to be derived. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @date 2010-04-20 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface Quantity extends CallableSBase { - - /** - * Returns the value of this {@link Quantity}. - * - * In {@link Compartment}s the value is its size, in {@link Species} the - * value defines its initial amount or concentration, and in - * {@link Parameter}s and {@link LocalParameter}s this returns the value - * attribute from SBML. - * - * @return the value - */ - public double getValue(); - - /** - * Returns true if the value of this {@link Quantity} is set. - * - * @return true if the value of this {@link Quantity} is set. - */ - public boolean isSetValue(); - - /** - * Sets the value of this {@link Quantity}. - * - * Note that the meaning of the value can be different in all derived - * classes. In {@link Compartment}s the value defines its size. In - * {@link Species} the value describes either the initial amount or the - * initial concentration. Only the class {@link Parameter} and - * {@link LocalParameter} really define a value attribute with this name. - * - * @param value - * the value to set - */ - public void setValue(double value); - - /** - * Unsets the value of this {@link Quantity}. - * - */ - public void unsetValue(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/QuantityWithUnit.java b/IPK_lib/src/org/sbml/jsbml/QuantityWithUnit.java deleted file mode 100644 index ddee7f331..000000000 --- a/IPK_lib/src/org/sbml/jsbml/QuantityWithUnit.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * $Id: QuantityWithUnit.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/QuantityWithUnit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - - -/** - * This object represents an element with identifier and name, a value, and a - * defined unit. In particular, this class defines methods to access and - * manipulate the value and the unit properties of an element within a model. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @date 2010-04-20 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public abstract class QuantityWithUnit extends AbstractNamedSBaseWithUnit - implements Quantity { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -9088772458214208160L; - - /** - * a boolean to help knowing is the value as been set by the user or is the - * default one. - */ - private boolean isSetValue = false; - /** - * The size, initial amount or concentration, or the actual value of this - * variable. - */ - /* - * Visibility modified to allow children classes to set a default value - * without having the isSetValue returning true. - */ - protected Double value = Double.NaN; - - /** - * - */ - public QuantityWithUnit() { - super(); - } - - /** - * - * @param level - * @param version - */ - public QuantityWithUnit(int level, int version) { - this(null, null, level, version); - } - - /** - * - * @param qwdu - */ - public QuantityWithUnit(QuantityWithUnit qwdu) { - super(qwdu); - if (qwdu.isSetValue()) { - this.value = new Double(qwdu.getValue()); - isSetValue = true; - } else { - this.value = qwdu.value == null ? null : new Double(qwdu.value); - } - } - - /** - * - * @param id - */ - public QuantityWithUnit(String id) { - this(); - setId(id); - } - - /** - * - * @param id - * @param level - * @param version - */ - public QuantityWithUnit(String id, int level, int version) { - super(id, null, level, version); - } - - /** - * - * @param id - * @param name - * @param level - * @param version - */ - public QuantityWithUnit(String id, String name, int level, - int version) { - super(id, name, level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#clone() - */ - public abstract QuantityWithUnit clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - QuantityWithUnit v = (QuantityWithUnit) object; - if (!(Double.isNaN(v.getValue()) && Double.isNaN(getValue()))) { - equals &= v.getValue() == getValue(); - } else { - equals &= (Double.isNaN(v.getValue()) && Double - .isNaN(getValue())); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#getValue() - */ - public double getValue() { - return value != null ? value : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#hashCode() - */ - @Override - public int hashCode() { - final int prime = 907; - int hashCode = super.hashCode(); - if (isSetValue()) { - hashCode += prime * value.hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#isSetValue() - */ - public boolean isSetValue() { - return isSetValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#setValue(double) - */ - public void setValue(double value) { - Double oldValue = this.value; - this.value = value; - isSetValue = true; - if (value != oldValue) { - firePropertyChange(TreeNodeChangeEvent.value, oldValue, value); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#unsetValue() - */ - public void unsetValue() { - if (!Double.isNaN(this.value)) { - Double oldValue = value; - value = Double.NaN; - isSetValue = false; - firePropertyChange(TreeNodeChangeEvent.value, oldValue, value); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/RateRule.java b/IPK_lib/src/org/sbml/jsbml/RateRule.java deleted file mode 100644 index 00f9c6bca..000000000 --- a/IPK_lib/src/org/sbml/jsbml/RateRule.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * $Id: RateRule.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/RateRule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * - * Represents the rateRule XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class RateRule extends ExplicitRule { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -1631920547145001765L; - - /** - * Creates a RateRule instance. By default, the variableID is null. - */ - public RateRule() { - super(); - } - - /** - * - * @param math - * @param level - * @param version - */ - public RateRule(ASTNode math, int level, int version) { - super(math, level, version); - } - - /** - * - * @param math - * @param parameter - */ - public RateRule(ASTNode math, Parameter parameter) { - this(parameter, math); - } - - /** - * - * @param variable - * @param math - */ - public RateRule(ASTNode math, Variable variable) { - this(variable, math); - } - - /** - * Creates a RateRule instance from a given RateRule. - * - * @param sb - */ - public RateRule(int level, int version) { - super(level, version); - } - - /** - * - * @param parameter - */ - public RateRule(Parameter parameter) { - super(parameter); - } - - /** - * - * @param parameter - * @param math - */ - public RateRule(Parameter parameter, ASTNode math) { - super(parameter, math); - } - - /** - * @param sb - */ - public RateRule(RateRule sb) { - super(sb); - } - - /** - * Creates a RateRule instance from a given Symbol. Takes level and version - * from the variable. - * - * @param variable - */ - public RateRule(Variable variable) { - super(variable); - } - - /** - * Creates a RateRule instance cloned from the given {@link ExplicitRule} - * - * @param rule - */ - public RateRule(ExplicitRule rule) { - super(rule); - } - - /** - * Creates a RateRule instance from a given Symbol and ASTNode. Takes level - * and version from the variable. - * - * @param variable - * @param math - */ - public RateRule(Variable variable, ASTNode math) { - super(math, variable); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#clone() - */ - public RateRule clone() { - return new RateRule(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#isScalar() - */ - public boolean isScalar() { - return false; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Reaction.java b/IPK_lib/src/org/sbml/jsbml/Reaction.java deleted file mode 100644 index 8561359b7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Reaction.java +++ /dev/null @@ -1,1370 +0,0 @@ -/* - * $Id: Reaction.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Reaction.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.filters.NameFilter; -import org.sbml.jsbml.util.filters.SpeciesReferenceFilter; - -/** - * Represents the reaction XML element of a SBML file. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class Reaction extends AbstractNamedSBase implements CallableSBase, - UniqueNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 1385417662249487643L; - /** - * Represents the 'compartment' XML attribute of a reaction element. - */ - private String compartmentID; - /** - * Represents the 'fast' XML attribute of a reaction element. - */ - private Boolean fast; - /** - * Checks whether the {@link #fast} attribute has been set by using a default or - * by changing its value. - */ - private boolean isSetFast = false; - /** - * Checks whether the {@link #reversible} attribute has been set by using a default or - * by changing its value. - */ - private boolean isSetReversible = false; - /** - * Represents the 'kineticLaw' XML subNode of a reaction element. - */ - private KineticLaw kineticLaw; - /** - * Represents the 'listOfModifiers' XML subNode of a reaction element. - */ - private ListOf listOfModifiers; - /** - * Represents the 'listOfProducts' XML subNode of a reaction element. - */ - private ListOf listOfProducts; - /** - * Represents the 'listOfReactants' XML subNode of a reaction element. - */ - private ListOf listOfReactants; - /** - * Represents the 'reversible' XML attribute of a reaction element. - */ - private Boolean reversible; - - /** - * Creates a Reaction instance. By default, the compartmentID, kineticLaw, {@link #listOfReactants}, {@link #listOfProducts} and {@link #listOfModifiers} are - * empty. - */ - public Reaction() { - super(); - initDefaults(); - } - - /** - * @param id - */ - public Reaction(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * Creates a Reaction instance from a given reaction. - * - * @param reaction - */ - public Reaction(Reaction reaction) { - super(reaction); - - if (reaction.isSetFast()) { - setFast(new Boolean(reaction.getFast())); - } else { - fast = reaction.fast == null ? null : new Boolean(reaction.fast.booleanValue()); - } - if (reaction.isSetKineticLaw()) { - setKineticLaw(reaction.getKineticLaw().clone()); - } - if (reaction.isSetListOfReactants()) { - this.listOfReactants = (ListOf) reaction - .getListOfReactants().clone(); - registerChild(listOfReactants); - } - if (reaction.isSetListOfProducts()) { - this.listOfProducts = (ListOf) reaction - .getListOfProducts().clone(); - registerChild(listOfProducts); - } - if (reaction.isSetListOfModifiers()) { - this.listOfModifiers = (ListOf) reaction - .getListOfModifiers().clone(); - registerChild(listOfModifiers); - } - if (reaction.isSetReversible()) { - setReversible(reaction.getReversible()); - } else { - reversible = reaction.reversible == null ? null : new Boolean(reaction.reversible.booleanValue()); - } - } - - /** - * @param id - */ - public Reaction(String id) { - super(id); - initDefaults(); - } - - /** - * Creates a {@link Reaction} instance from an id, level and version. By default, - * the compartmentID, {@link #kineticLaw}, {@link #listOfReactants}, {@link #listOfProducts} and {@link #listOfModifiers} are empty. - * - * @param id - * @param level - * @param version - */ - public Reaction(String id, int level, int version) { - super(id, level, version); - initDefaults(); - } - - /** - * Adds a {@link ModifierSpeciesReference} instance to this {@link Reaction}. - * - * @param modspecref - * @return true if the {@link #listOfModifiers} was - * changed as a result of this call. - */ - public boolean addModifier(ModifierSpeciesReference modspecref) { - return getListOfModifiers().add(modspecref); - } - - /** - * Adds a {@link SpeciesReference} instance to the listOfProducts of this {@link Reaction}. - * - * @param specref - * @return true if the {@link #listOfProducts} was - * changed as a result of this call. - */ - public boolean addProduct(SpeciesReference specref) { - return getListOfProducts().add(specref); - } - - /** - * Adds a {@link SpeciesReference} instance to the listOfReactants of this {@link Reaction}. - * - * @param specref - * @return true if the {@link #listOfReactants} was - * changed as a result of this call. - */ - public boolean addReactant(SpeciesReference specref) { - return getListOfReactants().add(specref); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#clone() - */ - public Reaction clone() { - return new Reaction(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#containsUndeclaredUnits() - */ - public boolean containsUndeclaredUnits() { - return isSetKineticLaw() ? getKineticLaw().containsUndeclaredUnits() - : false; - } - - /** - * Creates a new {@link KineticLaw} object, installs it as this {@link Reaction}'s 'kineticLaw' sub-element, and returns it. - * If this {@link Reaction} had a previous KineticLaw, it will be destroyed. - * - * @return the new {@link KineticLaw} object - */ - public KineticLaw createKineticLaw() { - KineticLaw kl = new KineticLaw(this); - return kl; - } - - /** - * Creates a new {@link ModifierSpeciesReference}, adds it to this {@link Reaction}'s list of modifiers and returns it. - * - * @return a new {@link ModifierSpeciesReference} object. - */ - public ModifierSpeciesReference createModifier() { - return createModifier((String) null); - } - - /** - * Creates a new {@link ModifierSpeciesReference}, which points to the given {@link Species}, adds it to this {@link Reaction}'s {@link #listOfModifiers}, - * and returns a pointer to it. - * - * @param species - * the {@link Species} to which this modifier should point. - * @see #createModifier(String, Species) - */ - public ModifierSpeciesReference createModifier(Species species) { - return createModifier(null, species); - } - - /** - * @param id - * @return - */ - public ModifierSpeciesReference createModifier(String id) { - ModifierSpeciesReference modifier = new ModifierSpeciesReference(id, - getLevel(), getVersion()); - addModifier(modifier); - return modifier; - } - - /** - * Creates a new {@link ModifierSpeciesReference} with the given id as its identifier, which points to the given {@link Species}, adds it to - * this {@link Reaction}'s {@link #listOfModifiers}, and returns a pointer to it. - * - * @param id - * the identifier of the {@link ModifierSpeciesReference} to be - * created. - * @param species - * the {@link Species} to which this modifier should point. - * @return a pointer to the newly created {@link ModifierSpeciesReference}. - */ - public ModifierSpeciesReference createModifier(String id, Species species) { - ModifierSpeciesReference modSpecRef = createModifier(id); - modSpecRef.setSpecies(species); - return modSpecRef; - } - - /** - * Creates a new {@link ModifierSpeciesReference} with the given id as its identifier, which points to the {@link Species} with the given - * id, adds it to this {@link Reaction}'s {@link #listOfModifiers}, and returns a pointer to it. - * - * @param id - * the identifier of the {@link ModifierSpeciesReference} to be - * created. - * @param species - * the identifier of the {@link Species} to be referenced. - * @return a pointer to the newly created {@link ModifierSpeciesReference}. - */ - public ModifierSpeciesReference createModifier(String id, String species) { - ModifierSpeciesReference modSpecRef = createModifier(id); - modSpecRef.setSpecies(species); - return modSpecRef; - } - - /** - * Creates a new {@link SpeciesReference}, adds it to this {@link Reaction}'s {@link #listOfProducts} and returns it. - * - * @return a new {@link SpeciesReference} object. - * @return - */ - public SpeciesReference createProduct() { - return createProduct((String) null); - } - - /** - * Creates a new {@link SpeciesReference}, which points to the given {@link Species}, adds it to this {@link Reaction}'s {@link #listOfProducts} and returns - * a pointer to it. - * - * @param species - * the {@link Species} to which the {@link SpeciesReference} should point. - * @return a pointer to a newly created {@link SpeciesReference} that has - * been added to this {@link Reaction}'s {@link #listOfProducts}. - * @see #createProduct(String, Species) - */ - public SpeciesReference createProduct(Species species) { - return createProduct(null, species); - } - - /** - * @param id - * @return - */ - public SpeciesReference createProduct(String id) { - SpeciesReference product = new SpeciesReference(id, getLevel(), - getVersion()); - addProduct(product); - return product; - } - - /** - * Creates a new {@link SpeciesReference} with the given id as - * its identifier, which points to the given {@link Species}, adds it to - * this {@link Reaction}'s {@link #listOfProducts} and returns a pointer to - * it. - * - * @param id - * the identifier of the {@link SpeciesReference} to be created. - * @param species - * the {@link Species} to which the {@link SpeciesReference} should point. - * @return a pointer to a newly created {@link SpeciesReference} that has - * been added to this {@link Reaction}'s {@link #listOfProducts}. - */ - public SpeciesReference createProduct(String id, Species species) { - SpeciesReference specRef = createProduct(id); - specRef.setSpecies(species); - return specRef; - } - - /** - * @param id - * @param species - * @return - */ - public SpeciesReference createProduct(String id, String species) { - SpeciesReference specRef = createProduct(id); - specRef.setSpecies(species); - return specRef; - } - - /** - * Creates a new {@link SpeciesReference}, adds it to this {@link Reaction}'s {@link #listOfReactants} and returns it. - * - * @return a new SpeciesReference object. - * @return - */ - public SpeciesReference createReactant() { - return createReactant((String) null); - } - - /** - * Creates a new {@link SpeciesReference} to the given {@link Species} and - * adds it to the {@link #listOfReactants}. - * - * @param species - * @return the newly created instance of {@link SpeciesReference} that - * points to the given {@link Species}. - * @see #createReactant(String, Species) - */ - public SpeciesReference createReactant(Species species) { - return createReactant(null, species); - } - - /** - * @param id - * @return - */ - public SpeciesReference createReactant(String id) { - SpeciesReference reactant = new SpeciesReference(id, getLevel(), - getVersion()); - addReactant(reactant); - return reactant; - } - - /** - * Creates a new {@link SpeciesReference} with the given id as - * identifier, which points to the given {@link Species} and adds it to the {@link #listOfReactants}. - * - * @param id - * the identifier of the {@link SpeciesReference} to be created. - * @param species - * the {@link Species} to which this reactant should point. - * @return a pointer to the newly created {@link SpeciesReference}. - */ - public SpeciesReference createReactant(String id, Species species) { - SpeciesReference specRef = createReactant(id); - specRef.setSpecies(species); - return specRef; - } - - /** - * @param id - * @param species - * @return - */ - public SpeciesReference createReactant(String id, String species) { - SpeciesReference specRef = createReactant(id); - specRef.setSpecies(species); - return specRef; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - // Check all child elements recursively in super class first: - boolean equals = super.equals(object); - if (equals) { - // Cast is possible because super class checks the class attributes - Reaction r = (Reaction) object; - equals &= r.getFast() == getFast(); - equals &= r.getReversible() == getReversible(); - equals &= r.getCompartment().equals(getCompartment()); - } - return equals; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetListOfReactants()) { - if (pos == index) { - return getListOfReactants(); - } - pos++; - } - if (isSetListOfProducts()) { - if (pos == index) { - return getListOfProducts(); - } - pos++; - } - if (isSetListOfModifiers()) { - if (pos == index) { - return getListOfModifiers(); - } - pos++; - } - if (isSetKineticLaw()) { - if (pos == index) { - return getKineticLaw(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int children = super.getChildCount(); - if (isSetListOfReactants()) { - children++; - } - if (isSetListOfProducts()) { - children++; - } - if (isSetListOfModifiers()) { - children++; - } - if (isSetKineticLaw()) { - children++; - } - return children; - } - - /** - * Only available if Level >= 3. - * - * @return the compartmentID of this {@link Reaction}. The empty {@link String} if it is not set. - */ - public String getCompartment() { - return isSetCompartment() ? this.compartmentID : ""; - } - - /** - * @return the Compartment instance which has the compartmentID of this - * Reaction as id. Can be null if it doesn't exist. - */ - public Compartment getCompartmentInstance() { - Model m = getModel(); - return m != null ? m.getCompartment(this.compartmentID) : null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnitDefinition() - */ - public UnitDefinition getDerivedUnitDefinition() { - return isSetKineticLaw() ? kineticLaw.getDerivedUnitDefinition() : null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#getDerivedUnits() - */ - public String getDerivedUnits() { - return isSetKineticLaw() ? kineticLaw.getDerivedUnits() : null; - } - - /** - * @return the fast Boolean of this Reaction. - */ - // Not using the isSetFast here to allow the value set in initDefaults() to - // be returned. - public boolean getFast() { - return fast != null ? fast : false; - } - - /** - * @return the kineticLaw of this Reaction. Can be null if not set. - */ - public KineticLaw getKineticLaw() { - return kineticLaw; - } - - /** - * @return the listOfModifiers of this Reaction. Is initialized here if not - * yet set. - */ - public ListOf getListOfModifiers() { - if (listOfModifiers == null) { - listOfModifiers = ListOf.newInstance(this, ModifierSpeciesReference.class); - } - return listOfModifiers; - } - - /** - * @return the listOfProducts of this Reaction. Is initialized here if not - * yet set. - */ - public ListOf getListOfProducts() { - if (listOfProducts == null) { - listOfProducts = ListOf.initListOf(this, - new ListOf(), ListOf.Type.listOfProducts); - } - return listOfProducts; - } - - /** - * @return the listOfReactants of this Reaction. Is initialized here if not - * yet set. - */ - public ListOf getListOfReactants() { - if (listOfReactants == null) { - listOfReactants = ListOf.initListOf(this, new ListOf(), - ListOf.Type.listOfReactants); - } - return listOfReactants; - } - - /** - * @param i - * @return the ith ModifierSpeciesReference of the listOfModifiers. Can be - * null if it doesn't exist. - */ - public ModifierSpeciesReference getModifier(int i) { - return getListOfModifiers().get(i); - } - - /** - * Searches the first {@link ModifierSpeciesReference} in the {@link #listOfModifiers} of this {@link Reaction} with the given - * identifier. - * - * @param id - * identifier of the desired {@link ModifierSpeciesReference}. - * Note that this is not the identifier of the {@link Species}. - * @return the {@link ModifierSpeciesReference} of the {@link #listOfModifiers} which has 'id' as id (or name depending - * on the level and version). Can be null if it doesn't exist. - */ - public ModifierSpeciesReference getModifier(String id) { - return getListOfModifiers().firstHit(new NameFilter(id)); - } - - /** - * @return the number of {@link ModifierSpeciesReference}s of this {@link Reaction}. - */ - public int getModifierCount() { - return listOfModifiers == null ? 0 : listOfModifiers.size(); - } - - /** - * Returns the first {@link ModifierSpeciesReference} in the {@link #listOfModifiers} of this {@link Reaction} whose 'species' - * attribute points to a {@link Species} with the given identifier. - * - * @param id - * The identifier of a referenced {@link Species} - * @return the {@link ModifierSpeciesReference} of the {@link #listOfModifiers} which has 'id' as species attribute (or - * name depending on the level and version). Can be null if it - * doesn't exist. - */ - public ModifierSpeciesReference getModifierForSpecies(String id) { - SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); - srf.setFilterForSpecies(true); - return getListOfModifiers().firstHit(srf); - } - - /** - * @return the number of {@link ModifierSpeciesReference}s of this {@link Reaction}. - * @deprecated use {@link #getModifierCount()} - */ - @Deprecated - public int getNumModifiers() { - return getModifierCount(); - } - - /** - * @return the number of products {@link SpeciesReference}. - * @deprecated use {@link #getProductCount()} - */ - @Deprecated - public int getNumProducts() { - return getProductCount(); - } - - /** - * @return the number of reactants {@link SpeciesReference}. - * @deprecated use {@link #getReactantCount()} - */ - @Deprecated - public int getNumReactants() { - return getReactantCount(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * @param i - * @return the ith product SpeciesReference of the listOfProducts. Can be - * null if it doesn't exist. - */ - public SpeciesReference getProduct(int i) { - return getListOfProducts().get(i); - } - - /** - * Searches the first {@link SpeciesReference} in the listOfProducts of this {@link Reaction} with the given identifier. - * - * @param id - * identifier of the desired {@link SpeciesReference}. Note that - * this is not the identifier of the {@link Species}. - * @return the {@link SpeciesReference} of the {@link #listOfProducts} which has 'id' as id - * (or name depending on the level and version). Can be null if it - * doesn't exist. - */ - public SpeciesReference getProduct(String id) { - return getListOfProducts().firstHit(new NameFilter(id)); - } - - /** - * @return the number of products {@link SpeciesReference}. - */ - public int getProductCount() { - return listOfProducts == null ? 0 : listOfProducts.size(); - } - - /** - * Returns the first {@link SpeciesReference} in the {@link #listOfProducts} of this {@link Reaction} whose 'species' attribute points to a {@link Species} - * with the given identifier. - * - * @param id - * The identifier of a referenced {@link Species} - * @return the {@link SpeciesReference} of the {@link #listOfProducts} which - * has 'id' as species attribute (or name depending on the level and - * version). Can be null if it doesn't exist. - */ - public SpeciesReference getProductForSpecies(String id) { - SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); - srf.setFilterForSpecies(true); - return getListOfProducts().firstHit(srf); - } - - /** - * @param i - * @return the ith reactant {@link SpeciesReference} of the listOfReactants. - * Can be null if it doesn't exist. - */ - public SpeciesReference getReactant(int i) { - return getListOfReactants().get(i); - } - - /** - * Searches the first {@link SpeciesReference} in the listOfReactants of - * this {@link Reaction} with the given identifier. - * - * @param id - * identifier of the desired {@link SpeciesReference}. Note that - * this is not the identifier of the {@link Species}. - * @return the {@link SpeciesReference} of the listOfReactants which has - * 'id' as id (or name depending on the level and version). Can be - * null if it doesn't exist. - */ - public SpeciesReference getReactant(String id) { - return getListOfReactants().firstHit(new NameFilter(id)); - } - - public SpeciesReference getReactantBySpeciesId(String speciesId) { - for (SpeciesReference ref : listOfReactants) { - if (ref.getSpecies().equals(speciesId)) { - return ref; - } - } - return null; - } - - /** - * @return the number of reactants {@link SpeciesReference}. - */ - public int getReactantCount() { - return listOfReactants == null ? 0 : listOfReactants.size(); - } - - /** - * Returns the first {@link SpeciesReference} in the {@link #listOfReactants} of this {@link Reaction} whose 'species' - * attribute points to a {@link Species} with the given identifier. - * - * @param id - * The identifier of a referenced {@link Species} - * @return the {@link SpeciesReference} of the {@link #listOfReactants} which has 'id' as species attribute (or name depending on the - * level and version). Can be null if it doesn't exist. - */ - public SpeciesReference getReactantForSpecies(String id) { - SpeciesReferenceFilter srf = new SpeciesReferenceFilter(id); - srf.setFilterForSpecies(true); - return getListOfReactants().firstHit(srf); - } - - /** - * @return the reversible Boolean of this reaction. - */ - // Not using the isSetReversible here to allow the value set in - // initDefaults() to be returned. - public boolean getReversible() { - return reversible != null ? reversible : true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 881; - int hashCode = super.hashCode(); - if (isSetFast()) { - hashCode += prime * fast.hashCode(); - } - if (isSetReversible()) { - hashCode += prime * reversible.hashCode(); - } - if (isSetCompartment()) { - hashCode += prime * getCompartment().hashCode(); - } - return hashCode; - } - - /** - * @param s - * @return - */ - public boolean hasModifier(Species s) { - return references(listOfModifiers, s); - } - - /** - * @param s - * @return - */ - public boolean hasProduct(Species s) { - return references(listOfProducts, s); - } - - /** - * @param s - * @return - */ - public boolean hasReactant(Species s) { - return references(listOfReactants, s); - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default variables of this Reaction. - */ - public void initDefaults(int level, int version) { - if ((0 < level) && (0 < version)) { - if (level < 3) { - reversible = new Boolean(true); - fast = new Boolean(false); - } else { - reversible = fast = null; - } - } - } - - /** - * Convenient test if the given species takes part in this reaction as a - * reactant, product, or modifier. - * - * @param s - * @return - */ - public boolean involves(Species s) { - return hasReactant(s) || hasProduct(s) || hasModifier(s); - } - - /** - * @return the boolean value of fast if it is set, false otherwise. - */ - public boolean isFast() { - return getFast(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return true; - } - - /** - * @return the value of reversible if it is set, false otherwise. - */ - public boolean isReversible() { - return getReversible(); - } - - /** - * @return true if the compartmentID of this Reaction is not null; - */ - public boolean isSetCompartment() { - return this.compartmentID != null; - } - - /** - * @return true if the Compartment which has the compartmentID of this - * Reaction as id is not null; - */ - public boolean isSetCompartmentInstance() { - Model m = getModel(); - return m != null ? m.getCompartment(this.compartmentID) != null : false; - } - - /** - * @return true if fast is not null. - */ - public boolean isSetFast() { - return isSetFast; - } - - /** - * @return true if the kineticLaw of this Reaction is not null. - */ - public boolean isSetKineticLaw() { - return kineticLaw != null; - } - - /** - * @return true if the listOfModifiers of this Reaction is not null and not - * empty. - */ - public boolean isSetListOfModifiers() { - return (listOfModifiers != null) && (listOfModifiers.size() > 0); - } - - /** - * @return true if the listOfProducts of this reaction is not null and not - * empty. - */ - public boolean isSetListOfProducts() { - return (listOfProducts != null) && (listOfProducts.size() > 0); - } - - /** - * @return true if the listOfReactants of this Reaction is not null and not - * empty. - */ - public boolean isSetListOfReactants() { - return (listOfReactants != null) && (listOfReactants.size() > 0); - } - - /** - * @return true if reversible is not null. - */ - public boolean isSetReversible() { - return isSetReversible; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("reversible")) { - setReversible(StringTools.parseSBMLBoolean(value)); - } else if (attributeName.equals("fast")) { - setFast(StringTools.parseSBMLBoolean(value)); - } else if (attributeName.equals("compartment")) { - this.setCompartment(value); - } else { - isAttributeRead = false; - } - } - return isAttributeRead; - } - - /** - * Checks whether the given list references the given species. - * - * @param list - * @param s - * @return - */ - private boolean references(ListOf list, - Species s) { - if (list != null) { - for (SimpleSpeciesReference specRef : list) { - if (specRef.getSpecies().equals(s.getId())) { - return true; - } - } - } - return false; - } - - /** - * @param - * @param list - * @param id - * @return - */ - private SimpleSpeciesReference remove( - ListOf list, String id) { - SimpleSpeciesReference deleted = null; - int index = 0; - for (SimpleSpeciesReference reference : list) { - if (reference.getSpecies().equals(id)) { - deleted = reference; - break; - } - index++; - } - if (deleted != null) { - list.remove(index); - } - return deleted; - - } - - /** - * Removes the nth modifier species (ModifierSpeciesReference object) in the - * list of modifiers in this Reaction and returns it. - * - * @param i - * the index of the ModifierSpeciesReference object to remove. - * @return the removed ModifierSpeciesReference object, or null if the given - * index is out of range. - */ - public ModifierSpeciesReference removeModifier(int i) { - return getListOfModifiers().remove(i); - } - - /** - * Removes the ModifierSpeciesReference 'modspecref' from this Reaction. - * - * @param modspecref - */ - public boolean removeModifier(ModifierSpeciesReference modspecref) { - return getListOfModifiers().remove(modspecref); - } - - /** - * Removes the modifier species (ModifierSpeciesReference object) having the - * given 'species' attribute in the list of modifiers in this Reaction and - * returns it. - * - * @param id - * the 'species' attribute of the ModifierSpeciesReference object - * (which correspond to a species id). - * @return - */ - public ModifierSpeciesReference removeModifier(String id) { - return (ModifierSpeciesReference) remove(listOfModifiers, id); - } - - /** - * Removes the nth product species (SpeciesReference object) in the list of - * products in this Reaction and returns it. - * - * @param i - * the index of the SpeciesReference object to remove. - * @return the removed SpeciesReference object, or null if the given index - * is out of range. - */ - public SpeciesReference removeProduct(int i) { - return listOfProducts.remove(i); - } - - /** - * Removes the SpeciesReference 'modspecref' from the listOfProducts of this - * Reaction. - * - * @param specref - */ - public void removeProduct(SpeciesReference specref) { - listOfProducts.remove(specref); - } - - /** - * Removes the product species (SpeciesReference object) having the given - * 'species' attribute in the list of products in this Reaction and returns - * it. - * - * @param id - * the 'species' attribute of the SpeciesReference object (which - * correspond to a species id). - * @return - */ - public SpeciesReference removeProduct(String id) { - return (SpeciesReference) remove(listOfProducts, id); - } - - /** - * Removes the nth reactant species (SpeciesReference object) in the list of - * reactants in this Reaction and returns it. - * - * @param i - * the index of the SpeciesReference object to remove. - * @return the removed SpeciesReference object, or null if the given index - * is out of range. - */ - public SpeciesReference removeReactant(int i) { - return getListOfReactants().remove(i); - } - - /** - * Removes the SpeciesReference 'modspecref' from the listOfReactants of - * this Reaction. - * - * @param specref - */ - public boolean removeReactant(SpeciesReference specref) { - return getListOfReactants().remove(specref); - } - - /** - * Removes the reactant species (SpeciesReference object) having the given - * 'species' attribute in the list of reactants in this Reaction and returns - * it. - * - * @param id - * the 'species' attribute of the SpeciesReference object (which - * correspond to a species id). - * @return - */ - public SpeciesReference removeReactant(String id) { - return (SpeciesReference) remove(listOfReactants, id); - } - - /** - * Sets the compartmentID of this {@link Reaction} to the id of the {@link Compartment} 'compartment'. - * - * @param compartment - */ - public void setCompartment(Compartment compartment) { - setCompartment(compartment != null ? compartment.getId() : null); - } - - /** - * Sets the compartmentID of this Reaction to 'compartmentID'. This method - * is only available for Level >= 3. - * - * @param compartmentID - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setCompartment(String compartmentID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.compartment, - this); - } - String oldCompartmentID = this.compartmentID; - this.compartmentID = compartmentID; - firePropertyChange(TreeNodeChangeEvent.compartment, oldCompartmentID, - compartmentID); - } - - /** - * Sets the fast Boolean of this {@link Reaction}. - * - * @param fast - */ - public void setFast(boolean fast) { - Boolean oldFast = this.fast; - this.fast = Boolean.valueOf(fast); - isSetFast = true; - firePropertyChange(TreeNodeChangeEvent.fast, oldFast, fast); - } - - /** - * Sets the kineticLaw of this {@link Reaction}. - * - * @param kineticLaw - */ - public void setKineticLaw(KineticLaw kineticLaw) { - unsetKineticLaw(); - this.kineticLaw = kineticLaw; - if (this.kineticLaw.isSetListOfLocalParameters()) { - /* - * Before we can register the new kineticLaw as a child of this - * reaction, we first have to clear the mapping from the kineticLaw - * to its local parameters (if there are any). Local parameters are - * registered at the level of the kineticLaw, i.e., besides all maps - * on the level of the model, kineticLaw contains its own map. - * Clearing this map is required because the registerChild method - * would recursively find all elements that have an id and try to - * the mapping. However, since all these local parameters have been - * existing already, this would cause an exception. The reason is - * that we could not distinguish between already correctly registered - * local parameters and new local parameters with an identical - * identifier. - */ - for (LocalParameter lp : this.kineticLaw.getListOfLocalParameters()) { - this.kineticLaw.registerLocalParameter(lp, true); - } - } - registerChild(this.kineticLaw); - } - - /** - * Sets the listOfModifiers of this {@link Reaction}. Automatically sets the - * parentSBML object of the list to this {@link Reaction} instance. - * - * @param listOfModifiers - */ - public void setListOfModifiers(ListOf listOfModifiers) { - unsetListOfModifiers(); - this.listOfModifiers = listOfModifiers; - if ((this.listOfModifiers != null) && (this.listOfModifiers.getSBaseListType() != ListOf.Type.listOfModifiers)) { - this.listOfModifiers.setSBaseListType(ListOf.Type.listOfModifiers); - } - registerChild(this.listOfModifiers); - } - - /** - * Sets the {@link #listOfProducts} of this {@link Reaction}. Automatically sets the - * parentSBML object of the list to this {@link Reaction} instance. - * - * @param listOfProducts - */ - public void setListOfProducts(ListOf listOfProducts) { - unsetListOfProducts(); - this.listOfProducts = listOfProducts; - if ((this.listOfProducts != null) && (this.listOfProducts.getSBaseListType() != ListOf.Type.listOfProducts)) { - this.listOfProducts.setSBaseListType(ListOf.Type.listOfProducts); - } - registerChild(this.listOfProducts); - } - - /** - * Sets the listOfReactants of this {@link Reaction}. Automatically sets the - * parentSBML object of the list to this {@link Reaction} instance. - * - * @param listOfReactants - */ - public void setListOfReactants(ListOf listOfReactants) { - unsetListOfReactants(); - this.listOfReactants = listOfReactants; - if ((this.listOfReactants != null) && (this.listOfReactants.getSBaseListType() != ListOf.Type.listOfReactants)) { - this.listOfReactants.setSBaseListType(ListOf.Type.listOfReactants); - } - registerChild(this.listOfReactants); - } - - /** - * Sets the reversible Boolean of this {@link Reaction}. - * - * @param reversible - */ - public void setReversible(boolean reversible) { - Boolean oldReversible = this.reversible; - this.reversible = Boolean.valueOf(reversible); - isSetReversible = true; - firePropertyChange(TreeNodeChangeEvent.reversible, oldReversible, reversible); - } - - /** - * Sets the fast Boolean of this Reaction to null. - */ - public void unsetFast() { - Boolean oldFast = this.fast; - isSetFast = false; - fast = null; - firePropertyChange(TreeNodeChangeEvent.fast, oldFast, fast); - } - - /** - * Sets the {@link KineticLaw} of this {@link Reaction} to null and notifies - * all {@link TreeNodeChangeListener} about changes. - * - * @return true if calling this method changed the properties - * of this element. - */ - public boolean unsetKineticLaw() { - if (this.kineticLaw != null) { - KineticLaw oldKinticLaw = this.kineticLaw; - this.kineticLaw = null; - oldKinticLaw.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfModifiers} from this {@link Reaction} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfModifiers() { - if (this.listOfModifiers != null) { - ListOf oldListOfModifiers = this.listOfModifiers; - this.listOfModifiers = null; - oldListOfModifiers.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfProducts} from this {@link Reaction} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfProducts() { - if (this.listOfProducts != null) { - ListOf oldListOfProducts = this.listOfProducts; - this.listOfProducts = null; - oldListOfProducts.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfReactants} from this {@link Reaction} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfReactants() { - if (this.listOfReactants != null) { - ListOf oldListOfReactants = this.listOfReactants; - this.listOfReactants = null; - oldListOfReactants.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Sets the reversible Boolean of this {@link Reaction} to null. - */ - public void unsetReversible() { - Boolean oldReversible = this.reversible; - isSetReversible = false; - reversible = null; - firePropertyChange(TreeNodeChangeEvent.reversible, oldReversible, reversible); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetReversible()) { - attributes.put("reversible", Boolean.toString(getReversible())); - } - if (isSetFast()) { - attributes.put("fast", Boolean.toString(getFast())); - } - - if (2 < getLevel()) { - if (isSetCompartment()) { - attributes.put("compartment", getCompartment()); - } - } - - return attributes; - } - - public SpeciesReference getProductBySpeciesId(String speciesId) { - for (SpeciesReference ref : listOfProducts) { - if (ref.getSpecies().equals(speciesId)) { - return ref; - } - } - return null; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Rule.java b/IPK_lib/src/org/sbml/jsbml/Rule.java deleted file mode 100644 index f007d740a..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Rule.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * $Id: Rule.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Rule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * The base class for the {@link AlgebraicRule}, {@link RateRule}, - * {@link AssignmentRule}. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public abstract class Rule extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -8151628772496225902L; - - /** - * Creates a Rule instance. - */ - public Rule() { - super(); - } - - /** - * Creates a Rule instance from an id, level and version. - * - * @param math - * @param level - * @param version - */ - public Rule(ASTNode math, int level, int version) { - super(math, level, version); - } - - /** - * Creates a Rule instance from a level and version. - * - * @param level - * @param version - */ - public Rule(int level, int version) { - super(level, version); - } - - /** - * Creates a new {@link Rule} instance from a given {@link Rule}. - * - * @param sb - */ - public Rule(Rule sb) { - super(sb); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - @Override - public abstract Rule clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * - * @return true if this Rule is an AlgebraicRule instance. - */ - public boolean isAlgebraic() { - return this instanceof AlgebraicRule; - } - - /** - * - * @return true if this Rule is an AssignmentRule instance. - */ - public boolean isAssignment() { - return this instanceof AssignmentRule; - } - - /** - * (SBML Level 1 only) Predicate returning true or false depending on - * whether this Rule is an CompartmentVolumeRule. - * - * @return true if this Rule is a CompartmentVolumeRule, false otherwise. - */ - public abstract boolean isCompartmentVolume(); - - /** - * (SBML Level 1 only) Predicate returning true or false depending on - * whether this Rule is an ParameterRule. - * - * @return true if this Rule is a ParameterRule, false otherwise. - */ - public abstract boolean isParameter(); - - /** - * - * @return true if this Rule is a RateRule instance. - */ - public boolean isRate() { - return this instanceof RateRule; - } - - /** - * (SBML Level 1 only) Predicate returning true or false depending on - * whether this Rule is an SpeciesConcentrationRule. - * - * @return true if this Rule is a SpeciesConcentrationRule, false otherwise. - */ - public abstract boolean isSpeciesConcentration(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBMLDocument.java b/IPK_lib/src/org/sbml/jsbml/SBMLDocument.java deleted file mode 100644 index fb391564b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBMLDocument.java +++ /dev/null @@ -1,1048 +0,0 @@ -/* - * $Id: SBMLDocument.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBMLDocument.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import javax.swing.tree.TreeNode; -import javax.xml.stream.XMLStreamException; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.validator.SBMLValidator; -import org.sbml.jsbml.validator.SBMLValidator.CHECK_CATEGORY; - -/** - * Represents the 'sbml' root node of a SBML file. - * - * @author Andreas Dräger - * @author marine - * @since 0.8 - * @version $Rev: 1187 $ - */ -public class SBMLDocument extends AbstractSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -3927709655186844513L; - - /** - * The namespace URI of SBML Level 1 Version 1 and 2. - */ - public static final transient String URI_NAMESPACE_L1 = "http://www.sbml.org/sbml/level1"; - - /** - * The namespace URI of SBML Level 2 Version 1. - */ - public static final transient String URI_NAMESPACE_L2V1 = "http://www.sbml.org/sbml/level2"; - - /** - * The namespace URI of SBML Level 2 Version 2. - */ - public static final String URI_NAMESPACE_L2V2 = "http://www.sbml.org/sbml/level2/version2"; - - /** - * The namespace URI of SBML Level 2 Version 3. - */ - public static final transient String URI_NAMESPACE_L2V3 = "http://www.sbml.org/sbml/level2/version3"; - - /** - * The namespace URI of SBML Level 2 Version 4. - */ - public static final transient String URI_NAMESPACE_L2V4 = "http://www.sbml.org/sbml/level2/version4"; - - /** - * The namespace URI of SBML Level 3 Version 1. - */ - public static final transient String URI_NAMESPACE_L3V1Core = "http://www.sbml.org/sbml/level3/version1/core"; - - /** - * Contains all the parameter to validate the SBML document - */ - private Map checkConsistencyParameters = new HashMap(); - - /** - * Memorizes all {@link SBMLError} when parsing the file containing this - * document. - */ - private SBMLErrorLog listOfErrors; - - /** - * logger used to print messages - */ - private transient Logger logger = Logger.getLogger(getClass()); - - /** - * Stores all the meta identifiers within this {@link SBMLDocument} to avoid - * the creation of multiple identical meta identifiers. These identifiers - * have to be unique within the document. - */ - private Map mappingFromMetaId2SBase; - /** - * Represents the 'model' XML subnode of a SBML file. - */ - private Model model; - /** - * Contains all the XML attributes of the sbml XML node. - */ - private Map SBMLDocumentAttributes; - /** - * Contains all the namespaces of the sbml XML node and their prefixes. - */ - private Map SBMLDocumentNamespaces; - - /** - * Creates a {@link SBMLDocument} instance. By default, the parent SBML object of - * this object is itself. The model is null. The SBMLDocumentAttributes and - * the SBMLDocumentNamespaces are empty. - * - * @param sb - */ - public SBMLDocument() { - super(); - this.mappingFromMetaId2SBase = new HashMap(); - this.model = null; - SBMLDocumentAttributes = new HashMap(); - SBMLDocumentNamespaces = new HashMap(); - setParentSBML(this); - checkConsistencyParameters.put(CHECK_CATEGORY.UNITS_CONSISTENCY.name(), false); - } - - /** - * Creates a SBMLDocument instance from a level and version. By default, the - * parent SBML object of this object is itself. The model is null. The - * SBMLDocumentAttributes and the SBMLDocumentNamespaces are empty. - * - * @param level - * @param version - */ - public SBMLDocument(int level, int version) { - this(); - setLevel(level); - setVersion(version); - if (!hasValidLevelVersionNamespaceCombination()) { - throw new LevelVersionError(this); - } - initDefaults(); - } - - /** - * Creates a new {@link SBMLDocument} instance from a given {@link SBMLDocument}. - * - * @param sb - */ - public SBMLDocument(SBMLDocument sb) { - super(sb); - this.mappingFromMetaId2SBase = new HashMap(); - this.SBMLDocumentAttributes = new HashMap(); - this.SBMLDocumentNamespaces = new HashMap(); - if (sb.isSetModel()) { - // This will also cause that all metaIds are registered correctly. - setModel(sb.getModel().clone()); - } else { - this.model = null; - } - Iterator> entryIterator = sb.SBMLDocumentAttributes.entrySet().iterator(); - Map.Entry entry; - while (entryIterator.hasNext()) { - entry = entryIterator.next(); - this.SBMLDocumentAttributes.put(entry.getKey(), entry.getValue()); - } - entryIterator = sb.SBMLDocumentNamespaces.entrySet().iterator(); - while (entryIterator.hasNext()) { - entry = entryIterator.next(); - this.SBMLDocumentNamespaces.put(entry.getKey(), entry.getValue()); - } - setParentSBML(this); - checkConsistencyParameters.put(CHECK_CATEGORY.UNITS_CONSISTENCY.name(), Boolean.valueOf(false)); - } - - /** - * Adds a name space to the SBMLNamespaces of this SBMLDocument. - * - * @param namespaceName - * @param prefix - * @param URI - */ - public void addNamespace(String namespaceName, String prefix, String URI) { - if (!prefix.equals("")) { - this.SBMLDocumentNamespaces.put(prefix + ":" + namespaceName, URI); - - } else { - this.SBMLDocumentNamespaces.put(namespaceName, URI); - } - this.addNamespace(URI); - this.firePropertyChange(TreeNodeChangeEvent.addNamespace, null, URI); - } - - /** - * Validates the {@link SBMLDocument} using the - * SBML.org online validator (http://sbml.org/validator/). - *

    - * you can control the consistency checks that are performed when - * {@link #checkConsistency()} is called with the - * {@link #setConsistencyChecks(CHECK_CATEGORY, boolean)} method. - * It will fill this {@link SBMLDocument}'s {@link #listOfErrors} - * with {@link SBMLError}s for each problem within this whole data - * structure. You will then be able to obtain this list by calling - * {@link #getError(int)} or {@link #getListOfErrors()}. - *

    - * If this method returns a nonzero value (meaning, one or more - * consistency checks have failed for SBML document), the failures may be - * due to warnings @em or errors. Callers should inspect the severity - * flag in the individual SBMLError objects returned by - * {@link SBMLDocument#getError(int)} to determine the nature of the failures. - * - * @return the number of errors found - * @see #setConsistencyChecks(CHECK_CATEGORY, boolean) - */ - public int checkConsistency() { - - File tmpFile = null; - - try { - tmpFile = File.createTempFile("jsbml-", ".xml"); - } catch (IOException e) { - logger.error("There was an error creating a temporary file :" + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - return -1; - } - - try { - new SBMLWriter().writeSBML(this, tmpFile); - } catch (IOException e) { - logger.error("There was an error creating a temporary file :" + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - return -1; - } catch (XMLStreamException e) { - logger.error("There was an error creating a temporary file :" + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - return -1; - } catch (SBMLException e) { - logger.error("There was an error creating a temporary file :" + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - return -1; - } - - /* - * u --> Disable checking the consistency of measurement units associated with quantities (SBML L2V3 rules 105nn) - * i --> Disable checking the correctness and consistency of identifiers used for model entities (SBML L2V3 rules 103nn) - * m --> Disable checking the syntax of MathML mathematical expressions (SBML L2V3 rules 102nn) - * s --> Disable checking the validity of SBO identifiers (if any) used in the model (SBML L2V3 rules 107nn) - * o --> Disable static analysis of whether the model is overdetermined - * p --> Disable additional checks for recommended good modeling practices - * g --> Disable all other general SBML consistency checks (SBML L2v3 rules 2nnnn) - */ - - // checkConsistencyParameters.put("offcheck", "u"); - // checkConsistencyParameters.put("offcheck", "u,p,o"); - - // System.out.println("SBMLDocument.checkConsistency : tmp file = " + tmpFile.getAbsolutePath()); - - HashMap consistencyParameters = new HashMap(); - String offcheck = null; - - for (String checkCategory : checkConsistencyParameters.keySet()) { - CHECK_CATEGORY typeOfCheck = CHECK_CATEGORY.valueOf(checkCategory); - boolean checkIsOn = checkConsistencyParameters.get(checkCategory).booleanValue(); - - logger.debug(" Type of check = " + typeOfCheck + " is " + checkIsOn); - - switch (typeOfCheck) { - case IDENTIFIER_CONSISTENCY: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "i" : offcheck + ",i"; - } - break; - } - case GENERAL_CONSISTENCY: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "g" : offcheck + ",g"; - } - break; - } - case SBO_CONSISTENCY: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "s" : offcheck + ",s"; - } - break; - } - case MATHML_CONSISTENCY: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "m" : offcheck + ",m"; - } - break; - } - case UNITS_CONSISTENCY: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "u" : offcheck + ",u"; - } - break; - } - case OVERDETERMINED_MODEL: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "o" : offcheck + ",o"; - } - break; - } - case MODELING_PRACTICE: { - if (!checkIsOn) { - offcheck = (offcheck == null) ? "p" : offcheck + ",p"; - } - break; - } - default: { - // If it's a category for which we don't have validators, ignore it. - // Should not happen as checkConsistencyParameters is only modified through - // setConsistencyChecks(CHECK_CATEGORY, boolean) - break; - } - } - } - if (offcheck != null) { - consistencyParameters.put("offcheck", offcheck); - } - - // Doing the actual check consistency - listOfErrors = SBMLValidator.checkConsistency(tmpFile.getAbsolutePath(), consistencyParameters); - - try { - tmpFile.delete(); - } catch (SecurityException e) { - logger.error("There was an error removing a temporary file :" + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - } - - if (listOfErrors == null) { - logger.error("There was an error accessing the sbml online validator !!"); - return -1; - } - - return listOfErrors.getErrorCount(); - } - - /** - * Checks if the given meta identifier can be added in this {@link SBMLDocument} - * 's {@link #mappingFromMetaId2SBase}. - * - * @param metaId - * the identifier whose value is to be checked. - * @throws IllegalArgumentException - * if a metaid to add is already present in the list of - * registered metaids. - */ - private void checkMetaId(String metaId) { - if (containsMetaId(metaId)) { - logger.error(String.format( - "An element with the metaid '%s' is already present in the SBML document. The new element will not get added to it.", - metaId)); - throw new IllegalArgumentException(String.format( - "Cannot set duplicate meta identifier '%s'.", metaId)); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.AbstractSBase#clone() - */ - @Override - public SBMLDocument clone() { - return new SBMLDocument(this); - } - - /** - * Collects all meta identifiers of this {@link AbstractSBase} and all of - * its sub-elements if recursively is true. - * - * @param metaIds - * the {@link Map} that gathers the result. - * @param sbase - * The {@link SBase} whose meta identifier is to be collected - * and from which we maybe have to recursively go through all - * of its children. - * @param recursively - * if true, this method will also consider all - * sub-elements of this {@link AbstractSBase}. - * @param delete - * if true this method will not check if - * the meta identifier can be added to the {@link SBMLDocument}. - * @throws IllegalArgumentException - * However, duplications are not legal and an - * {@link IllegalArgumentException} will be thrown in such - * cases. - */ - @SuppressWarnings("unchecked") - private void collectMetaIds(Map metaIds, SBase sbase, - boolean recursively, boolean delete) { - if (sbase.isSetMetaId()) { - if (!delete) { - // checks if the metaid can be added, throws an exception if not. - checkMetaId(sbase.getMetaId()); - } - metaIds.put(sbase.getMetaId(), sbase); - } - if (recursively) { - Enumeration children = (Enumeration) sbase.children(); - while (children.hasMoreElements()) { - TreeNode node = children.nextElement(); - if (node instanceof SBase) { - collectMetaIds(metaIds, (SBase) node, recursively, delete); - } - } - } - } - - /** - * A check to see whether elements have been registered to this - * {@link SBMLDocument} with the given meta identifier. - * - * @param metaId - * @return - */ - public boolean containsMetaId(String metaId) { - return mappingFromMetaId2SBase.containsKey(metaId); - } - - /** - * Creates a new Model inside this {@link SBMLDocument}, and returns a - * pointer to it. - * In SBML Level 2, the use of an identifier on a {@link Model} object is - * optional. This method takes an optional argument, sid, for setting the - * identifier. If not supplied, the identifier attribute on the Model - * instance is not set. - * - * @return the new {@link Model} instance. - * @deprecated If not working with SBML Level 2 use - * {@link #createModel(String)} instead. - */ - @Deprecated - public Model createModel() { - Model oldValue = getModel(); - this.setModel(new Model(getLevel(), getVersion())); - this.firePropertyChange(TreeNodeChangeEvent.model, oldValue, getModel()); - return getModel(); - } - - /** - * Creates a new instance of Model from id and the level and version of this - * SBMLDocument. - * - * @param id - * @return the new {@link Model} instance. - */ - public Model createModel(String id) { - setModel(new Model(id, getLevel(), getVersion())); - return getModel(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - boolean equals = super.equals(o); - if (equals) { - SBMLDocument d = (SBMLDocument) o; - if (!getSBMLDocumentAttributes().equals( - d.getSBMLDocumentAttributes())) { - return false; - } - if (!getSBMLDocumentNamespaces().equals( - d.getSBMLDocumentNamespaces())) { - return false; - } - } - return equals; - } - - /** - * Looks up the {@link SBase} registered in this {@link SBMLDocument} for the - * given metaId. - * - * @param metaId - * @return - */ - public SBase findSBase(String metaId) { - return mappingFromMetaId2SBase.get(metaId); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetModel()) { - if (pos == index) { - return getModel(); - } - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +Math.min(pos, 0))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - return super.getChildCount() + (isSetModel() ? 1 : 0); - } - - /** - * The default SBML Level of new SBMLDocument objects. - * - * @return 2 - */ - public int getDefaultLevel() { - return 2; - } - - /** - * The default Version of new SBMLDocument objects. - * - * @return 4 - */ - public int getDefaultVersion() { - return 4; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - return "sbml"; - } - - /** - * @param i - * @return - */ - public SBMLError getError(int i) { - if (!isSetListOfErrors() || (i < 0) || (i >= getErrorCount())) { - throw new IndexOutOfBoundsException("You are trying to access the error number " + i + ", which is invalid."); - } - - return listOfErrors.getError(i); - } - - /** - * This method returns a collection of all {@link SBMLError}s reflecting - * problems in the overall data structure of this {@link SBMLDocument}. - * - * @return - */ - public SBMLErrorLog getErrorLog() { - return getListOfErrors(); - } - - /** - * This method returns a collection of all {@link SBMLError}s reflecting - * problems in the overall data structure of this {@link SBMLDocument}. - * - * @return - */ - public SBMLErrorLog getListOfErrors() { - if (listOfErrors == null) { - listOfErrors = new SBMLErrorLog(); - } - return listOfErrors; - } - - /** - * Returns the model of this {@link SBMLDocument}. - * - * @return the model of this {@link SBMLDocument}. Can be null if it is not set. - */ - @Override - public Model getModel() { - return model; - } - - /** - * @return - * @deprecated use {@link #getErrorCount()} - */ - @Deprecated - public int getNumErrors() { - return getErrorCount(); - } - - /** - * @return - */ - public int getErrorCount() { - return isSetListOfErrors() ? listOfErrors.getErrorCount() : 0; - } - - /** - * @return the map SBMLDocumentAttributes of this SBMLDocument. - */ - public Map getSBMLDocumentAttributes() { - return SBMLDocumentAttributes; - } - - /** - * @return the map SBMLDocumentNamespaces of this SBMLDocument. - */ - public Map getSBMLDocumentNamespaces() { - return SBMLDocumentNamespaces; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 827; - int hashCode = super.hashCode(); - Map map = getSBMLDocumentAttributes(); - if (map != null) { - hashCode += prime * map.hashCode(); - } - map = getSBMLDocumentNamespaces(); - if (map != null) { - hashCode += prime * map.hashCode(); - } - return hashCode; - } - - /** - * - */ - private void initDefaults() { - String sbmlNamespace = JSBML.getNamespaceFrom(getLevel(), getVersion()); - SBMLDocumentNamespaces.put("xmlns", sbmlNamespace); - } - - /** - * @return - */ - private boolean isSetListOfErrors() { - return (listOfErrors != null) && (listOfErrors.getErrorCount() > 0); - } - - /** - * @return true if the model of this SBMLDocument is not null. - */ - public boolean isSetModel() { - return model != null; - } - - /** - * @return - */ - public String nextMetaId() { - String idOne; - do { - idOne = '_' + UUID.randomUUID().toString(); - } while (containsMetaId(idOne)); - return idOne; - } - - /** - * - */ - public void printErrors(PrintStream stream) { - int nbErrors = listOfErrors.getErrorCount(); - - for (int i = 0; i < nbErrors; i++) { - stream.println(listOfErrors.getError(i)); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("level")) { - setLevel(StringTools.parseSBMLInt(value)); - } else - if (attributeName.equals("version")) { - setVersion(StringTools.parseSBMLInt(value)); - } - if (!prefix.equals("")) { - getSBMLDocumentAttributes().put( - prefix + ":" + attributeName, value); - } else { - getSBMLDocumentAttributes().put(attributeName, value); - } - } - return isAttributeRead; - } - - /** - * Saves or removes the given meta identifier in this {@link SBMLDocument}'s - * {@link #mappingFromMetaId2SBase}. - * - * @param sbase - * the element whose meta identifier is to be registered (if it is set). - * @param add - * if true this will add the given meta identifier - * to this {@link SBMLDocument}'s {@link #mappingFromMetaId2SBase}. - * Otherwise, the given identifier will be removed from this set. - * @return - *

      - *
    • if add is true, then this method returns - * true if this set did not already contain the specified - * element, false otherwise.
    • - *
    • if add is not true, this method returns - * true if this set contained the specified element, - * false otherwise.
    • - *
    • This method also returns false if the given - * {@link SBase} does not have a defined metaId
    • - *
    - * @throws IllegalArgumentException - * if a metaid to add is already present in the list of - * registered metaids. - */ - boolean registerMetaId(SBase sbase, boolean add) { - if (sbase.isSetMetaId()) { - if (add) { - return mappingFromMetaId2SBase.put(sbase.getMetaId(), sbase) == null; - } else { - return mappingFromMetaId2SBase.remove(sbase.getMetaId()) != null; - } - } - return false; - } - - /** - * Collects all meta identifiers of this {@link AbstractSBase} and all of - * its sub-elements if recursively is true. It can also be used - * to delete meta identifiers from the given {@link Set}. - * - * @param sbase - * The {@link SBase} whose meta identifier is to be registered - * and from which we maybe have to recursively go through all - * of its children. - * @param recursively - * if true, this method will also consider all - * sub-elements of this {@link AbstractSBase}. - * @param delete - * if true the purpose of this method will be to - * delete the meta identifier from the given {@link Set}. - * Otherwise, it will try to add it to the set. - * @throws IllegalArgumentException - * However, duplications are not legal and an - * {@link IllegalArgumentException} will be thrown in such - * cases. - */ - void registerMetaIds(SBase sbase, boolean recursively, boolean delete) { - - Map metaIds = new HashMap(); - - collectMetaIds(metaIds, sbase, recursively, delete); - - if (delete) { - for (String key : metaIds.keySet()) { - mappingFromMetaId2SBase.remove(key); - } - } else { - mappingFromMetaId2SBase.putAll(metaIds); - } - } - - /** - * Controls the consistency checks that are performed when - * {@link SBMLDocument#checkConsistency()} is called. - *

    - * This method works by adding or subtracting consistency checks from the - * set of all possible checks that {@link SBMLDocument#checkConsistency()} knows - * how to perform. This method may need to be called multiple times in - * order to achieve the desired combination of checks. The first - * argument (category) in a call to this method indicates the category - * of consistency/error checks that are to be turned on or off, and the - * second argument (apply, a boolean) indicates whether to turn it on - * (value of true) or off (value of false). - *

    - * * The possible categories (values to the argument category) are the - * set of values from the {@link CHECK_CATEGORYH} enumeration. - * The following are the possible choices: - *

    - *

    - *

  • {@link GENERAL_CONSISTENCY}: - * Correctness and consistency of specific SBML language constructs. - * Performing this set of checks is highly recommended. With respect to - * the SBML specification, these concern failures in applying the - * validation rules numbered 2xxxx in the Level 2 Versions 2, 3 - * and 4 specifications. - *

    - *

  • {@link IDENTIFIER_CONSISTENCY}: - * Correctness and consistency of identifiers used for model entities. - * An example of inconsistency would be using a species identifier in a - * reaction rate formula without first having declared the species. With - * respect to the SBML specification, these concern failures in applying - * the validation rules numbered 103xx in the Level 2 - * Versions 2, 3 and 4 specifications. - *

    - *

  • {@link UNITS_CONSISTENCY}: - * Consistency of measurement units associated with quantities in a - * model. With respect to the SBML specification, these concern failures - * in applying the validation rules numbered 105xx in the Level 2 - * Versions 2, 3 and 4 specifications. - *

    - *

  • {@link MATHML_CONSISTENCY}: - * Syntax of MathML constructs. With respect to the SBML specification, - * these concern failures in applying the validation rules numbered 102xx - * in the Level 2 Versions 2, 3 and 4 specifications. - *

    - *

  • {@link SBO_CONSISTENCY}: - * Consistency and validity of SBO identifiers (if any) used in the - * model. With respect to the SBML specification, these concern failures - * in applying the validation rules numbered 107xx in the Level 2 - * Versions 2, 3 and 4 specifications. - *

    - *

  • {@link OVERDETERMINED_MODEL}: - * Static analysis of whether the system of equations implied by a model - * is mathematically overdetermined. With respect to the SBML - * specification, this is validation rule #10601 in the SBML Level 2 - * Versions 2, 3 and 4 specifications. - *

    - *

  • {@link MODELING_PRACTICE}: - * Additional checks for recommended good modeling practice. (These are - * tests performed by libSBML and do not have equivalent SBML validation - * rules.) - *

    - * By default, all validation checks are applied to the model in - * an {@link SBMLDocument} object unless {@link SBMLDocument#setConsistencyChecks(int, boolean)} is called to - * indicate that only a subset should be applied. Further, this default - * (i.e., performing all checks) applies separately to each new - * {@link SBMLDocument} object created. In other words, each time a model - * is read using {@link SBMLReader#readSBML(String)} , {@link SBMLReader#readSBMLFromString(String)}, a new - * {@link SBMLDocument} is created and for that document, a call to - * {@link SBMLDocument#checkConsistency()} will default to applying all possible checks. - * Calling programs must invoke {@link SBMLDocument#setConsistencyChecks(int, boolean)} for each such new - * model if they wish to change the consistency checks applied. - *

    - * - * @param category - * a value drawn from JSBML#JSBML.SBML_VALIDATOR_* indicating the - * consistency checking/validation to be turned on or off - *

    - * @param apply - * a boolean indicating whether the checks indicated by - * category should be applied or not. - *

    - * @see SBMLDocument#checkConsistency() - */ - public void setConsistencyChecks(SBMLValidator.CHECK_CATEGORY category, boolean apply) { - checkConsistencyParameters.put(category.name(), Boolean.valueOf(apply)); - } - - /** - *

    - * Sets the SBML Level and Version of this {@link SBMLDocument} instance, - * attempting to convert the model as needed. - *

    - *

    - * This method is equivalent to calling - * - *

    -	 * setLevelAndVersion(level, version, true);
    -	 * 
    - *

    - * - * @param level - * the desired SBML Level - * @param version - * the desired Version within the SBML Level - * @return true if 'level' and 'version' are valid. - * @see #setLevelAndVersion(int, int, boolean) - */ - public boolean setLevelAndVersion(int level, int version) { - return super.setLevelAndVersion(level, version, true); - } - - /** - *

    - * Sets the SBML Level and Version of this {@link SBMLDocument} instance, - * attempting to convert the model as needed. - *

    - *

    - * This method is the principal way in JSBML to convert models between - * Levels and Versions of SBML. Generally, models can be converted upward - * without difficulty (e.g., from SBML Level 1 to Level 2, or from an - * earlier Version of Level 2 to the latest Version of Level 2). Sometimes - * models can be translated downward as well, if they do not use constructs - * specific to more advanced Levels of SBML. - *

    - *

    - * Calling this method will not necessarily lead to a successful conversion. - * If the conversion fails, it will be logged in the error list associated - * with this {@link SBMLDocument}. Callers should consult - * {@link #getErrorCount()} to find out if the conversion succeeded - * without problems. For conversions from Level 2 to Level 1, callers can - * also check the Level of the model after calling this method to find out - * whether it is Level 1. (If the conversion to Level 1 failed, the Level of - * this model will be left unchanged.) - *

    - * - * @param level - * the desired SBML Level - * @param version - * the desired Version within the SBML Level - * @param strict - * boolean indicating whether to check consistency of both the - * source and target model when performing conversion (defaults - * to true) - * @return - */ - @Override - public boolean setLevelAndVersion(int level, int version, boolean strict) { - return super.setLevelAndVersion(level, version, strict); - } - - /** - * Sets the {@link Model} for this {@link SBMLDocument} to the given {@link Model}. - * - * @param model - */ - public void setModel(Model model) { - unsetModel(); - this.model = model; - registerChild(this.model); - } - - /** - * Sets the SBMLDocumentAttributes. - * - * @param sBMLDocumentAttributes - */ - public void setSBMLDocumentAttributes( - Map sBMLDocumentAttributes) { - Map oldAttributes = this.SBMLDocumentAttributes; - SBMLDocumentAttributes = sBMLDocumentAttributes; - firePropertyChange(TreeNodeChangeEvent.SBMLDocumentAttributes, - oldAttributes, this.SBMLDocumentAttributes); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#toString() - */ - @Override - public String toString() { - // return String.format("SBML Level %d Version %d", getLevel(), getVersion()); - return "SBML Level " + getLevel() + " Version " + getVersion(); - } - - /** - * Sets the {@link Model} of this {@link SBMLDocument} to null and notifies - * all {@link TreeNodeChangeListener} about changes. - * - * @return true if calling this method changed the properties - * of this element. - */ - public boolean unsetModel() { - if (this.model != null) { - Model oldModel = this.model; - this.model = null; - oldModel.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - attributes.putAll(SBMLDocumentAttributes); - - if (isSetLevel()) { - attributes.put("level", Integer.toString(this.getLevel())); - } - if (isSetVersion()) { - attributes.put("version", Integer.toString(this.getVersion())); - } - - Iterator> it = getSBMLDocumentNamespaces().entrySet().iterator(); - while (it.hasNext()) { - Map.Entry entry = it.next(); - if (!entry.getKey().equals("xmlns")) { - attributes.put(entry.getKey(), entry.getValue()); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBMLError.java b/IPK_lib/src/org/sbml/jsbml/SBMLError.java deleted file mode 100644 index 3937af154..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBMLError.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * $Id: SBMLError.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBMLError.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.util.Detail; -import org.sbml.jsbml.util.Location; -import org.sbml.jsbml.util.Message; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.xml.XMLException; - -/** - * Representation of errors, warnings and other diagnostics.
    - *
    - * For more details, see the libSBML SBMLError javadoc - * - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class SBMLError extends XMLException { - - /** - * - * @author Nicolas Rodriguez - * @version $Rev: 1169 $ - * @since 0.8 - */ - public enum SEVERITY { - /** - * - */ - INFO, - /** - * - */ - WARNING, - /** - * - */ - ERROR, - /** - * - */ - FATAL - }; - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6071833473902680630L; - /** - * - */ - private String category; - /** - * - */ - private int code; - /** - * - */ - private String excerpt; - /** - * - */ - private Location location; - /** - * - */ - private Message message; - - /** - * - */ - private Message shortmessage; - - /** - * - */ - private Detail detail; - /** - * - */ - private String severity; - - - /** - * Constructs a new {@link SBMLError}. - */ - public SBMLError() { - super(); - } - - /** - * Constructs a new {@link SBMLError} with the given message. - * - * @param message the error message - */ - public SBMLError(String message) { - super(message); - } - - /** - * Returns the category of the {@link SBMLError} - * - * @return the category of the {@link SBMLError} - */ - public String getCategory() { - return category; - } - - /** - * Returns the code of this {@link SBMLError}. - * - * @return the code of this {@link SBMLError}. - * - * @see the appendix on the SBML specifications about validations rules. - */ - public int getCode() { - return code; - } - - /** - * Returns the column where this {@link SBMLError} happened. - * - * @return the column where this {@link SBMLError} happened. - */ - public int getColumn() { - return location.getColumn(); - } - - /** - * Returns a fragment of the original XML file that induced the error. - * - * @return a fragment of the original XML file that induced the error. - */ - public String getExcerpt() { - return excerpt; - } - - /** - * Returns the line where this {@link SBMLError} happened. - * - * @return the line where this {@link SBMLError} happened. - */ - public int getLine() { - return location.getLine(); - } - - /** - * Returns the location where this {@link SBMLError} happened. - * - * @return the location where this {@link SBMLError} happened. - */ - public Location getLocation() { - return location; - } - - /** - * - * @return - */ - public Message getMessageInstance() { - return message; - } - - /** - * Returns the message of the {@link SBMLError} - * - * @return the message of the {@link SBMLError} - */ - public String getMessage() { - return message != null ? message.getMessage() : ""; - } - - /** - * Returns the severity of the {@link SBMLError} - * - * @return the severity of the {@link SBMLError} - */ - public String getSeverity() { - return severity; - } - - /** - * Returns true is the {@link SBMLError} severity is of type {@link SEVERITY#FATAL} - * - * @return true is the {@link SBMLError} severity is of type {@link SEVERITY#FATAL} - */ - public boolean isFatal() { - return severity != null && severity.equalsIgnoreCase("Fatal"); - } - - /** - * Returns true is the {@link SBMLError} severity is of type {@link SEVERITY#ERROR} - * - * @return true is the {@link SBMLError} severity is of type {@link SEVERITY#ERROR} - */ - public boolean isError() { - return severity != null && severity.equalsIgnoreCase("Error"); - } - - /** - * Returns true is the {@link SBMLError} severity is of type {@link SEVERITY#INFO} - * - * @return true is the {@link SBMLError} severity is of type {@link SEVERITY#INFO} - */ - public boolean isInfo() { - return severity != null && (severity.equalsIgnoreCase("Info") || severity.equalsIgnoreCase("Advisory")); - } - - /** - * Returns true is the {@link SBMLError} severity is of type {@link SEVERITY#WARNING} - * - * @return true is the {@link SBMLError} severity is of type {@link SEVERITY#WARNING} - */ - public boolean isWarning() { - return severity != null && severity.equalsIgnoreCase("Warning"); - } - - /** - * Returns true is the {@link SBMLError} category is of type internal - * - * @return true is the {@link SBMLError} category is of type internal - */ - public boolean isInternal() { - return category != null && category.equalsIgnoreCase("Internal"); - } - - /** - * Returns true is the {@link SBMLError} category is of type system - * - * @return true is the {@link SBMLError} category is of type system - */ - public boolean isSystem() { - return category != null && category.equalsIgnoreCase("System"); - } - - - /** - * Returns true is the {@link SBMLError} category is of type xml - * - * @return true is the {@link SBMLError} category is of type xml - */ - public boolean isXML() { - return category != null && category.equalsIgnoreCase("xml"); - } - - /** - * Sets the category of this {@link SBMLError}. - * - * @param category - */ - public void setCategory(String category) { - this.category = category; - } - - /** - * Sets the error code of this {@link SBMLError}. - * - * @param code - * - * @see the appendix on the SBML specifications about validations rules. - */ - public void setCode(int code) { - this.code = code; - } - - /** - * Sets the excerpt of this {@link SBMLError}. - * - * @param excerpt - */ - public void setExcerpt(String excerpt) { - this.excerpt = excerpt; - } - - /** - * Sets the location of this {@link SBMLError}. - * - * @param location - */ - public void setLocation(Location location) { - this.location = location; - } - - /** - * Sets the message of this {@link SBMLError}. - * - * @param messageObj - */ - public void setMessage(Message message) { - this.message = message; - } - - /** - * Sets the severity of this {@link SBMLError}. - * - * @param severity - */ - public void setSeverity(String severity) { - this.severity = severity; - } - - public Message getShortMessage() { - return shortmessage; - } - - public void setShortMessage(Message shortmessage) { - this.shortmessage = shortmessage; - } - - public Detail getDetail() { - return detail; - } - - public void setDetail(Detail detail) { - this.detail = detail; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return StringTools.concat("SBMLError ", code, " [", severity, "] [", category, "] ","\n excerpt = ", excerpt, "\n ", location, - "\n message = ", message.getMessage() ,"\n").toString(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBMLErrorLog.java b/IPK_lib/src/org/sbml/jsbml/SBMLErrorLog.java deleted file mode 100644 index 36ccedd1b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBMLErrorLog.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * $Id: SBMLErrorLog.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBMLErrorLog.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.sbml.jsbml.util.Option; - -/** - * Log of errors and other events encountered during SBML processing. - * - *

    - * This class is used both to have the same API as the libSBML equivalent, and also - * to store the information sent by the SBML online validator. - * - * see :
    - * - libSBML SBMLErrorLog - *
    - * - SBML Online Validator web API - * - * @author rodrigue - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class SBMLErrorLog { - - /** - * - */ - private File file; - - /** - * - */ - private List

    - * Index n is counted from 0. Callers should first inquire about the - * number of items in the log by using the - * {@link #getNumErrors()} method. - * Attempts to use an error index number that exceeds the actual number - * of errors in the log will result in a null being returned. - *

    - * @param n the index number of the error to retrieve (with 0 being the - * first error). - *

    - * @return the nth {@link SBMLError} in this log, or null if n is - * greater than or equal to {@link #getNumErrors()}. - *

    - * @see #getNumErrors() - */ - public SBMLError getError(long n) { - if (n >= 0 && n < validationErrors.size()) { - return validationErrors.get((int) n); - } - - return null; - } - - /** - * Returns the file containing the xml error log representation. - * - * @return the file containing the xml error log representation. - */ - File getFile() { - return file; - } - - /** - * Returns the number of errors that have been logged. - *

    - * To retrieve individual errors from the log, callers may use - * {@link #getError(long n)}. - *

    - * @return the number of errors that have been logged. - * @deprecated use {@link #getErrorCount()} - */ - @Deprecated - public int getNumErrors() { - return getErrorCount(); - } - - /** - * Returns the number of errors that have been logged. - *

    - * To retrieve individual errors from the log, callers may use - * {@link #getError(long n)}. - *

    - * @return the number of errors that have been logged. - */ - public int getErrorCount() { - return validationErrors.size(); - } - - /** - * Returns the number of errors that have been logged with the given - * severity code. - *

    - * LibSBML associates severity levels with every {@link SBMLError} object to - * provide an indication of how serious the problem is. Severities range - * from informational diagnostics to fatal (irrecoverable) errors. Given - * an {@link SBMLError} object instance, a caller can interrogate it for its - * severity level using methods such as {@link SBMLError#getSeverity()}, - * {@link SBMLError#isFatal()}, and so on. The present method encapsulates - * iteration and interrogation of all objects in an {@link SBMLErrorLog}, making - * it easy to check for the presence of error objects with specific - * severity levels. - *

    - * @param severity a value from the enumeration {@link SBMLError#SEVERITY} - *

    - * @return a count of the number of errors with the given severity code. - *

    - * @see #getNumErrors() - */ - public int getNumFailsWithSeverity(SBMLError.SEVERITY severity) { - - int nbWithSeverity = 0; - - for (SBMLError error : validationErrors) { - switch(severity) { - case INFO: { - if (error.isInfo()) { - nbWithSeverity++; - } - break; - } - case WARNING: { - if (error.isWarning()) { - nbWithSeverity++; - } - break; - } - case ERROR: { - if (error.isError()) { - nbWithSeverity++; - } - break; - } - case FATAL: { - if (error.isFatal()) { - nbWithSeverity++; - } - break; - } - } - } - - return nbWithSeverity; - } - - /** - * Returns the list of options. - * - * @return the list of options. - */ - List

    - * This {@link SBMLReader} is just a wrapper for the actual implementation - * in {@link org.sbml.jsbml.xml.stax.SBMLReader}. - * - *

    - * This class is - * provided for compatibility with libSBML and to avoid problems if the - * internal of jsbml change, so it is preferable to use it instead of directly - * using {@link org.sbml.jsbml.xml.stax.SBMLReader}. - * - *

    - * The {@link SBMLReader} class provides the main interface for reading SBML - * content from files and strings. The methods for reading SBML all return - * an {@link SBMLDocument} object representing the results. - *

    - * In the case of failures (such as if the SBML contains errors), the errors - * will be recorded with the {@link SBMLErrorLog} - * object kept in the {@link SBMLDocument} returned by {@link SBMLReader}. Consequently, - * immediately after calling a method on {@link SBMLReader}, callers should always - * check for errors and warnings using the methods for this purpose - * provided by {@link SBMLDocument}. - *

    - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1181 $ - */ -public class SBMLReader implements Cloneable, Serializable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -3313609137341424804L; - - /** - * Factory method for reading SBML from a given {@link File}. - * - * @param file - * @return - * @throws XMLStreamException - * @throws IOException if the file does not exist or cannot be read. - */ - public static SBMLDocument read(File file) throws XMLStreamException, IOException { - return read(file, null); - } - - /** - * Factory method for reading SBML from a given {@link File}. - * - * @param file - * @param listener - * @return - * @throws XMLStreamException - * @throws IOException if the file does not exist or cannot be read. - */ - public static SBMLDocument read(File file, TreeNodeChangeListener listener) throws XMLStreamException, IOException { - return new SBMLReader().readSBML(file, listener); - } - - /** - * @param file - * @param listener - * @return - * @throws IOException - * @throws XMLStreamException - */ - public SBMLDocument readSBML(File file, TreeNodeChangeListener listener) throws XMLStreamException, IOException { - return new org.sbml.jsbml.xml.stax.SBMLReader().readSBML(file, listener); - } - - /** - * Factory method for reading SBML from a given {@link InputStream}. - * - * @param stream - * @return - * @throws XMLStreamException - */ - public static SBMLDocument read(InputStream stream) - throws XMLStreamException { - return new SBMLReader().readSBMLFromStream(stream); - } - - /** - * Factory method for reading SBML from given XML code in its {@link String} - * representation. - * - * @param xml - * @return - * @throws XMLStreamException - */ - public static SBMLDocument read(String xml) throws XMLStreamException { - return new SBMLReader().readSBMLFromString(xml); - } - - /** - * Creates a new {@link SBMLReader}. - */ - public SBMLReader() { - super(); - } - - /** - * Clone constructor. - * - * @param sbmlReader - */ - public SBMLReader(SBMLReader sbmlReader) { - this(); - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public SBMLReader clone() { - return new SBMLReader(this); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - return (o instanceof SBMLReader) ? true : false; - } - - /** - * Reads an SBML document from a {@link File}. - *

    - * This method is identical to {@link SBMLReader#readSBMLFromFile(String filename)} - * or {@link SBMLReader#readSBML(String filename)}. - *

    - * If the {@link File} named file does not exist or its content is not - * valid SBML, one {@link Exception} will be thrown. - *

    - * This methods is not part of the libSBML SBMLReader API. - *

    - * @param file the file to be read. - *

    - * @return an {@link SBMLDocument} created from the SBML content. - * @throws XMLStreamException if any other problems prevent to create a {@link SBMLDocument} - * @throws IOException if the file does not exist or cannot be read. - * - */ - public SBMLDocument readSBML(File file) throws XMLStreamException, IOException { - return readSBML(file, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads an SBML document from a file. - *

    - * This method is identical to {@link SBMLReader#readSBMLFromFile(String filename)} - * or {@link SBMLReader#readSBML(File file)}. - *

    - * If the file named filename does not exist or its content is not - * valid SBML, one {@link Exception} will be thrown. - *

    - * @param fileName the name or full pathname of the file to be read. - *

    - * @return an {@link SBMLDocument} created from the SBML content. - * @throws XMLStreamException if any other problems prevent to create a {@link SBMLDocument} - * @throws IOException if the file does not exist or cannot be read. - * - */ - public SBMLDocument readSBML(String fileName) throws XMLStreamException, IOException { - return new org.sbml.jsbml.xml.stax.SBMLReader().readSBML(fileName); - } - - /** - * Reads an SBML document from a file. - *

    - * This method is identical to {@link SBMLReader#readSBML(String filename)} - * or {@link SBMLReader#readSBML(File file)}. - *

    - * If the file named filename does not exist or its content is not - * valid SBML, one {@link Exception} will be thrown. - *

    - * @param filename the name or full pathname of the file to be read. - *

    - * @return an {@link SBMLDocument} created from the SBML content. - * @throws XMLStreamException if any other problems prevent to create a {@link SBMLDocument} - * @throws IOException if the file does not exist or cannot be read. - * - */ - public SBMLDocument readSBMLFromFile(String filename) throws XMLStreamException, - IOException { - return new org.sbml.jsbml.xml.stax.SBMLReader().readSBMLFile(filename); - } - - /** - * Reads an SBML document from a data stream. - *

    - * This methods is not part of the libSBML SBMLReader API. - *

    - * @param stream the stream of data to be read. - *

    - * @return an {@link SBMLDocument} created from the SBML content. - * @throws XMLStreamException if any problems prevent to create a {@link SBMLDocument} - * - */ - public SBMLDocument readSBMLFromStream(InputStream stream) - throws XMLStreamException { - return (SBMLDocument) new org.sbml.jsbml.xml.stax.SBMLReader().readSBMLFromStream(stream); - } - - /** - * Reads an SBML document from the given XML string. - * - * @param xml a string containing a full SBML model - * @return an {@link SBMLDocument} created from the SBML content. - * @throws XMLStreamException if any problems prevent to create a {@link SBMLDocument} - * - */ - public SBMLDocument readSBMLFromString(String xml) - throws XMLStreamException { - return new org.sbml.jsbml.xml.stax.SBMLReader().readSBMLFromString(xml); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("%s[]", getClass().getSimpleName()); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBMLWriter.java b/IPK_lib/src/org/sbml/jsbml/SBMLWriter.java deleted file mode 100644 index 2e0fc05c0..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBMLWriter.java +++ /dev/null @@ -1,773 +0,0 @@ -/* - * $Id: SBMLWriter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBMLWriter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Serializable; - -import javax.xml.stream.XMLStreamException; - -/** - * Provides methods for writing SBML to files, text strings or streams. - *

    - * This {@link SBMLWriter} is just a wrapper for the actual implementation - * in {@link org.sbml.jsbml.xml.stax.SBMLWriter}. - *

    - * This class is - * provided for compatibility with libSBML and to avoid problems if the - * internal of jsbml change, so it is preferable to use it instead of directly - * using {@link org.sbml.jsbml.xml.stax.SBMLWriter}. - * - * The {@link SBMLWriter} class is the converse of {@link SBMLReader}, and provides the - * main interface for serializing SBML models into XML and writing the - * result to files and text strings. The methods for writing SBML all take - * an {@link SBMLDocument} object and a destination. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class SBMLWriter implements Cloneable, Serializable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7320725236081166704L; - - /** - * Writes the given SBML document to a {@link File}. - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param file - * the file where the SBML document is to be written. - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public static void write(SBMLDocument sbmlDocument, File file, - char indentChar, short indentCount) throws XMLStreamException, SBMLException, IOException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, file); - } - - /** - * Writes the given SBML document to a {@link File}. - *

    - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param file - * the file where the SBML document is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public static void write(SBMLDocument sbmlDocument, File file, String programName, - String programVersion) - throws XMLStreamException, SBMLException, IOException { - new org.sbml.jsbml.xml.stax.SBMLWriter().write(sbmlDocument, file, - programName, programVersion); - } - - /** - * Writes the given SBML document to a {@link File}. - *

    - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param file - * the file where the SBML document is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - * @see {@link #write(SBMLDocument, File, String, String)} - */ - public static void write(SBMLDocument sbmlDocument, File file, - String programName, String programVersion, char indentChar, - short indentCount) throws XMLStreamException, SBMLException, IOException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, file, programName, programVersion); - } - - /** - * Writes the given {@link SBMLDocument} to the {@link OutputStream}. - * - * @param sbmlDocument the SBML document to be written - * @param stream the stream object where the SBML is to be written. - * @param indentChar The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount The number of indentation characters. - * @throws XMLStreamException if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public static void write(SBMLDocument sbmlDocument, OutputStream stream, - char indentChar, short indentCount) throws XMLStreamException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, stream); - } - - /** - * Writes the given {@link SBMLDocument} to the {@link OutputStream}. - * - * @param sbmlDocument - * the SBML document to be written - * @param stream - * the stream object where the SBML is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public static void write(SBMLDocument sbmlDocument, OutputStream stream, - String programName, String programVersion) - throws XMLStreamException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter().write(sbmlDocument, stream, - programName, programVersion); - } - - /** - * Writes the given {@link SBMLDocument} to the {@link OutputStream}. - * - * @param sbmlDocument - * the SBML document to be written - * @param stream - * the stream object where the SBML is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @see #write(SBMLDocument, OutputStream, String, String) - */ - public static void write(SBMLDocument sbmlDocument, OutputStream stream, - String programName, String programVersion, char indentChar, - short indentCount) throws XMLStreamException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, stream, programName, programVersion); - } - - /** - * Writes the given {@link SBMLDocument} to file name. - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param fileName - * the name or full pathname of the file where the SBML document - * is to be written. - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws FileNotFoundException - * if the file does not exist or cannot be created. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public static void write(SBMLDocument sbmlDocument, String fileName, - char indentChar, short indentCount) throws XMLStreamException, - FileNotFoundException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, fileName); - } - - /** - * Writes the given {@link SBMLDocument} to file name. - *

    - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param fileName - * the name or full pathname of the file where the SBML document - * is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * - * @throws FileNotFoundException - * if the file does not exist or cannot be created. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public static void write(SBMLDocument sbmlDocument, String fileName, - String programName, String programVersion) - throws XMLStreamException, FileNotFoundException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter().write(sbmlDocument, fileName, - programName, programVersion); - } - - /** - * Writes the given {@link SBMLDocument} to file name. - *

    - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param fileName - * the name or full pathname of the file where the SBML document - * is to be written. - * @param programName - * the name of this program (where 'this program' refers to the - * program in which JSBML is embedded, not JSBML itself!) - * @param programVersion - * the version of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - * - * @throws FileNotFoundException - * if the file does not exist or cannot be created. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @see #write(SBMLDocument, String, String, String) - */ - public static void write(SBMLDocument sbmlDocument, String fileName, - String programName, String programVersion, char indentChar, - short indentCount) - throws XMLStreamException, FileNotFoundException, SBMLException { - new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, indentCount).write( - sbmlDocument, fileName, programName, programVersion); - } - - /** - * The name of the program that has been used to create an SBML - * {@link String} representation (possibly in a {@link File}) with the help - * of JSBML. - */ - private String programName; - - /** - * The version of the program using JSBML to serialize a model in an SBML - * {@link String} or {@link File}. - */ - private String programVersion; - - /** - * The actual writer. - */ - private org.sbml.jsbml.xml.stax.SBMLWriter sbmlWriter; - - /** - * Creates a new {@link SBMLwriter}. - */ - public SBMLWriter() { - this(null, null); - } - - /** - * Creates a new {@link SBMLwriter} that uses the given character for - * indentation of the XML representation of SBML data structures (with the - * given number of such symbols). - * - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - */ - public SBMLWriter(char indentChar, short indentCount) { - this(null, null, indentChar, indentCount); - } - - /** - * Clone constructor. - * - * @param sbmlWriter - */ - public SBMLWriter(SBMLWriter sbmlWriter) { - this(sbmlWriter.getProgramName(), sbmlWriter.getProgramVersion(), - sbmlWriter.getIndentationChar(), sbmlWriter - .getIndentationCount()); - } - - /** - * Creates a new {@link SBMLwriter} for the program with the given name and - * version. - * - * @param programName - * The name of the program that has been used to create an SBML - * {@link String} representation (possibly in a {@link File}) - * with the help of JSBML. - * @param programVersion - * The version of the program using JSBML to serialize a model in - * an SBML {@link String} or {@link File}. - */ - public SBMLWriter(String programName, String programVersion) { - this(programName, programVersion, org.sbml.jsbml.xml.stax.SBMLWriter - .getDefaultIndentChar(), org.sbml.jsbml.xml.stax.SBMLWriter - .getDefaultIndentCount()); - } - - /** - * Creates a new {@link SBMLwriter} for the program with the given name and - * version that uses the given character for indentation of the XML - * representation of SBML data structures (with the given number of such - * symbols). - * - * @param programName - * The name of the program that has been used to create an SBML - * {@link String} representation (possibly in a {@link File}) - * with the help of JSBML. - * @param programVersion - * The version of the program using JSBML to serialize a model in - * an SBML {@link String} or {@link File}. - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - * @param indentCount - * The number of indentation characters. - */ - public SBMLWriter(String programName, String programVersion, - char indentChar, short indentCount) { - this.programName = programName; - this.programVersion = programVersion; - this.sbmlWriter = new org.sbml.jsbml.xml.stax.SBMLWriter(indentChar, - indentCount); - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public SBMLWriter clone() { - return new SBMLWriter(this); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (o instanceof SBMLWriter) { - SBMLWriter writer = (SBMLWriter) o; - return (writer.getIndentationChar() == getIndentationChar()) - && (writer.getIndentationCount() == getIndentationCount()) - && writer.getProgramName().equals(getProgramName()) - && writer.getProgramVersion().equals(getProgramVersion()); - } - return false; - } - - - /** - * Gives the symbol that is used to indent the SBML output for a better - * structure and to improve human-readability. - * - * @return the character to be used for indentation. - */ - public char getIndentationChar() { - return sbmlWriter.getIndentationChar(); - } - - /** - * Gives the number of indent symbols that are inserted in a line to better - * structure the SBML output. - * - * @return the number of characters used for indentation in SBML - * serializations. - */ - public short getIndentationCount() { - return sbmlWriter.getIndentationCount(); - } - - /** - * @return the name of the program that uses JSBML for writing SBML data - * objects. - * @see #setProgramName(String) - */ - public String getProgramName() { - return (programName != null) ? programName : ""; - } - - /** - * @return the version of the program that uses JSBML for writing SBML data - * objects. - * @see #setProgramVersion(String) - */ - public String getProgramVersion() { - return (programVersion != null) ? programVersion : ""; - } - - /** - * Check if a program name has been defined for this {@link SBMLWriter}. - * - * @return - */ - public boolean isSetProgramName() { - return programName != null; - } - - /** - * Check if a program version has been defined for this {@link SBMLWriter}. - * - * @return - */ - public boolean isSetProgramVersion() { - return programVersion != null; - } - - /** - * Influences the way how SBML data structures are represented in XML. - * - * @param indentChar - * The symbol to be used to indent new blocks within an XML - * representation of SBML data structures. - */ - public void setIndentationChar(char indentChar) { - sbmlWriter.setIndentationChar(indentChar); - } - - /** - * Influences the way how SBML data structures are represented in XML. - * - * @param indentCount - * The number of indentation characters in the XML representation - * of SBML data structures. - */ - public void setIndentationCount(short indentCount) { - sbmlWriter.setIndentationCount(indentCount); - } - - /** - * Sets the name of this program, i.e., the program that is about to - * write out the {@link SBMLDocument}. - *

    - * If the program name and version are set (see - * {@link #setProgramVersion(String version)}), the - * following XML comment, intended for human consumption, will be written - * at the beginning of the document: - *

    -	   <!-- Created by <program name> version <program version>
    -	   on yyyy-MM-dd HH:mm with {@link JSBML} version <{@link JSBML} version>. -->
    -	
    - *

    - * @param name the name of this program (where 'this program' refers to - * the program in which JSBML is embedded, not JSBML itself!) - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • {@link JSBML.OPERATION_SUCCESS} - *

    - * @see #setProgramVersion(String version) - */ - public int setProgramName(String name) { - programName = name; - - return JSBML.OPERATION_SUCCESS; - } - - /** - * Sets the version of this program, i.e., the program that is about to - * write out the {@link SBMLDocument}. - *

    - * If the program version and name are set (see - * {@link setProgramName(String name)}), the - * following XML comment, intended for human consumption, will be written - * at the beginning of the document:

    <!-- Created by <program
    -	 * name> version <program version> on yyyy-MM-dd HH:mm with {@link JSBML}
    -	 * version <{@link JSBML} version>. --> 
    - *

    - * @param version the version of this program (where 'this program' - * refers to the program in which JSBML is embedded, not JSBML itself!) - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • {@link JSBML.OPERATION_SUCCESS} - *

    - * @see #setProgramName(String name) - */ - public int setProgramVersion(String version) { - programVersion = version; - - return JSBML.OPERATION_SUCCESS; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format( - "%s [programName=%s, programVersion=%s, indentationChar=%c, indentationCount=%d]", - getClass().getSimpleName(), programName, - programVersion, sbmlWriter.getIndentationChar(), - sbmlWriter.getIndentationCount()); - } - - /** - * - */ - public void unsetProgramName() { - setProgramName(null); - } - - /** - * - */ - public void unsetProgramVersion() { - setProgramVersion(null); - } - - /** - * Writes the given SBML document to a {@link File}. If specified in the - * constructor of this {@link SBMLWriter}, the {@link #programName} and - * {@link #programVersion} of the calling program will be made persistent in - * the resulting SBML {@link File}. - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param file - * the file where the SBML document is to be written. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public void write(SBMLDocument sbmlDocument, File file) - throws XMLStreamException, SBMLException, IOException { - sbmlWriter.write(sbmlDocument, file, programName, programVersion); - } - - /** - * Writes the given SBML document to the {@link OutputStream}. If specified - * in the constructor of this {@link SBMLWriter}, the {@link #programName} - * and {@link #programVersion} of the calling program will be made - * persistent in the resulting SBML representation. - * - * @param sbmlDocument - * the SBML document to be written - * @param stream - * the stream object where the SBML is to be written. - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * - */ - public void write(SBMLDocument sbmlDocument, OutputStream stream) - throws XMLStreamException, SBMLException { - sbmlWriter.write(sbmlDocument, stream, programName, programVersion); - } - - /** - * Writes the given {@link SBMLDocument} to file name. If specified in the - * constructor of this {@link SBMLWriter}, the {@link #programName} and - * {@link #programVersion} of the calling program will be made persistent in - * the resulting SBML {@link File}. - *

    - * - * @param sbmlDocument - * the {@link SBMLDocument} to be written - * @param fileName - * the name or full pathname of the file where the SBML document - * is to be written. - *

    - * @throws FileNotFoundException - * if the file does not exist or cannot be created. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * - */ - public void write(SBMLDocument sbmlDocument, String fileName) - throws XMLStreamException, FileNotFoundException, SBMLException { - sbmlWriter.write(sbmlDocument, fileName, programName, programVersion); - } - - /** - * Writes the given SBML document to a {@link File}. If specified in the - * constructor of this {@link SBMLWriter}, the {@link #programName} and - * {@link #programVersion} of the calling program will be made persistent in - * the resulting SBML {@link File}. - * - * @param sbmlDocument - * the SBML document to be written - * @param file - * the file where the SBML document is to be written. - * - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public void writeSBML(SBMLDocument sbmlDocument, File file) - throws XMLStreamException, SBMLException, IOException { - sbmlWriter.write(sbmlDocument, file, programName, programVersion); - } - - /** - * Writes the given SBML document to file name. If specified in the - * constructor of this {@link SBMLWriter}, the {@link #programName} and - * {@link #programVersion} of the calling program will be made persistent in - * the resulting SBML {@link File}. - *

    - * - * @param sbmlDocument - * the SBML document to be written - * @param fileName - * the name or full pathname of the file where the SBML document - * is to be written. - * - * @throws FileNotFoundException - * if the file does not exist or cannot be created. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public void writeSBMLToFile(SBMLDocument sbmlDocument, String fileName) - throws FileNotFoundException, XMLStreamException, SBMLException { - write(sbmlDocument, fileName); - } - - /** - * Writes the given SBML document to an in-memory {@link String} and returns - * it. If specified in the constructor of this {@link SBMLWriter}, the - * {@link #programName} and {@link #programVersion} of the calling program - * will be made persistent in the resulting SBML {@link String}. - *

    - * - * @param sbmlDocument - * the SBML document to be written - *

    - * @return the string representing the SBML document as XML. - * @throws XMLStreamException - * if any problems prevent to write the {@link SBMLDocument} as - * XML. - * @throws SBMLException - * if any SBML problems prevent to write the - * {@link SBMLDocument}. - */ - public String writeSBMLToString(SBMLDocument sbmlDocument) - throws XMLStreamException, SBMLException { - return sbmlWriter.writeSBMLToString(sbmlDocument, programName, - programVersion); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBO.java b/IPK_lib/src/org/sbml/jsbml/SBO.java deleted file mode 100644 index cf68d4982..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBO.java +++ /dev/null @@ -1,2170 +0,0 @@ -/* - * $Id: SBO.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBO.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Serializable; -import java.util.HashSet; -import java.util.NoSuchElementException; -import java.util.Properties; -import java.util.Set; - -import org.biojava.bio.Annotation; -import org.biojava.ontology.Ontology; -import org.biojava.ontology.Synonym; -import org.biojava.ontology.io.OboParser; -import org.sbml.jsbml.resources.Resource; -import org.sbml.jsbml.util.StringTools; - -/** - * Methods for interacting with Systems Biology Ontology (SBO) terms. - * - *

    This class - * uses the BioJava classes for working with ontologies and contains static - * classes to represent single {@link Term}s and {@link Triple}s of subject, - * predicate, and object, where each of these three entities is again an - * instance of {@link Term}. The classes {@link Term} and {@link Triple} - * basically wrap the underlying functions from BioJava, but the original - * {@link Object}s can be accessed via dedicated get methods. Furthermore, the - * {@link Ontology} from BioJava, which is used in this class, can also be - * obtained using the method {@link #getOntology()}. - * - *

    - * The values of 'id' attributes on SBML components allow the components to - * be cross-referenced within a model. The values of 'name' attributes on - * SBML components provide the opportunity to assign them meaningful labels - * suitable for display to humans. The specific identifiers and labels - * used in a model necessarily must be unrestricted by SBML, so that - * software and users are free to pick whatever they need. However, this - * freedom makes it more difficult for software tools to determine, without - * additional human intervention, the semantics of models more precisely - * than the semantics provided by the SBML object classes defined in other - * sections of this document. For example, there is nothing inherent in a - * parameter with identifier k that would indicate to a - * software tool it is a first-order rate constant (if that's what - * k happened to be in some given model). However, one may - * need to convert a model between different representations (e.g., - * Henri-Michaelis-Menten versus elementary steps), or to use it with - * different modeling approaches (discrete or continuous). One may also - * need to relate the model components with other description formats such - * as SBGN (http://www.sbgn.org/) using deeper - * semantics. Although an advanced software tool might be able to - * deduce the semantics of some model components through detailed analysis - * of the kinetic rate expressions and other parts of the model, this - * quickly becomes infeasible for any but the simplest of models. - *

    - * An approach to solving this problem is to associate model components - * with terms from carefully curated controlled vocabularies (CVs). This - * is the purpose of the optional 'sboTerm' attribute provided on the SBML - * class {@link SBase}. The 'sboTerm' attribute always refers to terms belonging - * to the Systems Biology Ontology (SBO). - *

    - *

    Use of {@link SBO}

    - *

    - * Labeling model components with terms from shared controlled vocabularies - * allows a software tool to identify each component using identifiers that - * are not tool-specific. An example of where this is useful is the desire - * by many software developers to provide users with meaningful names for - * reaction rate equations. Software tools with editing interfaces - * frequently provide these names in menus or lists of choices for users. - * However, without a standardized set of names or identifiers shared - * between developers, a given software package cannot reliably interpret - * the names or identifiers of reactions used in models written by other - * tools. - *

    - * The first solution that might come to mind is to stipulate that certain - * common reactions always have the same name (e.g., 'Michaelis-Menten'), but - * this is simply impossible to do: not only do humans often disagree on - * the names themselves, but it would not allow for correction of errors or - * updates to the list of predefined names except by issuing new releases - * of the SBML specification—to say nothing of many other limitations - * with this approach. Moreover, the parameters and variables that appear - * in rate expressions also need to be identified in a way that software - * tools can interpret mechanically, implying that the names of these - * entities would also need to be regulated. - *

    - * The Systems Biology Ontology (SBO) provides terms for identifying most - * elements of SBML. The relationship implied by an 'sboTerm' on an SBML - * model component is is-a between the characteristic of the - * component meant to be described by SBO on this element and the SBO - * term identified by the value of the 'sboTerm'. By adding SBO term - * references on the components of a model, a software tool can provide - * additional details using independent, shared vocabularies that can - * enable other software tools to recognize precisely what the - * component is meant to be. Those tools can then act on that information. - * For example, if the SBO identifier 'SBO:0000049' is assigned - * to the concept of 'first-order irreversible mass-action kinetics, - * continuous framework', and a given {@link KineticLaw} object in a model has an - * 'sboTerm' attribute with this value, then regardless of the identifier - * and name given to the reaction itself, a software tool could use this to - * inform users that the reaction is a first-order irreversible mass-action - * reaction. This kind of reverse engineering of the meaning of reactions - * in a model would be difficult to do otherwise, especially for more - * complex reaction types. - *

    - * The presence of SBO labels on {@link Compartment}, {@link Species}, and {@link Reaction} - * objects in SBML can help map those entities to equivalent concepts in - * other standards, such as (but not limited to) BioPAX (http://www.biopax.org/), PSI-MI (http://www.psidev.info), - * or the Systems Biology Graphical Notation (SBGN, http://www.sbgn.org/). Such mappings - * can be used in conversion procedures, or to build interfaces, with SBO - * becoming a kind of 'glue' between standards of representation. - *

    - * The presence of the label on a kinetic expression can also allow - * software tools to make more intelligent decisions about reaction rate - * expressions. For example, an application could recognize certain types - * of reaction formulas as being ones it knows how to solve with optimized - * procedures. The application could then use internal, optimized code - * implementing the rate formula indexed by identifiers such as - * 'SBO:0000049' appearing in SBML models. - *

    - * Finally, SBO labels may be very valuable when it comes to model - * integration, by helping identify interfaces, convert mathematical - * expressions and parameters etc. - *

    - * Although the use of SBO can be beneficial, it is critical to keep in - * mind that the presence of an 'sboTerm' value on an object must not - * change the fundamental mathematical meaning of the model. An SBML - * model must be defined such that it stands on its own and does not depend - * on additional information added by SBO terms for a correct mathematical - * interpretation. SBO term definitions will not imply any alternative - * mathematical semantics for any SBML object labeled with that term. Two - * important reasons motivate this principle. First, it would be too - * limiting to require all software tools to be able to understand the SBO - * vocabularies in addition to understanding SBML. Supporting SBO is not - * only additional work for the software developer; for some kinds of - * applications, it may not make sense. If SBO terms on a model are - * optional, it follows that the SBML model must remain - * unambiguous and fully interpretable without them, because an application - * reading the model may ignore the terms. Second, we believe allowing the - * use of 'sboTerm' to alter the mathematical meaning of a model would - * allow too much leeway to shoehorn inconsistent concepts into SBML - * objects, ultimately reducing the interoperability of the models. - *

    - *

    Relationships between {@link SBO} and SBML

    - *

    - * The goal of SBO labeling for SBML is to clarify to the fullest extent - * possible the nature of each element in a model. The approach taken in - * SBO begins with a hierarchically-structured set of controlled - * vocabularies with six main divisions: (1) entity, (2) participant role, - * (3) quantitative parameter, (4) modeling framework, (5) mathematical - * expression, and (6) interaction. The web site for SBO (http://biomodels.net) should be - * consulted for the current version of the ontology. - *

    - * The Systems Biology Ontology (SBO) is not part of SBML; it is being - * developed separately, to allow the modeling community to evolve the - * ontology independently of SBML. However, the terms in the ontology are - * being designed keeping SBML components in mind, and are classified into - * subsets that can be directly related with SBML components such as - * reaction rate expressions, parameters, and others. The use of 'sboTerm' - * attributes is optional, and the presence of 'sboTerm' on an element does - * not change the way the model is interpreted. Annotating SBML - * elements with SBO terms adds additional semantic information that may - * be used to convert the model into another model, or another - * format. Although SBO support provides an important source of - * information to understand the meaning of a model, software does not need - * to support 'sboTerm' to be considered SBML-compliant. - *

    - * - * @author Andreas Dräger - * @author rodrigue - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class SBO { - - /** - * This is a convenient wrapper class for the corresponding implementation - * of {@link org.biojava.ontology.Term} in BioJava as it provides - * specialized methods to obtain the information from the SBO OBO file - * directly and under the same name as the keys are given in that file. - * - * @see org.biojava.ontology.Term - */ - public static class Term implements Cloneable, Comparable, Serializable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -2753964994128680208L; - - /** - * Returns a String representing a term the same way as in the OBO file. - * - * @param term the term to print - * @return a String representing a term the same way as in the OBO file. - */ - public static String printTerm(Term term) { - StringBuilder sb = new StringBuilder(); - StringTools.append(sb, "[Term]\nid: ", term.getId(), "\nname: ", - term.getName(), "\ndef: ", term.getDefinition()); - if (term.isObsolete()) { - sb.append("\nis_obsolete: true"); - } - for (Object synonym : term.getSynonyms()) { - sb.append("\nsynonym: "); - if (synonym instanceof Synonym) { - Synonym s = (Synonym) synonym; - StringTools.append(sb, "\"", s.getName(), "\" ["); - if (s.getCategory() != null) { - sb.append(s.getCategory()); - } - sb.append(']'); - } else { - sb.append(synonym); - } - } - for (Term parent : term.getParentTerms()) { - StringTools.append(sb, "\nis_a ", parent, " ! ", parent.getName()); - } - return sb.toString(); - } - - /** - * The base properties of this {@link Term}. - */ - private String id, name, def; - - /** - * The underlying BioJava {@link org.biojava.ontology.Term}. - */ - private org.biojava.ontology.Term term; - - /** - * Creates a new Term instance. - * - * @param term a {@link org.biojava.ontology.Term} object - */ - private Term(org.biojava.ontology.Term term) { - if (term == null) { - throw new NullPointerException("Term must not be null."); - } - - this.term = term; - - id = name = def = null; - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public Term clone() { - return new Term(this.term); - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - public int compareTo(Term term) { - return getId().compareTo(term.getId()); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (o instanceof Term) { - Term term = (Term) o; - return (term.getId() != null) && term.getId().equals(getId()); - } - return false; - } - - /** - * Returns the definition of this {@link Term}, which is stored in the - * corresponding OBO file under the key def. - * - * @return the definition of this {@link Term}. - */ - public String getDefinition() { - if (def == null) { - Annotation annotation; - Object definition; - annotation = this.term.getAnnotation(); - definition = (annotation != null) - && (annotation.keys().size() > 0) ? annotation - .getProperty("def") : null; - def = definition != null ? definition.toString() : ""; - def = def.replace("\\n", "\n").replace("\\t", "\t").replace("\\", ""); - def = def.trim(); - } - return def; - } - - /** - * Returns the SBO identifier of this {@link Term}, for instance: - * SBO:0000031. - * - * @return the SBO identifier of this {@link Term} - */ - public String getId() { - if (id == null) { - id = term.getName(); - } - return id; - } - - /** - * Returns the name of this {@link Term}, i.e., a very short characterization. - * - * @return the name of this {@link Term} - */ - public String getName() { - if (name == null) { - String description; - description = this.term.getDescription(); - name = description != null ? description.replace("\\n", "\n") - .replace("\\,", ",").trim() : ""; - } - return name; - } - - /** - * Returns the parent Terms. - * - * @return the parent Terms. - * - */ - public Set getParentTerms() { - - Set parentRelationShip = SBO.getTriples(this, SBO.getTerm("is_a"), null); - Set parents = new HashSet(); - - for (Triple triple : parentRelationShip) { - parents.add(triple.getObject()); - } - - return parents; - } - - - /** - * Returns a set of all the children Term. - * - * @return a set of all the children Term. - */ - public Set getChildren() { - - Set childrenRelationShip = SBO.getTriples(null, SBO.getTerm("is_a"), this); - Set children = new HashSet(); - - for (Triple triple : childrenRelationShip) { - children.add(triple.getSubject()); - } - - return children; - } - - /** - * Returns all {@link Synonym}s of this {@link Term}. - * - * @return all {@link Synonym}s of this {@link Term}. Returns - * an empty array if no {@link Synonym}s exist for this term, - * but never null. - */ - public Synonym[] getSynonyms() { - Object synonyms[] = term.getSynonyms(); - if ((synonyms == null) || (synonyms.length == 0)) { - return new Synonym[0]; - } - Synonym syn[] = new Synonym[synonyms.length]; - for (int i = 0; i < synonyms.length; i++) { - syn[i] = (Synonym) synonyms[i]; - } - return syn; - } - - /** - * Grants access to the underlying BioJava - * {@link org.biojava.ontology.Term}. - * - * @return the underlying BioJava - * {@link org.biojava.ontology.Term}. - */ - public org.biojava.ontology.Term getTerm() { - return this.term; - } - - /** - * Checks whether or not this {@link Term} is obsolete. - * - * @return whether or not this {@link Term} is obsolete. - */ - public boolean isObsolete() { - if (term.getAnnotation().keys().contains("is_obsolete")) { - return true; - } - return false; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return getId(); - } - - } - - /** - * This is a wrapper class for the corresponding BioJava class - * {@link org.biojava.ontology.Triple}, to allow for simplified access to - * the properties of a subject-predicate-object triple in this ontology. - * - * @see org.biojava.ontology.Triple - */ - public static class Triple implements Cloneable, Comparable, Serializable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7289048361260650338L; - - /** - * The BioJava {@link org.biojava.ontology.Triple}. - */ - private org.biojava.ontology.Triple triple; - - /** - * Creates a new {@link Triple} from a given corresponding object from - * BioJava. - * - * @param triple - */ - private Triple(org.biojava.ontology.Triple triple) { - if (triple == null) { - throw new NullPointerException("Triple must not be null."); - } - this.triple = triple; - } - - /* (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public Triple clone() { - return new Triple(this.triple); - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - public int compareTo(Triple triple) { - String subject = getSubject() != null ? getSubject().toString() : ""; - String predicate = getPredicate() != null ? getPredicate() - .toString() : ""; - String object = getObject() != null ? getObject().toString() : ""; - String tSub = triple.getSubject() != null ? triple.getSubject() - .toString() : ""; - String tPred = triple.getPredicate() != null ? triple - .getPredicate().toString() : ""; - String tObj = triple.getObject() != null ? triple.getObject() - .toString() : ""; - int compare = subject.compareTo(tSub); - if (compare != 0) { - return compare; - } - compare = predicate.compareTo(tPred); - if (compare != 0) { - return compare; - } - compare = object.compareTo(tObj); - return compare; - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (o instanceof Triple) { - return getTriple().equals(((Triple) o).getTriple()); - } - return false; - } - - /** - * Returns the object of this {@link Triple}. - * - * @return the object of this {@link Triple}. - */ - public Term getObject() { - return new Term(triple.getObject()); - } - - /** - * Returns the predicate of this {@link Triple}. - * - * @return the predicate of this {@link Triple}. - */ - public Term getPredicate() { - return new Term(triple.getPredicate()); - } - - /** - * Returns the subject of this {@link Triple}. - * - * @return the subject of this {@link Triple}. - */ - public Term getSubject() { - return new Term(triple.getSubject()); - } - - /** - * Grants access to the original BioJava - * {@link org.biojava.ontology.Triple}. - * - * @return the original BioJava - * {@link org.biojava.ontology.Triple}. - */ - public org.biojava.ontology.Triple getTriple() { - return triple; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("%s %s %s", getSubject(), getPredicate(), - getObject()); - } - - } - - /** - * - */ - private static Properties alias2sbo; - - /** - * the prefix of all SBO ids. - */ - private static final String prefix = "SBO:"; - - /** - * - */ - private static Ontology sbo; - - /** - * - */ - private static Properties sbo2alias; - - /** - * - */ - private static Set terms; - - static { - OboParser parser = new OboParser(); - try { - String path = "org/sbml/jsbml/resources/cfg/"; - InputStream is = Resource.getInstance() - .getStreamFromResourceLocation(path + "SBO_OBO.obo"); - sbo = parser.parseOBO( - new BufferedReader(new InputStreamReader(is)), "SBO", - "Systems Biology Ontology"); - alias2sbo = Resource.readProperties(path + "Alias2SBO.cfg"); - sbo2alias = new Properties(); - for (Object key : alias2sbo.keySet()) { - sbo2alias.put(alias2sbo.get(key), key); - } - // convert between BioJava's Terms and our Terms. - terms = new HashSet(); - } catch (Throwable e) { - e.printStackTrace(); - } - } - - /** - * Checks the format of the given SBO integer portion. - * - * @param sboTerm - * @return true if sboTerm is in the range {0,.., 9999999}, false otherwise. - */ - public static boolean checkTerm(int sboTerm) { - return (0 <= sboTerm) && (sboTerm <= 9999999); - } - - /** - * Checks the format of the given SBO string. - * - * @param sboTerm - * @return true if sboTerm is in the correct format (a zero-padded, seven - * digit string), false otherwise. - */ - public static boolean checkTerm(String sboTerm) { - boolean correct = sboTerm.length() == 11; - correct &= sboTerm.startsWith(prefix); - if (correct) - try { - int sbo = Integer.parseInt(sboTerm.substring(4)); - correct &= checkTerm(sbo); - } catch (NumberFormatException nfe) { - correct = false; - } - return correct; - } - - /** - * Returns an SBO id corresponding to the given alias. - * - * @param alias - * @return an SBO id corresponding to the given alias. - */ - public static int convertAlias2SBO(String alias) { - Object value = alias2sbo.get(alias); - return value != null ? Integer.parseInt(value.toString()) : -1; - } - - /** - * Returns an alias corresponding to the given SBO id. - * - * @param sboterm - * @return an alias corresponding to the given SBO id. - */ - public static String convertSBO2Alias(int sboterm) { - Object value = sbo2alias.get(Integer.toString(sboterm)); - return value != null ? value.toString() : ""; - } - - /** - * Returns the SBO id for antisense RNA. - * - * @return the SBO id for antisense RNA. - */ - public static int getAntisenseRNA() { - return convertAlias2SBO("ANTISENSE_RNA"); - } - - /** - * - * @return - */ - public static int getBindingActivator() { - return 535; - } - - /** - * - * @return - */ - public static int getCatalysis() { - return 13; - } - - /** - * - * @return - */ - public static int getCatalyst() { - return convertAlias2SBO("CATALYSIS"); - } - - /** - * - * @return - */ - public static int getCatalyticActivator() { - return 534; - } - - /** - * - * @return - */ - public static int getCompetetiveInhibitor() { - return 206; - } - - /** - * - * @return - */ - public static int getCompleteInhibitor() { - return 537; - } - - /** - * - * @return - */ - public static int getComplex() { - return convertAlias2SBO("COMPLEX"); - } - - /** - * - * @return - */ - public static int getConservationLaw() { - return 355; - } - - /** - * - * @return - */ - public static int getContinuousFramework() { - return 62; - } - - /** - * Creates and returns a list of molecule types accepted as an enzyme by - * default. These are: - *

      - *
    • ANTISENSE_RNA
    • - *
    • SIMPLE_MOLECULE
    • - *
    • UNKNOWN
    • - *
    • COMPLEX
    • - *
    • TRUNCATED
    • - *
    • GENERIC
    • - *
    • RNA
    • - *
    • RECEPTOR
    • - *
    - * - * @return - */ - public static final Set getDefaultPossibleEnzymes() { - Set possibleEnzymes = new HashSet(); - for (String type : new String[] { "ANTISENSE_RNA", "SIMPLE_MOLECULE", - "UNKNOWN", "COMPLEX", "TRUNCATED", "GENERIC", "RNA", "RECEPTOR" }) - possibleEnzymes.add(Integer.valueOf(convertAlias2SBO(type))); - return possibleEnzymes; - } - - /** - * - * @return - */ - public static int getDiscreteFramework() { - return 63; - } - - /** - * - * @return - */ - public static int getDrug() { - return convertAlias2SBO("DRUG"); - } - - /** - * - * @return - */ - public static int getEmptySet() { - return convertAlias2SBO("DEGRADED"); - } - - /** - * - * @return - */ - public static int getEntity() { - return 236; - } - - /** - * - * @return - */ - public static int getEnzymaticCatalysis() { - return 460; - } - - /** - * - * @return - */ - public static int getEssentialActivator() { - return 461; - } - - /** - * - * @return - */ - public static int getEvent() { - return 231; - } - - /** - * - * @return - */ - public static int getFunctionalCompartment() { - return 289; - } - - /** - * - * @return - */ - public static int getFunctionalEntity() { - return 241; - } - - /** - * - * @return - */ - public static int getGene() { - return convertAlias2SBO("GENE"); - } - - /** - * - * @return - */ - public static int getGeneCodingRegion() { - return 335; - } - - /** - * - * @return - */ - public static int getGeneric() { - return convertAlias2SBO("GENERIC"); - } - - /** - * - * @return - */ - public static int getHillEquation() { - return 192; - } - - /** - * - * @return - */ - public static int getInhibitor() { - return convertAlias2SBO("INHIBITION"); - } - - /** - * - * @return - */ - public static int getInteraction() { - return 231; - } - - /** - * - * @return - */ - public static int getIon() { - return convertAlias2SBO("ION"); - } - - /** - * - * @return - */ - public static int getIonChannel() { - return convertAlias2SBO("ION_CHANNEL"); - } - - /** - * - * @return - */ - public static int getKineticConstant() { - return 9; - } - - /** - * - * @return - */ - public static int getLogicalFramework() { - return 234; - } - - /** - * - * @return - */ - public static int getMaterialEntity() { - return 240; - } - - /** - * - * @return - */ - public static int getMathematicalExpression() { - return 64; - } - - /** - * - * @return - */ - public static int getMessengerRNA() { - return 278; - } - - /** - * - * @return - */ - public static int getModellingFramework() { - return 4; - } - - /** - * - * @return - */ - public static int getModifier() { - return convertAlias2SBO("MODULATION"); - } - - /** - * - * @return - */ - public static int getNonCompetetiveInhibitor() { - return 207; - } - - /** - * - * @return - */ - public static int getNonEssentialActivator() { - return 462; - } - - /** - * Grants access to the underlying {@link Ontology} form BioJava. - * @return - */ - public static Ontology getOntology() { - return sbo; - } - - /** - * - * @return The SBO term identifier corresponding to the {@link Term} with - * the name "partial inhibitor". - */ - public static int getPartialInhibitor() { - return 536; - } - - /** - * - * @return - */ - public static int getParticipant() { - return 235; - } - - /** - * - * @return - */ - public static int getParticipantRole() { - return 3; - } - - /** - * - * @return - */ - public static int getPhenotype() { - return convertAlias2SBO("PHENOTYPE"); - } - - /** - * - * @return - */ - public static int getPhysicalCompartment() { - return 290; - } - - /** - * - * @return - */ - public static int getPhysicalParticipant() { - return 236; - } - - /** - * Creates and returns a list of molecule types that are accepted as an - * enzyme for the given type names. - * - * @param types - * @return - */ - public static final Set getPossibleEnzymes(String... types) { - Set possibleEnzymes = new HashSet(); - for (String type : types) { - possibleEnzymes.add(Integer.valueOf(convertAlias2SBO(type))); - } - return possibleEnzymes; - } - - /** - * - * @return - */ - public static int getProduct() { - return 11; - } - - /** - * - * @return - */ - public static int getProtein() { - return convertAlias2SBO("PROTEIN"); - } - - /** - * - * @return - */ - public static int getQuantitativeParameter() { - return 2; - } - - /** - * - * @return - */ - public static int getRateLaw() { - return 1; - } - - /** - * - * @return - */ - public static int getReactant() { - return 10; - } - - /** - * - * @return - */ - public static int getReceptor() { - return convertAlias2SBO("RECEPTOR"); - } - - /** - * - * @return - */ - public static int getRNA() { - return convertAlias2SBO("RNA"); - } - - /** - * - * @return - */ - public static int getSimpleMolecule() { - return convertAlias2SBO("SIMPLE_MOLECULE"); - } - - /** - * - * @return - */ - public static int getSpecificActivator() { - return 533; - } - - /** - * - * @return - */ - public static int getStateTransition() { - return convertAlias2SBO("STATE_TRANSITION"); - } - - /** - * - * @return - */ - public static int getSteadyStateExpression() { - return 391; - } - - /** - * - * @return - */ - public static int getStimulator() { - return convertAlias2SBO("PHYSICAL_STIMULATION"); - } - - /** - * Gets the SBO term with the id 'sboTerm'. - * - * @jsbml.warning The methods will throw NoSuchElementException if the id is not found. - * - * @param sboTerm the id of the SBO term to search for. - * @return the SBO term with the id 'sboTerm'. - * @throws NoSuchElementException if the id is not found. - */ - public static Term getTerm(int sboTerm) { - return getTerm(intToString(sboTerm)); - } - - /** - * Gets the SBO term with the id 'sboTerm'. - * - *

    The id need to be of the form 'SBO:XXXXXXX' where X is a digit number. - * - * @jsbml.warning The methods will throw NoSuchElementException if the id is not found or null. - * - * @param sboTerm the id of the SBO term to search for. - * @return the SBO term with the id 'sboTerm'. - * @throws NoSuchElementException if the id is not found or null. - */ - public static Term getTerm(String sboTerm) { - return new Term(sbo.getTerm(sboTerm)); - } - - /** - * Returns the root element of the SBO Ontology (SBO:0000000). - * - * @return the root element of the SBO Ontology (SBO:0000000). - */ - public static Term getSBORoot() { - return getTerm("SBO:0000000"); - } - - /** - * Return the set of terms of the SBO Ontology. - * - *

    This methods return only Term object and no Triple object that represent the - * relationship between terms. If you want to access the full set of {@link org.biojava.ontology.Term} - * containing also the {@link org.biojava.ontology.Triple}, use {@link SBO#getOntology()} - * to get the underlying biojava object. - * - * @return the set of terms of the SBO Ontology. - */ - public static Set getTerms() { - if (terms.size() < sbo.getTerms().size()) { - for (org.biojava.ontology.Term term : sbo.getTerms()) { - - if (term instanceof org.biojava.ontology.Triple) { - // does nothing - } else if (term instanceof org.biojava.ontology.Term) { - terms.add(new Term(term)); - } - } - } - return terms; - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSCRIPTION' - * - * @return the SBO id corresponding to the alias 'TRANSCRIPTION' - */ - public static int getTranscription() { - return convertAlias2SBO("TRANSCRIPTION"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSCRIPTIONAL_ACTIVATION' - * - * @return the SBO id corresponding to the alias 'TRANSCRIPTIONAL_ACTIVATION' - */ - public static int getTranscriptionalActivation() { - return convertAlias2SBO("TRANSCRIPTIONAL_ACTIVATION"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSCRIPTIONAL_INHIBITION' - * - * @return the SBO id corresponding to the alias 'TRANSCRIPTIONAL_INHIBITION' - */ - public static int getTranscriptionalInhibitor() { - return convertAlias2SBO("TRANSCRIPTIONAL_INHIBITION"); - } - - /** - * Returns the SBO id corresponding to the alias 'KNOWN_TRANSITION_OMITTED' - * - * @return the SBO id corresponding to the alias 'KNOWN_TRANSITION_OMITTED' - */ - public static int getTransitionOmitted() { - return convertAlias2SBO("KNOWN_TRANSITION_OMITTED"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSLATION' - * - * @return the SBO id corresponding to the alias 'TRANSLATION' - */ - public static int getTranslation() { - return convertAlias2SBO("TRANSLATION"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSLATIONAL_ACTIVATION' - * - * @return the SBO id corresponding to the alias 'TRANSLATIONAL_ACTIVATION' - */ - public static int getTranslationalActivation() { - return convertAlias2SBO("TRANSLATIONAL_ACTIVATION"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSLATIONAL_INHIBITION' - * - * @return the SBO id corresponding to the alias 'TRANSLATIONAL_INHIBITION' - */ - public static int getTranslationalInhibitor() { - return convertAlias2SBO("TRANSLATIONAL_INHIBITION"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRANSPORT' - * - * @return the SBO id corresponding to the alias 'TRANSPORT' - */ - public static int getTransport() { - return convertAlias2SBO("TRANSPORT"); - } - - /** - * Returns the SBO id corresponding to the alias 'TRIGGER' - * - * @return the SBO id corresponding to the alias 'TRIGGER' - */ - public static int getTrigger() { - return convertAlias2SBO("TRIGGER"); - } - - /** - * Returns a set of Triple which match the supplied subject, predicate and object. - * - *

    If any of the parameters of this method are null, they are treated as wildcards. - * - *

     for example : 
    -	 *    getTriples(SBO.getTerm("SBO:0000002"), SBO.getTerm("is_a"), null);
    -	 *    will returned all the parent Terms of SBO:0000002
    -	 * 
    -	 *    getTriples(null, SBO.getTerm("is_a"), SBO.getTerm(188));
    -	 *    will returned all the children Terms of SBO:0000188
    -	 *  
    -	 *  

    - * @param subject the subject to search for, or null. - * @param predicate the relationship to search for, or null. - * @param object the object to search for, or null. - * @return a set of Triple which match the supplied subject, predicate and object. - * - * @see org.biojava.ontology.Ontology#getTriples(org.biojava.ontology.Term, - * org.biojava.ontology.Term, org.biojava.ontology.Term) - */ - public static Set getTriples(Term subject, Term predicate, Term object) { - Set triples = new HashSet(); - for (org.biojava.ontology.Triple triple : sbo.getTriples( - subject != null ? subject.getTerm() : null, - object != null ? object.getTerm() : null, - predicate != null ? predicate.getTerm() : null)) { - triples.add(new Triple(triple)); - } - return triples; - } - - /** - * Returns the SBO id corresponding to the alias 'TRUNCATED' - * - * @return the SBO id corresponding to the alias 'TRUNCATED' - */ - public static int getTruncated() { - return convertAlias2SBO("TRUNCATED"); - } - - /** - * Returns the SBO id corresponding to the alias 'UNKNOWN' - * - * @return the SBO id corresponding to the alias 'UNKNOWN' - */ - public static int getUnknownMolecule() { - return convertAlias2SBO("UNKNOWN"); - } - - /** - * Returns the SBO id corresponding to the alias 'UNKNOWN_TRANSITION' - * - * @return the SBO id corresponding to the alias 'UNKNOWN_TRANSITION' - */ - public static int getUnknownTransition() { - return convertAlias2SBO("UNKNOWN_TRANSITION"); - } - - /** - * Returns the integer as a correctly formatted SBO string. If the sboTerm - * is not in the correct range ({0,.., 9999999}), an empty string is - * returned. - * - * @param sboTerm - * @return the given integer sboTerm as a zero-padded seven digit string. - */ - public static String intToString(int sboTerm) { - if (!checkTerm(sboTerm)) { - return ""; - } - return StringTools.concat(prefix, sboNumberString(sboTerm)).toString(); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isAntisenseRNA(int sboTerm) { - return isChildOf(sboTerm, getAntisenseRNA()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isBindingActivator(int sboTerm) { - return isChildOf(sboTerm, getBindingActivator()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isCatalyst(int sboTerm) { - return isChildOf(sboTerm, getCatalyst()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isCatalyticActivator(int sboTerm) { - return isChildOf(sboTerm, getCatalyticActivator()); - } - - /** - * Checks whether the given sboTerm is a member of the SBO subgraph rooted - * at parent. - * - * @param sboTerm - * An SBO term. - * @param parent - * An SBO term that is the root of a certain subgraph within the - * SBO. - * @return true if the subgraph of the SBO rooted at the term parent - * contains a term with the id corresponding to sboTerm. - */ - public static boolean isChildOf(int sboTerm, int parent) { - if (!checkTerm(sboTerm)) { - return false; - } - return isChildOf(new Term(sbo.getTerm(intToString(sboTerm))), new Term(sbo - .getTerm(intToString(parent)))); - } - - /** - * Traverses the systems biology ontology starting at {@link Term} subject until - * either the root (SBO:0000000) or the {@link Term} object is reached. - * - * @param subject - * Child - * @param object - * Parent - * @return true if subject is a child of object. - */ - private static boolean isChildOf(Term subject, Term object) { - if (subject.equals(object)) { - return true; - } - Set relations = sbo.getTriples( - subject != null ? subject.getTerm() : null, null, null); - for (org.biojava.ontology.Triple triple : relations) { - if (triple.getObject().equals(object.getTerm())) { - return true; - } - if (isChildOf(new Term(triple.getObject()), object)) { - return true; - } - } - return false; - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isCompetetiveInhibitor(int sboTerm) { - return isChildOf(sboTerm, getCompetetiveInhibitor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isCompleteInhibitor(int sboTerm) { - return isChildOf(sboTerm, getCompleteInhibitor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isComplex(int sboTerm) { - return isChildOf(sboTerm, getComplex()); - } - - /** - * Returns true if the term is-a conservation law, false otherwise - * - * @param sboTerm - * @return true if the term is-a conservation law, false otherwise - */ - public static boolean isConservationLaw(int sboTerm) { - return isChildOf(sboTerm, getConservationLaw()); - } - - /** - * Returns true if the term is-a continuous framework, false otherwise - * - * @param sboTerm - * @return true if the term is-a continuous framework, false otherwise - */ - public static boolean isContinuousFramework(int sboTerm) { - return isChildOf(sboTerm, getContinuousFramework()); - } - - /** - * Returns true if the term is-a discrete framework, false otherwise - * - * @param sboTerm - * @return true if the term is-a discrete framework, false otherwise - */ - public static boolean isDiscreteFramework(int sboTerm) { - return isChildOf(sboTerm, getDiscreteFramework()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isDrug(int sboTerm) { - return isChildOf(sboTerm, getDrug()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isEmptySet(int sboTerm) { - return isChildOf(sboTerm, getEmptySet()); - } - - /** - * Returns true if the term is-a Entity, false otherwise - * - * @param sboTerm - * @return true if the term is-a Entity, false otherwise - */ - public static boolean isEntity(int sboTerm) { - return isChildOf(sboTerm, getEntity()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isEnzymaticCatalysis(int sboTerm) { - return isChildOf(sboTerm, getEnzymaticCatalysis()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isEssentialActivator(int sboTerm) { - return isChildOf(sboTerm, getEssentialActivator()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-an Event, false otherwise - */ - public static boolean isEvent(int sboTerm) { - return isChildOf(sboTerm, getEvent()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a functional compartment, false otherwise - */ - public static boolean isFunctionalCompartment(int sboTerm) { - return isChildOf(sboTerm, getFunctionalCompartment()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a functional entity, false otherwise - */ - public static boolean isFunctionalEntity(int sboTerm) { - return isChildOf(sboTerm, getFunctionalEntity()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isGene(int sboTerm) { - return isChildOf(sboTerm, getGene()); - } - - /** - * Returns true if the sboTerm stands for a gene coding region, false - * otherwise - * - * @param sboTerm - * @return true if the sboTerm stands for a gene coding region, false - * otherwise - */ - public static boolean isGeneCodingRegion(int sboTerm) { - return isChildOf(sboTerm, getGeneCodingRegion()); - } - - /** - * Returns true if the sboTerm stands for a gene coding region or a gene, - * false otherwise - * - * @param sboTerm - * @return true if the sboTerm stands for a gene coding region or a gene, - * false otherwise - */ - public static boolean isGeneOrGeneCodingRegion(int sboTerm) { - return isGene(sboTerm) || isGeneCodingRegion(sboTerm); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isGeneric(int sboTerm) { - return isChildOf(sboTerm, getGeneric()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isHillEquation(int sboTerm) { - return isChildOf(sboTerm, getHillEquation()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isInhibitor(int sboTerm) { - return isChildOf(sboTerm, getInhibitor()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-an interaction, false otherwise - */ - public static boolean isInteraction(int sboTerm) { - return isChildOf(sboTerm, getInteraction()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isIon(int sboTerm) { - return isChildOf(sboTerm, getIon()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isIonChannel(int sboTerm) { - return isChildOf(sboTerm, getIonChannel()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a kinetic constant, false otherwise - */ - public static boolean isKineticConstant(int sboTerm) { - return isChildOf(sboTerm, getKineticConstant()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a logical framework, false otherwise - */ - public static boolean isLogicalFramework(int sboTerm) { - return isChildOf(sboTerm, getLogicalFramework()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a material entity, false otherwise - */ - public static boolean isMaterialEntity(int sboTerm) { - return isChildOf(sboTerm, getMaterialEntity()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a mathematical expression, false otherwise - */ - public static boolean isMathematicalExpression(int sboTerm) { - return isChildOf(sboTerm, getMathematicalExpression()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isMessengerRNA(int sboTerm) { - return isChildOf(sboTerm, getMessengerRNA()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a modelling framework, false otherwise - */ - public static boolean isModellingFramework(int sboTerm) { - return isChildOf(sboTerm, getModellingFramework()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a modifier, false otherwise - */ - public static boolean isModifier(int sboTerm) { - return isChildOf(sboTerm, getModifier()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isNonCompetetiveInhibitor(int sboTerm) { - return isChildOf(sboTerm, getNonCompetetiveInhibitor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isNonEssentialActivator(int sboTerm) { - return isChildOf(sboTerm, getNonEssentialActivator()); - } - - /** - * Function for checking whether the SBO term is obsolete. - * - * @param sboTerm - * @return true if the term is-an obsolete term, false otherwise - */ - public static boolean isObsolete(int sboTerm) { - return getTerm(intToString(sboTerm)).isObsolete(); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isPartialInhibitor(int sboTerm) { - return isChildOf(sboTerm, getPartialInhibitor()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. This term - * is actually obsolete. - * - * @param sboTerm - * @return true if the term is-a participant, false otherwise - */ - public static boolean isParticipant(int sboTerm) { - return isChildOf(sboTerm, getParticipant()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a participant role, false otherwise - */ - public static boolean isParticipantRole(int sboTerm) { - return isChildOf(sboTerm, getParticipantRole()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isPhenotype(int sboTerm) { - return isChildOf(sboTerm, getPhenotype()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isPhysicalCompartment(int sboTerm) { - return isChildOf(sboTerm, getPhysicalCompartment()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. Obsolete - * term. - * - * @param sboTerm - * @return true if the term is-a physical participant, false otherwise - */ - public static boolean isPhysicalParticipant(int sboTerm) { - return isChildOf(sboTerm, getPhysicalParticipant()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a product, false otherwise - */ - public static boolean isProduct(int sboTerm) { - return isChildOf(sboTerm, getProduct()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isProtein(int sboTerm) { - return isChildOf(sboTerm, getProtein()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a quantitative parameter, false otherwise - */ - public static boolean isQuantitativeParameter(int sboTerm) { - return isChildOf(sboTerm, getQuantitativeParameter()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a rate law, false otherwise - */ - public static boolean isRateLaw(int sboTerm) { - return isChildOf(sboTerm, getRateLaw()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a reactant, false otherwise - */ - public static boolean isReactant(int sboTerm) { - return isChildOf(sboTerm, getReactant()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isReceptor(int sboTerm) { - return isChildOf(sboTerm, getReceptor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isRNA(int sboTerm) { - return isChildOf(sboTerm, getRNA()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isRNAOrMessengerRNA(int sboTerm) { - return isRNA(sboTerm) || isMessengerRNA(sboTerm); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isSimpleMolecule(int sboTerm) { - return isChildOf(sboTerm, getSimpleMolecule()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isSpecificActivator(int sboTerm) { - return isChildOf(sboTerm, getSpecificActivator()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isStateTransition(int sboTerm) { - return isChildOf(sboTerm, getStateTransition()); - } - - /** - * Function for checking the SBO term is from correct part of SBO. - * - * @param sboTerm - * @return true if the term is-a steady state expression, false otherwise - */ - public static boolean isSteadyStateExpression(int sboTerm) { - return isChildOf(sboTerm, getSteadyStateExpression()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isStimulator(int sboTerm) { - return isChildOf(sboTerm, getStimulator()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranscription(int sboTerm) { - return isChildOf(sboTerm, getTranscription()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranscriptionalActivation(int sboTerm) { - return isChildOf(sboTerm, getTranscriptionalActivation()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranscriptionalInhibitor(int sboTerm) { - return isChildOf(sboTerm, getTranscriptionalInhibitor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTransitionOmitted(int sboTerm) { - return isChildOf(sboTerm, getTransitionOmitted()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranslation(int sboTerm) { - return isChildOf(sboTerm, getTranslation()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranslationalActivation(int sboTerm) { - return isChildOf(sboTerm, getTranslationalActivation()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTranslationalInhibitor(int sboTerm) { - return isChildOf(sboTerm, getTranslationalInhibitor()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTransport(int sboTerm) { - return isChildOf(sboTerm, getTransport()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTrigger(int sboTerm) { - return isChildOf(sboTerm, getTrigger()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isTruncated(int sboTerm) { - return isChildOf(sboTerm, getTruncated()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isUnknownMolecule(int sboTerm) { - return isChildOf(sboTerm, getUnknownMolecule()); - } - - /** - * Returns true if the given term identifier comes from the stated branch of SBO. - *

    - * @param sboTerm - * @return true if term is-a SBO 'product', false otherwise. - */ - public static boolean isUnknownTransition(int sboTerm) { - return isChildOf(sboTerm, getUnknownTransition()); - } - - /** - * Tests method. - * - * @param args no argument are processed. - */ - public static void main(String[] args) { - - int i = 0; - for (Term term : getTerms()) { - if (!term.isObsolete()) { - System.out.printf("%s\n\n", Term.printTerm(term)); - i++; - } - } - System.out.println("\nThere is " + i + " terms in the SBO ontology."); - - System.out.println("\nPrinting the SBO ontology tree :"); - Term sboRoot = SBO.getSBORoot(); - - for (Term term : sboRoot.getChildren()) { - System.out.println(" " + term.getId() + " - " + term.getName()); - - printChildren(term, " "); - } - - System.out.println("ANTISENSE_RNA = " + SBO.getAntisenseRNA()); - - // TODO : Shall we catch the exception thrown by the biojava getTerm() method or let it like that ?? - System.out.println("Search null Term : " + SBO.getTerm(null)); - System.out.println("Search invalid id Term : " + SBO.getTerm("SBO:004")); - System.out.println("Search invalid id Term : " + SBO.getTerm("0000004")); - } - - - /** - * Prints to the console all the sub-tree of terms, starting from the children - * of the given parent term. - * - * @param parent the parent term - * @param indent the indentation to use to print the children terms - */ - private static void printChildren(Term parent, String indent) { - for (Term term : parent.getChildren()) { - System.out.println(indent + " " + term.getId() + " - " + term.getName()); - printChildren(term, indent + " "); - } - } - - /** - * Creates and returns a 7 digit SBO number for the given {@link Term} identifier (if - * this is a valid identifier). The returned {@link String} will not contain the - * SBO prefix. - * - * @param sboTerm - * @return a 7 digit SBO number for the given {@link Term} identifier (if - * this is a valid identifier). The returned {@link String} will not contain the - * SBO prefix. - * @throws IllegalArgumentException if the given value is no valid SBO term number. - */ - public static String sboNumberString(int sboTerm) { - if (!checkTerm(sboTerm)) { - throw new IllegalArgumentException("Illegal sboTerm " + sboTerm); - } - return StringTools.leadingZeros(7, sboTerm); - } - - /** - * Returns the string as a correctly formatted SBO integer portion. - * - * @param sboTerm - * @return the given string sboTerm as an integer. If the sboTerm is not in - * the correct format (a zero-padded, seven digit string), -1 is - * returned. - */ - public static int stringToInt(String sboTerm) { - return checkTerm(sboTerm) ? Integer.parseInt(sboTerm.substring(4)) : -1; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBase.java b/IPK_lib/src/org/sbml/jsbml/SBase.java deleted file mode 100644 index 4372ca255..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBase.java +++ /dev/null @@ -1,614 +0,0 @@ -/* - * $Id: SBase.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBase.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.List; -import java.util.Map; -import java.util.SortedSet; - -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.ext.SBasePlugin; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.TreeNodeWithChangeSupport; -import org.sbml.jsbml.util.ValuePair; -import org.sbml.jsbml.xml.XMLNode; - -/** - * The interface to implement for each SBML component. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1169 $ - */ -public interface SBase extends TreeNodeWithChangeSupport { - - /** - * @param term - * @return true if a {@link CVTerm} instance has been added to - * the list of {@link CVTerm} of this object. - */ - public boolean addCVTerm(CVTerm term); - - /** - * Adds an additional name space to the set of declared namespaces of this - * {@link SBase}. - * - * @param prefix the prefix of the namespace to add - * @param namespace the namespace to add - * - */ - public void addDeclaredNamespace(String prefix, String namespace); - - /** - * add a SBase extension object 'sbase' associated with a name space - * 'namespace'. - * - * @param namespace - * @param sbase - */ - public void addExtension(String namespace, SBasePlugin sbase); - - /** - * Adds an additional name space to the set of name spaces of this - * {@link SBase} if the given name space is not yet present within this - * {@link SortedSet}. - * - * @param namespace the namespace to add - */ - public void addNamespace(String namespace); - - /** - * Appends 'notes' to the notes String of this object. - * - * @param notes - */ - public void appendNotes(String notes); - - /** - * Appends 'notes' to the notes of this object. - * - * @param notes - */ - public void appendNotes(XMLNode notes); - - /** - * - * Creates a copy of this object, i.e., e new {@link SBase} with the same properties - * like this one and returns a pointer to it. - * - * @return - */ - public SBase clone(); - - /** - * Returns true if and only if the given {@link SBase} has exactly the same - * properties like this {@link SBase} instance. - * - * @param sbase - * @return true if and only if the given {@link Object} is an instance of - * {@link SBase} that has exactly the same properties like this - * SBase instance. - */ - public boolean equals(Object sbase); - - /** - * This method returns a list of all qualifiers of the given type. - * - * @param qualifier - * @return - */ - public List filterCVTerms(Qualifier qualifier); - - /** - * Queries the list of controlled vocabulary terms for those terms whose - * qualifier is of the given type and selects only those resources from - * these terms that contain the given pattern. - * - * @param qualifier - * @param pattern - * for instance, 'kegg' or 'chebi'. - * @return - */ - public List filterCVTerms(Qualifier qualifier, String pattern); - - /** - * A recursive implementation of {@link #filterCVTerms(Qualifier, String)} - * that considers all child elements of the current instance of - * {@link SBase} as well. - * - * @param qualifier - * @param pattern - * @param recursive - * decides whether or not considering all child elements of this - * {@link SBase} and collecting the matching {@link CVTerm}s of - * all children recursively. If this argument is false, the - * behavior of the method will be equivalent to calling - * {@link #filterCVTerms(Qualifier, String)}. - * @return - * @see #filterCVTerms(Qualifier, String) - */ - public List filterCVTerms(Qualifier qualifier, String pattern, - boolean recursive); - - /** - * Returns the content of the 'annotation' sub-element of this object as an - * {@link Annotation} instance. - * - * @return the content of the 'annotation' sub-element of this object as an - * {@link Annotation} instance. - */ - public Annotation getAnnotation(); - - /** - * Returns the content of the 'annotation' sub-element of this object as a - * String. - * - * @return the content of the 'annotation' sub-element of this object as a - * String. - */ - public String getAnnotationString(); - - /** - * - * @param index - * @return the {@link CVTerm} instance at the position 'index' in the list of - * {@link CVTerm}s of this object. - */ - public CVTerm getCVTerm(int index); - - /** - * - * @return the list of {@link CVTerm}s of this object. If not yet set, this method - * initializes the annotation and returns an empty list. - */ - public List getCVTerms(); - - /** - * Returns all the namespaces declared on this object. These will be written on the - * resulting XML element. - * - * @return all the namespaces declared on this object. These will be written on the - * resulting XML element. - */ - public Map getDeclaredNamespaces(); - - /** - * - * @return the XML element name of this object. - */ - public String getElementName(); - - /** - * - * @param namespace - * @return the SBase extension object which matches this name space. - */ - public SBasePlugin getExtension(String namespace); - - /** - * - * @return the map containing all the extension objects of this object. - */ - public Map getExtensionPackages(); - - /** - * - * @return the {@link History} instance of this object. - */ - public History getHistory(); - - /** - * Returns the SBML Level of the overall SBML document. Returns -1 if it is - * not set. - * - * @return the SBML level of this SBML object. - * @see getVersion() - */ - public int getLevel(); - - /** - * Returns the Level and Version combination of this {@link SBase}. - * - * @return A {@link ValuePair} with the Level and Version of this - * {@link SBase}. Note that the returned {@link ValuePair} is never - * null, but if undeclared it may contain elements set to -1. - */ - public ValuePair getLevelAndVersion(); - - /** - * - * @return the metaid of this element. - */ - public String getMetaId(); - - /** - * Returns the {@link Model} object in which the current {@link SBase} is located. - * - * @return - */ - public Model getModel(); - - /** - * Returns all the namespaces of all the packages which are currently - * extending this object. - * - * @return all the name spaces of all the packages which are currently - * extending this object. - */ - public SortedSet getNamespaces(); - - /** - * Returns the XMLNode containing the notes sub-element of - * this object. - * - * @return the XMLNode containing the notes sub-element of - * this object. - */ - public XMLNode getNotes(); - - /** - * - * @return the notes sub-element of this object as a {@link String}. If no - * notes are set, an empty {@link String} will be returned. - */ - public String getNotesString(); - - /** - * - * @return the number of {@link CVTerm}s of this {@link SBase}. - * @deprecated use {@link #getCVTermCount()} - */ - @Deprecated - public int getNumCVTerms(); - - /** - * - * @return the number of {@link CVTerm}s of this {@link SBase}. - */ - public int getCVTermCount(); - - /** - * This method is convenient when holding an object nested inside other - * objects in an SBML model. It allows direct access to the <model> - * - * element containing it. - * - * @return Returns the parent SBML object. - * @see #getParent() - */ - public SBase getParentSBMLObject(); - - /** - * Returns the parent {@link SBMLDocument} object. - * - * LibSBML uses the class {@link SBMLDocument} as a top-level container for storing - * SBML content and data associated with it (such as warnings and error - * messages). An SBML model in libSBML is contained inside an {@link SBMLDocument} - * object. {@link SBMLDocument} corresponds roughly to the class 'sbml' defined in the - * SBML Level 2 specification, but it does not have a direct correspondence - * in SBML Level 1. (But, it is created by libSBML no matter whether the - * model is Level 1 or Level 2.) - * - * This method allows the {@link SBMLDocument} for the current object to be - * retrieved. - * - * @return the parent {@link SBMLDocument} object of this SBML object. - */ - public SBMLDocument getSBMLDocument(); - - /** - * Grants access to the Systems Biology Ontology (SBO) term associated with - * this {@link SBase}. - * - * @return the SBOTerm attribute of this element. - * @see SBO - */ - public int getSBOTerm(); - - /** - * Grants access to the Systems Biology Ontology (SBO) term associated with - * this {@link SBase}. - * - * @return the SBO term ID of this element. - * @see SBO - */ - public String getSBOTermID(); - - /** - * Returns the Version within the SBML Level of the overall SBML document. - * Return -1 if it is not set. - * - * @return the SBML version of this SBML object. - * @see getLevel() - */ - public int getVersion(); - - /** - * - * @return - * @see Object#hashCode() - */ - public int hashCode(); - - /** - * - * @return true if the {@link Annotation} 'about' {@link String} of this - * object matches the metaid of this object. - */ - public boolean hasValidAnnotation(); - - /** - * Predicate returning true or false depending on whether this object's - * level/version and name space values correspond to a valid SBML - * specification. - * - * @return - */ - public boolean hasValidLevelVersionNamespaceCombination(); - - /** - * - * @return true if this object is extended by other packages. - */ - public boolean isExtendedByOtherPackages(); - - /** - * Predicate returning true or false depending on whether this object's - * 'annotation' sub-element exists and has content. - * - * @return true if the {@link Annotation} instance of this object is not - * null and contains at least one {@link CVTerm} or one - * {@link String} containing other annotations than RDF or a - * {@link History} instance. - */ - public boolean isSetAnnotation(); - - /** - * - * @return true if the {@link Annotation} instance of this object - */ - public boolean isSetHistory(); - - /** - * - * @return true if the level is not null. - */ - public boolean isSetLevel(); - - /** - * Returns true if both, Level and Version are set for this - * {@link SBase}. - * - * @return true if {@link #isSetLevel()} and - * {@link #isSetVersion()}. - */ - public boolean isSetLevelAndVersion(); - - /** - * Predicate returning true or false depending on whether this object's - * 'metaid' attribute has been set. - * - * @return true if the metaid is not null. - */ - public boolean isSetMetaId(); - - /** - * Predicate returning true or false depending on whether this object's - * 'notes' sub-element exists and has content. - * - * @return true if the notes {@link String} is not null. - */ - public boolean isSetNotes(); - - /** - * Check whether this {@link SBase} has been linked to a parent within the - * hierarchical SBML data structure. - * - * @return true if this {@link SBase} has a parent SBML object, - * false otherwise. - * @see #getParentSBMLObject() - */ - public boolean isSetParentSBMLObject(); - - /** - * - * @return true if the SBOTerm is not -1. - * @see SBO - */ - public boolean isSetSBOTerm(); - - /** - * - * @return true if the version is not null. - */ - public boolean isSetVersion(); - - /** - * If the attribute is an id or name attribute, it will set the id or name - * of this object with the value of the XML attribute ('value'). - * - * @param attributeName - * : localName of the XML attribute - * @param prefix - * : prefix of the XML attribute - * @param value - * : value of the XML attribute - * @return true if the attribute has been successfully read. - */ - public boolean readAttribute(String attributeName, String prefix, - String value); - - /** - * Sets this object as SBML parent of 'sbase'. Check if the level and version - * of sbase are set, otherwise sets the level and version of 'sbase' with - * those of this object. This method should actually not be called by any tool - * as it is used internally within JSBML to maintain the hierarchical document - * structure. - * - * If the level and version of sbase are set but not valid, an {@link Exception} is - * thrown. - */ - public void registerChild(SBase sbase) throws LevelVersionError; - - /** - * Unregisters recursively the given SBase from the {@link Model} - * and {@link SBMLDocument}. - * - */ - public void unregister(SBase sbase); - - /** - * Removes the given {@link TreeNodeChangeListener} from this element. - * - * @param l - */ - public void removeTreeNodeChangeListener(TreeNodeChangeListener l); - - /** - * Sets the value of the 'annotation' sub-element of this SBML object to a - * copy of annotation given as an {@link Annotation} instance. - * - * @param annotation - */ - public void setAnnotation(Annotation annotation); - - /** - * - * @return the {@link History} instance of this object. - */ - public void setHistory(History history); - - /** - * Sets the level of this object with 'level'. If the SBML parent of this - * object is set and 'level' is different with the SBML parent level, an - * {@link Exception} is thrown. - * - * @param level - */ - public void setLevel(int level); - - /** - * Sets the metaid value with 'metaid'. - * - * @param metaid - * @throws PropertyNotAvailableException - * in Level 1. - */ - public void setMetaId(String metaid); - - /** - * Sets the notes with 'notes'. - * - * @param notes - */ - public void setNotes(String notes); - - /** - * Sets the XMLNode containing the notes sub-element of - * this object. - * - */ - public void setNotes(XMLNode notesXMLNode); - - /** - * - * @param parent - */ - public void setParentSBML(SBase parent); - - /** - * Sets the value of the 'sboTerm' attribute. - * - * @param term - * @see SBO - * @throws PropertyNotAvailableException in Level 1. - */ - public void setSBOTerm(int term); - - /** - * Sets the value of the 'sboTerm' attribute. - * - * @param sboid - * @see SBO - */ - public void setSBOTerm(String sboid); - - /** - * Sets this object as SBML parent of 'sbase'. Check if the level and version - * of sbase are set, otherwise sets the level and version of 'sbase' with - * those of this object. This method should actually not be called by any tool - * as it is used internally within JSBML to maintain the hierarchical document - * structure. - * - * If the level and version of sbase are set but not valid, an {@link Exception} is - * thrown. - * - * @deprecated use {@link #registerChild(SBase)} - */ - @Deprecated - public void setThisAsParentSBMLObject(SBase sbase) throws LevelVersionError; - - /** - * Sets the version of this object with 'version'. If the SBML parent of this - * object is set and 'version' is different with the SBMLparent version, an - * {@link Exception} is thrown. - * - * @param level - */ - public void setVersion(int version); - - /** - * Unsets the value of the 'annotation' sub-element of this SBML object. - */ - public void unsetAnnotation(); - - /** - * Unsets the list of {@link CVTerm} of this object. - */ - public void unsetCVTerms(); - - /** - * Unsets the {@link History} of this object. - */ - public void unsetHistory(); - - /** - * Unsets the value of the 'metaid' attribute of this SBML object. - */ - public void unsetMetaId(); - - /** - * Unsets the value of the 'notes' sub-element of this SBML object. - */ - public void unsetNotes(); - - /** - * Unsets the value of the 'sboTerm' attribute of this SBML object. - */ - public void unsetSBOTerm(); - - /** - * @return a {@link Map} containing the XML attributes of this object. - */ - public Map writeXMLAttributes(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBaseWithDerivedUnit.java b/IPK_lib/src/org/sbml/jsbml/SBaseWithDerivedUnit.java deleted file mode 100644 index 1d5663f7a..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBaseWithDerivedUnit.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * $Id: SBaseWithDerivedUnit.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBaseWithDerivedUnit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * This type represents an SBase object that is associated to a unit. This may - * be a directly defined unit or a unit that has to be derived by evaluating - * other elements within this object. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @date 2010-04-20 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface SBaseWithDerivedUnit extends SBase { - - /** - * Returns true or false depending on whether this - * {@link SBaseWithDerivedUnit} refers to elements such as parameters or - * numbers with undeclared units. - * - * A return value of true indicates that the UnitDefinition - * returned by {@see getDerivedUnitDefinition()} may not accurately - * represent the units of the expression. - * - * @return true if the math expression of this {@link SBaseWithDerivedUnit} - * includes parameters/numbers with undeclared units, - * false otherwise. - */ - public boolean containsUndeclaredUnits(); - - /** - * This method derives the unit of this quantity and tries to identify an - * equivalent {@link UnitDefinition} within the corresponding {@link Model}. - * If no equivalent unit definition can be found, a new unit definition will - * be created that is not part of the model but represents the unit of this - * quantity. If it is not possible to derive a unit for this quantity, null - * will be returned. - * - * @return - */ - public UnitDefinition getDerivedUnitDefinition(); - - /** - * This method derives the unit of this quantity. If the model that contains - * this quantity already contains a unit that is equivalent to the derived - * unit, the corresponding identifier will be returned. In case that the - * unit cannot be derived or that no equivalent unit exists within the - * model, or if the model has not been defined yet, null will be returned. - * In case that this quantity represents a basic {@link Unit.Kind} this - * method will return the {@link String} representation of this - * {@link Unit.Kind}. - * - * @return - */ - public String getDerivedUnits(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SBaseWithUnit.java b/IPK_lib/src/org/sbml/jsbml/SBaseWithUnit.java deleted file mode 100644 index ca38d4763..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SBaseWithUnit.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * $Id: SBaseWithUnit.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SBaseWithUnit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.Unit.Kind; - -/** - * Defines a kind of {@link SBase} that is equipped with a defined unit. This - * means, instances of this interface have a derived unit and a defined unit and - * provide methods to manipulate the kind of {@link Unit} or - * {@link UnitDefinition} associated with this data type. - * - * @author Andreas Dräger - * @date 2010-12-15 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface SBaseWithUnit extends SBaseWithDerivedUnit { - - /** - * - * @return the unitsID of this {@link SBaseWithUnit}. The empty - * {@link String} if it is not set. - */ - public String getUnits(); - - /** - * - * @return The UnitDefinition instance which has the {@link #unitsID} of - * this {@link SBaseWithUnit} as id. Null if it doesn't - * exist. In case that the unit of this {@link SBaseWithUnit} - * represents a base {@link Unit}, a new {@link UnitDefinition} will - * be created and returned by this method. This new - * {@link UnitDefinition} will only contain the one unit represented - * by the unit identifier in this {@link SBaseWithUnit}. Note - * that the corresponding model will not contain this - * {@link UnitDefinition}. The identifier of this new - * {@link UnitDefinition} will be set to the same value as the name - * of the base {@link Unit}. - */ - public UnitDefinition getUnitsInstance(); - - /** - * - * @return true if the unitsID of this element is not null. - */ - public boolean isSetUnits(); - - /** - * Checks whether the element referenced by the unitsID - * attribute of this {@link SBaseWithUnit} is either an existing base - * {@link Unit}, i.e., a simple {@link Unit} that can directly be addressed - * via its {@link Kind} element, or the identifier of an existing - * {@link UnitDefinition} in the {@link Model} to which this - * {@link SBaseWithUnit} belongs. - * - * @return true if either a {@link UnitDefinition}, which has the - * unitsID of this {@link SBaseWithUnit}, can be - * found in the {@link Model} to which this - * {@link SBaseWithUnit} belongs, or if this element's - * unitsID as a corresponding base {@link Unit} for the - * given Level/Version combination. - */ - public boolean isSetUnitsInstance(); - - /** - * Sets the unitsID of this {@link SBaseWithUnit}. Only valid unit - * kind names or identifiers of already existing {@link UnitDefinition}s are - * allowed arguments of this function. - * - * @param units - * the identifier of an already existing {@link UnitDefinition} - * or an {@link Unit.Kind} identifier for the current - * level/version combination of this unit. Passing a null value - * to this method is equivalent to calling {@link #unsetUnits()}. - */ - public void setUnits(String units); - - /** - * Sets the {@link Unit} of this {@link SBaseWithUnit}. - * - * @param unit - */ - public void setUnits(Unit unit); - - /** - * Sets the unit of this {@link SBaseWithUnit}. - * - * A new unit will be created base on this kind. - * - * @param unitKind - */ - public void setUnits(Unit.Kind unitKind); - - /** - * Set the unit attribute of this {@link SBaseWithUnit} to the given - * unit definition. - * - * @param units - */ - public void setUnits(UnitDefinition units); - - /** - * Sets the unitsID of this {@link SBaseWithUnit} to null. - */ - public void unsetUnits(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SimpleSpeciesReference.java b/IPK_lib/src/org/sbml/jsbml/SimpleSpeciesReference.java deleted file mode 100644 index 550951d0b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SimpleSpeciesReference.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * $Id: SimpleSpeciesReference.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SimpleSpeciesReference.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * The base class of {@link SpeciesReference} and - * {@link ModifierSpeciesReference}. - * - * @author Simon Schäfer - * @author Marine Dumousseau - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public abstract class SimpleSpeciesReference extends AbstractNamedSBase - implements UniqueNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -504780573593345060L; - - /** - * Represents the 'species' XML attribute. - */ - private String speciesID; - /** - * Creates a SimpleSpeciesReference instance. By default, the speciesId is - * null. - */ - public SimpleSpeciesReference() { - super(); - this.speciesID = null; - } - - /** - * - * @param level - * @param version - */ - public SimpleSpeciesReference(int level, int version) { - this(null, level, version); - } - - /** - * Creates a SimpleSpeciesReference instance from a given - * SimpleSpeciesReference. - * - * @param ssr - */ - public SimpleSpeciesReference(SimpleSpeciesReference ssr) { - super(ssr); - this.speciesID = ssr.isSetSpecies() ? new String(ssr.getSpecies()) - : null; - } - - /** - * Creates a SimpleSpeciesReference instance from a given Species. - * - * @param ssr - */ - public SimpleSpeciesReference(Species s) { - this(s.getLevel(), s.getVersion()); - this.speciesID = s.isSetId() ? new String(s.getId()) : null; - } - - /** - * - * @param id - */ - public SimpleSpeciesReference(String id) { - super(id); - } - - /** - * - * @param id - * @param level - * @param version - */ - public SimpleSpeciesReference(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * - * @param id - * @param name - * @param level - * @param version - */ - public SimpleSpeciesReference(String id, String name, int level, int version) { - super(id, name, level, version); - this.speciesID = null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - SimpleSpeciesReference ssr = (SimpleSpeciesReference) object; - equals &= isSetSpecies() == ssr.isSetSpecies(); - if (equals && isSetSpecies()) { - equals &= ssr.getSpecies().equals(speciesID); - } - } - return equals; - } - - /** - * - * @return the speciesID of this {@link Species}. The empty String if it is not set. - */ - public String getSpecies() { - return isSetSpecies() ? speciesID : ""; - } - - /** - * - * @return The Species instance which has the speciesID of this - * SimpleSpeciesReference as id. Can be null if it doesn't exist. - */ - public Species getSpeciesInstance() { - Model m = getModel(); - return m != null ? m.getSpecies(speciesID) : null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 883; - int hashCode = super.hashCode(); - if (isSetSpecies()) { - hashCode += prime * getSpecies().hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * - * @return true if ths speciesID of this SimpleSpeciesReference is not null. - */ - public boolean isSetSpecies() { - return speciesID != null; - } - - /** - * - * @return true if the Species instance which has the speciesID of this - * SimpleSpeciesReference as id is not null. - */ - public boolean isSetSpeciesInstance() { - Model m = getModel(); - return m != null ? m.getSpecies(this.speciesID) != null : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("species") - && (((getLevel() == 1) && (getVersion() == 2)) || (getLevel() > 1))) { - setSpecies(value); - } else if (attributeName.equals("specie") && (getLevel() == 1) - && (getVersion() == 1)) { - setSpecies(value); - } else { - isAttributeRead = false; - } - } - return isAttributeRead; - } - - /** - * Sets the speciesID to the id of the {@link Species} 'species'. - * - * @param species - */ - public void setSpecies(Species species) { - setSpecies((species != null) && (species.isSetId()) ? species.getId() : null); - } - - /** - * Sets the speciesID to 'spec'. - * - * @param species - */ - public void setSpecies(String species) { - // TODO : make the checkIdentifier(String) optional - // For performance and not to loose any data when reading - if ((species == null) || (species.trim().length() == 0) - || checkIdentifier(species)) { - String oldSpecies = this.speciesID; - speciesID = ((species != null) && (species.trim().length() == 0)) ? null - : species; - firePropertyChange(TreeNodeChangeEvent.species, oldSpecies, speciesID); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.NamedSBase#toString() - */ - @Override - public String toString() { - - /* - * this block seems to be quite slow !! - - if (isSetSpeciesInstance()) { - return getSpeciesInstance().toString(); - } - * - */ - if (isSetId() || isSetName()) { - return super.toString(); - } - if (isSetSpecies()) { - return getSpecies(); - } - - return getElementName(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetSpecies()) { - if (((getLevel() == 1) && (getVersion() == 2)) || (getLevel() > 1)) { - attributes.put("species", getSpecies()); - } else if ((getLevel() == 1) && (getVersion() == 1)) { - attributes.put("specie", getSpecies()); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Species.java b/IPK_lib/src/org/sbml/jsbml/Species.java deleted file mode 100644 index 6a18f5c30..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Species.java +++ /dev/null @@ -1,1205 +0,0 @@ -/* - * $Id: Species.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Species.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.Locale; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the species XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class Species extends Symbol { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 4427015656530890393L; - - /** - * A {@link Logger} for this class. - */ - private static final Logger logger = Logger.getLogger(Species.class); - - /** - * True means initial amount is set. False means that an initial - * concentration is set. - */ - private boolean amount; - - /** - * Represents the 'boundaryCondition' attribute of a Species element. - */ - private Boolean boundaryCondition; - /** - * Represents the 'charge' attribute of a Species element. - */ - @Deprecated - private Integer charge; - - /** - * Represents the 'compartment' attribute of a Species element. - */ - private String compartmentID; - /** - * Represents the 'conversionFactor' attribute of a Species element. - */ - private String conversionFactorID; - /** - * Represents the 'hasOnlySubstanceUnits' attribute of a Species element. - */ - private Boolean hasOnlySubstanceUnits; - /** - * - */ - private boolean isSetBoundaryCondition = false; - /** - * Boolean value to test if the charge has been set. - */ - private boolean isSetCharge; - /** - * - */ - private boolean isSetHasOnlySubstanceUnits = false; - /** - * Represents the 'spatialSizeUnits' attribute of a Species element. - * - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - private String spatialSizeUnitsID; - - /** - * Represents the 'speciesType' attribute of a Species element. - */ - @Deprecated - private String speciesTypeID; - - /** - * Creates a Species instance. By default, the charge, compartmentID, - * speciesTypeID, conversionFactorID, hasOnlySubstanceUnits, - * boundaryCondition are null. - */ - public Species() { - super(); - initDefaults(); - } - - /** - * Creates a Species instance from a level and version. By default, the - * charge, compartmentID, speciesTypeID, conversionFactorID, - * hasOnlySubstanceUnits, boundaryCondition are null. - * - * @param level - * @param version - */ - public Species(int level, int version) { - this(null, null, level, version); - } - - /** - * Creates a Species instance from a Species. - * - * @param species - */ - public Species(Species species) { - super(species); - - if (species.isSetBoundaryCondition()) { - setBoundaryCondition(species.getBoundaryCondition()); - } else { - boundaryCondition = species.boundaryCondition == null ? null : new Boolean(species.boundaryCondition); - } - if (species.isSetCharge()) { - setCharge(species.getCharge()); - } else { - charge = species.charge == null ? null : new Integer(species.charge); - } - if (species.isSetCompartment()) { - setCompartment(new String(species.getCompartment())); - } - if (species.isSetSubstanceUnits()) { - setSubstanceUnits(new String(species.getSubstanceUnits())); - } - if (species.isSetHasOnlySubstanceUnits()) { - setHasOnlySubstanceUnits(new Boolean( - species.getHasOnlySubstanceUnits())); - } else { - hasOnlySubstanceUnits = species.hasOnlySubstanceUnits == null ? null : new Boolean(species.hasOnlySubstanceUnits); - } - if (species.isSetInitialAmount()) { - setInitialAmount(new Double(species.getInitialAmount())); - } else if (species.isSetInitialConcentration()) { - setInitialConcentration(new Double(species.getInitialConcentration())); - } - if (species.isSetSpatialSizeUnits()) { - setSpatialSizeUnits(new String(species.getSpatialSizeUnits())); - } else { - this.spatialSizeUnitsID = species.spatialSizeUnitsID == null ? null : new String(species.spatialSizeUnitsID); - } - if (species.isSetConversionFactor()) { - setConversionFactor(species.conversionFactorID); - } - } - - /** - * @param id - */ - public Species(String id) { - this(); - setId(id); - } - - /** - * Creates a Species instance from a level and verison. By default, the - * charge, compartmentID, speciesTypeID, conversionFactorID, - * hasOnlySubstanceUnits, boundaryCondition are null. - * - * @param id - * @param level - * @param version - */ - public Species(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * @param id - * @param name - * @param level - * @param version - */ - public Species(String id, String name, int level, int version) { - super(id, name, level, version); - initDefaults(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.Symbol#clone() - */ - @Override - public Species clone() { - return new Species(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.Symbol#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Species s = (Species) object; - equals &= s.getBoundaryCondition() == getBoundaryCondition(); - equals &= s.getHasOnlySubstanceUnits() == getHasOnlySubstanceUnits(); - equals &= s.getCharge() == getCharge(); - - equals &= s.isSetSpeciesType() == isSetSpeciesType(); - if (equals && isSetSpeciesType()) { - equals &= s.getSpeciesType().equals(getSpeciesType()); - } - equals &= s.isSetCompartment() == isSetCompartment(); - if (equals && isSetCompartment()) { - equals &= s.getCompartment().equals(getCompartment()); - } - - equals &= s.isSetInitialAmount() == isSetInitialAmount(); - equals &= s.isSetInitialConcentration() == isSetInitialConcentration(); - // value is already checked by super class. - - equals &= s.isSetSpatialSizeUnits() == isSetSpatialSizeUnits(); - if (equals && isSetSpatialSizeUnits()) { - equals &= s.getSpatialSizeUnits().equals(getSpatialSizeUnits()); - } - } - return equals; - } - - /** - * @return the boundaryCondition Boolean of this Species. - */ - public boolean getBoundaryCondition() { - return isSetBoundaryCondition() ? boundaryCondition : false; - } - - /** - * @return the charge value of this Species if it is set, 0 otherwise. - */ - @Deprecated - public int getCharge() { - return isSetCharge() ? this.charge : 0; - } - - /** - * @return the compartmentID of this Species. The empty String if it is not - * set. - */ - public String getCompartment() { - return isSetCompartment() ? compartmentID : ""; - } - - /** - * @return The Compartment instance which as the compartmentID of this - * Species as id. Null if it doesn't exist. - */ - public Compartment getCompartmentInstance() { - if (getModel() == null) { - return null; - } - return getModel().getCompartment(this.compartmentID); - } - - /** - * @return the conversionFactorID of this Species. - */ - public String getConversionFactor() { - return conversionFactorID; - } - - /** - * @return the Parameter instance which has the conversionFactorID of this - * Species as id, null if it doesn't exist. - */ - public Parameter getConversionFactorInstance() { - if (getModel() == null) { - return null; - } - return getModel().getParameter(this.conversionFactorID); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getDerivedUnitDefinition() - */ - @Override - public UnitDefinition getDerivedUnitDefinition() { - UnitDefinition specUnit = super.getDerivedUnitDefinition(); - Model model = getModel(); - if ((specUnit == null) && (getLevel() > 2) && (model != null) && (model.isSetSubstanceUnits())) { - // According to SBML specification of Level 3 Version 1, page 44, lines 20-22: - specUnit = model.getSubstanceUnitsInstance(); - } - Compartment compartment = getCompartmentInstance(); - if ((specUnit != null) && !hasOnlySubstanceUnits() && (compartment != null) - && (0d < compartment.getSpatialDimensions())) { - UnitDefinition sizeUnit; // = getSpatialSizeUnitsInstance(); - if ((model != null) && isSetSpatialSizeUnits()) { - sizeUnit = model.getUnitDefinition(getSpatialSizeUnits()); - } else { - sizeUnit = compartment.getDerivedUnitDefinition(); - } - if (sizeUnit != null) { - UnitDefinition derivedUD = specUnit.clone().divideBy(sizeUnit); - derivedUD.setId(derivedUD.getId() + "_per_" + sizeUnit.getId()); - if (derivedUD.isSetName()) { - derivedUD.setName(derivedUD.getName() + " per " - + (sizeUnit.isSetName() ? sizeUnit.getName() : sizeUnit.getId())); - } - /* - * If possible, let's return an equivalent unit that is already part of the model - * rather than returning some newly created UnitDefinition: - */ - if (model != null) { - UnitDefinition ud = model.findIdentical(derivedUD); - if (ud != null) { - return ud; - } - } - return derivedUD; - } - } - return specUnit; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - if ((getLevel() == 1) && (getVersion() == 1)) { - return "specie"; - } - return super.getElementName(); - } - - /** - * @return the hasOnlySubstanceUnits Boolean of this Species. - */ - public boolean getHasOnlySubstanceUnits() { - return hasOnlySubstanceUnits(); - } - - /** - * @return the initialAmount of this Species if it has been set, o - * otherwise. - */ - public double getInitialAmount() { - if (isSetInitialAmount()) { - return getValue(); - } - return Double.NaN; - } - - /** - * @return the initialConcentration of this {@link Species} if it has been - * set, o otherwise. - */ - public double getInitialConcentration() { - if (isSetInitialConcentration()) { - return getValue(); - } - return Double.NaN; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBaseWithUnit#getPredefinedUnitID() - */ - public String getPredefinedUnitID() { - int level = getLevel(); - if (level < 3) { - // if (level == 2) { - // Compartment compartment = getCompartmentInstance(); - // if ((compartment != null) - // && (compartment.getSpatialDimensions() > 0d)) { - // return null; - // } - // } - /* - * L1V1: default "substance"; also "volume" or any base unit - * L1V2: default "substance"; also any base unit - */ - return "substance"; - } - return null; - } - - /** - * If determined, this method first checks the explicitly set spatial size - * units of this {@link Species}. If no such value is defined, it will - * return the units of the surrounding {@link Compartment}. Only if this is - * also not possible, an empty {@link String} will be returned. - * - * @return the spatialSizeUnits of this {@link Species}. - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - public String getSpatialSizeUnits() { - if (isSetSpatialSizeUnits()) { - return spatialSizeUnitsID; - } - Compartment c = getCompartmentInstance(); - return c != null ? c.getUnits() : ""; - } - - /** - * Determines the spatial units of this {@link Species}. If the spatial - * units have been set explicitly using {@link #spatialSizeUnitsID} the - * corresponding {@link UnitDefinition} from the {@link Model} to which this {@link Species} belongs will be returned. Otherwise, the size unit from - * the surrounding {@link Compartment} of this {@link Species} will be - * returned. If this also fails, null will be returned. - * - * @return The {@link UnitDefinition} instance which as the {@link #spatialSizeUnitsID} of this {@link Species} as id or the - * size unit of the surrounding {@link Compartment}. Null if it doesn't exist. - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - public UnitDefinition getSpatialSizeUnitsInstance() { - if (isSetSpatialSizeUnits()) { - Model model = getModel(); - return model != null ? model - .getUnitDefinition(this.spatialSizeUnitsID) : null; - } - Compartment compartment = getCompartmentInstance(); - return compartment != null ? compartment.getUnitsInstance() : null; - } - - /** - * @return the speciesTypeID of this {@link Species}. The empty String if it - * is not set. - * @deprecated Only valid for SBML Level 2 Versions 2, 3, and 4. - */ - @Deprecated - public String getSpeciesType() { - return isSetSpeciesType() ? this.speciesTypeID : ""; - } - - /** - * @return the SpeciesType instance which has the speciesTypeID of this - * Species as id. Null if it doesn't exist. - * @deprecated Only valid for SBML Level 2 Versions 2, 3, and 4. - */ - @Deprecated - public SpeciesType getSpeciesTypeInstance() { - if (getModel() == null) { - return null; - } - return getModel().getSpeciesType(this.speciesTypeID); - } - - /** - * @return the substanceUnitsID of this Species. - */ - public String getSubstanceUnits() { - return getUnits(); - } - - /** - * @return The UnitsDefinition instance which has the substanceUnistID of - * this Species as id. - */ - public UnitDefinition getSubstanceUnitsInstance() { - return getUnitsInstance(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.Symbol#hashCode() - */ - @Override - public int hashCode() { - final int prime = 997; - int hashCode = super.hashCode(); - hashCode += prime * Boolean.valueOf(amount).hashCode(); - if (isSetBoundaryCondition()) { - hashCode += prime * boundaryCondition.hashCode(); - } - if (isSetHasOnlySubstanceUnits()) { - hashCode += prime * hasOnlySubstanceUnits.hashCode(); - } - if (isSetCharge()) { - hashCode += prime * charge.hashCode(); - } - if (isSetSpeciesType()) { - hashCode += prime * getSpeciesType().hashCode(); - } - if (isSetCompartment()) { - hashCode += prime * getCompartment().hashCode(); - } - if (isSetSpatialSizeUnits()) { - hashCode += prime * getSpatialSizeUnits().hashCode(); - } - return hashCode; - } - - /** - * @return - */ - public boolean hasOnlySubstanceUnits() { - return isSetHasOnlySubstanceUnits() ? this.hasOnlySubstanceUnits - : false; - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default values of this Species. - */ - public void initDefaults(int level, int version) { - amount = true; - unitsID = null; - if (level < 3) { - hasOnlySubstanceUnits = new Boolean(false); - boundaryCondition = new Boolean(false); - constant = new Boolean(false); - } else { - hasOnlySubstanceUnits = null; - boundaryCondition = null; - constant = null; - } - } - - /** - * @return the value of the boundaryCondition Boolean if it is set, false - * otherwise. - */ - public boolean isBoundaryCondition() { - return isSetBoundaryCondition() ? boundaryCondition : false; - } - - /** - * @return the value of the hasOnlySubstanceUnits Boolean if it is set, - * false otherwise. - */ - public boolean isHasOnlySubstanceUnits() { - return hasOnlySubstanceUnits(); - } - - /** - * @return true if the boundaryCondition of this Species is not null. - */ - public boolean isSetBoundaryCondition() { - return isSetBoundaryCondition; - } - - /** - * @return true if the charge of this Species if not null. - */ - public boolean isSetCharge() { - return isSetCharge; - } - - /** - * @return true if the compartmentID of this Species is not null. - */ - public boolean isSetCompartment() { - return compartmentID != null; - } - - /** - * @return true if the Compartment instance which has the compartmentID of - * this Species as id is not null. - */ - public boolean isSetCompartmentInstance() { - if (getModel() == null) { - return false; - } - return getModel().getCompartment(this.compartmentID) != null; - } - - /** - * @return true if the conversionFactorID of this Species is not null. - */ - public boolean isSetConversionFactor() { - return conversionFactorID != null; - } - - /** - * @return true if the Parameter which has the conversionFactorID of this - * Species as id is not null. - */ - public boolean isSetConversionFactorInstance() { - if (getModel() == null) { - return false; - } - return getModel().getParameter(this.conversionFactorID) != null; - } - - /** - * @return true if the hasOnlySubstanceUnits of this Species is not null. - */ - public boolean isSetHasOnlySubstanceUnits() { - return isSetHasOnlySubstanceUnits; - } - - /** - * @return Returns true if an initial amount has been set for this species. - */ - public boolean isSetInitialAmount() { - return amount && isSetValue(); - } - - /** - * @return Returns true if an initial concentration has been set for this - * species. - */ - public boolean isSetInitialConcentration() { - return !amount && isSetValue(); - } - - /** - * @return true if the spatialSizeUnits of this {@link Species} is not null. - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - public boolean isSetSpatialSizeUnits() { - return this.spatialSizeUnitsID != null; - } - - /** - * @return true if the {@link UnitDefinition} which has the - * spatialSizeUnitsID of - * this {@link Species} as id is not null. - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - public boolean isSetSpatialSizeUnitsInstance() { - if (getModel() == null) { - return false; - } - return getModel().getUnitDefinition(this.spatialSizeUnitsID) != null; - } - - /** - * @return true if the speciesTypeID of this Species is not null. - */ - @Deprecated - public boolean isSetSpeciesType() { - return speciesTypeID != null; - } - - /** - * @return true if the SpeciesType instance which has the speciesTypeID of - * this Species as id is not null. - */ - @Deprecated - public boolean isSetSpeciesTypeInstance() { - if (getModel() == null) { - return false; - } - return getModel().getSpeciesType(this.speciesTypeID) != null; - } - - /** - * @return true if the substanceUnitsID of this species is not null. - */ - public boolean isSetSubstanceUnits() { - return isSetUnits(); - } - - /** - * @return true if the UnitDefinition which has the substanceUnitsID of this - * Species as id is not null. - */ - public boolean isSetSubstanceUnitsInstance() { - return isSetUnitsInstance(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value)( - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - - if (getLevel() == 1) { - if (attributeName.equals("units")) { - setUnits(value); - return true; - } - } else { - if (attributeName.equals("initialConcentration")) { - setInitialConcentration(StringTools.parseSBMLDouble(value)); - return true; - } else if (attributeName.equals("substanceUnits")) { - setUnits(value); - return true; - } - } - - if (getLevel() > 1) { - if (attributeName.equals("hasOnlySubstanceUnits")) { - setHasOnlySubstanceUnits(StringTools - .parseSBMLBoolean(value)); - return true; - } - if (attributeName.equals("constant")) { - setConstant(StringTools.parseSBMLBoolean(value)); - return true; - } - } - - if (getLevel() == 2) { - - if (getVersion() < 3) { - if (attributeName.equals("spatialSizeUnits")) { - setSpatialSizeUnits(value); - return true; - } - } - - if (getVersion() > 1) { - if (attributeName.equals("speciesType")) { - setSpeciesType(value); - return true; - } - } - } - - if (getLevel() < 3) { - if (attributeName.equals("charge")) { - setCharge(StringTools.parseSBMLInt(value)); - return true; - } - } - - if (getLevel() == 3) { - if (attributeName.equals("conversionFactor")) { - setConversionFactor(value); - return true; - } - } - - if (attributeName.equals("compartment")) { - setCompartment(value); - return true; - } else if (attributeName.equals("initialAmount")) { - setInitialAmount(StringTools.parseSBMLDouble(value)); - return true; - } else if (attributeName.equals("boundaryCondition")) { - setBoundaryCondition(StringTools.parseSBMLBoolean(value)); - return true; - - } - } - - return isAttributeRead; - } - - /** - * Sets the boundaryCondition Boolean. - * - * @param boundaryCondition - */ - public void setBoundaryCondition(Boolean boundaryCondition) { - Boolean oldBoundaryCondition = this.boundaryCondition; - this.boundaryCondition = boundaryCondition; - isSetBoundaryCondition = true; - firePropertyChange(TreeNodeChangeEvent.boundaryCondition, - oldBoundaryCondition, this.boundaryCondition); - } - - /** - * Sets the charge of this {@link Species}. - * - * @param charge - * @deprecated Only defined in SBML Level 1, Version 1 and 2, and Level 2 - * Version 1. Since Level 2 Version 2 it has been marked as a - * deprecated property, but has been completely removed in SBML - * Level 3. - * @throws PropertyNotAvailableException if Level >= 3. - */ - @Deprecated - public void setCharge(int charge) { - if (3 <= getLevel()) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.charge, this); - } - Integer oldCharge = this.charge; - this.charge = Integer.valueOf(charge); - isSetCharge = true; - firePropertyChange(TreeNodeChangeEvent.charge, oldCharge, this.charge); - } - - /** - * Sets the {@link #compartmentID} of this {@link Species} to the id of - * 'compartment'. - * - * @param compartment - */ - public void setCompartment(Compartment compartment) { - if (compartment != null) { - setCompartment(compartment.getId()); - } else { - unsetCompartment(); - } - } - - /** - * Sets the {@link #compartmentID} of this {@link Species} to 'compartment'. - * - * @param compartment - */ - public void setCompartment(String compartment) { - if ((compartment != null) && (compartment.trim().length() == 0)) { - compartment = null; - // If we pass the empty String or null, the value is reset. - } - // TODO: Check for dimensions of the compartment with respect to spatialDimensions units in this class! - if ((compartment == null) || checkIdentifier(compartment)) { - String oldCompartment = this.compartmentID; - if ((compartment != null) && (compartment.trim().length() == 0)) { - this.compartmentID = null; - } else { - this.compartmentID = compartment; - } - firePropertyChange(TreeNodeChangeEvent.compartment, oldCompartment, - compartmentID); - } - } - - /** - * Sets the conversionFactorID of this {@link Species} to the id of - * 'conversionFactor'. This is only possible if Level >= 3. - * - * @param conversionFactor - */ - public void setConversionFactor(Parameter conversionFactor) { - setConversionFactor(conversionFactor != null ? conversionFactor.getId() - : null); - } - - /** - * Sets the conversionFactorID of this {@link Species} to - * 'conversionFactorID'. This is only possible if Level >= 3. - * - * @param conversionFactorID - * @throws PropertyNotAvailableException if Level < 3. - */ - public void setConversionFactor(String conversionFactorID) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.conversionFactor, this); - } - String oldConversionFactor = this.conversionFactorID; - if ((conversionFactorID != null) - && (conversionFactorID.trim().length() == 0)) { - this.conversionFactorID = null; - } else { - this.conversionFactorID = conversionFactorID; - } - firePropertyChange(TreeNodeChangeEvent.conversionFactor, - oldConversionFactor, conversionFactorID); - } - - /** - * Sets hasOnlySubstanceUnits Boolean - * - * @param hasOnlySubstanceUnits - * @throws PropertyNotAvailableException if Level < 2. - */ - public void setHasOnlySubstanceUnits(boolean hasOnlySubstanceUnits) { - if (getLevel() < 2) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.hasOnlySubstanceUnits, this); - } - if (hasOnlySubstanceUnits && isSetSpatialSizeUnits()) { - String ud = isSetUnitsInstance() ? UnitDefinition.printUnits( - getSpatialSizeUnitsInstance(), true) : getSpatialSizeUnits(); - throw new SBMLException(MessageFormat.format( - "Cannot define that species {0} with spatial size units {1} has only substance units.", - toString(), ud)); - } - Boolean oldHasOnlySubstanceUnits = this.hasOnlySubstanceUnits; - this.hasOnlySubstanceUnits = Boolean.valueOf(hasOnlySubstanceUnits); - isSetHasOnlySubstanceUnits = true; - firePropertyChange(TreeNodeChangeEvent.hasOnlySubstanceUnits, - oldHasOnlySubstanceUnits, this.hasOnlySubstanceUnits); - } - - /** - * Sets the initialAmount of this {@link Species}. - * - * @param initialAmount - */ - public void setInitialAmount(double initialAmount) { - if (!this.amount) { - this.amount = true; - firePropertyChange(TreeNodeChangeEvent.initialAmount, Boolean.FALSE, - Boolean.TRUE); - } - setValue(initialAmount); - } - - /** - * Sets the initialConcentration of this {@link Species}. - * - * @param initialConcentration - */ - public void setInitialConcentration(double initialConcentration) { - if (this.amount) { - this.amount = false; - firePropertyChange(TreeNodeChangeEvent.initialAmount, Boolean.TRUE, - Boolean.FALSE); - } - setValue(initialConcentration); - } - - /** - * Sets the spatialSizeUnitsID of this {@link Species} to - * 'spatialSizeUnits'. - * - * @param spatialSizeUnits - * @deprecated This property is only valid for SBML Level 2 Versions 1 and - * 2. - * @throws PropertyNotAvailableException - * for inapropriate Level/Version combinations. - * @throws SBMLException - * in case that {@link #hasOnlySubstanceUnits()} is set to true or the spatial dimensions of the surrounding - * compartment are zero. - */ - @Deprecated - public void setSpatialSizeUnits(String spatialSizeUnits) - throws PropertyNotAvailableException, SBMLException { - if ((getLevel() != 2) && ((1 != getVersion()) || (2 != getVersion()))) { - throw new PropertyNotAvailableException( - TreeNodeChangeEvent.spatialSizeUnits, this); - } - /* - * For the rules for semantic check of this attribute see specifications of - * SBML Level 2 Version 1, page 20, and - * SBML Level 2 Version 2, page 45, line 5 - */ - if (hasOnlySubstanceUnits()) { - throw new SBMLException(MessageFormat.format( - "Cannot set spatial size units on species {0} because it has only substance units.", - toString())); - } - Compartment c = getCompartmentInstance(); - if ((c != null) && (c.getSpatialDimensions() == 0d)) { - // Note that it is still possible to change the dimensions of the - // compartment later on or to change the entire compartment. - throw new SBMLException(MessageFormat.format( - "Cannot set spatial size units on species {0} because its surrounding compartment has zero dimensions.", - toString())); - } - String oldSpatialSizeUnits = this.spatialSizeUnitsID; - if ((spatialSizeUnits != null) - && (spatialSizeUnits.trim().length() == 0)) { - this.spatialSizeUnitsID = null; - } else { - this.spatialSizeUnitsID = spatialSizeUnits; - } - firePropertyChange(TreeNodeChangeEvent.spatialSizeUnits, - oldSpatialSizeUnits, this.spatialSizeUnitsID); - } - - /** - * Sets the spatialSizeUnitsID of this {@link Species} to the id of - * 'spatialSizeUnits'. - * - * @param spatialSizeUnits - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - * @throws PropertyNotAvailableException - * for inapropriate Level/Version combinations. - * @throws SBMLException - * in case that {@link #hasOnlySubstanceUnits()} is set to true or the spatial dimensions of the surrounding - * compartment are zero. - */ - @Deprecated - public void setSpatialSizeUnits(UnitDefinition spatialSizeUnits) - throws PropertyNotAvailableException, SBMLException { - setSpatialSizeUnits(spatialSizeUnits != null ? spatialSizeUnits.getId() : null); - } - - /** - * Sets the speciesTypeID of this {@link Species} to the id of - * 'speciesType'. - * - * @param speciesType - * @deprecated - */ - @Deprecated - public void setSpeciesType(SpeciesType speciesType) { - setSpeciesType(speciesType != null ? speciesType.getId() : null); - } - - /** - * Sets the speciesTypeID of this {@link Species} to 'speciesType'. - * - * @param speciesType - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - * @throws PropertyNotAvailableException - * for inapropriate Level/Version combinations. - */ - @Deprecated - public void setSpeciesType(String speciesType) { - if ((getLevel() != 2) || ((getLevel() == 2) && (getVersion() == 1))) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.speciesType, - this); - } - if ((speciesType == null) || (speciesType.trim().length() == 0) - || checkIdentifier(speciesType)) { - String oldSpeciesType = this.speciesTypeID; - this.speciesTypeID = ((speciesType != null) && (speciesType.trim() - .length() == 0)) ? null : speciesType; - firePropertyChange(TreeNodeChangeEvent.speciesType, oldSpeciesType, - this.speciesTypeID); - } - } - - /** - * Sets the substanceUnitsID to 'unit'. - * - * @param unit - */ - public void setSubstanceUnits(String unit) { - setUnits(unit); - } - - /** - * Sets the substanceUnits. - * - * @param unit - */ - public void setSubstanceUnits(Unit unit) { - setUnits(unit); - } - - /** - * Sets the substanceUnits. - * - * @param unitKind - */ - public void setSubstanceUnits(Unit.Kind unitKind) { - setUnits(unitKind); - } - - /** - * Sets the substanceUnitsID to the id of 'units'. - * - * @param units - */ - public void setSubstanceUnits(UnitDefinition units) { - setUnits(units); - } - - /** - * Unsets the charge of this Species - * - * @deprecated - */ - @Deprecated - public void unsetCharge() { - Integer oldCharge = charge; - charge = null; - isSetCharge = false; - firePropertyChange(TreeNodeChangeEvent.charge, oldCharge, this.charge); - } - - /** - * Remove the reference to a comparmtent. - */ - public void unsetCompartment() { - setCompartment((String) null); - } - - /** - * Unsets the conversionFactorID of this Species. - */ - public void unsetConversionFactor() { - setConversionFactor((String) null); - } - - /** - * Unsets the initialAmount of this Species. - */ - public void unsetInitialAmount() { - amount = false; - unsetValue(); - } - - /** - * Unsets the initialConcentration of this Species. - */ - public void unsetInitialConcentration() { - amount = true; - unsetValue(); - } - - /** - * Unsets the spatialSizeUnits of this Species - * - * @deprecated Only valid for SBML Level 2 Versions 1 and 2. - */ - @Deprecated - public void unsetSpatialSizeUnits() { - setSpatialSizeUnits((String) null); - } - - /** - * Unsets the substanceUnits of this Species. - */ - public void unsetSubstanceUnits() { - unsetUnits(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes( - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - Locale en = Locale.ENGLISH; - if (isSetCompartment()) { - attributes.put("compartment", getCompartment()); - } - if (isSetInitialAmount()) { - attributes.put("initialAmount", - StringTools.toString(en, getInitialAmount())); - } - if (isSetBoundaryCondition()) { - attributes.put("boundaryCondition", - Boolean.toString(getBoundaryCondition())); - } - - if (1 < getLevel()) { - if (isSetInitialConcentration() && !isSetInitialAmount()) { - attributes.put("initialConcentration", - StringTools.toString(en, getInitialConcentration())); - } - if (isSetSubstanceUnits()) { - attributes.put("substanceUnits", getSubstanceUnits()); - } - if (isSetHasOnlySubstanceUnits()) { - attributes.put("hasOnlySubstanceUnits", - Boolean.toString(getHasOnlySubstanceUnits())); - } - if (isSetConstant()) { - attributes.put("constant", Boolean.toString(getConstant())); - } - } - if (getLevel() < 3) { - if (isSetCharge) { - attributes.put("charge", Integer.toString(getCharge())); - } - } - if (getLevel() == 2) { - if ((getVersion() == 1) || (getVersion() == 2)) { - if (isSetSpatialSizeUnits()) { - if (hasOnlySubstanceUnits()) { - logger.warn(MessageFormat.format( - "Attribute spatialSizeUnits got lost because species {0} has only substance units.", - toString())); - } else if (isSetCompartmentInstance() && (getCompartmentInstance().getSpatialDimensions() == 0d)) { - logger.warn(MessageFormat.format( - "Attribute spatialSizeUnits got lost because species {0} is surrounded by a compartment of zero dimensions.", - toString())); - } else { - attributes.put("spatialSizeUnits", getSpatialSizeUnits()); - } - } - } - if (getVersion() >= 2) { - if (isSetSpeciesType()) { - attributes.put("speciesType", getSpeciesType()); - } - } - } else if (getLevel() == 3) { - if (isSetConversionFactor()) { - attributes.put("conversionFactor", getConversionFactor()); - } - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SpeciesReference.java b/IPK_lib/src/org/sbml/jsbml/SpeciesReference.java deleted file mode 100644 index 09b56810f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SpeciesReference.java +++ /dev/null @@ -1,625 +0,0 @@ -/* - * $Id: SpeciesReference.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SpeciesReference.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Locale; -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Represents the speciesReference XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1153 $ - */ -public class SpeciesReference extends SimpleSpeciesReference implements - Variable { - - /** - * Message to be displayed in case that an illegal stoichiometric value has been set. - */ - private static final String ILLEGAL_STOCHIOMETRY_VALUE = "Only positive integer values can be set as %s. Invalid value %d."; - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 4400834403773787677L; - /** - * Represents the 'constant' XML attribute of this SpeciesReference. - */ - private Boolean constant; - /** - * Represents the 'denominator' XML attribute of this SpeciesReference. - */ - private Integer denominator; - /** - * - */ - private boolean isSetConstant; - /** - * Boolean value to know if the SpeciesReference denominator has been set. - */ - private boolean isSetDenominator; - /** - * - */ - private boolean isSetStoichiometry; - /** - * Represents the 'stoichiometry' XML attribute of this SpeciesReference. - */ - private Double stoichiometry; - /** - * Contains the MathML expression for the stoichiometry of this - * SpeciesReference. - * - * @deprecated - */ - @Deprecated - private StoichiometryMath stoichiometryMath; - - /** - * Creates a SpeciesReference instance. By default, if the level is superior - * or equal to 3, the constant, stoichiometryMath and stoichiometry are - * null. - * - * @param spec - */ - public SpeciesReference() { - super(); - initDefaults(); - } - - /** - * - * @param level - * @param version - */ - public SpeciesReference(int level, int version) { - this(null, level, version); - } - - /** - * Creates a SpeciesReference instance from a Species. By default, if the - * level is superior or equal to 3, the constant, stoichiometryMath and - * stoichiometry are null. - * - * @param speciesReference - */ - public SpeciesReference(Species species) { - super(species); - initDefaults(); - } - - /** - * Creates a SpeciesReference instance from a given SpeciesReference. - * - * @param speciesReference - */ - @SuppressWarnings("deprecation") - public SpeciesReference(SpeciesReference speciesReference) { - super(speciesReference); - if (speciesReference.isSetStoichiometryMath()) { - setStoichiometryMath(speciesReference.getStoichiometryMath() - .clone()); - } - if (speciesReference.isSetStoichiometry()) { - setStoichiometry(new Double(speciesReference.getStoichiometry())); - } else { - stoichiometry = speciesReference.stoichiometry == null ? null : new Double(speciesReference.stoichiometry); - } - if (speciesReference.isSetConstant()) { - setConstant(new Boolean(speciesReference.isConstant())); - } else { - constant = speciesReference.constant == null ? null : new Boolean(speciesReference.constant); - } - if (speciesReference.isSetDenominator) { - setDenominator(new Integer(speciesReference.getDenominator())); - } else { - denominator = speciesReference.denominator == null ? null : new Integer(speciesReference.denominator); - } - } - - /** - * - * @param id - */ - public SpeciesReference(String id) { - super(id); - initDefaults(); - } - - /** - * - * @param id - * @param level - * @param version - */ - public SpeciesReference(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * - * @param id - * @param name - * @param level - * @param version - */ - public SpeciesReference(String id, String name, int level, int version) { - super(id, name, level, version); - initDefaults(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#clone() - */ - @Override - public SpeciesReference clone() { - return new SpeciesReference(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SBaseWithDerivedUnit#containsUndeclaredUnits() - */ - public boolean containsUndeclaredUnits() { - if (isSetStoichiometryMath()) { - return getStoichiometryMath().containsUndeclaredUnits(); - } - return isSetStoichiometry() ? false : true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SimpleSpeciesReference#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - SpeciesReference sr = (SpeciesReference) object; - equals &= sr.isSetStoichiometry() == isSetStoichiometry(); - if (equals && isSetStoichiometry()) { - equals &= sr.getStoichiometry() == getStoichiometry(); - } - equals &= sr.isSetConstant() == isSetConstant(); - if (equals && isSetConstant()) { - equals &= sr.isConstant() == isConstant(); - } - equals &= sr.isSetDenominator() == isSetDenominator(); - if (equals && isSetDenominator()) { - equals &= sr.getDenominator() == getDenominator(); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /** - * This method computes the fraction of the stoichiometry and the - * denominator. Actually, the denominator is only defined in SBML Level 1. - * For convenience, this method might be usefull. - * - * @return The fraction between {@link #stoichiometry} and - * {@link #denominator}. - */ - public double getCalculatedStoichiometry() { - int denominator = getDenominator(); - return (denominator != 1) ? getStoichiometry() / denominator - : getStoichiometry(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetStoichiometryMath()) { - if (pos == index) { - return getStoichiometryMath(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - return super.getChildCount() + (isSetStoichiometryMath() ? 1 : 0); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.State#getConstant() - */ - public boolean getConstant() { - return isConstant(); - } - - /** - * - * @return the denominator value if it is set, 1 otherwise - * @deprecated Use for Level 1 only. - */ - @Deprecated - public int getDenominator() { - return isSetDenominator ? denominator.intValue() : 1; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#getDerivedUnitInstance() - */ - public UnitDefinition getDerivedUnitDefinition() { - if (isSetStoichiometryMath()) { - return stoichiometryMath.getDerivedUnitDefinition(); - } - UnitDefinition ud = new UnitDefinition(getLevel(), getVersion()); - ud.addUnit(Unit.Kind.DIMENSIONLESS); - return ud; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#getDerivedUnit() - */ - public String getDerivedUnits() { - if (isSetStoichiometryMath()) { - return stoichiometryMath.getDerivedUnits(); - } - return Unit.Kind.DIMENSIONLESS.toString(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getElementName() - */ - @Override - public String getElementName() { - if ((getLevel() == 1) && (getVersion() == 1)) { - return "specieReference"; - } - return super.getElementName(); - } - - /** - * - * @return the stoichiometry value of this {@link SpeciesReference} if it is - * set, otherwise, depending on the Level attribute, 1 for Level < 3 - * or {@link Double#NaN}. - */ - public double getStoichiometry() { - if (isSetStoichiometry()) { - return stoichiometry.doubleValue(); - } - return (getLevel() < 3) ? 1d : Double.NaN; - } - - /** - * - * @return the stoichiometryMath of this SpeciesReference. Can be null if - * the stoichiometryMath is not set. - * @deprecated since SBML Level 3 this should not be used anymore. - */ - @Deprecated - public StoichiometryMath getStoichiometryMath() { - return stoichiometryMath; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#getValue() - */ - public double getValue() { - return getStoichiometry(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.SimpleSpeciesReference#hashCode() - */ - @Override - public int hashCode() { - final int prime = 937; - int hashCode = super.hashCode(); - if (isSetStoichiometry()) { - hashCode += prime * stoichiometry.hashCode(); - } - if (isSetConstant()) { - hashCode += prime * constant.hashCode(); - } - if (isSetDenominator()) { - hashCode += prime * denominator.hashCode(); - } - return hashCode; - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the default values of this SpeciesReference. - */ - public void initDefaults(int level, int version) { - // See - // http://sbml.org/Community/Wiki/SBML_Level_3_Core/Reaction_changes/Changes_to_stoichiometry - if (level <= 2) { - constant = Boolean.valueOf(true); - stoichiometry = Double.valueOf(1d); - denominator = Integer.valueOf(1); - } else { - isSetConstant = false; - isSetDenominator = false; - isSetStoichiometry = false; - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.State#isConstant() - */ - public boolean isConstant() { - return constant != null ? constant.booleanValue() : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.State#isSetConstant() - */ - public boolean isSetConstant() { - return isSetConstant; - } - - /** - * - * @return true if the denominator is not null. - */ - public boolean isSetDenominator() { - return denominator != null; - } - - /** - * - * @return true if the stoichiometry of this SpeciesReference is not null. - */ - public boolean isSetStoichiometry() { - return isSetStoichiometry; - } - - /** - * - * @return true if the stoichiometryMath of this SpeciesReference is not - * null. - */ - public boolean isSetStoichiometryMath() { - return stoichiometryMath != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#isSetValue() - */ - public boolean isSetValue() { - return isSetStoichiometry(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("stoichiometry")) { - setStoichiometry(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("constant")) { - setConstant(StringTools.parseSBMLBoolean(value)); - } else if (attributeName.equals("denominator")) { - setDenominator(StringTools.parseSBMLInt(value)); - } else { - isAttributeRead = false; - } - } - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.State#setConstant(boolean) - */ - public void setConstant(boolean constant) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.constant, - this); - } - Boolean oldConstant = this.constant; - this.constant = Boolean.valueOf(constant); - isSetConstant = true; - firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, - this.constant); - } - - /** - * Sets the denominator of this {@link SpeciesReference}. - * - * @param denominator - * @deprecated - */ - @Deprecated - public void setDenominator(int denominator) { - if ((getLevel() == 1) && (getVersion() == 2)) { - if (denominator < 0) { - throw new IllegalArgumentException(String.format( - ILLEGAL_STOCHIOMETRY_VALUE, - "denominator", stoichiometry)); - } - } - Integer oldDenominator = this.denominator; - this.denominator = denominator; - isSetDenominator = true; - firePropertyChange(TreeNodeChangeEvent.denominator, oldDenominator, this.denominator); - } - - /** - * Sets the stoichiometry of this {@link SpeciesReference}. - * - * @param stoichiometry - */ - public void setStoichiometry(double stoichiometry) { - if ((getLevel() == 1) && (getVersion() == 2)) { - int stoch = (int) stoichiometry; - if ((stoch < 0) || (stoch - stoichiometry != 0d)) { - throw new IllegalArgumentException(String.format( - ILLEGAL_STOCHIOMETRY_VALUE, "stoichiometry", - stoichiometry)); - } - } - Double oldStoichiometry = this.stoichiometry; - this.stoichiometry = Double.valueOf(stoichiometry); - if (isSetStoichiometryMath()) { - stoichiometryMath = null; - } - if (Double.isNaN(stoichiometry)) { - isSetStoichiometry = false; - } else { - isSetStoichiometry = true; - } - firePropertyChange(TreeNodeChangeEvent.stoichiometry, oldStoichiometry, - this.stoichiometry); - } - - /** - * Sets the {@link StoichiometryMath} of this {@link SpeciesReference). - * - * @param math - * @deprecated - */ - @Deprecated - public void setStoichiometryMath(StoichiometryMath math) { - unsetStoichiometryMath(); - this.stoichiometryMath = math; - setThisAsParentSBMLObject(this.stoichiometryMath); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#setValue(double) - */ - public void setValue(double value) { - setStoichiometry(value); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#unsetConstant() - */ - public void unsetConstant() { - if(this.constant != null){ - Boolean oldConstant = this.constant; - this.constant = null; - isSetConstant = false; - firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, - this.constant); - } - } - - /** - * Unsets the stoichiometry property of this element. - */ - public void unsetStoichiometry() { - if(this.stoichiometry != null){ - Double oldStoichiometry = this.stoichiometry; - this.stoichiometry = null; - isSetStoichiometry = false; - firePropertyChange(TreeNodeChangeEvent.stoichiometry, oldStoichiometry, - this.stoichiometry); - } - } - - /** - * - * @return - * @deprecated - */ - @Deprecated - public boolean unsetStoichiometryMath() { - if (this.stoichiometryMath != null) { - StoichiometryMath oldStoichiometryMath = this.stoichiometryMath; - this.stoichiometryMath = null; - oldStoichiometryMath.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Quantity#unsetValue() - */ - public void unsetValue() { - unsetStoichiometry(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetStoichiometry()) { - attributes.put("stoichiometry", StringTools.toString( - Locale.ENGLISH, getStoichiometry())); - } - if (isSetConstant()) { - attributes.put("constant", Boolean.toString(isConstant())); - } - if (isSetDenominator() && (getLevel() == 1)) { - int denominator = getDenominator(); - if (denominator != 1) { - attributes.put("denominator", Integer.toString(denominator)); - } - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/SpeciesType.java b/IPK_lib/src/org/sbml/jsbml/SpeciesType.java deleted file mode 100644 index 5c0b9dc09..000000000 --- a/IPK_lib/src/org/sbml/jsbml/SpeciesType.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * $Id: SpeciesType.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/SpeciesType.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - - -/** - * Represents the speciesType XML element of a SBML file. It is deprecated - * since level 3 and not defined in SBML before Level 2 Version 2. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - * @deprecated Only valid in SBML Level 2 for Versions 2 through 4. - */ -@Deprecated -public class SpeciesType extends AbstractNamedSBase implements UniqueNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7341517738480127866L; - - /** - * Creates a SpeciesType instance. - */ - @Deprecated - public SpeciesType() { - super(); - } - - /** - * Creates a SpeciesType instance from a level and version. - * - * @param level - * @param version - */ - @Deprecated - public SpeciesType(int level, int version) { - super(level, version); - } - - /** - * Creates a SpeciesType instance from a given SpeciesType. - * - * @param nsb - */ - @Deprecated - public SpeciesType(SpeciesType nsb) { - super(nsb); - } - - /** - * - * @param id - * @deprecated - */ - @Deprecated - public SpeciesType(String id) { - super(id); - } - - /** - * Creates a SpeciesType instance from an id, level and version. - * - * @param id - * @param level - * @param version - */ - @Deprecated - public SpeciesType(String id, int level, int version) { - super(id, level, version); - } - - /** - * Creates a SpeciesType instance from an id, name, level and version. - * - * @param id - * @param name - * @param level - * @param version - */ - @Deprecated - public SpeciesType(String id, String name, int level, int version) { - super(id, name, level, version); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Deprecated - public SpeciesType clone() { - return new SpeciesType(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - @Deprecated - public boolean isIdMandatory() { - return true; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/StoichiometryMath.java b/IPK_lib/src/org/sbml/jsbml/StoichiometryMath.java deleted file mode 100644 index 164774393..000000000 --- a/IPK_lib/src/org/sbml/jsbml/StoichiometryMath.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * $Id: StoichiometryMath.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/StoichiometryMath.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * Contains the MathMl expression of the Stoichiometry. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - * @deprecated Since SBML Level 3 Version 1 use {@link AssignmentRule} with - * instances of {@link SpeciesReference} as {@link Variable} - * instead. - */ -@Deprecated -public class StoichiometryMath extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -7070065639669486763L; - - /** - * Creates a StoichiometryMath instance. - */ - @Deprecated - public StoichiometryMath() { - super(); - } - - /** - * Creates a StoichiometryMath instance from a level and version. - * - * @param level - * @param version - */ - @Deprecated - public StoichiometryMath(int level, int version) { - super(level, version); - } - - /** - * Creates a StoichiometryMath instance from a given StoichiometryMath. - * - * @param stoichiometryMath - */ - @Deprecated - public StoichiometryMath(StoichiometryMath stoichiometryMath) { - super(stoichiometryMath); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - @Deprecated - public StoichiometryMath clone() { - return new StoichiometryMath(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - @Deprecated - public SpeciesReference getParent() { - return (SpeciesReference) super.getParent(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Symbol.java b/IPK_lib/src/org/sbml/jsbml/Symbol.java deleted file mode 100644 index 7584b7242..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Symbol.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * $Id: Symbol.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Symbol.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - - -/** - * The base class for {@link Compartment}, {@link Species}, {@link Parameter}. A - * symbol is a {@link Variable} of the system that declares a unit and a value, - * i.e., neither its {@link Unit} or {@link UnitDefinition}, nor its value are - * derived. A Symbol defines both fields. Furthermore, a Symbol may vary through - * a simulation and can be accessed within the model through its identifier and - * name attributes. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1153 $ - */ -public abstract class Symbol extends QuantityWithUnit implements - Variable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 3061467418198640109L; - - /** - * The constant attribute of this variable. - */ - protected Boolean constant; - - /** - * - */ - protected boolean isSetConstant = false; - - /** - * Creates a Symbol instance. By default, value, unitsID, constant are null. - */ - public Symbol() { - super(); - this.constant = null; - } - - /** - * Creates a Symbol instance from a level and version. By default, value, - * unitsID, constant are null. - * - * @param id - * @param level - * @param version - */ - public Symbol(int level, int version) { - super(level, version); - this.constant = null; - } - - /** - * - * @param quantity - */ - public Symbol(QuantityWithUnit quantity) { - super(quantity); - this.constant = null; - } - - /** - * - * @param id - */ - public Symbol(String id) { - this(); - setId(id); - } - - /** - * Creates a Symbol instance from an id, level and version. By default, - * value, unitsID, constant are null. - * - * @param id - * @param level - * @param version - */ - public Symbol(String id, int level, int version) { - this(id, null, level, version); - } - - /** - * Creates a Symbol instance from an id, name, level and version. By - * default, value, unitsID, constant are null. - * - * @param id - * @param name - * @param level - * @param version - */ - public Symbol(String id, String name, int level, int version) { - super(id, name, level, version); - this.constant = null; - } - - /** - * Creates a Symbol instance from a given Symbol. - * - * @param nsb - */ - public Symbol(Symbol nsb) { - super(nsb); - if (nsb.isSetConstant()) { - setConstant(nsb.isConstant()); - } else { - constant = nsb.constant == null ? null : new Boolean(nsb.constant); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#clone() - */ - public abstract Symbol clone(); - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - boolean equals = super.equals(o); - if (equals) { - Symbol v = (Symbol) o; - equals &= v.isSetConstant() == isSetConstant(); - if (v.isSetConstant() && isSetConstant()) { - equals &= v.isConstant() == isConstant(); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#getConstant() - */ - public boolean getConstant() { - return isConstant(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.QuantityWithUnit#hashCode() - */ - @Override - public int hashCode() { - final int prime = 929; - int hashCode = super.hashCode(); - if (isSetConstant()) { - hashCode += prime * constant.hashCode(); - } - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#isConstant() - */ - public boolean isConstant() { - /* - * Cannot use the method isSetConstant here as for level 2 we put a - * value in constant but without using the setConstant method, so the - * boolean isSetConstant is false and the value set, corresponding to - * the default value in the specs, is never returned. - */ - // TODO : check if they are some other cases like that !! - return constant != null ? constant.booleanValue() : false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#isSetConstant() - */ - public boolean isSetConstant() { - return isSetConstant; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#setConstant(boolean) - */ - public void setConstant(boolean constant) { - if (getLevel() == 1) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.constant, this); - } - Boolean oldConstant = this.constant; - this.constant = Boolean.valueOf(constant); - isSetConstant = true; - firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, constant); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.Variable#unsetConstant() - */ - public void unsetConstant() { - Boolean oldConstant = this.constant; - this.constant = null; - isSetConstant = false; - firePropertyChange(TreeNodeChangeEvent.constant, oldConstant, constant); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Trigger.java b/IPK_lib/src/org/sbml/jsbml/Trigger.java deleted file mode 100644 index 8f2e82a39..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Trigger.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * $Id: Trigger.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Trigger.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.util.Map; - -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - - -/** - * Represents the trigger XML element of a SBML file. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1169 $ - */ -public class Trigger extends AbstractMathContainer { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6964409168614117235L; - - /** - * - */ - private Boolean initialValue; - - /** - * - */ - private Boolean persistent; - - /** - * Creates a {@link Trigger} instance. - */ - public Trigger() { - super(); - initDefaults(); - } - - /** - * Creates a {@link Trigger} instance from a level and version. - * - * @param level - * @param version - */ - public Trigger(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * Creates a {@link Trigger} instance from a given {@link Trigger}. - * - * @param trigger - */ - public Trigger(Trigger trigger) { - super(trigger); - - if (trigger.isSetInitialValue()) { - this.initialValue = trigger.getInitialValue(); - } - if (trigger.isSetPersistent()) { - this.persistent = trigger.getPersistent(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#clone() - */ - @Override - public Trigger clone() { - return new Trigger(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equal = super.equals(object); - if (equal) { - Trigger t = (Trigger) object; - equal &= t.isSetInitialValue() == isSetInitialValue(); - if (equal && isSetInitialValue()) { - equal &= getInitialValue() == t.getInitialValue(); - } - equal &= t.isSetPersistent() == isSetPersistent(); - if (equal && isSetPersistent()) { - equal &= getPersistent() == t.getPersistent(); - } - } - return equal; - } - - /** - * @return the initialValue - */ - public boolean getInitialValue() { - if (getLevel() < 3) { - return true; - } - if (!isSetInitialValue()) { - throw new PropertyUndefinedError("initialValue", this); - } - return initialValue.booleanValue(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @Override - public Event getParent() { - return (Event) super.getParent(); - } - - /** - * @return the persistent - */ - public boolean getPersistent() { - if (getLevel() < 3) { - return true; - } - if (!isSetPersistent()) { - throw new PropertyUndefinedError("persistent", this); - } - return persistent.booleanValue(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 863; - int hashCode = super.hashCode(); - if (isSetInitialValue()) { - hashCode += prime * initialValue.hashCode(); - } - if (isSetPersistent()) { - hashCode += prime * persistent.hashCode(); - } - return hashCode; - } - - /** - * Sets the properties {@link #initialValue} and {@link #persistent} to null, i.e., undefined. - */ - public void initDefaults() { - initialValue = persistent = null; - } - - /** - * - * @return whether or not this {@link Trigger} is initially set to true. - */ - public boolean isInitialValue() { - return getInitialValue(); - } - - /** - * - * @return whether or not this is a persistent {@link Trigger} - */ - public boolean isPersistent() { - return getPersistent(); - } - - /** - * - * @return - */ - public boolean isSetInitialValue() { - return initialValue != null; - } - - /** - * - * @return - */ - public boolean isSetPersistent() { - return persistent != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - if (!isAttributeRead) { - if (attributeName.equals("initialValue")) { - setInitialValue(StringTools.parseSBMLBoolean(value)); - return true; - } else if (attributeName.equals("persistent")) { - setPersistent(StringTools.parseSBMLBoolean(value)); - return true; - } - } - return isAttributeRead; - } - - /** - * Can only be set if Level >= 3. - * - * @param initialValue - * the initialValue to set - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setInitialValue(boolean initialValue) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.initialValue, this); - } - Boolean oldInitialValue = this.initialValue; - this.initialValue = Boolean.valueOf(initialValue); - firePropertyChange(TreeNodeChangeEvent.initialValue, oldInitialValue, this.initialValue); - } - - /** - * Can only be set if Level >= 3. - * - * @param persistent - * the persistent to set - * @throws PropertyNotAvailableException - * if Level < 3. - */ - public void setPersistent(boolean persistent) { - if (getLevel() < 3) { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.persistent, this); - } - Boolean oldPersistent = this.persistent; - this.persistent = Boolean.valueOf(persistent); - firePropertyChange(TreeNodeChangeEvent.persistent, oldPersistent, this.persistent); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractMathContainer#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - if (isSetLevel() && (2 < getLevel())) { - if (isSetInitialValue()) { - attributes.put("initialValue", Boolean - .toString(getInitialValue())); - } - if (isSetPersistent()) { - attributes - .put("persistent", Boolean.toString(getPersistent())); - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/UniqueNamedSBase.java b/IPK_lib/src/org/sbml/jsbml/UniqueNamedSBase.java deleted file mode 100644 index 62c920c62..000000000 --- a/IPK_lib/src/org/sbml/jsbml/UniqueNamedSBase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * $Id: UniqueNamedSBase.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/UniqueNamedSBase.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml; - -/** - * This interface is used to tag all those elements - * whose identifier must be unique within an SBML {@link Model}. Since Level 2 Version 1 - * {@link UnitDefinition}s are allowed to have their own id-name space. Therefore, - * {@link UnitDefinition}s should not implement this interface - * introducing an additional check for Level 1 models. - * - * @author Andreas Dräger - * @version $Rev: 1116 $ - * @since 0.8 - * @date 19.09.2011 - */ -public interface UniqueNamedSBase extends NamedSBase { - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Unit.java b/IPK_lib/src/org/sbml/jsbml/Unit.java deleted file mode 100644 index d508cb708..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Unit.java +++ /dev/null @@ -1,2407 +0,0 @@ -/* - * $Id: Unit.java,v 1.1 2012-11-07 14:43:34 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Unit.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.Maths; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeEvent; -import org.sbml.jsbml.util.compilers.FormulaCompiler; - -/** - * Represents the unit XML element of a SBML file. - * - * @author Andreas Dräger - * @date 2009-08-31 - * @since 0.8 - * @version $Rev: 1235 $ - */ -public class Unit extends AbstractSBase { - - /** - * This enumeration contains an exhaustive list of all available unit kinds - * within all Levels and Versions of SBML. Note that some of these kinds are - * not available in some Level/Version combinations, such as - * {@link #AVOGADRO}, which has been defined in Level 3 for the first time, - * or {@link #CELSIUS}, which has been removed from the specification of - * SBML in Level 2 Version 4. This enum also provides helpful methods, for - * instance, to check if two instances of {@link Kind} with different names - * are still equivalent ({@link #areEquivalent(Kind, Kind)}), or to get the - * formula symbol of the {@link Kind} ({@link #getSymbol()}). - * - * @author Andreas Dräger - * @date 2009-08-31 - */ - public static enum Kind { - /** - * The ampere unit. - */ - AMPERE, - /** - * This unit is DIMENSIONLESS multiplied with Avogadro's number. - */ - AVOGADRO, - /** - * The becquerel unit. - */ - BECQUEREL, - /** - * The candela unit. - */ - CANDELA, - /** - * The Celsius unit. - * @deprecated use {@link #KELVIN} instead (1 Celsius = 1 K + 271.15) - */ - @Deprecated - CELSIUS, - /** - * The coulomb unit. - */ - COULOMB, - /** - * A pseudo-unit indicating a dimensionless quantity. (This is in fact - * defined in the SBML specification.) - */ - DIMENSIONLESS, - /** - * The farad unit. - */ - FARAD, - /** - * The gram unit. - */ - GRAM, - /** - * The gray unit. - */ - GRAY, - /** - * The henry unit. - */ - HENRY, - /** - * The hertz unit. - */ - HERTZ, - /** - * Marker used to indicate an invalid or not yet set unit. - */ - INVALID, - /** - * A pseudo-unit representing a single 'thing'. (This is in fact defined - * in the SBML specification.) - */ - ITEM, - /** - * The joule unit. - */ - JOULE, - /** - * The katal unit. - */ - KATAL, - /** - * The kelvin unit. - */ - KELVIN, - /** - * The kilogram unit. - */ - KILOGRAM, - /** - * Alternate spelling of litre. - * @deprecated use {@link #LITRE} instead. - */ - @Deprecated - LITER, - /** - * The litre unit. - */ - LITRE, - /** - * The lumen unit. - */ - LUMEN, - /** - * The lux unit. - */ - LUX, - /** - * Alternate spelling of metre. - * @deprecated use {@link #METRE} instead. - */ - @Deprecated - METER, - /** - * The metre unit. - */ - METRE, - /** - * The mole unit. - */ - MOLE, - /** - * The newton unit. - */ - NEWTON, - /** - * The ohm unit. - */ - OHM, - /** - * The pascal unit. - */ - PASCAL, - /** - * The radian unit. - */ - RADIAN, - /** - * The second unit. - */ - SECOND, - /** - * The siemens unit. - */ - SIEMENS, - /** - * The sievert unit. - */ - SIEVERT, - /** - * The steradian unit. - */ - STERADIAN, - /** - * The tesla unit. - */ - TESLA, - /** - * The volt unit. - */ - VOLT, - /** - * The watt unit. - */ - WATT, - /** - * The weber unit. - */ - WEBER; - - /** - * Tests whether the both given unit kinds are equivalent, i.e., it also - * considers METRE and METER and LITRE and LITER. - * - * @param kind1 - * @param kind2 - * @return - */ - public static boolean areEquivalent(Kind kind1, Kind kind2) { - return kind1 == kind2 || (kind1 == METER && kind2 == METRE) - || (kind2 == METER && kind1 == METRE) - || (kind1 == LITER && kind2 == LITRE) - || (kind2 == LITER && kind1 == LITRE); - } - - /** - * Returns a set of {@link Kind} objects for the given level/version - * combination of SBML. - * - * @param level - * @param version - * @return A {@link Set} that only contains {@link Kind}s for the given - * level/version combination. - */ - public static Set getUnitKindsDefinedIn(int level, int version) { - Kind[] kinds = {}; - switch (level) { - case 1: - switch (version) { - case 1: - case 2: - kinds = new Kind[] { AMPERE, BECQUEREL, CANDELA, CELSIUS, - COULOMB, DIMENSIONLESS, FARAD, GRAM, GRAY, HENRY, - HERTZ, ITEM, JOULE, KATAL, KELVIN, KILOGRAM, LITER, - LITRE, LUMEN, LUX, METER, METRE, MOLE, NEWTON, OHM, - PASCAL, RADIAN, SECOND, SIEMENS, SIEVERT, - STERADIAN, TESLA, VOLT, WATT, WEBER }; - break; - default: - break; - } - break; - case 2: - switch (version) { - case 1: - // Like Level 1 Version 2 without LITER and METER - kinds = new Kind[] { AMPERE, BECQUEREL, CANDELA, CELSIUS, - COULOMB, DIMENSIONLESS, FARAD, GRAM, GRAY, HENRY, - HERTZ, ITEM, JOULE, KATAL, KELVIN, KILOGRAM, LITRE, - LUMEN, LUX, METRE, MOLE, NEWTON, OHM, PASCAL, - RADIAN, SECOND, SIEMENS, SIEVERT, STERADIAN, TESLA, - VOLT, WATT, WEBER }; - break; - case 2: - case 3: - case 4: - // Like Level 2 Version 1 without CELSIUS - kinds = new Kind[] { AMPERE, BECQUEREL, CANDELA, COULOMB, - DIMENSIONLESS, FARAD, GRAM, GRAY, HENRY, HERTZ, - ITEM, JOULE, KATAL, KELVIN, KILOGRAM, LITRE, LUMEN, - LUX, METRE, MOLE, NEWTON, OHM, PASCAL, RADIAN, - SECOND, SIEMENS, SIEVERT, STERADIAN, TESLA, VOLT, - WATT, WEBER }; - break; - default: - break; - } - break; - case 3: - switch (version) { - case 1: - // like Level 2 Version 4 with additional AVOGADRO - kinds = new Kind[] { AMPERE, AVOGADRO, BECQUEREL, CANDELA, - COULOMB, DIMENSIONLESS, FARAD, GRAM, GRAY, HENRY, - HERTZ, ITEM, JOULE, KATAL, KELVIN, KILOGRAM, LITRE, - LUMEN, LUX, METRE, MOLE, NEWTON, OHM, PASCAL, - RADIAN, SECOND, SIEMENS, SIEVERT, STERADIAN, TESLA, - VOLT, WATT, WEBER }; - break; - default: - break; - } - break; - default: - break; - } - Set set = new HashSet(); - for (Kind k : kinds) { - set.add(k); - } - return set; - } - - /** - * This method is equivalent to converting the {@link String} to a - * {@link Kind} and then calling its {@link #isDefinedIn} method. Only - * entirely upper or entirely lower case {@link String}s are valid - * attributes here. - * - * This method tests whether a given string corresponds to a predefined - * {@link Unit.Kind} enumeration value. - * - * To check whether a given {@link String} represents some predefined - * {@link UnitDefinition}, please use the method - * {@link Unit#isPredefined(String, int)}. - * - * @param unitKind - * the unit string. - * @param level - * the SBML level. - * @param version - * the SBML version. - * @return true if the given string is valid for the - * particular SBML level and version, false otherwise. - * @see Unit#isPredefined(String, int) - */ - public static boolean isValidUnitKindString(String unitKind, int level, int version) { - if ((unitKind != null) && (unitKind.length() > 0)) { - try { - // We need to do that as our enum is upper case and sbml - // kind are lower case in the SBML XML representation. - Kind uk = Kind.valueOf(unitKind.toUpperCase()); - return uk.isDefinedIn(level, version); - } catch (IllegalArgumentException exc) { - logger.debug("isValidUnitKindString exception : " + exc.getMessage()); - } - } - return false; - } - - /** - * Returns the name of this unit kind. - * - * @return - */ - public String getName() { - if (this == CELSIUS) { - return "degree " - + StringTools.firstLetterUpperCase(toString() - .toLowerCase()); - } - if (this == DIMENSIONLESS || this == GRAM || this == ITEM - || this == INVALID || this == KILOGRAM || this == LUX - || this == METER || this == METRE || this == MOLE - || this == SECOND) { - return toString().toLowerCase(); - } else { - return StringTools.firstLetterUpperCase(toString() - .toLowerCase()); - } - } - - /** - * - * @return the formula symbol of this unit kind in uni-code notation. - */ - public String getSymbol() { - switch (this) { - case AMPERE: - return "A"; - case BECQUEREL: - return "Bq"; - case CANDELA: - return "cd"; - case CELSIUS: // °C in uni code - return "\u00B0C"; - case COULOMB: - return "C"; - case FARAD: - return "F"; - case GRAM: - return "g"; - case GRAY: - return "Gy"; - case HENRY: - return "H"; - case HERTZ: - return "Hz"; - case JOULE: - return "J"; - case KATAL: - return "kat"; - case KELVIN: - return "K"; - case KILOGRAM: - return "kg"; - case LITER: - return "l"; - case LITRE: - return "l"; - case LUMEN: - return "lm"; - case LUX: - return "lx"; - case METER: - return "m"; - case METRE: - return "m"; - case MOLE: - return "mol"; - case NEWTON: - return "N"; - case OHM: // upper case Omega character - return "\u03A9"; - case PASCAL: - return "Pa"; - case RADIAN: - return "rad"; - case SECOND: - return "s"; - case SIEMENS: - return "S"; - case SIEVERT: - return "Sv"; - case STERADIAN: - return "sr"; - case TESLA: - return "T"; - case VOLT: - return "V"; - case WATT: - return "W"; - case WEBER: - return "Wb"; - default: // AVOGADRO, DIMENSIONLESS, ITEM, INVALID: - return toString().toLowerCase(); - } - } - - /** - * Creates a unit ontology identifier for this {@link Kind} if possible - * and returns it. See {@link http - * ://obo.cvs.sourceforge.net/viewvc/obo/obo - * /ontology/phenotype/unit.obo} for more information. - * - * @return the unit ontology identifier for this {@link Kind} or null if - * this {@link Kind} has no corresponding type in the unit - * ontology. - * - * @see #getUnitOntologyNumber() - */ - public String getUnitOntologyIdentifier() { - int id = getUnitOntologyNumber(); - if (id > -1) { - StringBuilder sb = new StringBuilder(); - sb.append("UO:"); - sb.append(id); - while (sb.toString().length() < 10) { - sb.insert(3, 0); - } - return sb.toString(); - } - return null; - } - - /** - * Looks for the corresponding unit ontology resource for this - * {@link Kind}. Please visit {@link http://bioportal.bioontology.org/visualize/44519/?conceptid=UO%3A0000003} - * and {@link http://www.ebi.ac.uk/miriam/main/datatypes/MIR:00000136} - * for more details. - * - * @return the unit ontology number of this {@link Kind} or -1 if no - * entry exists for this {@link Kind} in the unit ontology. - */ - public int getUnitOntologyNumber() { - switch (this) { - case AMPERE: - return 11; - // case AVOGADRO: - // return ""; - case BECQUEREL: - return 132; - case CANDELA: - return 14; - case CELSIUS: - return 27; - case COULOMB: - return 220; - case DIMENSIONLESS: - return 186; - // case FARAD: - // return ""; - case GRAM: - return 21; - case GRAY: - return 134; - // case HENRY: - // return ""; - case HERTZ: - return 106; - // case INVALID: - // return ""; - // case ITEM: - // return ""; - case JOULE: - return 112; - case KATAL: - return 120; - case KELVIN: - return 12; - case KILOGRAM: - return 9; - case LITER: - case LITRE: - return 99; - case LUMEN: - return 118; - case LUX: - return 116; - case METER: - case METRE: - return 8; - case MOLE: - return 13; - case NEWTON: - return 108; - // case OHM: - // return ""; - case PASCAL: - return 110; - case RADIAN: - return 123; - case SECOND: - return 10; - case SIEMENS: - return 264; - case SIEVERT: - return 137; - case STERADIAN: - return 125; - case TESLA: - return 228; - case VOLT: - return 218; - case WATT: - return 114; - case WEBER: - return 226; - default: - return -1; - } - } - - /** - * Creates a MIRIAM resource pointing to the entry in the unit ontology - * corresponding to this {@link Kind}. If such an entry exists, this - * method will return the {@link String} - * urn:miriam:obo.unit:UO%3A plus the number of the - * resource filled to a seven-digit number by inserting leading zeros. - * - * @return null if no corresponding entry exists in the unit ontology, - * otherwise a MIRIAM resource pointing to it. - */ - public String getUnitOntologyResource() { - String uo = getUnitOntologyIdentifier(); - if (uo != null) { - return "urn:miriam:obo.unit:" + uo.replace(":", "%3A"); - } - return null; - } - - /** - * Tests whether this kind of unit is defined in the given level and - * version of SBML. - * - * @param level - * @param version - * @return - */ - public boolean isDefinedIn(int level, int version) { - return getUnitKindsDefinedIn(level, version).contains(this); - } - } - - /** - * A {@link Logger} for this class. - */ - private static final transient Logger logger = Logger.getLogger(Unit.class); - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6335465287728562136L; - - /** - * Checks whether the given {@link Unit} and the {@link Unit} represented by - * the given {@link String} are equivalent. - * - * @param unit - * @param units - * @return - * @see #areEquivalent(Unit, Unit) - */ - public static boolean areEquivalent(Unit unit, String units) { - return areEquivalent(unit, new Unit(units, unit.getLevel(), unit - .getVersion())); - } - - /** - *

    - * Predicate returning true or false depending on whether Unit objects are - * equivalent. - *

    - *

    - * Two Unit objects are considered to be equivalent if their 'kind' and - * 'exponent' attributes are equal. (Contrast this to the method - * areIdentical(Unit unit1, Unit unit2), which compares Unit objects with - * respect to all attributes, not just the kind and exponent.) - *

    - * - * @param unit1 - * the first Unit object to compare - * @param unit2 - * the second Unit object to compare - * @return if the 'kind' and 'exponent' attributes of unit1 are identical to - * the kind and exponent attributes of unit2, false otherwise. - */ - public static boolean areEquivalent(Unit unit1, Unit unit2) { - return Kind.areEquivalent(unit1.getKind(), unit2.getKind()) - && unit1.getExponent() == unit2.getExponent(); - } - - /** - *

    - * Predicate returning true or false depending on whether two Unit objects - * are identical. - *

    - *

    - * Two Unit objects are considered to be identical if they match in all - * attributes. (Contrast this to the method areEquivalent(Unit unit1, Unit - * unit2), which compares Unit objects only with respect to certain - * attributes.) - *

    - * - * @param unit1 - * the first Unit object to compare - * @param unit2 - * the second Unit object to compare - * @return true if all the attributes of unit1 are identical to the - * attributes of unit2, false otherwise. - * @see areEquivalent - */ - public static boolean areIdentical(Unit unit1, Unit unit2) { - boolean identical = areEquivalent(unit1, unit2); - identical &= unit1.getOffset() == unit2.getOffset(); - identical &= unit1.getMultiplier() == unit2.getMultiplier(); - return identical && unit1.getScale() == unit2.getScale(); - } - - /** - * Returns a UnitDefinition object which contains the argument Unit - * converted to the appropriate SI unit. - * - * @param unit - * the Unit object to convert to SI - * @return a UnitDefinition object containing the SI unit. - */ - public static UnitDefinition convertToSI(Unit unit) { - double mult = unit.getMultiplier(); - double exp = unit.getExponent(); - int scale = unit.getScale(); - int l = unit.getLevel(); - int v = unit.getVersion(); - UnitDefinition ud = new UnitDefinition(l, v); - - switch (unit.getKind()) { - case AMPERE: - /* Ampere is the SI unit of current */ - ud.addUnit(new Unit(mult, scale, Kind.AMPERE, exp, l, v)); - break; - - case BECQUEREL: - case HERTZ: - /* 1 Becquerel = 1 sec^-1 */ - /* 1 Hertz = 1 sec^-1 */ - ud.addUnit(new Unit(Math.pow(mult, -1d), scale, Kind.SECOND, -exp, - l, v)); - break; - - case CANDELA: - /* Candela is the SI unit of luminous intensity */ - ud.addUnit(new Unit(mult, scale, Kind.CANDELA, exp, l, v)); - break; - - case CELSIUS: - /* 1 °Celsius = 1 Kelvin + 273.15 */ - Unit newUnit = new Unit(mult, scale, Kind.KELVIN, exp, l, v); - newUnit.setOffset(273.15); - ud.addUnit(newUnit); - break; - - case COULOMB: - /* 1 Coulomb = 1 Ampere * second */ - ud.addUnit(new Unit(mult, scale, Kind.AMPERE, exp, l, v)); - ud.addUnit(new Unit(mult, scale, Kind.SECOND, exp, l, v)); - break; - - case DIMENSIONLESS: - case ITEM: - case RADIAN: - case STERADIAN: - /* all dimensionless */ - ud.addUnit(new Unit(mult, scale, Kind.DIMENSIONLESS, exp, l, v)); - break; - - case FARAD: - /* 1 Farad = 1 m^-2 kg^-1 s^4 A^2 */ - ud.addUnit(new Unit(Math.sqrt(mult), scale, Kind.AMPERE, 2 * exp, - l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, -2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, 4 * exp, l, v)); - break; - - case GRAM: - /* 1 gram = 0.001 Kg */ - ud.addUnit(new Unit(0.001 * mult, scale, Kind.KILOGRAM, exp, l, v)); - break; - - case GRAY: - case SIEVERT: - /* 1 Gray = 1 m^2 sec^-2 */ - /* 1 Sievert = 1 m^2 sec^-2 */ - ud.addUnit(new Unit(mult, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case HENRY: - /* 1 Henry = 1 m^2 kg s^-2 A^-2 */ - ud.addUnit(new Unit(1d / Math.sqrt(mult), scale, Kind.AMPERE, (-2) - * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case JOULE: - /* 1 joule = 1 m^2 kg s^-2 */ - ud.addUnit(new Unit(mult, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case KATAL: - /* 1 katal = 1 mol * s^-1 */ - ud.addUnit(new Unit(mult, scale, Kind.MOLE, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, -exp, l, v)); - break; - - case KELVIN: - /* Kelvin is the SI unit of temperature */ - ud.addUnit(new Unit(mult, scale, Kind.KELVIN, exp, l, v)); - break; - - case KILOGRAM: - /* Kilogram is the SI unit of mass */ - ud.addUnit(new Unit(mult, scale, Kind.KILOGRAM, exp, l, v)); - break; - - case LITER: - case LITRE: - /* 1 litre = 0.001 m^3 = (0.1 m)^3 */ - ud.addUnit(new Unit(Math.pow(0.001d * mult, 1d / 3d), scale, - Kind.METRE, 3 * exp, l, v)); - break; - - case LUMEN: - /* 1 Lumen = 1 Candela */ - ud.addUnit(new Unit(mult, scale, Kind.CANDELA, exp, l, v)); - break; - - case LUX: - /* 1 Lux = 1 Candela * m^-2 */ - ud.addUnit(new Unit(mult, scale, Kind.CANDELA, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, (-2) * exp, l, v)); - break; - - case METER: - case METRE: - /* metre is the SI unit of length */ - ud.addUnit(new Unit(mult, scale, Kind.METRE, exp, l, v)); - break; - - case MOLE: - /* mole is the SI unit of substance */ - ud.addUnit(new Unit(mult, scale, Kind.MOLE, exp, l, v)); - break; - - case NEWTON: - /* 1 newton = 1 m kg s^-2 */ - ud.addUnit(new Unit(mult, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case OHM: - /* 1 ohm = 1 m^2 kg s^-3 A^-2 */ - ud.addUnit(new Unit(1d / Math.sqrt(mult), scale, Kind.AMPERE, (-2) - * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-3) * exp, l, v)); - break; - - case PASCAL: - /* 1 pascal = 1 m^-1 * kg s^-2 */ - ud.addUnit(new Unit(mult, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case SECOND: - /* second is the SI unit of time */ - ud.addUnit(new Unit(mult, scale, Kind.SECOND, exp, l, v)); - break; - - case SIEMENS: - /* 1 Siemens = 1 m^-2 * kg^-1 * s^3 * A^2 */ - ud.addUnit(new Unit(Math.sqrt(mult), scale, Kind.AMPERE, 2 * exp, - l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, (-2) * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, 3 * exp, l, v)); - break; - - case TESLA: - /* 1 tesla = 1 kg * s^-2 * A^-1 */ - ud.addUnit(new Unit(1d / mult, scale, Kind.AMPERE, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case VOLT: - /* 1 volt = 1 m^2 * kg * s^-3 * A^-1 */ - ud.addUnit(new Unit(1d / mult, scale, Kind.AMPERE, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-3) * exp, l, v)); - break; - - case WATT: - /* 1 Watt = 1 m^2 * kg * s^-3 */ - ud.addUnit(new Unit(mult, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-3) * exp, l, v)); - break; - - case WEBER: - /* 1 Weber = 1 m^2 * kg * s^-2 * A^-1 */ - ud.addUnit(new Unit(1d / mult, scale, Kind.AMPERE, -exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.KILOGRAM, exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.METRE, 2 * exp, l, v)); - ud.addUnit(new Unit(1d, scale, Kind.SECOND, (-2) * exp, l, v)); - break; - - case INVALID: - break; - default: - break; - } - return ud.simplify(); - } - - /** - * Predicate to test whether a given string is the name of a predefined SBML - * unit. - * - * @param name - * a {@link String} to be tested against the predefined unit - * names - * @param level - * the Level of SBML for which the determination should be made. - * This is necessary because there are a few small differences in - * allowed units between SBML Level 1 and Level 2. - * @return true, if name is one of the five SBML predefined - * unit identifiers ('substance', 'volume', 'area', 'length' or - * 'time'), false otherwise. The predefined unit - * identifiers 'length' and 'area' were added in Level 2 Version 1 - * @deprecated use {@link #isPredefined(String, int)} - */ - @Deprecated - public static boolean isBuiltIn(String name, int level) { - return isPredefined(name, level); - } - - /** - * Predicate to test whether a given string is the name of a predefined SBML - * unit. - * - * @param name - * a {@link String} to be tested against the predefined unit - * names - * @param level - * the Level of SBML for which the determination should be made. - * This is necessary because there are a few small differences in - * allowed units between SBML Level 1 and Level 2. - * @return true, if name is one of the five SBML predefined - * unit identifiers ('substance', 'volume', 'area', 'length' or - * 'time'), false otherwise. The predefined unit - * identifiers 'length' and 'area' were added in Level 2 Version 1 - */ - public static boolean isPredefined(String name, int level) { - if (level < 3) { - if ((level == 2) - && (name.equals(UnitDefinition.AREA) || name - .equals(UnitDefinition.LENGTH))) { - return true; - } - if (name.equals(UnitDefinition.SUBSTANCE) - || name.equals(UnitDefinition.VOLUME) - || name.equals(UnitDefinition.TIME)) { - return true; - } - } - return false; - } - - /** - * - * @param kind - * @param level - * @param version - * @return - */ - public static boolean isUnitKind(Kind kind, int level, int version) { - try { - return kind.isDefinedIn(level, version); - } catch (Exception e) { - return false; - } - } - - /** - *

    - * Predicate to test whether a given string is the name of a valid base unit - * in SBML (such as 'gram' or 'mole'). - *

    - *

    - * This method exists because prior to SBML Level 2 Version 3, an - * enumeration called UnitKind was defined by SBML. This enumeration was - * removed in SBML Level 2 Version 3 and its values were folded into the - * space of values of a type called UnitSId. This method therefore has less - * significance in SBML Level 2 Version 3 and Level 2 Version 4, but remains - * for backward compatibility and support for reading models in older - * Versions of Level 2. - *

    - * - * @param name - * a string to be tested - * @param level - * an integer representing the SBML specification Level - * @param version - * an integer representing the SBML specification Version - * @return true if name is a valid UnitKind, false otherwise - * @jsbml.note The allowed unit names differ between SBML Levels 1 and 2 and again - * slightly between Level 2 Versions 1 and 2. - */ - public static boolean isUnitKind(String name, int level, int version) { - if ((name == null) || UnitDefinition.isPredefined(name, level)) { - // predefined units are always unit definitions. - return false; - } - Kind kind = null; - try { - kind = Kind.valueOf(name.toUpperCase()); - } catch (IllegalArgumentException exc) { - return false; - } - return isUnitKind(kind, level, version); - - } - - /** - * Returns true if the unit is a valid unit kind name or an - * identifier of an existing {@link UnitDefinition}. - * - * If either the unit or model are null, it will return false. - * - * @param unit - * the identifier of a {@link UnitDefinition} or a valid - * {@link Unit.Kind} identifier for the current level/version - * combination of the model. - * @param model - * the model where to look for the unit. - * - * @return true if the unit is a valid unit kind name or an identifier of an - * existing {@link UnitDefinition}. - */ - public static boolean isValidUnit(Model model, String unit) { - boolean isValidUnit = false; - - if (unit != null && model != null) { - unit = unit.trim(); - if (unit.length() > 0) { - if (Kind.isValidUnitKindString(unit, model.getLevel(), model - .getVersion())) { - isValidUnit = true; - } else if (model.getUnitDefinition(unit) != null) { - isValidUnit = true; - } - } - } else if (model == null && unit != null) { - isValidUnit = true; - } - - return isValidUnit; - } - - /** - * Merges two {@link Unit} objects with the same 'kind' attribute value into a - * single {@link Unit}. - * - * @param unit1 - * the first {@link Unit} object; the result of the operation is left as - * a new version of this {@link Unit}, modified in-place. - * @param unit2 - * the second {@link Unit} object to merge with the first - */ - public static void merge(Unit unit1, Unit unit2) { - Kind k1 = unit1.getKind(); - Kind k2 = unit2.getKind(); - boolean equivalent = Kind.areEquivalent(k1, k2); - if (equivalent || unit1.isDimensionless() || unit2.isDimensionless()) { - int s1 = unit1.getScale(), s2 = unit2.getScale(); - /* - * Let's get rid of this offset if there is any... - * - * We remove the offset by expressing it within a new multiplier, - * m-prime. - * - * m-prime = offset / 10^scale + multiplier - * - * When inserting this again into the unit formula, the offset - * vanishes: - * - * ((offset + multiplier * 10^scale) * unit)^exponent - * - * then becomes - * - * (m-prime * 10^scale * unit)^exponent - * - * This is possible because offset and multiplier are real double numbers. - */ - double m1 = unit1.getOffset() / Math.pow(10, s1) + unit1.getMultiplier(); - double m2 = unit2.getOffset() / Math.pow(10, s2) + unit2.getMultiplier(); - double e1 = k1 == Kind.DIMENSIONLESS - && unit1.getExponent() != 0d ? 0d : unit1.getExponent(); - double e2 = k2 == Kind.DIMENSIONLESS - && unit2.getExponent() != 0d ? 0d : unit2.getExponent(); - if (unit1.getOffset() != 0d) { - unit1.setOffset(0d); - } - - double newScale = s1; - double newMultiplier = m1; - double newExponent = e1 + e2; - - /* - * Note how we combine units: - * ========================== - * - * We have (m_1 * 10^{s_1} * u)^e_1 and (m_2 * 10^{s_2} * u)^e_2 - * - * m, s, e denoting multiplier, scale and exponent for each unit. - * u is either of identical kind or dimensionless or invalid. - * - * The merged unit is: - * - * (m_1^{e_1/(e_1 + e_2)} * m_2^{e_2/(e_1 + e_2)} * 10^{(s_1 * e_1 + s_2 * e_2)/(e_1 + e_2)} * u)^{e_1 + e_2} - * - * Special cases occur if s_1 or s_2 equal 0. - * - * It is important to know that the scale must be an integer. Hence, if the - * fraction (s_1 * e_1 + s_2 * e_2)/(e_1 + e_2) is not exactly an integer, - * we have to merge the scale with the multiplier and set the scale to 0. - * - * Also note that the exponent of a dimensionless unit must be one, - * even if it is the result of a cancelation of two other units, i.e., - * it should actually be 0. - */ - - if (newExponent != 0d) { - - /* - * Now that we know how the new exponent must look like we have to reset - * exponents of dimensionless units as these are defined. Otherwise - * scales and multipliers might get lost. - */ - if (k1 == Kind.DIMENSIONLESS) { - e1 = unit1.getExponent(); - } - if (k2 == Kind.DIMENSIONLESS) { - e2 = unit2.getExponent(); - } - - if (m1 != m2) { - newMultiplier = Math.pow(Math.pow(m1, e1) * Math.pow(m2, e2), 1d / newExponent); - } - - if (s1 != s2) { - - double ns = Double.NaN; - - if (s1 == 0) { - ns = s2 * e2 / newExponent; - } else if (s2 == 0) { - ns = s1 * e1 / newExponent; - } else if ((e1 != 0d) && (1 + e2 != 0d)) { - // factored out e_1 from (s_1 * e_1 + s_2 * e_2)/(e_1 + e_2) - // for a simpler computation: - ns = (s1 + e2 * s2 / e1) / (1 + e2 / e1); - } - - if (Maths.isInt(ns)) { - newScale = ns; - } else { - /* - * If rounding fails, we have to remove the scale and shift it to - * the multiplier. Otherwise, it would be too inaccurate. - * - * - * This is a bit ugly, but there's no other choice, - * because the scale can only be an integer number. This - * is the method from libSBML: - */ - removeScale(unit1); - removeScale(unit2); - newScale = 0d; - newExponent = unit1.getExponent() + unit2.getExponent(); - if (newExponent == 0d) { - newMultiplier = 1d; - } else if (unit1.getMultiplier() != unit2.getMultiplier()) { - m1 = unit1.getMultiplier(); - m2 = unit2.getMultiplier(); - e1 = unit1.getExponent(); - e2 = unit2.getExponent(); - newMultiplier = Math.pow(Math.pow(m1, e1) * Math.pow(m2, e2), 1d / newExponent); - } - } - } - - // Adapt unit kind if necessary - if (k1 == Kind.METER) { - unit1.setKind(Kind.METRE); - } else if (k1 == Kind.LITER) { - unit1.setKind(Kind.LITRE); - } - - } else { - /* - * If the unit has become dimentionless, mark it accordingly - * However, we must keep scale and multiplier even in dimensionless - * units because these could become important in later operations. - */ - newMultiplier = Math.pow(m1, e1) * Math.pow(m2, e2); // 1d; - newScale = s1 * e1 + s2 * e2; // 0d; - newExponent = 1d; - unit1.setKind(Kind.DIMENSIONLESS); - } - - unit1.setMultiplier(newMultiplier); - unit1.setScale((int) newScale); - unit1.setExponent(newExponent); - - } else if (k1.equals(Kind.INVALID) || k2.equals(Kind.INVALID)) { - if (!k2.equals(Kind.INVALID)) { - if (unit2.isSetOffset) { - unit1.setOffset(unit2.getOffset()); - } - unit1.setMultiplier(unit2.getMultiplier()); - unit1.setScale(unit2.getScale()); - unit1.setKind(k2); - unit1.setExponent(unit2.getExponent()); - unit1.removeMultiplier(); - } - } else { - throw new IllegalArgumentException(MessageFormat.format( - "Cannot merge units with different kind properties {0} and {1}. Units can only be merged if both have the same kind attribute or if one of them is dimensionless.", - k1, k2)); - } - } - - /** - * Manipulates the attributes of the Unit to express the unit with the value - * of the scale attribute reduced to zero. - * - * For example, 1 millimetre can be expressed as a Unit with kind= 'metre' - * multiplier='1' scale='-3' exponent='1'. It can also be expressed as a - * Unit with kind='metre' multiplier='0.001' scale='0' exponent='1'. - * - * @param unit - * the Unit object to manipulate. - */ - public static void removeScale(Unit unit) { - unit.removeScale(); - } - - /** - * Represents the 'exponent' XML attribute of an unit element. - */ - private Double exponent; - - /** - * - */ - private boolean isSetExponent; - /** - * - */ - private boolean isSetMultiplier; - - /** - * - */ - private boolean isSetOffset; - - /** - * - */ - private boolean isSetScale; - /** - * Represents the 'kind' XML attribute of an unit element. - */ - private Kind kind; - - /** - * Represents the 'multiplier' XML attribute of an unit element. - */ - private Double multiplier; - - /** - * Represents the 'offset' XML attribute of an unit element. - * @deprecated the offset attribute should no longer be used. - */ - @Deprecated - private Double offset; - - /** - * Represents the 'scale' XML attribute of an unit element. - */ - private Integer scale; - - /** - * Creates a Unit instance. If the level is set and is superior or equal to - * 3 the multiplier, scale, kind and exponent are null. - */ - public Unit() { - super(); - initDefaults(); - } - - /** - * Creates a {@link Unit} instance from a multiplier, scale, kind and exponent. The - * offset is null. - * - * @param multiplier - * @param scale - * @param kind - * @param exponent - * @param level - * @param version - */ - public Unit(double multiplier, int scale, Kind kind, double exponent, - int level, int version) { - super(level, version); - - // Using the set method to have the isSet properly set to true. - setMultiplier(multiplier); - setScale(scale); - setKind(kind); - setExponent(exponent); - this.offset = null; - } - - /** - * Creates a {@link Unit} instance from a level and version. If the level is set and - * is superior or equal to 3 the multiplier, scale, kind, offset and - * exponent are null. - * - * @param level - * @param version - */ - public Unit(int level, int version) { - super(level, version); - initDefaults(); - } - - /** - * Creates a Unit instance from a scale, kind, exponent, level and version. - * - * @param scale - * @param kind - * @param exponent - * @param level - * @param version - */ - public Unit(int scale, Kind kind, double exponent, int level, int version) { - this(1d, scale, kind, exponent, level, version); - isSetMultiplier = false; - } - - /** - * Creates a Unit instance from a scale, kind, level and version. - * - * @param scale - * @param kind - * @param level - * @param version - */ - public Unit(int scale, Kind kind, int level, int version) { - this(scale, kind, 1d, level, version); - isSetExponent = false; - } - - /** - * Creates a Unit instance from a kind, exponent, level and version. - * - * @param kind - * @param exponent - * @param level - * @param version - */ - public Unit(Kind kind, double exponent, int level, int version) { - this(0, kind, exponent, level, version); - isSetScale = false; - } - - /** - * Creates a Unit instance from a kind, level and version. If the level is - * set and is superior or equal to 3 the multiplier, scale, offset and - * exponent are null. - * - * @param kind - */ - public Unit(Kind kind, int level, int version) { - super(level, version); - if ((kind == null) || !isUnitKind(kind, level, version) && (kind != Kind.INVALID)) { - throw new IllegalArgumentException(MessageFormat.format( - "Unit kind {0} is undefined for SBML Level {1,number,integer} Version {2,number,integer}.", - kind != null ? kind.toString() : "null", level, version)); - } - initDefaults(); - setKind(kind); - } - - /** - * - * @param units - * @param level - * @param version - */ - public Unit(String units, int level, int version) { - this(Unit.Kind.valueOf(units), level, version); - } - - /** - * Creates a Unit instance from a given Unit. - * - * @param unit - */ - public Unit(Unit unit) { - super(unit); - - exponent = unit.exponent != null ? Double.valueOf(unit.getExponent()) - : null; - multiplier = unit.multiplier != null ? new Double(unit.getMultiplier()) - : null; - offset = unit.offset != null ? new Double(unit.getOffset()) : null; - scale = unit.scale != null ? Integer.valueOf(unit.getScale()) : null; - kind = unit.isSetKind() ? unit.getKind() : Kind.INVALID; - isSetExponent = unit.isSetExponent; - isSetMultiplier = unit.isSetMultiplier; - isSetOffset = unit.isSetOffset; - isSetScale = unit.isSetScale; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public Unit clone() { - return new Unit(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Unit u = (Unit) object; - equals &= getMultiplier() == u.getMultiplier(); - equals &= getScale() == u.getScale(); - equals &= getExponent() == u.getExponent(); - equals &= getOffset() == u.getOffset(); - equals &= getKind() == u.getKind(); - } - return equals; - } - - /** - * - * @return the exponent of this {@link Unit} if it is set, 1 otherwise. - */ - public double getExponent() { - return isSetExponent() ? exponent : 1d; - } - - /** - * Returns the exponent of this {@link Unit}. This method is provided for - * compatibility to libSBML only. - * - * @return - * @deprecated use {@link #getExponent()} - */ - @Deprecated - public double getExponentAsDouble() { - return getExponent(); - } - - /** - * - * @return the kind of this Unit if it is set, null otherwise. - * - */ - public Kind getKind() { - return isSetKind() ? kind : Kind.INVALID; - } - - /** - * - * @return the multiplier of this Unit if it is set, 1 otherwise. - */ - public double getMultiplier() { - return isSetMultiplier() ? multiplier : 1d; - } - - /** - * - * @return the offset of this {@link Unit} if it is set, 0 otherwise. - * @deprecated - */ - @Deprecated - public double getOffset() { - return isSetOffset() ? offset : 0d; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - @Override - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * @return This method returns the abbreviated prefix of this {@link Unit}, - * for instance, "m" for milli, i.e., if the scale is -3. In case - * that the {@link #scale} equals zero, an empty {@link String} is - * returned. If no defined prefix exists for the current {@link #scale}, - * the {@link String} 10^(%d) is returned, where - * %d denotes the {@link #scale}. - * @see #getPrefixAsWord() - */ - public String getPrefix() { - if (!isDimensionless()) { - switch (getScale()) { - case 24: - return Character.valueOf('Y').toString(); - case 21: - return Character.valueOf('Z').toString(); - case 18: - return Character.valueOf('E').toString(); - case 15: - return Character.valueOf('P').toString(); - case 12: - return Character.valueOf('T').toString(); - case 9: - return Character.valueOf('G').toString(); - case 6: - return Character.valueOf('M').toString(); - case 3: - return Character.valueOf('k').toString(); - case 2: - return Character.valueOf('h').toString(); - case 1: - return "da"; - case 0: - return ""; - case -1: - return Character.valueOf('d').toString(); - case -2: - return Character.valueOf('c').toString(); - case -3: - return Character.valueOf('m').toString(); - case -6: - return Character.valueOf('\u03BC').toString(); - case -9: - return Character.valueOf('n').toString(); - case -12: - return Character.valueOf('p').toString(); - case -15: - return Character.valueOf('f').toString(); - case -18: - return Character.valueOf('a').toString(); - case -21: - return Character.valueOf('z').toString(); - case -24: - return Character.valueOf('y').toString(); - default: - break; - } - } - return String.format("10^(%d)", getScale()); - } - - /** - * @return the prefix of this {@link Unit}, for instance, "milli" if the {@link #scale} is -3. - * In case that the {@link #scale} equals zero, an empty {@link String} is - * returned. If no defined prefix exists for the current {@link #scale}, - * the {@link String} 10^(%d) is returned, where - * %d denotes the {@link #scale}. - * @see #getPrefix() - */ - public String getPrefixAsWord() { - if (!isDimensionless()) { - switch (getScale()) { - case 24: - return "yotta"; - case 21: - return "zetta"; - case 18: - return "exa"; - case 15: - return "peta"; - case 12: - return "tera"; - case 9: - return "giga"; - case 6: - return "mega"; - case 3: - return "kilo"; - case 2: - return "hecto"; - case 1: - return "deca"; - case 0: - return ""; - case -1: - return "deci"; - case -2: - return "centi"; - case -3: - return "milli"; - case -6: - return "micro"; - case -9: - return "nano"; - case -12: - return "pico"; - case -15: - return "femto"; - case -18: - return "atto"; - case -21: - return "zepto"; - case -24: - return "yocto"; - default: - break; - } - } - return String.format("10^(%d)", getScale()); - } - - /** - * - * @return the scale of this Unit if it is set, 0 otherwise. - */ - public int getScale() { - return isSetScale() ? scale : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 823; - int hashCode = super.hashCode(); - hashCode += prime * Double.valueOf(getMultiplier()).hashCode(); - hashCode += prime * getScale(); - hashCode += prime * Double.valueOf(getExponent()).hashCode(); - hashCode += prime * Double.valueOf(getOffset()).hashCode(); - if (isSetKind()) { - hashCode += prime * getKind().hashCode(); - } - return hashCode; - } - - /** - * Predicate returning true or false depending on whether all the required - * attributes for this Unit object have been set. - * - * @return a boolean value indicating whether all the required elements for - * this object have been defined. - */ - public boolean hasRequiredAttributes() { - return isSetKind(); - } - - /** - * Initializes the default values using the current Level/Version configuration. - */ - public void initDefaults() { - initDefaults(getLevel(), getVersion()); - } - - /** - * Initializes the attributes of this Unit (except for 'kind') to their - * defaults values. - * - * The default values are as follows: - *
      - *
    • exponent = 1
    • - *
    • scale = 0
    • - *
    • multiplier = 1.0
    • - *
    - * The 'kind' attribute is left unchanged. - */ - public void initDefaults(int level, int version) { - kind = Kind.INVALID; - if (level < 3) { - exponent = Double.valueOf(1d); - scale = Integer.valueOf(0); - multiplier = new Double(1); - offset = new Double(0); - } else { - exponent = null; - offset = null; - multiplier = null; - scale = null; - } - isSetExponent = false; - isSetScale = false; - isSetMultiplier = false; - isSetOffset = false; - } - - /** - * Predicate for testing whether this Unit is of the kind ampere. - * - * @return - */ - public boolean isAmpere() { - return kind == Kind.AMPERE; - } - - /** - * Predicate for testing whether this Unit is of the kind avogadro. - * - * @return true if the kind of this Unit is avogadro, false otherwise. - */ - public boolean isAvogadro() { - return kind == Kind.AVOGADRO; - } - - /** - * Predicate for testing whether this Unit is of the kind becquerel. - * - * @return - */ - public boolean isBecquerel() { - return kind == Kind.BECQUEREL; - } - - /** - * Predicate for testing whether this Unit is of the kind candela - * - * @return - */ - public boolean isCandela() { - return kind == Kind.CANDELA; - } - - /** - * Predicate for testing whether this Unit is of the kind Celsius - * - * @return - * @deprecated {@link Kind#CELSIUS} should no longer be used. - */ - @Deprecated - public boolean isCelsius() { - return kind == Kind.CELSIUS; - } - - /** - * Predicate for testing whether this Unit is of the kind coulomb. - * - * @return - */ - public boolean isCoulomb() { - return kind == Kind.COULOMB; - } - - /** - * Predicate for testing whether this Unit is of the {@link Kind} - * {@link DIMENSIONLESS}. A unit is also dimensionless if it does not - * declare an offset and at the same time its exponent is zero. In this case - * the unit represents a dimensionless quantity. - * - * @return True if this unit represents a dimensionless quantity, i.e., its - * {@link Kind} is {@link DIMENSIONLESS} or offset = exponent = 0 - */ - public boolean isDimensionless() { - return (kind == Kind.DIMENSIONLESS) - || ((getOffset() == 0d) && (getExponent() == 0d)); - } - - /** - * Predicate for testing whether this Unit is of the kind farad - * - * @return - */ - public boolean isFarad() { - return kind == Kind.FARAD; - } - - /** - * Predicate for testing whether this Unit is of the kind gram - * - * @return - */ - public boolean isGram() { - return kind == Kind.GRAM; - } - - /** - * Predicate for testing whether this Unit is of the kind gray - * - * @return - */ - public boolean isGray() { - return kind == Kind.GRAY; - } - - /** - * Predicate for testing whether this Unit is of the kind henry - * - * @return - */ - public boolean isHenry() { - return kind == Kind.HENRY; - } - - /** - * Predicate for testing whether this Unit is of the kind hertz - * - * @return - */ - public boolean isHertz() { - return kind == Kind.HERTZ; - } - - /** - * Predicate for testing whether this Unit is of the kind invalid. - * - * @return - */ - public boolean isInvalid() { - return kind == Kind.INVALID; - } - - /** - * Predicate for testing whether this Unit is of the kind item - * - * @return - */ - public boolean isItem() { - return kind == Kind.ITEM; - } - - /** - * Predicate for testing whether this Unit is of the kind Joule - * - * @return - */ - public boolean isJoule() { - return kind == Kind.JOULE; - } - - /** - * Predicate for testing whether this Unit is of the kind katal - * - * @return - */ - public boolean isKatal() { - return kind == Kind.KATAL; - } - - /** - * Predicate for testing whether this Unit is of the kind kelvin - * - * @return - */ - public boolean isKelvin() { - return kind == Kind.KELVIN; - } - - /** - * Predicate for testing whether this Unit is of the kind kilogram - * - * @return - */ - public boolean isKilogram() { - return kind == Kind.KILOGRAM; - } - - /** - * Predicate for testing whether this Unit is of the kind litre. - * - * @return true if the kind of this Unit is litre or 'liter', false - * otherwise. - */ - public boolean isLitre() { - return (kind == Kind.LITRE) || (kind == Kind.LITER); - } - - /** - * Predicate for testing whether this Unit is of the kind lumen - * - * @return - */ - public boolean isLumen() { - return kind == Kind.LUMEN; - } - - /** - * Predicate for testing whether this Unit is of the kind lux - * - * @return - */ - public boolean isLux() { - return kind == Kind.LUX; - } - - /** - * Predicate for testing whether this Unit is of the kind metre - * - * @return - */ - public boolean isMetre() { - return (kind == Kind.METRE) || (kind == Kind.METER); - } - - /** - * Predicate for testing whether this Unit is of the kind mole. - * - * @return true if the kind of this Unit is mole, false otherwise. - */ - public boolean isMole() { - return kind == Kind.MOLE; - } - - /** - * Predicate for testing whether this Unit is of the kind newton - * - * @return - */ - public boolean isNewton() { - return kind == Kind.NEWTON; - } - - /** - * Predicate for testing whether this Unit is of the kind ohm - * - * @return - */ - public boolean isOhm() { - return kind == Kind.OHM; - } - - /** - * Predicate for testing whether this Unit is of the kind pascal - * - * @return - */ - public boolean isPascal() { - return kind == Kind.PASCAL; - } - - /** - * Predicate for testing whether this Unit is of the kind radian - * - * @return - */ - public boolean isRadian() { - return kind == Kind.RADIAN; - } - - /** - * Predicate for testing whether this Unit is of the kind second - * - * @return - */ - public boolean isSecond() { - return kind == Kind.SECOND; - } - - /** - * - * @return true if the exponent of this Unit is not null. - */ - public boolean isSetExponent() { - return isSetExponent && (exponent != null); - } - - /** - * Predicate to test whether the 'kind' attribute of this {@link Unit} has been set. - * - * @return - */ - public boolean isSetKind() { - return (kind != null) && (kind != Kind.INVALID); - } - - /** - * - * @return true if the multiplier of this Unit is not null. - */ - public boolean isSetMultiplier() { - return isSetMultiplier && (multiplier != null); - } - - /** - * - * @return - * @deprecated the offset attribute should no longer be used. - */ - @Deprecated - public boolean isSetOffset() { - return isSetOffset && (offset != null); - } - - /** - * - * @return true if the scale of this Unit is not null. - */ - public boolean isSetScale() { - return isSetScale && (scale != null); - } - - /** - * Predicate for testing whether this Unit is of the kind siemens - * - * @return - */ - public boolean isSiemens() { - return kind == Kind.SIEMENS; - } - - /** - * Predicate for testing whether this Unit is of the kind sievert - * - * @return - */ - public boolean isSievert() { - return kind == Kind.SIEVERT; - } - - /** - * Predicate for testing whether this Unit is of the kind steradian - * - * @return - */ - public boolean isSteradian() { - return kind == Kind.STERADIAN; - } - - /** - * Predicate for testing whether this Unit is of the kind tesla - * - * @return - */ - public boolean isTesla() { - return kind == Kind.TESLA; - } - - /** - * - * @return true if this Unit is a variant of area. - */ - public boolean isVariantOfArea() { - Kind kind = getKind(); - return (kind == Kind.METER) || (kind == Kind.METRE) - && (getOffset() == 0d) && (getExponent() == 2d); - } - - /** - * - * @return true if this Unit is a variant of length. - */ - public boolean isVariantOfLength() { - Kind kind = getKind(); - return (kind == Kind.METER) || (kind == Kind.METRE) - && (getOffset() == 0d) && (getExponent() == 1d); - } - - /** - * - * @return true if this Unit is a variant of substance. - */ - public boolean isVariantOfSubstance() { - Kind kind = getKind(); - if ((kind == Kind.MOLE) - || (kind == Kind.ITEM) - || ((((getLevel() == 2) && (getVersion() > 1)) || (getLevel() > 2)) && (kind == Kind.GRAM || isKilogram()))) { - return (getOffset() == 0d) && (getExponent() == 1d); - } - return false; - } - - /** - * - * @return - */ - public boolean isVariantOfTime() { - return (getKind() == Kind.SECOND) && (getOffset() == 0d) - && (getExponent() == 1d); - } - - /** - * - * @return true if this Unit is a variant of volume. - */ - public boolean isVariantOfVolume() { - Kind kind = getKind(); - if ((kind == Kind.LITER) || (kind == Kind.LITRE)) { - return (getOffset() == 0d) && (getExponent() == 1d); - } - if ((kind == Kind.METER) || (kind == Kind.METRE)) { - return (getOffset() == 0d) && (getExponent() == 3d); - } - return false; - } - - /** - * Predicate for testing whether this Unit is of the kind volt - * - * @return - */ - public boolean isVolt() { - return kind == Kind.VOLT; - } - - /** - *Predicate for testing whether this Unit is of the kind watt - * - * @return - */ - public boolean isWatt() { - return kind == Kind.WATT; - } - - /** - * Predicate for testing whether this Unit is of the kind weber - * - * @return - */ - public boolean isWeber() { - return kind == Kind.WEBER; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - isAttributeRead = true; - - if (attributeName.equals("kind")) { - try { - Kind kind = Kind.valueOf(value.toUpperCase()); - setKind(kind); - } catch (Exception e) { - isAttributeRead = false; - } - } else if (attributeName.equals("exponent")) { - setExponent(getLevel() < 3 ? StringTools.parseSBMLInt(value) - : StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("scale")) { - setScale(StringTools.parseSBMLInt(value)); - } else if (attributeName.equals("multiplier")) { - setMultiplier(StringTools.parseSBMLDouble(value)); - } else if (attributeName.equals("offset")) { - setOffset(StringTools.parseSBMLDouble(value)); - } else { - isAttributeRead = false; - } - } - return isAttributeRead; - } - - /** - * This method tries to remove the {@link #multiplier} of this unit. - * Nothing will happen in the case that there is no {@link #multiplier}. - * Otherwise, it first computes the decadic logarithm of the - * {@link #multiplier}. - * If this logarithm is either an integer or nearly an integer (with an - * accepted - * error of 10-24), it is added to the {@link #scale} and the - * {@link #multiplier} is set to 1. - * Note that it is not always possible to remove the {@link #multiplier} - * without loosing information. In order to avoid computational errors, - * nothing is done if the rounding error would be too large. - * - * @return a pointer to this {@link Unit}. - */ - public Unit removeMultiplier() { - if (isSetMultiplier() && (getMultiplier() != 1d)) { - double exp = Math.log10(getMultiplier()); - if (Maths.isInt(exp)) { - setScale(getScale() + ((int) exp)); - setMultiplier(1d); - } else if (Math.round(exp) - exp < 1E-15) { - // 1E-15 is an acceptable noise range due to the limitation of doubles to 17 decimal positions. - setScale(getScale() + ((int) Math.round(exp))); - setMultiplier(1d); - } - } - return this; - } - - /** - * We remove the offset by expressing it within a new {@link #multiplier}, - * m': - *

    - * m' = {@link #offset} / 10^{@link #scale} + {@link #multiplier} - *

    - * When inserting this again into the unit formula, the offset vanishes: - *

    - * (({@link #offset} + {@link #multiplier} * 10^{@link #scale}) * - * {@link #kind})^{@link #exponent} - *

    - * then becomes - *

    - * (0 + ({@link #offset} / 10^{@link #scale} + {@link #multiplier}) * 10^{@link #scale} * {@link #kind})^{@link #exponent} = - *

    - * (m' * 10^{@link #scale} * {@link #kind})^{@link #exponent} - *

    - * This is possible because offset and multiplier are real double numbers. - * - * @return this {@link Unit} whose {@link #offset} and {@link #multiplier} - * might have been changed in case that there was an {@link #offset} - * defined that was different to zero. - */ - public Unit removeOffset() { - if (isSetOffset() && (getOffset() != 0d)) { - setMultiplier(getOffset() / Math.pow(10, getScale()) + getMultiplier()); - setOffset(0d); - } - return this; - } - - /** - * Manipulates the attributes of the Unit to express the unit with the value - * of the scale attribute reduced to zero. - * - * For example, 1 millimetre can be expressed as a Unit with kind= 'metre' - * multiplier='1' scale='-3' exponent='1'. It can also be expressed as a - * Unit with kind='metre' multiplier='0.001' scale='0' exponent='1'. - */ - public Unit removeScale() { - setMultiplier(getMultiplier() * Math.pow(10, getScale())); - setScale(0); - return this; - } - - /** - * Sets the exponent of this {@link Unit} - * - * @param exponent - */ - public void setExponent(double exponent) { - Double oldExponent = this.exponent; - isSetExponent = true; - this.exponent = Double.valueOf(exponent); - firePropertyChange(TreeNodeChangeEvent.exponent, oldExponent, this.exponent); - } - - /** - * Sets the exponent of this {@link Unit} - * - * @param exponent - * @deprecated use {@link #setExponent(double)} - */ - @Deprecated - public void setExponent(int exponent) { - setExponent((double) exponent); - } - - /** - * Sets the {@link Kind} of this {@link Unit} - * - * @param kind - */ - public void setKind(Kind kind) { - Kind oldKind = this.kind; - this.kind = (kind != null) ? kind : Kind.INVALID; - firePropertyChange(TreeNodeChangeEvent.kind, oldKind, this.kind); - } - - /** - * Sets the multiplier of this {@link Unit} - * - * @param multiplier - * @throws PropertyNotAvailableException - * if Level < 2 and the given multiplier != 1. - */ - public void setMultiplier(double multiplier) { - if ((getLevel() < 2) && (multiplier != 1d)) { - // added the multiplier test != 1 to prevent error being reported when it is not necessary - throw new PropertyNotAvailableException(TreeNodeChangeEvent.multiplier, this); - } - Double oldMultiplyer = this.multiplier; - isSetMultiplier = true; - this.multiplier = multiplier; - firePropertyChange(TreeNodeChangeEvent.multiplier, oldMultiplyer, this.multiplier); - } - - /** - * Sets the offset of this {@link Unit} - * - * @param offset - * @deprecated Only defined for SBML Level 2 Version 1. - * @throws PropertyNotAvailableException - * if Level/Version combination is not 2.1. - */ - @Deprecated - public void setOffset(double offset) { - if ((getLevel() == 2) && (getVersion() == 1)) { - Double oldOffset = this.offset; - isSetOffset = true; - this.offset = Double.valueOf(offset); - firePropertyChange(TreeNodeChangeEvent.offset, oldOffset, this.offset); - } else { - throw new PropertyNotAvailableException(TreeNodeChangeEvent.offset, this); - } - } - - /** - * Sets the scale of this Unit - * - * @param scale - */ - public void setScale(int scale) { - Integer oldScale = this.scale; - isSetScale = true; - this.scale = scale; - firePropertyChange(TreeNodeChangeEvent.scale, oldScale, scale); - } - - /** - * Produces a text formula representation of this unit. - */ - @Override - public String toString() { - StringBuffer times = new StringBuffer(); - if (getMultiplier() != 0d) { - if (getMultiplier() != 1d) { - times.append(StringTools.toString(getMultiplier())); - } - StringBuffer pow = new StringBuffer(); - pow.append(kind != null ? kind.getSymbol() : "undefined"); - String prefix = getPrefix(); - if ((prefix.length() > 0) && !prefix.startsWith("10")) { - pow.insert(0, prefix); - } else if (getScale() != 0) { - pow = FormulaCompiler.times(FormulaCompiler.pow(Integer.valueOf(10), - getScale()), pow); - } - times = FormulaCompiler.times(times, pow); - } - if ((offset != null) && (offset.doubleValue() != 0d)) { - times = FormulaCompiler.sum(StringTools.toString(offset.doubleValue()), - times); - } - return FormulaCompiler.pow(times, StringTools.toString(getExponent())).toString(); - } - - /** - * - */ - public void unsetExponent() { - Double oldExponent = this.exponent; - exponent = null; - isSetExponent = false; - firePropertyChange(TreeNodeChangeEvent.exponent, oldExponent, this.exponent); - } - - /** - * - */ - public void unsetKind() { - Kind oldKind = this.kind; - kind = Kind.INVALID; - firePropertyChange(TreeNodeChangeEvent.kind, oldKind, this.kind); - } - - /** - * - */ - public void unsetMultiplier() { - Double oldMultipler = this.multiplier; - multiplier = null; - isSetMultiplier = false; - firePropertyChange(TreeNodeChangeEvent.multiplier, oldMultipler, - this.multiplier); - } - - /** - * @deprecated the offset attribute should no longer be used. - */ - @Deprecated - public void unsetOffset() { - Double oldOffset = this.offset; - offset = null; - isSetOffset = false; - firePropertyChange(TreeNodeChangeEvent.offset, oldOffset, this.offset); - } - - /** - * - */ - public void unsetScale() { - Integer oldScale = this.scale; - scale = null; - isSetScale = false; - firePropertyChange(TreeNodeChangeEvent.scale, oldScale, scale); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.SBase#readAttribute(String attributeName, String prefix, String value) - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - int level = getLevel(), version = getVersion(); - Locale en = Locale.ENGLISH; - - if (isSetKind()) { - attributes.put("kind", getKind().toString().toLowerCase()); - } - if (isSetScale()) { - attributes.put("scale", Integer.toString(getScale())); - } - if (1 < level) { - if (isSetMultiplier()) { - attributes.put("multiplier", StringTools.toString(en, getMultiplier())); - } - } - if ((level == 2) && (version == 1)) { - if (isSetOffset()) { - attributes.put("offset", StringTools.toString(en, getOffset())); - } - } - if (isSetExponent()) { - if (2 < level) { - attributes.put("exponent", StringTools.toString(en, getExponent())); - } else { - int exponent = (int) getExponent(); - attributes.put("exponent", Integer.toString((int) getExponent())); - if (exponent - getExponent() != 0d) { - logger.warn(MessageFormat.format( - "Loss of information because the illegal non-integer exponent {0,number} has been rounded to {1,number,integer}.", - getExponent(), exponent)); - } - } - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/UnitDefinition.java b/IPK_lib/src/org/sbml/jsbml/UnitDefinition.java deleted file mode 100644 index 50d1dc1a6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/UnitDefinition.java +++ /dev/null @@ -1,1190 +0,0 @@ -/* - * $Id: UnitDefinition.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/UnitDefinition.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.ListOf.Type; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.util.ValuePair; - -/** - * Represents the unitDefinition XML element of a SBML file. - * - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1235 $ - */ -public class UnitDefinition extends AbstractNamedSBase { - - /** - * Identifier of the (for SBML Level 2) predefined {@link UnitDefinition} - * area. - */ - public static final String AREA = "area"; - /** - * Identifier of the (for SBML Level 2) predefined {@link UnitDefinition} - * length. - */ - public static final String LENGTH = "length"; - /** - * The logger for this class. - */ - private static final Logger logger = Logger.getLogger(UnitDefinition.class); - /** - * Generated serial version identifier. - */ - public static final long serialVersionUID = -4705380036260408123L; - /** - * Identifier of the (for the SBML Levels 1 and 2) predefined - * {@link UnitDefinition} substance. - */ - public static final String SUBSTANCE = "substance"; - /** - * Identifier of the (for the SBML Levels 1 and 2) predefined - * {@link UnitDefinition} time. - */ - public static final String TIME = "time"; - /** - * Identifier of the (for some SBML Levels 1 and 2) predefined - * {@link UnitDefinition} volume. - */ - public static final String VOLUME = "volume"; - - /** - * Predefined unit for area. - */ - public static final UnitDefinition area(int level, int version) { - return getPredefinedUnit(AREA, level, version); - } - - /** - *

    - * Predicate returning true or false depending on - * whether two UnitDefinition objects are compatible. - *

    - *

    - * For the purposes of performing this comparison, two - * {@link UnitDefinition} objects are considered compatible when they - * contain compatible list of {@link Unit} objects. This means two - * {@link UnitDefinition} objects are compatible if both satisfy the method - * {@link #areEquivalent(UnitDefinition, UnitDefinition)} or one of both has - * {@link Kind#INVALID} as {@link Unit.Kind} - * - * @param ud1 - * the first {@link UnitDefinition} object to compare - * @param ud2 - * the second {@link UnitDefinition} object to compare - * @return true if all the {@link Unit} objects in ud1 are - * compatible to the {@link Unit} objects in ud2, false - * otherwise. - * @see #areIdentical(UnitDefinition, UnitDefinition) - * @see Unit#areEquivalent(Unit, Unit) - */ - public static boolean areCompatible(UnitDefinition ud1, UnitDefinition ud2) { - return areEquivalent(ud1, ud2) || ud2.isInvalid() || ud1.isInvalid(); - } - - /** - * Checks whether the given {@link UnitDefinition} and the - * {@link UnitDefinition} or {@link Unit} represented by the given - * {@link String} are equivalent. - * - * @param ud - * @param units - * @return - * @see #areEquivalent(UnitDefinition, UnitDefinition) - * @see Unit#areEquivalent(Unit, Unit) - */ - public static boolean areEquivalent(UnitDefinition ud, String units) { - UnitDefinition ud2 = ud.getModel().getUnitDefinition(units); - if (ud2 != null) { - return areEquivalent(ud, ud2); - } else if (ud.isUnitKind() - && Unit.isUnitKind(units, ud.getLevel(), ud.getVersion())) { - return Unit.areEquivalent(ud.getUnit(0), units); - } - - return false; - } - - /** - *

    - * Predicate returning true or false depending on whether two - * {@link UnitDefinition} objects are equivalent. - *

    - *

    - * For the purposes of performing this comparison, two {@link UnitDefinition} - * objects are considered equivalent when they contain equivalent list of - * {@link Unit} objects. {@link Unit} objects are in turn considered - * equivalent if they satisfy the predicate - * {@link Unit#areEquivalent(Unit, Unit)}. The predicate tests a subset of the - * objects's attributes. - *

    - * - * @param ud1 - * the first {@link UnitDefinition} object to compare - * @param ud2 - * the second {@link UnitDefinition} object to compare - * @return true if all the Unit objects in ud1 are equivalent to - * the {@link Unit} objects in ud2, false otherwise. - * @see #areIdentical(UnitDefinition, UnitDefinition) - * @see Unit#areEquivalent(Unit, String) - */ - public static boolean areEquivalent(UnitDefinition ud1, UnitDefinition ud2) { - UnitDefinition ud1clone = ud1.clone().simplify(); - UnitDefinition ud2clone = ud2.clone().simplify(); - if (ud1clone.getUnitCount() == ud2clone.getUnitCount()) { - boolean equivalent = true; - for (int i = 0; i < ud1clone.getUnitCount(); i++) { - equivalent &= Unit.areEquivalent(ud1clone.getUnit(i), - ud2clone.getUnit(i)); - } - return equivalent; - } - return false; - } - - /** - *

    - * Predicate returning true or false depending on - * whether two {@link UnitDefinition} objects are identical. - *

    - *

    - * For the purposes of performing this comparison, two {@link UnitDefinition} - * objects are considered identical when they contain identical lists of - * {@link Unit} objects. Pairs of {@link Unit} objects in the lists are in - * turn considered identical if they satisfy the predicate - * {@link Unit#areIdentical(Unit, Unit)}. The predicate compares every - * attribute of the {@link Unit} objects. - *

    - * - * @param ud1 - * the first {@link UnitDefinition} object to compare - * @param ud2 - * the second {@link UnitDefinition} object to compare - * @return true if all the {@link Unit} objects in ud1 are - * identical to the {@link Unit} objects of ud2, false - * otherwise. - */ - public static boolean areIdentical(UnitDefinition ud1, UnitDefinition ud2) { - UnitDefinition ud1clone = ud1.clone().simplify(); - UnitDefinition ud2clone = ud2.clone().simplify(); - if (ud1clone.getUnitCount() == ud2clone.getUnitCount()) { - boolean identical = true; - for (int i = 0; i < ud1clone.getUnitCount(); i++) { - identical &= Unit.areIdentical(ud1clone.getUnit(i), - ud2clone.getUnit(i)); - } - return identical; - } - return false; - } - - /** - * This method returns the predefined unit with the given identifier for the - * specified level and version combination or null if either for the given - * combination of level and version there is no such predefined unit or the - * identifier is not one of those belonging to the group of predefined unit - * definitions. - * - * @param id - * one of the values - *
      - *
    • substance
    • - *
    • volume
    • - *
    • area
    • - *
    • length
    • - *
    • time
    • - *
    • any of the basic kind
    • - *
    - * @param level - * a number greater than zero. - * @param version - * a number greater than zero. - * @return The predefined unit definition with the given identifier for the - * specified level version combination or null if no such predefined - * unit exists. - */ - public static final UnitDefinition getPredefinedUnit(String id, int level, - int version) { - - if (id == null) { - logger.warn("Cannot create predefined unit object with id = null."); - return null; - } else if (!(isPredefined(id, level) || (Unit.isUnitKind(id, level, - version)))) { - logger.warn(MessageFormat.format( - "No such predefined unit {0} in SBML Level {1,number,integer}.", id, level)); - - return null; - } - - id = id.toLowerCase(); - Unit u = new Unit(level, version); - if (id.equals(SUBSTANCE)) { - u.setKind(Kind.MOLE); - } else if (id.equals(VOLUME)) { - u.setKind(Kind.LITRE); - } else if (id.equals(AREA)) { - u.setKind(Kind.METRE); - u.setExponent(2d); - } else if (id.equals(LENGTH)) { - u.setKind(Kind.METRE); - } else if (id.equals(TIME)) { - u.setKind(Kind.SECOND); - } else { - Kind kind = null; - try { - kind = Kind.valueOf(id.toUpperCase()); - } catch (IllegalArgumentException exc) { - logger.warn(MessageFormat.format( - "No such unit kind {0} in SBML Level {1,number,integer} Version {1,number,integer}", id, - level, version)); - return null; - } - u.setKind(kind); - } - if ((level > 1) && (version > 1)) { - String resource = u.getKind().getUnitOntologyResource(); - if (resource != null) { - // metaid will be created upon nessesity. - u.addCVTerm(new CVTerm(Qualifier.BQB_IS, resource)); - } - } - String name = " unit " + id; - if (!Unit.isPredefined(id, level)) { - id += "_base"; - name = "Base" + name; - } else { - name = "Predefined" + name; - } - UnitDefinition ud = new UnitDefinition(id, level, version); - ud.setName(name); - ud.addUnit(u); - return ud; - } - - /** - * Test if the given unit is a predefined unit. - * - * @param ud - * @deprecated use {@link #isPredefined()} - */ - @Deprecated - public static boolean isBuiltIn(UnitDefinition ud) { - return isPredefined(ud); - } - - /** - * - * @param name - * @param level - * @return - */ - public static boolean isPredefined(String name, int level) { - return Unit.isPredefined(name, level); - } - - /** - * Test if the given unit is a predefined unit. - * - * @param ud - * @return - */ - public static boolean isPredefined(UnitDefinition ud) { - if (ud.getLevel() > 2) { - return false; - } - if (ud.getUnitCount() == 1) { - UnitDefinition predef = getPredefinedUnit(ud.getId(), - ud.getLevel(), ud.getVersion()); - if ((predef != null) - && Unit.isPredefined(ud.getId(), ud.getLevel())) { - return ud.equals(predef); - } - } - return false; - } - - /** - * Predefined unit for length. - */ - public static final UnitDefinition length(int level, int version) { - return getPredefinedUnit(LENGTH, level, version); - } - - /** - * Returns a string that expresses the unit definition represented by this - * UnitDefinition object. - * - * @param ud - * the UnitDefinition object - * @return a string expressing the unit definition - */ - public static String printUnits(UnitDefinition ud) { - return printUnits(ud, false); - } - - /** - * Returns a string that expresses the unit definition represented by this - * UnitDefinition object. - * - * @param ud - * the UnitDefinition object - * @param compact - * boolean indicating whether the compact form should be used - * (defaults to false) - * @return a string expressing the unit definition - */ - public static String printUnits(UnitDefinition ud, boolean compact) { - StringBuilder sb = new StringBuilder(); - if (ud == null) { - sb.append("null"); - } else { - for (int i = 0; i < ud.getUnitCount(); i++) { - Unit unit = ud.getUnit(i); - if (i > 0) { - sb.append('*'); // multiplication dot \u22c5. - } - if (compact) { - sb.append(unit.toString()); - } else { - sb.append(unit.getKind().getName().toLowerCase()); - sb.append(MessageFormat.format( - " (exponent = {0}, multiplier = {1}, scale = {2})", - StringTools.toString(unit.getExponent()), - StringTools.toString(unit.getMultiplier()), - unit.getScale())); - } - } - } - return sb.toString(); - } - - /** - * Orders alphabetically the {@link Unit} objects within the - * {@link #listOfUnits} of a {@link UnitDefinition}. - * - * @param ud - * the {@link UnitDefinition} object whose {@link Unit}s are to be - * reordered. - */ - public static void reorder(UnitDefinition ud) { - if (1 < ud.getUnitCount()) { - ListOf orig = ud.getListOfUnits(); - ListOf units = new ListOf(ud.getLevel(), ud.getVersion()); - units.setSBaseListType(Type.listOfUnits); - orig.removeAllTreeNodeChangeListeners(); - units.add(orig.remove(orig.size() - 1)); - int i, j; - for (i = orig.size() - 1; i >= 0; i--) { - Unit u = orig.remove(i); - j = 0; - while ((j < units.size()) - && (0 < u.getKind().compareTo(units.get(j).getKind()))) { - j++; - } - units.add(j, u); - } - ud.setListOfUnits(units); - } - } - - /** - * @param ud - * @return a simplified version of the given {@link UnitDefinition}. In order - * to make sure that the original {@link UnitDefinition} is not - * changed, it is cloned before the simplification. - */ - public static UnitDefinition simplify(UnitDefinition ud) { - return ud.clone().simplify(); - } - - /** - * Predefined unit for substance. - */ - public static final UnitDefinition substance(int level, int version) { - return getPredefinedUnit(SUBSTANCE, level, version); - } - - /** - * Predefined unit for time. - */ - public static final UnitDefinition time(int level, int version) { - return getPredefinedUnit(TIME, level, version); - } - - /** - * Predefined unit for volume. - */ - public static final UnitDefinition volume(int level, int version) { - return getPredefinedUnit(VOLUME, level, version); - } - - /** - * Represents the 'listOfUnit' XML sub-element of a UnitDefinition. - */ - private ListOf listOfUnits; - - /** - * Creates an UnitDefinition instance. By default, the listOfUnit is null. - */ - public UnitDefinition() { - super(); - } - - /** - * - * @param level - * @param version - */ - public UnitDefinition(int level, int version) { - super(level, version); - } - - /** - * - * @param id - */ - public UnitDefinition(String id) { - super(id); - } - - /** - * Creates an UnitDefinition instance from an id, level and version. By - * default, the listOfUnit is null. - * - * @param id - * @param level - * @param version - */ - public UnitDefinition(String id, int level, int version) { - super(id, level, version); - } - - /** - * Creates an UnitDefinition instance from an id, level and version. By - * default, the listOfUnit is null. - * - * @param id - * @param name - * @param level - * @param version - */ - public UnitDefinition(String id, String name, int level, int version) { - super(id, name, level, version); - } - - /** - * Creates an UnitDefinition instance from a given UnitDefinition. - * - * @param unitDefinition - */ - public UnitDefinition(UnitDefinition unitDefinition) { - super(unitDefinition); - if (unitDefinition.isSetListOfUnits()) { - setListOfUnits(unitDefinition.getListOfUnits().clone()); - } - } - - /** - * - * @param unit - */ - public void addUnit(String unit) { - addUnit(Unit.Kind.valueOf(unit)); - } - - /** - * Adds an {@link Unit} to this {@link UnitDefinition}. - * - * @param u - */ - public void addUnit(Unit u) { - listOfUnits = getListOfUnits(); - if (!listOfUnits.contains(u)) { - listOfUnits.add(u); - } - } - - /** - * Convenient method to add a new unit object with the given kind that will - * have the same level/version combination than this {@link UnitDefinition} - * object. - * - * @param kind - */ - public void addUnit(Unit.Kind kind) { - addUnit(new Unit(kind, getLevel(), getVersion())); - } - - /** - * Removes all {@link Unit} elements from the list of Units in this object. - */ - public void clear() { - getListOfUnits().clear(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.element.AbstractSBase#clone() - */ - @Override - public UnitDefinition clone() { - return new UnitDefinition(this); - } - - /** - * This method converts this unit definition to a - */ - public void convertToSIUnits() { - UnitDefinition ud[] = new UnitDefinition[getUnitCount()]; - Set listeners = new HashSet( - getListOfTreeNodeChangeListeners()); - removeAllTreeNodeChangeListeners(); - for (int i = ud.length - 1; i >= 0; i--) { - ud[i] = Unit.convertToSI(removeUnit(i)); - } - for (UnitDefinition u : ud) { - getListOfUnits().addAll(u.getListOfUnits()); - } - simplify(); - addAllChangeListeners(listeners); - } - - /** - * - * @return - */ - public Unit createUnit() { - return createUnit(Unit.Kind.INVALID); - } - - /** - * - * @param kind - * @return - */ - public Unit createUnit(Unit.Kind kind) { - Unit unit = new Unit(kind, getLevel(), getVersion()); - addUnit(unit); - - return unit; - } - - /** - * Divides this unit definition by the second unit definition. - * - * @param definition - */ - public UnitDefinition divideBy(UnitDefinition definition) { - // Avoid creation of not needed empty list: - if (definition.isSetListOfUnits()) { - for (Unit unit1 : definition.getListOfUnits()) { - Unit unit = unit1.clone(); - if (!(unit.isDimensionless() || unit.isInvalid())) { - unit.setExponent(-unit1.getExponent()); - } - boolean contains = false; - for (int i = getUnitCount() - 1; (i >= 0) && !contains; i--) { - Unit u = getUnit(i); - if (Unit.Kind.areEquivalent(u.getKind(), unit.getKind()) - || u.isDimensionless() || unit.isDimensionless() - || u.isInvalid() || unit.isInvalid()) { - if (u.isDimensionless()) { - Unit.merge(unit, removeUnit(i)); - break; - } else { - Unit.merge(u, unit); - contains = true; - } - } - } - if (!contains) { - addUnit(unit); - } - } - } - return this; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(index + " < 0"); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetListOfUnits()) { - if (index == pos) { - return getListOfUnits(); - } - pos++; - } - throw new IndexOutOfBoundsException(MessageFormat.format( - "Index {0,number,integer} >= {1,number,integer}", index, - + ((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int children = super.getChildCount(); - if (isSetListOfUnits()) { - children++; - } - return children; - } - - /** - * - * @return the listOfUnits of this UnitDefinition. Can be empty. - */ - public ListOf getListOfUnits() { - if (listOfUnits == null) { - listOfUnits = ListOf.newInstance(this, Unit.class); - listOfUnits.fireNodeAddedEvent(); - } - return listOfUnits; - } - - /** - * - * @return the number of Unit. - * @deprecated use {@link #getUnitCount()} - */ - @Deprecated - public int getNumUnits() { - return getUnitCount(); - } - - /** - * - * @return the number of Unit. - */ - public int getUnitCount() { - return isSetListOfUnits() ? listOfUnits.size() : 0; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getParent() - */ - @SuppressWarnings("unchecked") - public ListOf getParent() { - return (ListOf) super.getParent(); - } - - /** - * Returns a specific Unit instance belonging to this UnitDefinition. - * - * @param i - * an integer, the index of the Unit to be returned. - * @return the ith Unit of this UnitDefinition - */ - public Unit getUnit(int i) { - return getListOfUnits().get(i); - } - - /** - * This method tests if this unit definition is a predefined unit. - * - * @return - * @deprecated use {@link #isPredefined()} - */ - @Deprecated - public boolean isBuiltIn() { - return isBuiltIn(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return true; - } - - /** - * This method checks, if this UnitDefinition only contains Invalid as - * {@link Unit.Kind}. - * - * @return - */ - public boolean isInvalid() { - UnitDefinition ud = this.clone().simplify(); - - if (ud.getUnitCount() == 1) { - return ud.getUnit(0).isInvalid(); - } - - return false; - - } - - /** - * This method tests if this unit definition is a predefined unit. - * - * @return - */ - public boolean isPredefined() { - return isPredefined(this); - } - - /** - * - * @return true if the listOfUnits is not null and not empty. - */ - public boolean isSetListOfUnits() { - return (listOfUnits != null) && (listOfUnits.size() > 0); - } - - /** - * Convenient method to test whether this {@link UnitDefinition} contains - * exactly one {@link Unit} that itself represents a {@link Kind}, i.e., - * multiplier = 1, exponent = 1, scale = 1. Note that this method requires - * the level and version attributes of this {@link UnitDefinition} to be - * set. - * - * @return - */ - public boolean isUnitKind() { - if (getUnitCount() == 1) { - return Unit.isUnitKind(getUnit(0).getKind(), getLevel(), - getVersion()); - } - return false; - } - - /** - * - * @return true if this UnitDefinition is a variant of Area - */ - public boolean isVariantOfArea() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 1) { - Unit unit = listOfUnits.get(0); - return unit.isVariantOfArea(); - } - } - return false; - } - - /** - * Convenience function for testing if a given unit definition is a variant - * of the predefined unit identifier 'length'. - * - * @param two - * @return true if this UnitDefinition is a variant of the predefined unit - * length, meaning metres with only arbitrary variations in scale or - * multiplier values; false otherwise. - */ - public boolean isVariantOfLength() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 1) { - Unit unit = listOfUnits.get(0); - return unit.isVariantOfLength(); - } - } - return false; - } - - /** - * Convenience function for testing if a given unit definition is a variant - * of the predefined unit identifier 'substance'. - * - * @return true if this UnitDefinition is a variant of the predefined unit - * substance, meaning moles or items (and grams or kilograms from - * SBML Level 2 Version 2 onwards) with only arbitrary variations in - * scale or multiplier values; false otherwise. - */ - public boolean isVariantOfSubstance() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 1) { - Unit unit = listOfUnits.get(0); - return unit.isVariantOfSubstance(); - } - } - return false; - } - - /** - * - * @return - */ - public boolean isVariantOfSubstancePerArea() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 2) { - if (getUnit(0).isVariantOfSubstance()) { - Unit two = getUnit(1).clone(); - two.setExponent(-two.getExponent()); - return two.isVariantOfArea(); - } else if (getUnit(1).isVariantOfSubstance()) { - Unit one = getUnit(0).clone(); - one.setExponent(-one.getExponent()); - return one.isVariantOfArea(); - } - } - } - return false; - } - - /** - * - * @return true if this UnitDefinition is a variant of substance per length. - */ - public boolean isVariantOfSubstancePerLength() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 2) { - Unit unit = listOfUnits.get(0); - Unit unit2 = listOfUnits.get(1); - if (unit.isVariantOfSubstance()) { - Unit two = listOfUnits.get(1).clone(); - two.setExponent(-two.getExponent()); - return two.isVariantOfLength(); - } else if (unit2.isVariantOfSubstance()) { - Unit one = listOfUnits.get(0).clone(); - one.setExponent(-one.getExponent()); - return one.isVariantOfLength(); - } - } - } - return false; - } - - /** - * - * @return - */ - public boolean isVariantOfSubstancePerTime() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 2) { - Unit unit1 = listOfUnits.get(0); - Unit unit2 = listOfUnits.get(1); - if (unit1.isVariantOfSubstance()) { - Unit two = listOfUnits.get(1).clone(); - two.setExponent(-two.getExponent()); - return two.isVariantOfTime(); - } else if (unit2.isVariantOfSubstance()) { - Unit one = listOfUnits.get(0).clone(); - one.setExponent(-one.getExponent()); - return one.isVariantOfTime(); - } - } - } - return false; - } - - /** - * - * @return true if this UnitDefinition is a variant of substance per volume. - */ - public boolean isVariantOfSubstancePerVolume() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 2) { - Unit unit = listOfUnits.get(0); - Unit unit2 = listOfUnits.get(1); - if (unit.isVariantOfSubstance()) { - Unit two = listOfUnits.get(1).clone(); - two.setExponent(-two.getExponent()); - return two.isVariantOfVolume(); - } else if (unit2.isVariantOfSubstance()) { - Unit one = listOfUnits.get(0).clone(); - one.setExponent(-one.getExponent()); - return one.isVariantOfVolume(); - } - } - } - return false; - } - - /** - * Convenience function for testing if a given unit definition is a variant - * of the predefined unit identifier 'time'. - * - * @return true if this {@link UnitDefinition} is a variant of - * the predefined unit time, meaning second with only arbitrary - * variations in scale or multiplier values; false - * otherwise. - */ - public boolean isVariantOfTime() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 1) { - Unit unit = listOfUnits.get(0); - return unit.isVariantOfTime(); - } - } - return false; - } - - /** - * Convenience function for testing if a given unit definition is a variant - * of the predefined unit identifier 'volume'. - * - * @return true if this {@link UnitDefinition} is a variant of - * the predefined unit volume, meaning litre or cubic metre with - * only arbitrary variations in scale or multiplier values; - * false otherwise. - */ - public boolean isVariantOfVolume() { - if (isSetListOfUnits()) { - if (listOfUnits.size() == 1) { - Unit unit = listOfUnits.get(0); - return unit.isVariantOfVolume(); - } - } - return false; - } - - /** - * Multiplies this unit with the given unit definition, i.e., adds a clone - * of each unit object in the list of units of the given definition to the - * list of this unit. - * - * @param definition - * @return - */ - public UnitDefinition multiplyWith(UnitDefinition definition) { - // Avoid creation of not needed empty list: - if (definition.isSetListOfUnits()) { - for (Unit unit : definition.getListOfUnits()) { - boolean contains = false; - for (int i = getUnitCount() - 1; (i >= 0) && !contains; i--) { - Unit u = getUnit(i); - if (Unit.Kind.areEquivalent(u.getKind(), unit.getKind()) - || u.isDimensionless() || unit.isDimensionless() - || u.isInvalid() || unit.isInvalid()) { - if (u.isDimensionless()) { - unit = unit.clone(); - Unit.merge(unit, removeUnit(i)); - break; - } else { - Unit.merge(u, unit); - contains = true; - } - } - } - if (!contains) { - addUnit(unit.clone()); - } - } - } - return this; - } - - /** - * Raises this unit definition by the power of the given exponent, i.e., the - * exponents of every unit contained by this unit definition are multiplied - * with the given exponent. - * - * @param exponent - * @return a pointer to this {@link UnitDefinition}. - */ - public UnitDefinition raiseByThePowerOf(double exponent) { - if (isSetListOfUnits()) { - Unit u; - for (int i = listOfUnits.size() - 1; i >= 0; i--) { - u = listOfUnits.get(i); - u.setExponent(u.getExponent() * exponent); - if (u.getExponent() == 0d) { - listOfUnits.remove(i); - } - } - } - return this; - } - - /** - * Removes the nth {@link Unit} object from this {@link UnitDefinition} object and returns a - * pointer to it. - * - * The caller owns the returned object and is responsible for deleting it. - * - * @param i - * the index of the Unit object to remove - * @return the {@link Unit} object removed. As mentioned above, the caller owns the - * returned item. null is returned if the given index is out of - * range. - */ - public Unit removeUnit(int i) { - if (isSetListOfUnits()) { - // Note that ListOf will already notify listeners. - Unit u = listOfUnits.remove(i); - return u; - } - return null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#setId(java.lang.String) - */ - @Override - public void setId(String id) { - // This test should be performed in order to ensure valid identifiers - // for Units: - ValuePair lv = getLevelAndVersion(); - if ((0 <= lv.compareTo(Integer.valueOf(2), Integer.valueOf(3))) - && Unit.Kind.isValidUnitKindString(id, lv.getL().intValue(), lv - .getV().intValue())) { - throw new IllegalArgumentException( - MessageFormat.format( - "Cannot use the name {0} of a unit base kind as an identifier for a UnitDefinition.", - id)); - } - super.setId(id); - } - - /** - * Sets the {@link #listOfUnits} of this {@link UnitDefinition}. - * Automatically sets the parent SBML object of the list to this - * {@link UnitDefinition} instance. - * - * @param listOfUnits - */ - public void setListOfUnits(ListOf listOfUnits) { - unsetListOfUnits(); - this.listOfUnits = listOfUnits; - if ((this.listOfUnits != null) - && (this.listOfUnits.getSBaseListType() != ListOf.Type.listOfUnits)) { - this.listOfUnits.setSBaseListType(ListOf.Type.listOfUnits); - } - registerChild(this.listOfUnits); - } - - /** - * Simplifies the {@link UnitDefinition} so that any {@link Unit} objects - * occurring within the {@link #listOfUnits} occurs only once. {@link Unit}s - * of {@link Kind} {@link Kind.INVALID} are treated like - * {@link Kind.DIMENSIONLESS} units and will therefore tend to disappear by - * merging with other units. - * - * @return a pointer to the simplified {@link UnitDefinition}. - */ - public UnitDefinition simplify() { - if (isSetListOfUnits()) { - reorder(this); - Unit u, s; - // Merge units with equivalent or similar kinds if possible: - for (int i = getUnitCount() - 2; i >= 0; i--) { - u = getUnit(i); // current unit - s = getUnit(i + 1); // successor unit - if (Unit.Kind.areEquivalent(u.getKind(), s.getKind()) - || u.isDimensionless() || s.isDimensionless() - || u.isInvalid() || s.isInvalid()) { - if (s.isDimensionless()) { - Unit.merge(u, removeUnit(i + 1)); - } else { - Unit.merge(s, removeUnit(i)); - } - } - } - - // Remove units that have become dimensionless by merging with subsequent units - while ((getUnitCount() > 1) && (getUnit(0).getKind().equals(Kind.DIMENSIONLESS))) { - u = removeUnit(0); - Unit.merge(getUnit(0), u); - } - - // TODO: Reorder all units first to have all those with a positive exponent in the front! - - // Shift scales and multipliers to the front if possible: - for (int i = getUnitCount() - 2; i >= 0; i--) { - u = getUnit(i); // current unit - s = getUnit(i + 1); // successor unit - if (!Unit.Kind.areEquivalent(u.getKind(), s.getKind()) - && !u.isDimensionless() && !s.isDimensionless() - && !u.isInvalid() && !s.isInvalid()) { - // double m1 = u.getMultiplier(); - // double m2 = s.getMultiplier(); - int s1 = u.getScale(); - int s2 = s.getScale(); - double e1 = u.getExponent(); - double e2 = s.getExponent(); - double p1 = s1 * e1; - double p2 = s2 * e2; - // Try re-scaling by merging the scale of the second unit into the first unit: - if ((Math.signum(p1) != Math.signum(p2)) && (e1 != 0d)) { - double newScale = s1 + p2 / e1; - if (((i > 1) || ((s1 != 0) && (s2 != 0))) && (newScale - ((int) newScale) == 0)) { - /* - * Only re-scale if we can obtain an integer and if there is more - * than two units in the list (otherwise it is not necessary to - * simplify these units), i.e., loss-free rounding. - */ - u.setScale((int) newScale); - s.setScale(0); - } - } - /* - * Better do not try to remove the multiplier from the second unit - * because this can lead to very strange numbers. Often multipliers - * are strictly bound to one unit, for instance, 3600 * second (which - * is hour). When shifting the multiplier to the next unit in the - * front, the result might become very strange. - */ - } - } - } - return this; - } - - /** - * Removes the {@link #listOfUnits} from this {@link UnitDefinition} and - * notifies all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfUnits() { - if (this.listOfUnits != null) { - ListOf oldListOfUnits = this.listOfUnits; - this.listOfUnits = null; - oldListOfUnits.fireNodeRemovedEvent(); - return true; - } - return false; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/Variable.java b/IPK_lib/src/org/sbml/jsbml/Variable.java deleted file mode 100644 index 253d3a79d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/Variable.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * $Id: Variable.java,v 1.1 2012-11-07 14:43:33 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/Variable.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml; - -/** - * A variable of the system is a {@link Quantity} whose value may change during - * a simulation. To decide whether it has to stay constant, this interface - * provides the necessary methods. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @date 2010-04-20 - * @since 0.8 - * @version $Rev: 1169 $ - */ -public interface Variable extends Quantity, UniqueNamedSBase { - - /** - * - * @return the constant boolean of this variable. - */ - public boolean getConstant(); - - /** - * - * @return the constant value if it is set, false otherwise. - */ - public boolean isConstant(); - - /** - * - * @return true if the constant boolean of this Variable is not null. - */ - public boolean isSetConstant(); - - /** - * Sets the constant boolean of this Variable. - * - * @param constant - * @throws PropertyNotAvailableException - * for inappropriate Level/Version combinations depending on the - * implementing class. - */ - public void setConstant(boolean constant); - - /** - * With this method the constant property of this variable will be set to an - * undefined state. - */ - public void unsetConstant(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/AbstractSBasePlugin.java b/IPK_lib/src/org/sbml/jsbml/ext/AbstractSBasePlugin.java deleted file mode 100644 index 1e8af7e5c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/AbstractSBasePlugin.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * $Id: AbstractSBasePlugin.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ext/AbstractSBasePlugin.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext; - -import java.util.Enumeration; -import java.util.NoSuchElementException; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBase; - - -/** - * @author Andreas Dräger - * @author Florian Mittag - * @version $Rev: 1116 $ - * @since 1.0 - * @date 28.10.2011 - */ -public abstract class AbstractSBasePlugin implements SBasePlugin { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 3741496965840142920L; - - /** - * - */ - protected SBase extendedSBase; - - /** - * - */ - public AbstractSBasePlugin() { - super(); - } - - - /** - * @param extendedSBase - */ - public AbstractSBasePlugin(SBase extendedSBase) { - this(); - this.extendedSBase = extendedSBase; - } - - /** - * Returns the SBase object that is extended by this plug-in. - * - * @return the SBase object that is extended by this plug-in. - */ - public SBase getExtendedSBase() { - return extendedSBase; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#children() - */ - public Enumeration children() { - return new Enumeration() { - /** - * Total number of children in this enumeration. - */ - private int childCount = getChildCount(); - /** - * Current position in the list of children. - */ - private int index; - - /* - * (non-Javadoc) - * - * @see java.util.Enumeration#hasMoreElements() - */ - public boolean hasMoreElements() { - return index < childCount; - } - - /* - * (non-Javadoc) - * - * @see java.util.Enumeration#nextElement() - */ - public TreeNode nextElement() { - synchronized (this) { - if (index < childCount) { - return getChildAt(index++); - } - } - throw new NoSuchElementException("Enumeration"); - } - }; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public abstract SBasePlugin clone(); - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - // Check if the given object is a pointer to precisely the same object: - if (super.equals(object)) { - return true; - } - // Check if the given object is of identical class and not null: - if ((object == null) || (!getClass().equals(object.getClass()))) { - return false; - } - // Check all child nodes recursively: - if (object instanceof SBase) { - SBase stn = (SBase) object; - int childCount = getChildCount(); - boolean equal = stn.isLeaf() == isLeaf(); - /* - * This is not good because cloned SBase may not point - * to the same parent as the original and would hence not be equal - * to the cloned object. - */ - // equal &= ((stn.getParent() == null) && isRoot()) - // || (stn.getParent() == getParent()); - equal &= stn.getChildCount() == childCount; - if (equal && (childCount > 0)) { - for (int i = 0; i < childCount; i++) { - if (!stn.getChildAt(i).equals(getChildAt(i))) { - return false; - } - } - } - return equal; - } - return false; - } - - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getIndex(org.sbml.jsbml.SBase) - */ - public int getIndex(SBase node) { - // TODO Auto-generated method stub - return 0; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - // A constant and arbitrary, sufficiently large prime number: - final int prime = 769; - /* - * This method is implemented as suggested in the JavaDoc API - * documentation of the List interface. - */ - - // Compute the initial hashCode based on the name of the actual class. - int hashCode = getClass().getName().hashCode(); - /* - * The following start wouldn't work because it will compute the - * hashCode from the address in memory of the object. - */ - // int hashCode = super.hashCode(); - - // Recursively compute the hashCode for each child node: - TreeNode child; - for (int i = 0; i < getChildCount(); i++) { - child = getChildAt(i); - hashCode = prime * hashCode + (child == null ? 0 : child.hashCode()); - } - - return hashCode; - } - - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#isLeaf() - */ - public boolean isLeaf() { - return getChildCount() == 0; - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/SBasePlugin.java b/IPK_lib/src/org/sbml/jsbml/ext/SBasePlugin.java deleted file mode 100644 index 3c5b664ac..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/SBasePlugin.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * $Id: SBasePlugin.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/ext/SBasePlugin.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext; - -import java.io.Serializable; -import java.util.Enumeration; -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBase; - -/** - * Defines the methods necessary for an SBase Plugin. When a SBML level 3 is extending - * one of the core SBML elements with additional attributes or child elements, a {@link SBasePlugin} - * is created to serve as a place holder for there new attributes or elements. - * - * - * @author Nicolas Rodriguez - * @version $Rev: 1116 $ - * @since 1.0 - */ -public interface SBasePlugin extends Cloneable, Serializable { - - /** - * Reads and sets the attribute if it is know from this {@link SBasePlugin}. - * - * @param attributeName - * : localName of the XML attribute - * @param prefix - * : prefix of the XML attribute - * @param value - * : value of the XML attribute - * @return true if the attribute has been successfully read. - */ - public boolean readAttribute(String attributeName, String prefix, - String value); - - /** - * Returns the child TreeNode at index - * childIndex. - */ - public TreeNode getChildAt(int childIndex); - - /** - * Returns the number of children TreeNodes the receiver - * contains. - */ - public int getChildCount(); - - /** - * Returns the index of node in the receivers children. - * If the receiver does not contain node, -1 will be - * returned. - */ - public int getIndex(SBase node); - - /** - * Returns true if the receiver allows children. - */ - public boolean getAllowsChildren(); - - /** - * Returns true if the receiver is a leaf. - */ - public boolean isLeaf(); - - /** - * Returns the children of the receiver as an Enumeration. - */ - public Enumeration children(); - - /** - * Returns a {@link Map} containing the XML attributes of this object. - * - * @return a {@link Map} containing the XML attributes of this object. - */ - public Map writeXMLAttributes(); - - public boolean equals(Object obj); - - public int hashCode(); - - public SBasePlugin clone(); -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint1.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint1.java deleted file mode 100644 index 8495b1abb..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint1.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: BasePoint1.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BasePoint1.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * - * @author Sebastian Fröhlich - * @version $Rev: 1116 $ - * @since 1.0 - * @date 21.11.2011 - */ -public class BasePoint1 extends Point { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -7544027003069685943L; - - public BasePoint1() { - super(); - } - - public BasePoint1(Point point) { - super(point); - clonePointAttributes(point, this); - } - -@Override - public BasePoint1 clone() { - return new BasePoint1(this); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint2.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint2.java deleted file mode 100644 index b2014fdea..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/BasePoint2.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: BasePoint2.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BasePoint2.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * - * @author Sebastian Fröhlich - * @version $Rev: 1116 $ - * @since 1.0 - * @date 21.11.2011 - */ -public class BasePoint2 extends Point { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -7781069728939292255L; - - public BasePoint2() { - super(); - } - - public BasePoint2(Point point) { - super(point); - clonePointAttributes(point, this); - } - -@Override - public BasePoint2 clone() { - return new BasePoint2(this); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/BoundingBox.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/BoundingBox.java deleted file mode 100644 index 3a655ef08..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/BoundingBox.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * $Id: BoundingBox.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/BoundingBox.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractNamedSBase; - -/** - * - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1116 $ - */ -public class BoundingBox extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6371039558611201798L; - - /** - * - */ - private Dimensions dimensions; - - /** - * - */ - private Point position; - - /** - * - */ - public BoundingBox() { - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param boundingBox - */ - public BoundingBox(BoundingBox boundingBox) { - super(boundingBox); - if (boundingBox.isSetDimensions()) { - this.dimensions = boundingBox.getDimensions().clone(); - } - - if (boundingBox.isSetPosition()) { - this.position = boundingBox.getPosition().clone(); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public BoundingBox clone() { - return new BoundingBox(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - // Check all child elements recursively in super class first: - boolean equals = super.equals(object); - - if (equals) { - // Cast is possible because super class checks the class attributes - BoundingBox bb = (BoundingBox) object; - - // compare position and dimensions - equals &= bb.isSetPosition() == isSetPosition(); - if (equals && isSetPosition()) { - equals &= bb.getPosition().equals(getPosition()); - } - - equals &= bb.isSetDimensions() == isSetDimensions(); - if (equals && isSetDimensions()) { - equals &= bb.getDimensions().equals(getDimensions()); - } - - } - return equals; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetPosition()) { - if (pos == index) { - return getPosition(); - } - pos++; - } - if (isSetDimensions()) { - if (pos == index) { - return getDimensions(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetPosition()) { - count++; - } - if (isSetDimensions()) { - count++; - } - return count; - } - - /** - * - * @return - */ - public Dimensions getDimensions() { - return dimensions; - } - - - /** - * - * @return - */ - public Point getPosition() { - return position; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 7; - int hashCode = super.hashCode(); - hashCode += prime * getId().hashCode(); - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * @return - */ - public boolean isSetDimensions() { - return dimensions != null; - } - - /** - * @return - */ - public boolean isSetPosition() { - return position != null; - } - - - /** - * - * @param dimensions - */ - public void setDimensions(Dimensions dimensions) { - if(this.dimensions != null){ - Dimensions oldValue = this.dimensions; - this.dimensions = null; - oldValue.fireNodeRemovedEvent(); - } - this.dimensions = dimensions; - registerChild(this.dimensions); - } - - /** - * - * @param point - */ - public void setPosition(Point point) { - Point oldValue = this.position; - this.position = point; - if(oldValue != null){ - oldValue.fireNodeRemovedEvent(); - } - if(this.position != null){ - if (! (this.position instanceof Position)) { - this.position = new Position(this.position); - } - this.position.fireNodeAddedEvent(); - } - } - - - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId()) { - attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); - } - if (isSetName()) { - // Problem !!! no name defined officially - // write an error message ? - // TODO : override the setName method to report an error ? - attributes.remove("name"); - // attributes.put(LayoutConstant.shortLabel + ":name", getName()); - } - - return attributes; - } - - /** - * Creates, sets and returns {@link Dimensions} based on the - * given values. - * @param width - * @param height - * @param depth - * @return new {@link Dimensions} object. - */ - public Dimensions createDimensions(double width, double height, double depth) { - Dimensions d = new Dimensions(); - d.setWidth(width); - d.setHeight(height); - d.setDepth(depth); - setDimensions(d); - return d; - } - - /** - * Creates, sets and returns a {@link Dimensions} - * - * @return new {@link Dimensions} object. - */ - public Dimensions createDimensions() { - Dimensions d = new Dimensions(); - setDimensions(d); - return d; - } - - - /** - * Creates, sets and returns a {@link Position} based on the - * given values. - * @param x - * @param y - * @param z - * @return new {@link Position} object. - */ - public Position createPosition(double x, double y, double z) { - Position p = new Position(); - p.setX(x); - p.setY(y); - p.setZ(z); - setPosition(p); - return p; - } - - /** - * Creates, sets and returns a {@link Position} - * - * @return new {@link Position} object. - */ - public Position createPosition() { - Position p = new Position(); - setPosition(p); - return p; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java deleted file mode 100644 index 408ca5673..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * $Id: CompartmentGlyph.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CompartmentGlyph.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class CompartmentGlyph extends GraphicalObject { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -831178362695634919L; - /** - * - */ - private String compartment; - - /** - * - */ - public CompartmentGlyph() { - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param compartmentGlyph - */ - public CompartmentGlyph(CompartmentGlyph compartmentGlyph) { - super(compartmentGlyph); - if (compartmentGlyph.isSetCompartment()) { - this.compartment = new String(compartmentGlyph.getCompartment()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#clone() - */ - @Override - public CompartmentGlyph clone() { - return new CompartmentGlyph(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - CompartmentGlyph cg = (CompartmentGlyph) object; - equals &= isSetCompartment() && cg.isSetCompartment(); - if (equals && isSetCompartment()) { - equals &= getCompartment().equals(cg.getCompartment()); - } - } - return equals; - } - - /** - * - * @return - */ - public String getCompartment() { - return compartment; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 983; - int hashCode = super.hashCode(); - if (isSetCompartment()) { - hashCode += prime * getCompartment().hashCode(); - } - return hashCode; - } - - /** - * @return - */ - public boolean isSetCompartment() { - return (compartment != null) && (compartment.length() > 0); - } - - /** - * - * @param compartment - */ - public void setCompartment(String compartment) { - String oldCompartment = this.compartment; - this.compartment = compartment; - firePropertyChange(TreeNodeChangeEvent.compartment, oldCompartment, this.compartment); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) - { - - if(attributeName.equals(LayoutConstant.compartment)) - { - setCompartment(value); - } - else - { - return false; - } - - return true; - } - - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetCompartment()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.compartment, compartment); - } - - return attributes; - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/CubicBezier.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/CubicBezier.java deleted file mode 100644 index 8d4f6afd7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/CubicBezier.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * $Id: CubicBezier.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CubicBezier.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import javax.swing.tree.TreeNode; - -/** - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1116 $ - */ -public class CubicBezier extends LineSegment { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6747242964512145076L; - - /** - * - */ - private Point basePoint1; - - /** - * - */ - private Point basePoint2; - - /** - * - */ - public CubicBezier() { - - } - - /** - * @param cubicBezier - */ - public CubicBezier(CubicBezier cubicBezier) { - super(cubicBezier); - if (cubicBezier.isSetBasePoint1()) { - basePoint1 = cubicBezier.getBasePoint1(); - } - if (cubicBezier.isSetBasePoint2()) { - basePoint2 = cubicBezier.getBasePoint2(); - } - } - - /** - * - * @param level - * @param version - */ - public CubicBezier(int level, int version) { - super(level, version); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.LineSegment#clone() - */ - @Override - public CubicBezier clone() { - return new CubicBezier(this); - } - - /** - * - * @return - */ - public Point getBasePoint1() { - return basePoint1; - } - - /** - * - * @return - */ - public Point getBasePoint2() { - return basePoint2; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.LineSegment#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetBasePoint1()) { - if (pos == index) { - return getBasePoint1(); - } - pos++; - } - if (isSetBasePoint2()) { - if (pos == index) { - return getBasePoint2(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.LineSegment#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetBasePoint1()) { - count++; - } - if (isSetBasePoint2()) { - count++; - } - return count; - } - - /** - * @return - */ - public boolean isSetBasePoint1() { - return basePoint1 != null; - } - - /** - * @return - */ - public boolean isSetBasePoint2() { - return basePoint2 != null; - } - - /** - * - * @param basePoint1 - */ - public void setBasePoint1(Point basePoint1) { - if(this.basePoint1 != null){ - Point oldValue = this.basePoint1; - this.basePoint1 = null; - oldValue.fireNodeRemovedEvent(); - } - if (!(basePoint1 instanceof BasePoint1)) { - basePoint1 = new BasePoint1(basePoint1); - } - this.basePoint1 = basePoint1; - registerChild(this.basePoint1); - } - - /** - * - * @param basePoint2 - */ - public void setBasePoint2(Point basePoint2) { - if(this.basePoint2 != null){ - Point oldValue = this.basePoint2; - this.basePoint2 = null; - oldValue.fireNodeRemovedEvent(); - } - if (!(basePoint2 instanceof BasePoint1)) { - basePoint2 = new BasePoint2(basePoint2); - } - this.basePoint2 = basePoint2; - registerChild(this.basePoint2); - } - - /** - * Creates, sets and returns a {@link Point} - * - * @return new {@link Point} object. - */ - public Point createBasePoint1() { - Point p = new BasePoint1(); - setBasePoint1(p); - return p; - } - - /** - * Creates, sets and returns a {@link Point} based on the - * given values. - * @param x - * @param y - * @param z - * @return new {@link Point} object. - */ - public Point createBasePoint1(double x, double y, double z) { - Point p = new BasePoint1(); - p.setX(x); - p.setY(y); - p.setZ(z); - setBasePoint1(p); - return p; - } - - /** - * Creates, sets and returns a {@link Point} - * - * @return new {@link Point} object. - */ - public Point createBasePoint2() { - Point p = new BasePoint2(); - setBasePoint2(p); - return p; - } - - /** - * Creates, sets and returns a {@link Point} based on the - * given values. - * @param x - * @param y - * @param z - * @return new {@link Point} object. - */ - public Point createBasePoint2(double x, double y, double z) { - Point p = new BasePoint2(); - p.setX(x); - p.setY(y); - p.setZ(z); - setBasePoint2(p); - return p; - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Curve.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Curve.java deleted file mode 100644 index d2cc3d8e3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Curve.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * $Id: Curve.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Curve.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractNamedSBase; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * - * - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1116 $ - */ -public class Curve extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5435135643993920570L; - /** - * - */ - ListOf listOfCurveSegments = new ListOf(); - - /** - * @param curve - * - */ - public Curve(Curve curve) { - super(curve); - if (curve.isSetListOfCurveSegments()) { - this.listOfCurveSegments = curve.getListOfCurveSegments().clone(); - } - } - - /** - * - */ - public Curve() { - super(); - addNamespace(LayoutConstant.namespaceURI); - - listOfCurveSegments.addNamespace(LayoutConstant.namespaceURI); - listOfCurveSegments.setSBaseListType(ListOf.Type.other); - registerChild(listOfCurveSegments); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public Curve clone() { - return new Curve(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetListOfCurveSegments()) { - if (pos == index) { - return getListOfCurveSegments(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetListOfCurveSegments()) { - count++; - } - return count; - } - - /** - * - * @return - */ - public ListOf getListOfCurveSegments() { - return listOfCurveSegments; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * - * @return - */ - public boolean isSetListOfCurveSegments() { - return (listOfCurveSegments != null) && (listOfCurveSegments.size() > 0); - } - - /** - * - * @param listOfCurveSegments - */ - public void setListOfCurveSegments(ListOf listOfCurveSegments) { - unsetListOfCurveSegments(); - this.listOfCurveSegments = listOfCurveSegments; - if ((this.listOfCurveSegments != null) && (this.listOfCurveSegments.getSBaseListType() != ListOf.Type.other)) { - this.listOfCurveSegments.setSBaseListType(ListOf.Type.other); - } - registerChild(this.listOfCurveSegments); - } - - /** - * Removes the {@link #listOfLineSegments} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfCurveSegments() { - if (this.listOfCurveSegments != null) { - ListOf oldListOfCurveSegments = this.listOfCurveSegments; - this.listOfCurveSegments = null; - oldListOfCurveSegments.fireNodeRemovedEvent(); - return true; - } - return false; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/CurveSegment.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/CurveSegment.java deleted file mode 100644 index 518d3c78c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/CurveSegment.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * $Id: CurveSegment.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/CurveSegment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * @author Sebastian Fr&oum;hlich - * @since 1.0 - * @version $Rev: 1116 $ - */ -public class CurveSegment extends CubicBezier { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5085246314333062152L; - - /** - * - */ - private String type; - - /** - * - */ - private Logger logger = Logger.getLogger(CurveSegment.class); - - /** - * - */ - public CurveSegment() { - super(); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param lineSegment - */ - public CurveSegment(CurveSegment lineSegment) { - super(lineSegment); - if (lineSegment.isSetStart()) { - this.start = lineSegment.getStart().clone(); - } - if (lineSegment.isSetEnd()) { - this.end = lineSegment.getEnd().clone(); - } - if (lineSegment.isSetType()) { - this.type = lineSegment.getType(); - } - // TODO : basePoint1 and basePoint2 - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public CurveSegment clone() { - return new CurveSegment(this); - } - - - /** - * - * @return - */ - public String getType() { - return type; - } - - /** - * - * @param type - */ - public void setType(String type) { - String oldType = this.type; - this.type = type; - firePropertyChange(TreeNodeChangeEvent.type, oldType, this.type); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * - * @return - */ - public boolean isSetType() { - return type != null; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.AbstractMathContainer#readAttribute(java.lang.String, - * java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - logger.debug("reading CurveSegment: " + prefix + " : " + attributeName); - - if (!isAttributeRead) { - isAttributeRead = true; - if ((prefix.equals("xsi") || prefix.equals("")) - && attributeName.equals("type")) { - setType(value); - return true; - } - } - return isAttributeRead; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - logger.debug("process attributes of CurveSegment"); - logger.debug("isSetType: " + isSetType()); - if (isSetType()) { - attributes.put("xsi:type", getType()); - } - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Dimensions.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Dimensions.java deleted file mode 100644 index eecb598eb..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Dimensions.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * $Id: Dimensions.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Dimensions.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.sbml.jsbml.AbstractNamedSBase; -import org.sbml.jsbml.util.StringTools; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1207 $ - */ -public class Dimensions extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6114634391235520057L; - /** - * - */ - private double depth; - /** - * - */ - private double height; - /** - * - */ - private double width; - - /** - * - */ - public Dimensions() { - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param dimensions - */ - public Dimensions(Dimensions dimensions) { - super(dimensions); - if (dimensions.isSetDepth()) { - this.depth = dimensions.getDepth(); - } - if (dimensions.isSetHeight()) { - this.height = dimensions.getHeight(); - } - if (dimensions.isSetWidth()) { - this.width = dimensions.getWidth(); - } - } - - /** - * - * @param level - * @param version - */ - public Dimensions(int level, int version) { - super(level, version); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param width - * @param height - * @param depth - * @param level - * @param version - */ - public Dimensions(double width, double height, double depth, int level, int version) { - this(level, version); - this.width = width; - this.height = height; - this.depth = depth; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public Dimensions clone() { - return new Dimensions(this); - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Dimensions d = (Dimensions) object; - equals &= d.isSetDepth() == isSetDepth(); - if (equals && isSetDepth()) { - equals &= Double.valueOf(d.getDepth()).equals(Double.valueOf(getDepth())); - } - equals &= d.isSetHeight() == isSetHeight(); - if (equals && isSetHeight()) { - equals &= Double.valueOf(d.getHeight()).equals(Double.valueOf(getHeight())); - } - equals &= d.isSetWidth() == isSetWidth(); - if (equals && isSetWidth()) { - equals &= Double.valueOf(d.getWidth()).equals(Double.valueOf(getWidth())); - } - } - return equals; - } - - /** - * - * @return - */ - public double getDepth() { - return depth; - } - - /** - * - * @return - */ - public double getHeight() { - return height; - } - - /** - * - * @return - */ - public double getWidth() { - return width; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 941; - int hashCode = super.hashCode(); - hashCode += prime * Double.valueOf(depth).hashCode(); - hashCode += prime * Double.valueOf(height).hashCode(); - hashCode += prime * Double.valueOf(width).hashCode(); - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * @return - */ - public boolean isSetDepth() { - return !Double.isNaN(depth); - } - - /** - * @return - */ - public boolean isSetHeight() { - return !Double.isNaN(height); - } - - /** - * @return - */ - public boolean isSetWidth() { - return !Double.isNaN(width); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) - { - - //isAttributeRead = true; - if(attributeName.equals(LayoutConstant.width)) - { - setWidth(StringTools.parseSBMLDouble(value)); - } - else if(attributeName.equals(LayoutConstant.height)) - { - setHeight(StringTools.parseSBMLDouble(value)); - } - else if(attributeName.equals(LayoutConstant.depth)) - { - setDepth(StringTools.parseSBMLDouble(value)); - } - else - { - return false; - } - - return true; - } - - return isAttributeRead; - } - - /** - * - * @param depth - */ - public void setDepth(double depth) { - Double oldDepth = this.depth; - this.depth = depth; - firePropertyChange(LayoutConstant.depth, oldDepth, this.depth); - } - - /** - * - * @param height - */ - public void setHeight(double height) { - Double oldHeight = this.height; - this.height = height; - firePropertyChange(LayoutConstant.height, oldHeight, this.height); - } - - /** - * - * @param width - */ - public void setWidth(double width) { - Double oldWidth = this.width; - this.width = width; - firePropertyChange(LayoutConstant.width, oldWidth, this.width); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId()) { - attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); - } - - if (isSetDepth()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.depth, StringTools.toString(depth)); - } - if (isSetHeight()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.height, StringTools.toString(height)); - } - if (isSetWidth()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.width, StringTools.toString(width)); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/End.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/End.java deleted file mode 100644 index e874b6340..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/End.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * $Id: End.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/End.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * - * @author Sebastian Fröhlich - * @version $Rev: 1116 $ - * @since 1.0 - * @date 21.11.2011 - */ -public class End extends Point { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 984781247140057518L; - - /** - * - */ - public End() { - super(); - } - - /** - * @param end - */ - public End(Point end) { - super(end); - clonePointAttributes(end, this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.Point#clone() - */ - @Override - public End clone() { - return new End(this); - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java deleted file mode 100644 index 6cacfa9ad..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * $Id: ExtendedLayoutModel.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ExtendedLayoutModel.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.AbstractSBasePlugin; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1116 $ - */ -public class ExtendedLayoutModel extends AbstractSBasePlugin { - - // TODO : need to be adapted to the new way of dealing with L3 packages - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6666014348571697514L; - /** - * - */ - protected ListOf listOfLayouts; - - /** - * - */ - private Model model; - - /** - * - */ - public ExtendedLayoutModel(Model model) { - super(model); - - this.model = model; - createListOfLayout(); - } - - /** - * Creates a new list of layout - */ - private void createListOfLayout() { - listOfLayouts = new ListOf(); - listOfLayouts.addNamespace(LayoutConstant.namespaceURI); - listOfLayouts.setSBaseListType(ListOf.Type.other); - model.registerChild(listOfLayouts); - } - - /** - * @param elm - */ - public ExtendedLayoutModel(ExtendedLayoutModel elm) { - // We don't clone the pointer to the containing model. - if (elm.listOfLayouts != null) { - this.listOfLayouts = elm.listOfLayouts.clone(); - } - } - - public ListOf getAllSpeciesGlyphById(String speciesID) { - ListOf speicesGlyphs = new ListOf(model.getLevel(), model.getVersion()); - for (Layout layout : listOfLayouts) { - SpeciesGlyph speciesGlyph = layout.getSpeciesGlyph(speciesID); - if (speciesGlyph != null) { - speicesGlyphs.add(speciesGlyph); - } - } - return speicesGlyphs; - } - - public ListOf getAllReactionGlyphById(String reactionID) { - ListOf reactionGlyphs = new ListOf(model.getLevel(), model.getVersion()); - for (Layout layout : listOfLayouts) { - ReactionGlyph reactionGlyph = layout.getReactionGlyph(reactionID); - if (reactionGlyph != null) { - reactionGlyphs.add(reactionGlyph); - } - } - return reactionGlyphs; - } - - /** - * @param layout - */ - public void add(Layout layout) { - addLayout(layout); - } - - /** - * @param layout - */ - public void addLayout(Layout layout) { - if (layout != null) { - getListOfLayouts().add(layout); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.Model#clone() - */ - @Override - public ExtendedLayoutModel clone() { - return new ExtendedLayoutModel(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.Model#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - // ExtendedLayoutModel elm = (ExtendedLayoutModel) object; - // An equals call on the model would cause a cyclic check! - // Actually, I'm not sure if we should compare the model - // here at all because this would be like checking a pointer - // to the parent node in the SBML tree, which we never do. - // Therefore, there's also no hashCode method here, because - // nothing to check, in my opinion. - // Hence, we can delete this method here. - // equals &= getModel() == elm.getModel(); - } - return equals; - } - - /* - * (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getChildAt(int) - */ - public SBase getChildAt(int index) { - if (isSetListOfLayouts() && (index == getChildCount() - 1)) { - return getListOfLayouts(); - } - return null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#getChildCount() - */ - public int getChildCount() { - int count = 0; - if (isSetListOfLayouts()) { - count++; - } - return count; - } - - /** - * @param i - * @return - */ - public Layout getLayout(int i) { - return listOfLayouts.get(i); - } - - /** - * @return - */ - public ListOf getListOfLayouts() { - if (listOfLayouts == null) { - createListOfLayout(); - } - return listOfLayouts; - } - - public Model getParent() { - return model; - } - - public Model getParentSBMLObject() { - return model; - } - - /** - * @return - */ - public boolean isSetListOfLayouts() { - return ((listOfLayouts == null) || listOfLayouts.isEmpty()) ? false - : true; - } - - public boolean readAttribute(String attributeName, String prefix, - String value) { - return false; - } - - /** - * @param listOfLayouts - */ - public void setListOfLayouts(ListOf listOfLayouts) { - unsetListOfLayouts(); - if (listOfLayouts == null) { - this.listOfLayouts = new ListOf(); - } else { - this.listOfLayouts = listOfLayouts; - } - if ((this.listOfLayouts != null) && (this.listOfLayouts.getSBaseListType() != ListOf.Type.other)) { - this.listOfLayouts.setSBaseListType(ListOf.Type.other); - } - model.registerChild(listOfLayouts); - } - - /** - * @param layoutId - * @return - */ - public Layout getLayout(String layoutID) { - if (isSetListOfLayouts()) { - for (Layout layout : listOfLayouts) { - if (layout.getId().equals(layout)) { - return layout; - } - } - } - return null; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - // TODO Auto-generated method stub - return null; - } - - /** - * Removes the {@link #listOfLayouts} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfLayouts() { - if (this.listOfLayouts != null) { - ListOf oldListOfLayouts = this.listOfLayouts; - this.listOfLayouts = null; - oldListOfLayouts.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ext.SBasePlugin#writeXMLAttributes() - */ - public Map writeXMLAttributes() { - return null; - } - - /** - * @return - */ - public Model getModel() { - return (Model) extendedSBase; - } - - /** - * Creates a new layout and adds it to the current list of layouts. - * - * @return new layout. - */ - public Layout createLayout() { - Layout layout = new Layout(model.getLevel(), model.getVersion()); - addLayout(layout); - return layout; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/GraphicalObject.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/GraphicalObject.java deleted file mode 100644 index 6e8f0caf8..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/GraphicalObject.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * $Id: GraphicalObject.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/GraphicalObject.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractNamedSBase; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class GraphicalObject extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 7587814013754302901L; - - private String layoutId; - /** - * - */ - private BoundingBox boundingBox; - - /** - * - */ - public GraphicalObject() { - super(); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * @param graphicalObject - */ - public GraphicalObject(GraphicalObject graphicalObject) { - super(graphicalObject); - setBoundingBox(graphicalObject.getBoundingBox()); - } - - /** - * @param id - */ - public GraphicalObject(String id) { - super(id); - addNamespace(LayoutConstant.namespaceURI); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public GraphicalObject clone() { - return new GraphicalObject(this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getAllowsChildren() - */ - @Override - public boolean getAllowsChildren() { - return true; - } - - /** - * @return - */ - public BoundingBox getBoundingBox() { - return boundingBox; - } - - public String getLayoutId() { - return layoutId; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetBoundingBox()) { - if (pos == index) { - return getBoundingBox(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetBoundingBox()) { - count++; - } - return count; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - // See Layout Extension (April 25, 2005) page 9, SId use="required" - return true; - } - - /** - * @return - */ - public boolean isSetBoundingBox() { - return boundingBox != null; - } - - /** - * @param boundingBox - */ - public void setBoundingBox(BoundingBox boundingBox) { - unsetBoundingBox(); - this.boundingBox = boundingBox; - registerChild(this.boundingBox); - } - - /** - * - */ - public void unsetBoundingBox() { - if (isSetBoundingBox()) { - BoundingBox oldValue = this.boundingBox; - this.boundingBox = null; - oldValue.fireNodeRemovedEvent(); - } - } - - public boolean isSetLayoutId() { - return layoutId != null && layoutId.length() > 0; - } - - public void setLayoutId(String layoutId) { - this.layoutId = layoutId; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId()) { - attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); - } - - return attributes; - } - - /** - * Creates and sets a {@link BoundingBox} for this object. - * - * @return {@link BoundingBox}. - */ - public BoundingBox createBoundingBox() { - BoundingBox bb = new BoundingBox(); - setBoundingBox(bb); - return bb; - } - - public BoundingBox createBoundingBox(Dimensions dimensions) { - BoundingBox bb = createBoundingBox(); - bb.setDimensions(dimensions); - return bb; - } - - /** - * Creates and sets a {@link BoundingBox} for this object, with the - * given parameters for {@link Dimensions}. - * - * @param width - * @param height - * @param depth - * @return {@link BoundingBox}. - */ - public BoundingBox createBoundingBox(double width, double height, double depth) { - BoundingBox bb = createBoundingBox(); - bb.createDimensions(width, height, depth); - return bb; - } - - /** - * Creates and sets a {@link BoundingBox} for this object, with the - * given parameters for {@link Dimensions} and {@link Point}. - * - * @param width - * @param height - * @param depth - * @param x - * @param y - * @param z - * @return {@link BoundingBox}. - */ - public BoundingBox createBoundingBox(double width, double height, double depth, - double x, double y, double z) { - BoundingBox bb = createBoundingBox(width, height, depth); - bb.createPosition(x, y, z); - return bb; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Layout.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Layout.java deleted file mode 100644 index 4ac918cd1..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Layout.java +++ /dev/null @@ -1,767 +0,0 @@ -/* - * $Id: Layout.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Layout.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractNamedSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.util.TreeNodeChangeListener; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1241 $ - */ -public class Layout extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 8866612784809904674L; - - /** - * - */ - private ListOf listOfAdditionalGraphicalObjects = new ListOf(); - /** - * - */ - private Dimensions dimensions; - /** - * - */ - private ListOf listOfCompartmentGlyphs = new ListOf(); - /** - * - */ - private ListOf listOfReactionGlyphs = new ListOf(); - /** - * - */ - private ListOf listOfSpeciesGlyphs = new ListOf(); - /** - * - */ - private ListOf listOfTextGlyphs = new ListOf(); - - /** - * - */ - public Layout() { - super(); - initDefault(); - } - - /** - * @param level - * @param version - */ - public Layout(int level, int version) { - super(level, version); - initDefault(); - } - - private void initDefault() { - addNamespace(LayoutConstant.namespaceURI); - - listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); - - listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpeciesGlyphs); - - listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfReactionGlyphs); - - listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfTextGlyphs); - - listOfAdditionalGraphicalObjects.addNamespace(LayoutConstant.namespaceURI); - listOfAdditionalGraphicalObjects.setSBaseListType(ListOf.Type.other); - registerChild(listOfAdditionalGraphicalObjects); - - } - - /** - * @param layout - */ - public Layout(Layout layout) { - super(layout); - - if (layout.listOfAdditionalGraphicalObjects != null) { - listOfAdditionalGraphicalObjects = layout.listOfAdditionalGraphicalObjects.clone(); - } - if (layout.dimensions != null) { - dimensions = layout.dimensions.clone(); - } - if (layout.listOfCompartmentGlyphs != null) { - listOfCompartmentGlyphs = layout.listOfCompartmentGlyphs.clone(); - } - if (layout.listOfReactionGlyphs != null) { - listOfReactionGlyphs = layout.listOfReactionGlyphs.clone(); - } - if (layout.listOfSpeciesGlyphs != null) { - listOfSpeciesGlyphs = layout.listOfSpeciesGlyphs.clone(); - } - if (layout.listOfTextGlyphs != null) { - listOfTextGlyphs = layout.listOfTextGlyphs.clone(); - } - - } - - /** - * @param speciesGlyph - */ - public void add(SpeciesGlyph speciesGlyph) { - addSpeciesGlyph(speciesGlyph); - } - - /** - * @param reactionGlyph - */ - public void add(ReactionGlyph reactionGlyph) { - addReactionGlyph(reactionGlyph); - } - - /** - * @param speciesGlyph - */ - public void addSpeciesGlyph(SpeciesGlyph speciesGlyph) { - if (speciesGlyph != null) { - registerChild(speciesGlyph); - listOfSpeciesGlyphs.add(speciesGlyph); - } - } - - /** - * Add an arbitrary additional graphical object. - * - * @param object - */ - public void addAdditionalGraphical(GraphicalObject object) { - if (object != null) { - registerChild(object); - listOfAdditionalGraphicalObjects.add(object); - } - } - - /** - * @param reactionGlyph - */ - public void addReactionGlyph(ReactionGlyph reactionGlyph) { - if (reactionGlyph != null) { - registerChild(reactionGlyph); - listOfReactionGlyphs.add(reactionGlyph); - } - } - - /** - * @param compartmentGlyph - */ - public void addCompartmentGlyph(CompartmentGlyph compartmentGlyph) { - if (compartmentGlyph != null) { - registerChild(compartmentGlyph); - listOfCompartmentGlyphs.add(compartmentGlyph); - } - } - - /** - * @param TextGlyph - */ - public void addTextGlyph(TextGlyph TextGlyph) { - if (TextGlyph != null) { - registerChild(TextGlyph); - listOfTextGlyphs.add(TextGlyph); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public Layout clone() { - return new Layout(this); - } - - /** - * @return - */ - public ListOf getListOfAdditionalGraphicalObjects() { - return listOfAdditionalGraphicalObjects; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetDimensions()) { - if (index == pos) { - return getDimensions(); - } - pos++; - } - if (isSetListOfCompartmentGlyphs()) { - if (index == pos) { - return getListOfCompartmentGlyphs(); - } - pos++; - } - if (isSetListOfSpeciesGlyphs()) { - if (index == pos) { - return getListOfSpeciesGlyphs(); - } - pos++; - } - if (isSetListOfReactionGlyphs()) { - if (index == pos) { - return getListOfReactionGlyphs(); - } - pos++; - } - if (isSetListOfTextGlyphs()) { - if (index == pos) { - return getListOfTextGlyphs(); - } - pos++; - } - if (isSetAddGraphicalObjects()) { - if (index == pos) { - return getListOfAdditionalGraphicalObjects(); - } - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetDimensions()) { - count++; - } - if (isSetListOfCompartmentGlyphs()) { - count++; - } - if (isSetListOfSpeciesGlyphs()) { - count++; - } - if (isSetListOfReactionGlyphs()) { - count++; - } - if (isSetListOfTextGlyphs()) { - count++; - } - if (isSetAddGraphicalObjects()) { - count++; - } - return count; - } - - /** - * @param i - * @return - */ - public CompartmentGlyph getCompartmentGlyph(int i) { - if (i >= 0 && i < listOfCompartmentGlyphs.size()) { - return listOfCompartmentGlyphs.get(i); - } - - return null; - } - - /** - * @return - */ - public Dimensions getDimensions() { - return dimensions; - } - - /** - * @return - */ - public ListOf getListOfCompartmentGlyphs() { - if (!isSetListOfCompartmentGlyphs()) { - listOfCompartmentGlyphs = new ListOf(getLevel(), getVersion()); - listOfCompartmentGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); - } - return listOfCompartmentGlyphs; - } - - /** - * @return - */ - public ListOf getListOfReactionGlyphs() { - if (!isSetListOfReactionGlyphs()) { - listOfReactionGlyphs = new ListOf(getLevel(), getVersion()); - listOfReactionGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfCompartmentGlyphs); - } - return listOfReactionGlyphs; - } - - /** - * @return - */ - public ListOf getListOfSpeciesGlyphs() { - if (!isSetListOfSpeciesGlyphs()) { - listOfSpeciesGlyphs = new ListOf(getLevel(), getVersion()); - listOfSpeciesGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpeciesGlyphs); - } - return listOfSpeciesGlyphs; - } - - /** - * @return - */ - public ListOf getListOfTextGlyphs() { - if (!isSetListOfTextGlyphs()) { - listOfTextGlyphs = new ListOf(getLevel(), getVersion()); - listOfTextGlyphs.addNamespace(LayoutConstant.namespaceURI); - listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(listOfTextGlyphs); - } - return listOfTextGlyphs; - } - - /** - * @param i - * @return - */ - public GraphicalObject getAdditionalGraphicalObject(int i) { - if (isSetListOfAdditionalGraphicalObjects() && i >= 0 && i < listOfAdditionalGraphicalObjects.size()) { - return listOfAdditionalGraphicalObjects.get(i); - } - - return null; - } - - /** - * @param i - * @return - */ - public SpeciesGlyph getSpeciesGlyph(int i) { - if (isSetListOfSpeciesGlyphs() && i >= 0 && i < listOfSpeciesGlyphs.size()) { - return listOfSpeciesGlyphs.get(i); - } - - return null; - } - - /** - * @param speciesID - * @return - */ - public SpeciesGlyph getSpeciesGlyph(String speciesID) { - if (isSetListOfSpeciesGlyphs()) { - for (SpeciesGlyph g : listOfSpeciesGlyphs) { - if (g.getSpecies().equals(speciesID)) { - return g; - } - } - } - - return null; - } - - /** - * @param i - * @return - */ - public ReactionGlyph getReactionGlyph(int i) { - if (!isSetListOfReactionGlyphs() || i < 0 || i >= listOfReactionGlyphs.size()) { - return null; - } - - return listOfReactionGlyphs.get(i); - } - - /** - * @param reactionID - * @return - */ - public ReactionGlyph getReactionGlyph(String reactionID) { - if (isSetListOfReactionGlyphs()) { - for (ReactionGlyph g : listOfReactionGlyphs) { - if (g.getReaction().equals(reactionID)) { - return g; - } - } - } - - return null; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - // TODO Is it? - return false; - } - - /** - * @return - */ - public boolean isSetAddGraphicalObjects() { - return (listOfAdditionalGraphicalObjects != null) && (listOfAdditionalGraphicalObjects.size() > 0); - } - - /** - * @return - */ - public boolean isSetDimensions() { - return dimensions != null; - } - - /** - * @return - */ - public boolean isSetListOfCompartmentGlyphs() { - return (listOfCompartmentGlyphs != null) && (listOfCompartmentGlyphs.size() > 0); - } - - /** - * @return - */ - public boolean isSetListOfReactionGlyphs() { - return (listOfReactionGlyphs != null) && (listOfReactionGlyphs.size() > 0); - } - - /** - * @return - */ - public boolean isSetListOfSpeciesGlyphs() { - return (listOfSpeciesGlyphs != null) && (listOfSpeciesGlyphs.size() > 0); - } - - /** - * @return - */ - public boolean isSetListOfAdditionalGraphicalObjects() { - return (listOfAdditionalGraphicalObjects != null) && (listOfAdditionalGraphicalObjects.size() > 0); - } - - /** - * @return - */ - public boolean isSetListOfTextGlyphs() { - return (listOfTextGlyphs != null) && (listOfTextGlyphs.size() > 0); - } - - /** - * @param attributeName - * @param prefix - * @param value - * @return - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - return isAttributeRead; - } - - /** - * @param listOfAdditionalGraphicalObjects - */ - public void setAddGraphicalObjects(ListOf addGraphicalObjects) { - if (this.listOfAdditionalGraphicalObjects != null) { - this.listOfAdditionalGraphicalObjects.fireNodeRemovedEvent(); - } - this.listOfAdditionalGraphicalObjects = addGraphicalObjects; - registerChild(this.listOfAdditionalGraphicalObjects); - } - - /** - * @param dimensions - */ - public void setDimensions(Dimensions dimensions) { - if (this.dimensions != null) { - this.dimensions.fireNodeRemovedEvent(); - } - this.dimensions = dimensions; - registerChild(this.dimensions); - } - - /** - * @param compartmentGlyphs - */ - public void setListOfCompartmentGlyphs(ListOf compartmentGlyphs) { - unsetListOfCompartmentGlyphs(); - this.listOfCompartmentGlyphs = compartmentGlyphs; - if ((this.listOfCompartmentGlyphs != null) && (this.listOfCompartmentGlyphs.getSBaseListType() != ListOf.Type.other)) { - this.listOfCompartmentGlyphs.setSBaseListType(ListOf.Type.other); - } - registerChild(this.listOfCompartmentGlyphs); - } - - /** - * @param reactionGlyphs - */ - public void setListOfReactionGlyphs(ListOf reactionGlyphs) { - unsetListOfReactionGlyphs(); - this.listOfReactionGlyphs = reactionGlyphs; - if (this.listOfReactionGlyphs != null) { - this.listOfReactionGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(this.listOfReactionGlyphs); - } - } - - /** - * @param speciesGlyphs - */ - public void setListOfSpeciesGlyphs(ListOf speciesGlyphs) { - unsetListOfSpeciesGlyphs(); - if (speciesGlyphs == null) { - this.listOfSpeciesGlyphs = new ListOf(); - } else { - this.listOfSpeciesGlyphs = speciesGlyphs; - } - if (this.listOfSpeciesGlyphs != null) { - this.listOfSpeciesGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(this.listOfSpeciesGlyphs); - } - } - - /** - * @param textGlyphs - */ - public void setListOfTextGlyphs(ListOf textGlyphs) { - unsetListOfTextGlyphs(); - this.listOfTextGlyphs = textGlyphs; - if (this.listOfTextGlyphs != null) { - this.listOfTextGlyphs.setSBaseListType(ListOf.Type.other); - registerChild(this.listOfTextGlyphs); - } - } - - /** - * @param AdditionalGraphicalObjects - */ - public void setListOfAdditionalGraphicalObjects(ListOf additionalGraphicalObjects) { - unsetListOfAdditionalGraphicalObjects(); - this.listOfAdditionalGraphicalObjects = additionalGraphicalObjects; - if (this.listOfAdditionalGraphicalObjects != null) { - this.listOfAdditionalGraphicalObjects.setSBaseListType(ListOf.Type.other); - registerChild(this.listOfAdditionalGraphicalObjects); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#toString() - */ - @Override - public String toString() { - return getElementName(); - } - - /** - * Removes the {@link #listOfCompartmentGlyphs} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfCompartmentGlyphs() { - if (this.listOfCompartmentGlyphs != null) { - ListOf oldListOfCompartmentGlyphs = this.listOfCompartmentGlyphs; - this.listOfCompartmentGlyphs = null; - oldListOfCompartmentGlyphs.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfReactionGlyphs} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfReactionGlyphs() { - if (this.listOfReactionGlyphs != null) { - ListOf oldListOfReactionGlyphs = this.listOfReactionGlyphs; - this.listOfReactionGlyphs = null; - oldListOfReactionGlyphs.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfSpeciesGlyphs} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfSpeciesGlyphs() { - if (this.listOfSpeciesGlyphs != null) { - ListOf oldListOfSpeciesGlyphs = this.listOfSpeciesGlyphs; - this.listOfSpeciesGlyphs = null; - oldListOfSpeciesGlyphs.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfTextGlyphs} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfTextGlyphs() { - if (this.listOfTextGlyphs != null) { - ListOf oldListOfTextGlyphs = this.listOfTextGlyphs; - this.listOfTextGlyphs = null; - oldListOfTextGlyphs.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Removes the {@link #listOfAdditionalGraphicalObjects} from this {@link Model} and notifies - * all registered instances of {@link TreeNodeChangeListener}. - * - * @return true if calling this method lead to a change in this - * data structure. - */ - public boolean unsetListOfAdditionalGraphicalObjects() { - if (this.listOfAdditionalGraphicalObjects != null) { - ListOf oldListOfAdditionalGraphicalObjects = this.listOfAdditionalGraphicalObjects; - this.listOfAdditionalGraphicalObjects = null; - oldListOfAdditionalGraphicalObjects.fireNodeRemovedEvent(); - return true; - } - return false; - } - - /** - * Creates and adds a new {@link SpeciesGlyph}. - * - * @param species {@link Species} ID. - * @return new {@link SpeciesGlyph}. - */ - public SpeciesGlyph createSpeciesGlyph(String species) { - SpeciesGlyph glyph = new SpeciesGlyph(); - glyph.setSpecies(species); - glyph.setLayoutId(getId()); - addSpeciesGlyph(glyph); - return glyph; - } - - /** - * Creates and adds a new {@link ReactionGlyph}. - * - * @param reaction {@link Reaction} ID. - * @return new {@link ReactionGlyph}. - */ - public ReactionGlyph createReactionGlyph(String reaction) { - ReactionGlyph glyph = new ReactionGlyph(); - glyph.setReaction(reaction); - glyph.setLayoutId(getId()); - addReactionGlyph(glyph); - return glyph; - } - - /** - * Creates and adds a new {@link CompartmentGlyph}. - * - * @param compartment {@link Compartment} ID. - * @return new {@link CompartmentGlyph}. - */ - public CompartmentGlyph createCompartmentGlyph(String compartment) { - CompartmentGlyph glyph = new CompartmentGlyph(); - glyph.setCompartment(compartment); - addCompartmentGlyph(glyph); - return glyph; - } - - /** - * Creates and adds a new {@link TextGlyph}. - * - * @param text the text for the new glyph - * @return new {@link TextGlyph}. - */ - public TextGlyph createTextGlyph(String text) { - TextGlyph glyph = new TextGlyph(); - glyph.setText(text); - addTextGlyph(glyph); - return glyph; - } - - /** - * Creates, sets and returns {@link Dimensions} based on the - * given values. - * - * @param width - * @param height - * @param depth - * @return new {@link Dimensions} object. - */ - public Dimensions createDimensions(double width, double height, double depth) { - Dimensions d = new Dimensions(); - d.setWidth(width); - d.setHeight(height); - d.setDepth(depth); - setDimensions(d); - return d; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/LayoutConstant.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/LayoutConstant.java deleted file mode 100644 index 4bfdce7a6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/LayoutConstant.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * $Id: LayoutConstant.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LayoutConstant.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -public class LayoutConstant { - - /** - * The namespace URI of this parser. - */ - public static final String namespaceURI = "http://www.sbml.org/sbml/level3/version1/layout/version1"; - public static final String namespaceURI_L2 = "http://projects.eml.org/bcb/sbml/level2"; - - public static final String shortLabel = "layout"; - - public static final String listOfLayouts = "listOfLayouts"; - public static final String listOfCompartmentGlyphs = "listOfCompartmentGlyphs"; - public static final String listOfSpeciesGlyphs = "listOfSpeciesGlyphs"; - public static final String listOfReactionGlyphs = "listOfReactionGlyphs"; - public static final String listOfTextGlyphs = "listOfTextGlyphs"; - public static final String listOfAdditionalGraphicalObjects = "listOfAdditionalGraphicalObjects"; - public static final String listOfCurveSegments = "listOfCurveSegments"; - public static final String listOfSpeciesReferenceGlyphs = "listOfSpeciesReferenceGlyphs"; - - public static final String layout = "layout"; - public static final String compartmentGlyph = "compartmentGlyph"; - public static final String speciesGlyph = "speciesGlyph"; - public static final String reactionGlyph = "reactionGlyph"; - public static final String textGlyph = "textGlyph"; - public static final String speciesReferenceGlyph = "speciesReferenceGlyph"; - public static final String boundingBox = "boundingBox"; - public static final String position = "position"; - public static final String dimensions = "dimensions"; - public static final String start = "start"; - public static final String end = "end"; - public static final String curve = "curve"; - public static final String curveSegment = "curveSegment"; - - // Attribute names of the Point XML type - public static final String x = "x"; - public static final String y = "y"; - public static final String z = "z"; - - // Attribute names of the Dimensions XML type - public static final String depth = "depth"; - public static final String width = "width"; - public static final String height = "height"; - - // Attribute names of the CompartmentGlyph XML type - public static final String compartment = "compartment"; - - // Attribute names of the speciesGlyph XML type - public static final String species = "species"; - - // Attribute names of the textGlyph XML type - public static final String graphicalObject = "graphicalObject"; - public static final String text = "text"; - public static final String originOfText = "originOfText"; - - // Attribute names of the speciesReferenceGlyph XML type - public static final String speciesReference = "speciesReference"; - public static final String role = "role"; - - - public static final String basePoint1 = "basePoint1"; - public static final String basePoint2 = "basePoint2"; - public static final String reaction = "reaction"; - - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/LineSegment.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/LineSegment.java deleted file mode 100644 index ae9e3aa98..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/LineSegment.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * $Id: LineSegment.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/LineSegment.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractNamedSBase; - -/** - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class LineSegment extends AbstractNamedSBase { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5085246314333062152L; - - /** - * - */ - Point end; - - /** - * - */ - Point start; - - /** - * - */ - public LineSegment() { - - } - - /** - * - * @param level - * @param version - */ - public LineSegment(int level, int version) { - super(level, version); - } - - /** - * - * @param lineSegment - */ - public LineSegment(LineSegment lineSegment) { - super(lineSegment); - if (lineSegment.isSetStart()) { - this.start = lineSegment.getStart().clone(); - } - if (lineSegment.isSetEnd()) { - this.end = lineSegment.getEnd().clone(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - public LineSegment clone() { - return new LineSegment(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetStart()) { - if (pos == index) { - return getStart(); - } - pos++; - } - if (isSetEnd()) { - if (pos == index) { - return getEnd(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetStart()) { - count++; - } - if (isSetEnd()) { - count++; - } - return count; - } - - /** - * - * @return - */ - public Point getEnd() { - return end; - } - - /** - * - * @return - */ - public Point getStart() { - return start; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * @return - */ - public boolean isSetEnd() { - return end != null; - } - - /** - * @return - */ - public boolean isSetStart() { - return start != null; - } - - /** - * - * @param end - */ - public void setEnd(Point end) { - if(this.end != null){ - this.end.fireNodeRemovedEvent(); - } - if (!(end instanceof End)) { - end = new End(end); - } - this.end = end; - registerChild(this.end); - } - - /** - * - * @param start - */ - public void setStart(Point start) { - if(this.start != null){ - this.start.fireNodeRemovedEvent(); - } - if (!(start instanceof Start)) { - start = new Start(start); - } - this.start = start; - registerChild(this.start); - } - - /** - * Creates, sets and returns a {@link Point} - * - * @return new {@link Point} object. - */ - public Point createStart() { - Point p = new Start(); - setStart(p); - return p; - } - - /** - * Creates, sets and returns a {@link Point} based on the - * given values. - * @param x - * @param y - * @param z - * @return new {@link Point} object. - */ - public Point createStart(double x, double y, double z) { - Point p = new Start(); - p.setX(x); - p.setY(y); - p.setZ(z); - setStart(p); - return p; - } - - - /** - * Creates, sets and returns a {@link Point} - * - * @return new {@link Point} object. - */ - public Point createEnd() { - Point p = new End(); - setStart(p); - return p; - - } - - /** - * Creates, sets and returns a {@link Point} based on the - * given values. - * @param x - * @param y - * @param z - * @return new {@link Point} object. - */ - public Point createEnd(double x, double y, double z) { - Point p = new End(); - p.setX(x); - p.setY(y); - p.setZ(z); - setEnd(p); - return p; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Point.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Point.java deleted file mode 100644 index b1a5b97cf..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Point.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * $Id: Point.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Point.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.sbml.jsbml.AbstractNamedSBase; -import org.sbml.jsbml.util.StringTools; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1207 $ - */ -public class Point extends AbstractNamedSBase { - - /** - * - */ - private static final long serialVersionUID = -7464572763198848890L; - /** - * - */ - private double x; - /** - * - */ - private double y; - /** - * - */ - private double z; - - /** - * - */ - public Point() { - super(); - addNamespace(LayoutConstant.namespaceURI); - x = y = z = Double.NaN; - } - - /** - * - * @param x - * @param y - * @param z - */ - public Point(double x, double y, double z) { - this(); - this.x = x; - this.y = y; - this.z = z; - } - - /** - * - * @param x - * @param y - * @param z - * @param level - * @param version - */ - public Point(double x, double y, double z, int level, int version) { - this(level, version); - this.x = x; - this.y = y; - this.z = z; - } - - /** - * - * @param level - * @param version - */ - public Point(int level, int version) { - super(level, version); - addNamespace(LayoutConstant.namespaceURI); - x = y = z = Double.NaN; - } - - /** - * - * @param point - */ - public Point(Point point) { - super(point); - clonePointAttributes(point, this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - public Point clone() { - return new Point(this); - } - - /** - * - * @param point - * @param cloned - */ - protected void clonePointAttributes(Point point, Point cloned) { - if (point.isSetX()) { - cloned.setX(point.getX()); - } - if (point.isSetY()) { - cloned.setY(point.getY()); - } - if (point.isSetZ()) { - cloned.setZ(point.getZ()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - Point p = (Point) object; - equals &= p.isSetX() == isSetX(); - if (equals && isSetX()) { - equals &= Double.valueOf(p.getX()).equals(Double.valueOf(getX())); - } - equals &= p.isSetY() == isSetY(); - if (equals && isSetY()) { - equals &= Double.valueOf(p.getY()).equals(Double.valueOf(getY())); - } - equals &= p.isSetZ() == isSetZ(); - if (equals && isSetZ()) { - equals &= Double.valueOf(p.getZ()).equals(Double.valueOf(getZ())); - } - } - return equals; - } - - /** - * - * @return - */ - public double getX() { - return x; - } - - /** - * - * @return - */ - public double getY() { - return y; - } - - /** - * - * @return - */ - public double getZ() { - return z; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 947; - int hashCode = super.hashCode(); - hashCode += prime * Double.valueOf(x).hashCode(); - hashCode += prime * Double.valueOf(y).hashCode(); - hashCode += prime * Double.valueOf(z).hashCode(); - return hashCode; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.NamedSBase#isIdMandatory() - */ - public boolean isIdMandatory() { - return false; - } - - /** - * @return - */ - public boolean isSetX() { - return !Double.isNaN(x); - } - - /** - * @return - */ - public boolean isSetY() { - return !Double.isNaN(y); - } - - /** - * @return - */ - public boolean isSetZ() { - return !Double.isNaN(z); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if (!isAttributeRead) { - - isAttributeRead = true; - - if (attributeName.equals(LayoutConstant.x)) { - setX(StringTools.parseSBMLDouble(value)); - } - else if(attributeName.equals(LayoutConstant.y)) - { - setY(StringTools.parseSBMLDouble(value)); - } - else if(attributeName.equals(LayoutConstant.z)) - { - setZ(StringTools.parseSBMLDouble(value)); - } - else { - return false; - } - } - - return isAttributeRead; - } - - /** - * - * @param x - */ - public void setX(double x) { - Double oldX = this.x; - this.x = x; - firePropertyChange(LayoutConstant.x, oldX, this.x); - } - - /** - * - * @param y - */ - public void setY(double y) { - Double oldY = this.y; - this.y = y; - firePropertyChange(LayoutConstant.y, oldY, this.y); - } - - /** - * - * @param z - */ - public void setZ(double z) { - Double oldZ = this.z; - this.z = z; - firePropertyChange(LayoutConstant.z, oldZ, this.z); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#toString() - */ - @Override - public String toString() { - return "Point [" + x + ", " + y + ", " + z + "]"; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId()) { - attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); - } - - if (isSetX()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.x, StringTools.toString(x)); - } - if (isSetY()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.y, StringTools.toString(y)); - } - if (isSetZ()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.z, StringTools.toString(z)); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Position.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Position.java deleted file mode 100644 index 8691c6be3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Position.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id: Position.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Position.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * - * @author Sebastian Fröhlich - * @version $Rev: 1116 $ - * @since 1.0 - * @date 21.11.2011 - */ -public class Position extends Point { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 2969810879942863084L; - - public Position() { - super(); - } - - public Position(Point point) { - super(point); - clonePointAttributes(point, this); - } - -@Override - public Position clone() { - return new Position(this); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java deleted file mode 100644 index 185762c4c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * $Id: ReactionGlyph.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/ReactionGlyph.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.ListOf; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class ReactionGlyph extends GraphicalObject { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 8770691813350594995L; - - /** - * - */ - private Curve curve; - - /** - * - */ - private ListOf listOfSpeciesReferencesGlyph = new ListOf(); - - /** - * - */ - private String reaction; - - /** - * - */ - public ReactionGlyph() { - super(); - addNamespace(LayoutConstant.namespaceURI); - - listOfSpeciesReferencesGlyph.addNamespace(LayoutConstant.namespaceURI); - listOfSpeciesReferencesGlyph.setSBaseListType(ListOf.Type.other); - registerChild(listOfSpeciesReferencesGlyph); - } - - /** - * - * @param reactionGlyph - */ - public ReactionGlyph(ReactionGlyph reactionGlyph) { - super(reactionGlyph); - if (reactionGlyph.isSetCurve()) { - this.curve = reactionGlyph.getCurve().clone(); - } - if (reactionGlyph.isSetListOfSpeciesReferencesGlyph()) { - this.listOfSpeciesReferencesGlyph = reactionGlyph - .getListOfSpeciesReferenceGlyphs().clone(); - } - if (reactionGlyph.isSetReaction()) { - this.reaction = new String(reactionGlyph.getReaction()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#clone() - */ - @Override - public ReactionGlyph clone() { - return new ReactionGlyph(this); - } - - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - ReactionGlyph r = (ReactionGlyph) object; - equals &= r.isSetId() == isSetId(); - if (equals && isSetId()) { - equals &= r.getId().equals(getId()); - } - // This can lead to a cyclic check! - // equals &= r.isSetReaction() == isSetReaction(); - // if (equals && isSetReaction()) { - // equals &= r.getReaction().equals(getReaction()); - // } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetCurve()) { - if (pos == index) { - return getCurve(); - } - pos++; - } - if (isSetListOfSpeciesReferencesGlyph()) { - if (pos == index) { - return getListOfSpeciesReferenceGlyphs(); - } - pos++; - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetCurve()) { - count++; - } - if (isSetListOfSpeciesReferencesGlyph()) { - count++; - } - return count; - } - - /** - * - * @return - */ - public Curve getCurve() { - return curve; - } - - /** - * - * @return - */ - public ListOf getListOfSpeciesReferenceGlyphs() { - return listOfSpeciesReferencesGlyph; - } - - /** - * - * @return - */ - public String getReaction() { - return reaction; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 971; - int hashCode = super.hashCode(); - if (isSetId()) { - hashCode += prime * getId().hashCode(); - } - return hashCode; - } - - /** - * @return - */ - public boolean isSetCurve() { - return curve != null; - } - - /** - * @return - */ - public boolean isSetListOfSpeciesReferencesGlyph() { - return listOfSpeciesReferencesGlyph != null; - } - - /** - * @return - */ - public boolean isSetReaction() { - return reaction != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) { - - isAttributeRead = true; - if(attributeName.equals("reaction")) - { - this.reaction = value; - } - else { - return false; - } - } - - return isAttributeRead; - } - - /** - * - * @param curve - */ - public void setCurve(Curve curve) { - if(this.curve != null){ - Curve oldValue = this.curve; - this.curve = null; - oldValue.fireNodeRemovedEvent(); - } - this.curve = curve; - registerChild(this.curve); - } - - /** - * - * @param listOfSpeciesReferencesGlyph - */ - public void setListOfSpeciesReferencesGlyph( - ListOf listOfSpeciesReferencesGlyph) { - unsetListOfSpeciesReferencesGlyph(); - this.listOfSpeciesReferencesGlyph = listOfSpeciesReferencesGlyph; - registerChild(this.listOfSpeciesReferencesGlyph); - } - - /** - * - * @param reaction - */ - public void setReaction(String reaction) { - String oldReaction = this.reaction; - this.reaction = reaction; - firePropertyChange(LayoutConstant.reaction, oldReaction, this.reaction); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#toString() - */ - @Override - public String toString() { - return super.toString(); - } - - /** - * - */ - private void unsetListOfSpeciesReferencesGlyph() { - if(this.listOfSpeciesReferencesGlyph != null){ - ListOf oldValue = this.listOfSpeciesReferencesGlyph; - this.listOfSpeciesReferencesGlyph = null; - oldValue.fireNodeRemovedEvent(); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetReaction()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.reaction, reaction); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java deleted file mode 100644 index ddf85d112..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * $Id: SpeciesGlyph.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesGlyph.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @author Clemens Wrzodek - * @since 1.0 - * @version $Rev: 1241 $ - */ -public class SpeciesGlyph extends GraphicalObject { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 1077785483575936434L; - - /** - * Reference to species id, described by this {@link SpeciesGlyph}. - */ - private String speciesId; - - /** - * - */ - public SpeciesGlyph() { - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param speciesGlyph - */ - public SpeciesGlyph(SpeciesGlyph speciesGlyph) { - super(speciesGlyph); - - if (speciesGlyph.isSetSpecies()) { - this.speciesId = new String(speciesGlyph.getSpecies()); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#clone() - */ - @Override - public SpeciesGlyph clone() { - return new SpeciesGlyph(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - SpeciesGlyph s = (SpeciesGlyph) object; - - equals &= s.isSetSpecies() == isSetSpecies(); - if (equals && isSetSpecies()) { - equals &= s.getSpecies().equals(getSpecies()); - } - } - return equals; - } - - - /** - * - * @return - */ - public String getSpecies() { - return speciesId; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 977; - int hashCode = super.hashCode(); - if (isSetSpecies()) { - hashCode += prime * getSpecies().hashCode(); - } - return hashCode; - } - - /** - * @return the {@link #speciesId} - */ - public boolean isSetSpecies() { - return speciesId != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) - { - if (attributeName.equals("species")) { - setSpecies(value); - } - else - { - return false; - } - } - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetId()) { - attributes.remove("id"); - attributes.put(LayoutConstant.shortLabel + ":id", getId()); - } - if (isSetSpecies()) { - attributes.put(LayoutConstant.shortLabel + ":species", getSpecies()); - } - - return attributes; - } - - /** - * - * @param species - */ - public void setSpecies(String species) { - String oldSpecies = this.speciesId; - this.speciesId = species; - firePropertyChange(TreeNodeChangeEvent.species, oldSpecies, this.speciesId); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#toString() - */ - @Override - public String toString() { - return "speciesGlyph [" + (isSetSpecies() ? getSpecies() : "") + "]"; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java deleted file mode 100644 index 7697ad9fd..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * $Id: SpeciesReferenceGlyph.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceGlyph.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBMLException; - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class SpeciesReferenceGlyph extends GraphicalObject { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -8810905237933499989L; - - /** - * - */ - private Curve curve; - - /** - * - */ - private SpeciesReferenceRole role; - - /** - * - */ - private String speciesGlyph; - - /** - * - */ - private String speciesReference; - - /** - * - */ - public SpeciesReferenceGlyph() { - super(); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param speciesReferencesGlyph - */ - public SpeciesReferenceGlyph(SpeciesReferenceGlyph speciesReferencesGlyph) { - super(speciesReferencesGlyph); - // TODO - } - - /** - * - * @param id - */ - public SpeciesReferenceGlyph(String id) { - super(id); - addNamespace(LayoutConstant.namespaceURI); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#clone() - */ - @Override - public SpeciesReferenceGlyph clone() { - return new SpeciesReferenceGlyph(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - SpeciesReferenceGlyph s = (SpeciesReferenceGlyph) object; - equals &= s.isSetSpeciesReferenceRole() && isSetSpeciesReferenceRole(); - if (equals && isSetSpeciesReferenceRole()) { - equals &= s.getSpeciesReferenceRole().equals(getSpeciesReferenceRole()); - } - equals &= s.isSetSpeciesReference() == isSetSpeciesReference(); - if (equals && isSetSpeciesReference()) { - equals &= s.getSpeciesReference().equals(getSpeciesReference()); - } - equals &= s.isSetSpeciesGlyph() == isSetSpeciesGlyph(); - if (equals && isSetSpeciesGlyph()) { - equals &= s.getSpeciesGlyph().equals(getSpeciesGlyph()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#getChildAt(int) - */ - @Override - public TreeNode getChildAt(int index) { - if (index < 0) { - throw new IndexOutOfBoundsException(Integer.toString(index)); - } - int count = super.getChildCount(), pos = 0; - if (index < count) { - return super.getChildAt(index); - } else { - index -= count; - } - if (isSetCurve()) { - if (pos == index) { - return getCurve(); - } - pos++; - } - - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - index, +((int) Math.min(pos, 0)))); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#getChildCount() - */ - @Override - public int getChildCount() { - int count = super.getChildCount(); - if (isSetCurve()) { - count++; - } - - return count; - } - - /** - * - * @return - */ - public Curve getCurve() { - return curve; - } - - /** - * - * @return - */ - public String getSpeciesGlyph() { - return speciesGlyph; - } - - /** - * - * @return - */ - public String getSpeciesReference() { - return speciesReference; - } - - /** - * @return - */ - public SpeciesReferenceRole getSpeciesReferenceRole() { - return role; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 953; - int hashCode = super.hashCode(); - if (isSetId()) { - hashCode += prime * getId().hashCode(); - } - if (isSetSpeciesReferenceRole()) { - hashCode += prime * getSpeciesReferenceRole().hashCode(); - } - if (isSetSpeciesReference()) { - hashCode += prime * getSpeciesReference().hashCode(); - } - if (isSetSpeciesGlyph()) { - hashCode += prime * getSpeciesGlyph().hashCode(); - } - - return hashCode; - } - - /** - * @return - */ - public boolean isSetCurve() { - return curve != null; - } - - /** - * @return - */ - public boolean isSetSpeciesGlyph() { - return speciesGlyph != null; - } - - /** - * @return - */ - public boolean isSetSpeciesReference() { - return speciesReference != null; - } - - /** - * @return - */ - public boolean isSetSpeciesReferenceRole() { - return role != null; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) { - - isAttributeRead = true; - - if(attributeName.equals(LayoutConstant.speciesReference)) - { - setSpeciesReference(value); - } - else if(attributeName.equals(LayoutConstant.speciesGlyph)) - { - setSpeciesGlyph(value); - } - else if(attributeName.equals(LayoutConstant.role)) - { - try { - setRole(SpeciesReferenceRole.valueOf(value.toUpperCase())); - } catch (Exception e) { - throw new SBMLException("Could not recognized the value '" + value - + "' for the attribute " + LayoutConstant.role - + " on the 'SpeciesReferenceGlyph' element."); - } - } - else - { - return false; - } - } - - return isAttributeRead; - } - - public void setRole(SpeciesReferenceRole valueOf) { - SpeciesReferenceRole oldRole = this.role; - this.role = valueOf; - firePropertyChange(LayoutConstant.role, oldRole, this.role); - } - - /** - * - * @param curve - */ - public void setCurve(Curve curve) { - Curve oldCurve = this.curve; - this.curve = curve; - firePropertyChange(LayoutConstant.curve, oldCurve, this.role); - registerChild(this.curve); - } - - /** - * - * @param speciesGlyph - */ - public void setSpeciesGlyph(String speciesGlyph) { - String oldValue = this.speciesGlyph; - this.speciesGlyph = speciesGlyph; - firePropertyChange(LayoutConstant.speciesGlyph, oldValue, this.speciesGlyph); - } - - /** - * - * @param speciesReference - */ - public void setSpeciesReference(String speciesReference) { - String oldSpeciesReference = this.speciesReference; - this.speciesReference = speciesReference; - firePropertyChange(LayoutConstant.speciesReference, oldSpeciesReference, this.speciesReference); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetSpeciesGlyph()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.speciesGlyph, speciesGlyph); - } - if (isSetSpeciesReference()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.speciesReference, speciesReference); - } - if (isSetSpeciesReferenceRole()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.role, role.toString().toLowerCase()); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceRole.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceRole.java deleted file mode 100644 index 7a9e9764c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/SpeciesReferenceRole.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * $Id: SpeciesReferenceRole.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/SpeciesReferenceRole.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1116 $ - */ -public enum SpeciesReferenceRole { - /** - * - */ - ACTIVATOR, - /** - * - */ - INHIBITOR, - /** - * - */ - MODIFIER, - /** - * - */ - PRODUCT, - /** - * - */ - SIDEPRODUCT, - /** - * - */ - SIDESUBSTRATE, - /** - * - */ - SUBSTRATE, - /** - * - */ - UNDEFINED -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/Start.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/Start.java deleted file mode 100644 index 21c23fe57..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/Start.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * $Id: Start.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/Start.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -/** - * - * @author Sebastian Fröhlich - * @version $Rev: 1116 $ - * @since 1.0 - * @date 21.11.2011 - */ -public class Start extends Point { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = 2483784742600803529L; - - /** - * - */ - public Start() { - super(); - } - - /** - * @param start - */ - public Start(Point point) { - super(point); - clonePointAttributes(point, this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.Point#clone() - */ - @Override - public Start clone() { - return new Start(this); - } - - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/TextGlyph.java b/IPK_lib/src/org/sbml/jsbml/ext/layout/TextGlyph.java deleted file mode 100644 index 892eb0ef8..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/TextGlyph.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * $Id: TextGlyph.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/ext/layout/TextGlyph.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.ext.layout; - -import java.util.Map; - - - -/** - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1237 $ - */ -public class TextGlyph extends GraphicalObject { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -2582985174711830815L; - - /** - * - */ - private String graphicalObject; - - /** - * - */ - private String originOfText; - - /** - * - */ - private String text; - - /** - * - */ - public TextGlyph() { - super(); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param id - */ - public TextGlyph(String id) { - super(id); - addNamespace(LayoutConstant.namespaceURI); - } - - /** - * - * @param textGlyph - */ - public TextGlyph(TextGlyph textGlyph) { - super(textGlyph); - - // TODO : use the iSet methods - - this.graphicalObject = new String(textGlyph.getGraphicalObject()); - this.originOfText = new String(textGlyph.getOriginOfText()); - this.text = new String(textGlyph.getText()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractSBase#clone() - */ - @Override - public TextGlyph clone() { - return new TextGlyph(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - TextGlyph t = (TextGlyph) object; - equals &= t.isSetOriginOfText() == isSetOriginOfText(); - if (equals && isSetOriginOfText()) { - equals &= t.getOriginOfText().equals(getOriginOfText()); - } - equals &= t.isSetText() == isSetText(); - if (equals && isSetText()) { - equals &= t.getText().equals(getText()); - } - equals &= t.isSetGraphicalObject() == isSetGraphicalObject(); - if (equals && isSetGraphicalObject()) { - equals &= t.getGraphicalObject().equals(getGraphicalObject()); - } - } - return equals; - } - - /** - * - * @return - */ - public String getGraphicalObject() { - return graphicalObject; - } - - /** - * - * @return - */ - public String getOriginOfText() { - return originOfText; - } - - /** - * - * @return - */ - public String getText() { - return text; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#hashCode() - */ - @Override - public int hashCode() { - final int prime = 967; - int hashCode = super.hashCode(); - if (isSetOriginOfText()) { - hashCode += prime * getOriginOfText().hashCode(); - } - if (isSetText()) { - hashCode += prime * getText().hashCode(); - } - if (isSetGraphicalObject()) { - hashCode += prime * getGraphicalObject().hashCode(); - } - - return hashCode; - } - - /** - * @return - */ - public boolean isSetGraphicalObject() { - return graphicalObject != null; - } - - /** - * @return - */ - public boolean isSetOriginOfText() { - return originOfText != null; - } - - /** - * @return - */ - public boolean isSetText() { - return text != null; - } - - /** - * - * @param graphicalObject - */ - public void setGraphicalObject(String graphicalObject) { - String oldValue = this.graphicalObject; - this.graphicalObject = graphicalObject; - firePropertyChange(LayoutConstant.graphicalObject, oldValue, this.graphicalObject); - } - - /** - * - * @param originOfText - */ - public void setOriginOfText(String originOfText) { - String oldOriginOfText = this.originOfText; - this.originOfText = originOfText; - firePropertyChange(LayoutConstant.originOfText, oldOriginOfText, this.originOfText); - } - - /** - * - * @param text - */ - public void setText(String text) { - String oldText = this.text; - this.text = text; - firePropertyChange(LayoutConstant.text, oldText, this.text); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractNamedSBase#readAttribute(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, - String value) { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, - value); - - if(!isAttributeRead) - { - - if(attributeName.equals(LayoutConstant.graphicalObject)) - { - setGraphicalObject(value); - } - else if(attributeName.equals(LayoutConstant.text)) - { - setText(value); - } - else if(attributeName.equals(LayoutConstant.originOfText)) - { - setOriginOfText(value); - } - else - { - return false; - } - - return true; - } - - return isAttributeRead; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ext.layout.GraphicalObject#writeXMLAttributes() - */ - @Override - public Map writeXMLAttributes() { - Map attributes = super.writeXMLAttributes(); - - if (isSetGraphicalObject()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.graphicalObject, graphicalObject); - } - if (isSetText()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.text, text); - } - if (isSetOriginOfText()) { - attributes.put(LayoutConstant.shortLabel + ":" - + LayoutConstant.originOfText, originOfText); - } - - return attributes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/ext/layout/package.html b/IPK_lib/src/org/sbml/jsbml/ext/layout/package.html deleted file mode 100644 index e25a80716..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/layout/package.html +++ /dev/null @@ -1,6 +0,0 @@ - -

    Provides classes for the - Layout package.

    - -

    There is no formal SBML level 3 proposal but the classes implemented are derived from the Layout proposal by Gauges et al. as an annotation in SBMl level 2

    - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/ext/package.html b/IPK_lib/src/org/sbml/jsbml/ext/package.html deleted file mode 100644 index 2f7cf1323..000000000 --- a/IPK_lib/src/org/sbml/jsbml/ext/package.html +++ /dev/null @@ -1 +0,0 @@ -The base package for all SBML extensions. \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/package.html b/IPK_lib/src/org/sbml/jsbml/package.html deleted file mode 100644 index 3b85dfffd..000000000 --- a/IPK_lib/src/org/sbml/jsbml/package.html +++ /dev/null @@ -1,3 +0,0 @@ - -

    Pure Java implementation of the data structures to represent all SBML constructs.

    - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/resources/Resource.java b/IPK_lib/src/org/sbml/jsbml/resources/Resource.java deleted file mode 100644 index 25ce1458d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/Resource.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * $Id: Resource.java,v 1.1 2012-11-07 14:43:39 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/resources/Resource.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.resources; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * Dummy class that just loads resource files if required. - * - * @author Hannes Borch - * @author Andreas Dräger - * @date 2009-02-05 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public final class Resource { - - private static Resource resource; - - static { - resource = new Resource(); - } - - public static Resource getInstance() { - return resource; - } - - /** - * - * @param resourceName - * @return - * @throws IOException - */ - public static Properties readProperties(String resourceName) - throws IOException { - Properties prop = null; - Resource loader = getInstance(); - - byte bytes[] = loader.getBytesFromResourceLocation(resourceName); - if (bytes != null) { - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - prop = new Properties(); - prop.load(bais); - } - if (prop != null) { - return prop; - } - // /////////// - - int slInd = resourceName.lastIndexOf('/'); - if (slInd != -1) { - resourceName = resourceName.substring(slInd + 1); - } - Properties userProps = new Properties(); - File propFile = new File(File.separatorChar + "resources" - + File.separatorChar + resourceName); - if (propFile.exists()) { - userProps.load(new FileInputStream(propFile)); - } - return userProps; - } - - private Resource() { - } - - /** - * Gets the byte data from a file at the given resource location. - * - * @param rawResrcLoc - * Description of the Parameter - * @return the byte array of file. - */ - public byte[] getBytesFromResourceLocation(String rawResrcLoc) { - InputStream in = getStreamFromResourceLocation(rawResrcLoc); - if (in == null) - return null; - return getBytesFromStream(in); - } - - /** - * Gets the byte data from a file. - * - * @param fileName - * Description of the Parameter - * @return the byte array of the file. - */ - private byte[] getBytesFromStream(InputStream stream) { - if (stream == null) - return null; - BufferedInputStream bis = new BufferedInputStream(stream); - try { - int size = (int) bis.available(); - byte[] b = new byte[size]; - int rb = 0; - int chunk = 0; - - while (((int) size - rb) > 0) { - chunk = bis.read(b, rb, (int) size - rb); - - if (chunk == -1) { - break; - } - - rb += chunk; - } - return b; - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - /** - * Gets the byte data from a file. - * - * @param fileName - * Description of the Parameter - * @return the byte array of the file. - */ - private FileInputStream getStreamFromFile(String fileName) { - if (fileName.startsWith("/cygdrive/")) { - int length = "/cygdrive/".length(); - fileName = fileName.substring(length, length + 1) + ":" - + fileName.substring(length + 1); - } - File file = new File(fileName); - FileInputStream fis = null; - try { - fis = new FileInputStream(file); - return fis; - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return null; - } - - /** - * Gets the byte data from a file at the given resource location. - * - * @param rawResrcLoc - * Description of the Parameter - * @return the byte array of file. - */ - public InputStream getStreamFromResourceLocation(String rawResrcLoc) { - String resourceLocation = rawResrcLoc.replace('\\', '/'); - if (resourceLocation == null) { - return null; - } - // to avoid hours of debugging non-found-files under linux with - // some f... special characters at the end which will not be shown - // at the console output !!! - resourceLocation = resourceLocation.trim(); - InputStream in = null; - - // is a relative path defined ? - // this can only be possible, if this is a file resource location - if (resourceLocation.startsWith("..") - || resourceLocation.startsWith("/") - || resourceLocation.startsWith("\\") - || ((resourceLocation.length() > 1) && (resourceLocation - .charAt(1) == ':'))) { - in = getStreamFromFile(resourceLocation); - } - // InputStream inTest = getStreamFromFile(resourceLocation); - if (in == null) { - in = ClassLoader.getSystemResourceAsStream(resourceLocation); - } - if (in == null) { - // try again for web start applications - in = this.getClass().getClassLoader().getResourceAsStream( - resourceLocation); - } - if (in == null) { - // try to search other classpathes...? not really necessary. - // in = getStreamFromClassPath(resourceLocation); - } - return in; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/ASTNodeTokens.xml b/IPK_lib/src/org/sbml/jsbml/resources/cfg/ASTNodeTokens.xml deleted file mode 100644 index 298bcb5f4..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/ASTNodeTokens.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - $Id: ASTNodeTokens.xml,v 1.1 2012-11-07 14:43:37 klukas Exp $ - $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/ASTNodeTokens.xml $ - ---------------------------------------------------------------------------- - This file is part of JSBML. Please visit http://sbml.org/Software/JSBML - for the latest version of JSBML and more information about SBML. - - Copyright (C) 2009-2011 jointly by the following organizations: - 1. The University of Tuebingen, Germany - 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - 3. The California Institute of Technology, Pasadena, CA, USA - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation. A copy of the license agreement is provided - in the file named "LICENSE.txt" included with this software distribution - and also available online as http://sbml.org/Software/JSBML/License. - ---------------------------------------------------------------------------- - - Mapping between tokens in a textual representation of a mathematical - expression and a corresponding ASTNode.Type. - - Version: $Rev: 792 $ - - FUNCTION_ABS - FUNCTION_SIN - FUNCTION_COS - FUNCTION_TAN - FUNCTION_ARCSIN - FUNCTION_ARCCOS - FUNCTION_ARCCOSH - FUNCTION_ARCCOT - FUNCTION_ARCCOTH - FUNCTION_ARCCSC - FUNCTION_ARCCSCH - FUNCTION_ARCSEC - FUNCTION_ARCSECH - FUNCTION_ARCSINH - FUNCTION_ARCTANH - FUNCTION_COSH - FUNCTION_COT - FUNCTION_COTH - FUNCTION_CSC - FUNCTION_CSCH - FUNCTION_ARCTAN - FUNCTION_CEILING - FUNCTION_FLOOR - FUNCTION_LN - FUNCTION_LOG - FUNCTION_POWER - FUNCTION_POWER - FUNCTION_ROOT - FUNCTION_EXP - FUNCTION_FACTORIAL - FUNCTION_FACTORIAL - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/Alias2SBO.cfg b/IPK_lib/src/org/sbml/jsbml/resources/cfg/Alias2SBO.cfg deleted file mode 100644 index 60bce5484..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/Alias2SBO.cfg +++ /dev/null @@ -1,130 +0,0 @@ -# -# $Id: Alias2SBO.cfg 543 2011-01-20 22:41:22Z mhucka $ -# $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/Alias2SBO.cfg $ -# ----------------------------------------------------------------------------- -# This file is part of JSBML. Please visit -# for the latest version of JSBML and more information about SBML. -# -# Copyright (C) 2009-2011 jointly by the following organizations: -# 1. The University of Tuebingen, Germany -# 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK -# 3. The California Institute of Technology, Pasadena, CA, USA -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation. A copy of the license agreement is provided -# in the file named "LICENSE.txt" included with this software distribution -# and also available online as . -# ----------------------------------------------------------------------------- -# -# Aliases are a construct introduced and used by CellDesigner. -# Their purpose is to provide a similar but rather limited -# annotation system as the Systems Biology Ontology (SBO). -# This file provides a mapping between all those aliases and -# the SBO. Unfortunately, it is not possible to provide a -# one-to-one matching because some aliases don't have an exact -# equivalent in the SBO, e.g., "inhibition" and "translational -# inhibition" can both only represented by SBO:0000020. -# The usage of this mapping file simplifies the implementation -# of the SBO class in jsbml and makes the usage of certain SBO -# terms more transparent. -# -# PLEASE NOTE: -# Some of the aliases cannot be mapped to a SBO term with the same or -# with a very similar name. However, it is most important to have a -# unique mapping from aliases to SBO terms and back. Therefore, it is -# highly discouraged to reuse the same SBO term more than once. -# - -#################### -# Species Aliases # -#################### - -# small interfering RNA -# This term is not exact but SBO does not provide something closer. -ANTISENSE_RNA=317 -# non-covalent complex -COMPLEX=253 -# empty set -DEGRADED=291 -# synthetic chemical compound -DRUG=298 -# gene -GENE=243 -# polypeptide chain -GENERIC=252 -# non-macromolecular ion -ION=327 -# phenotype -PHENOTYPE=358 -# protein complex -PROTEIN=297 -# receptor -RECEPTOR=244 -# ribonucleic acid -RNA=250 -# channel -ION_CHANNEL=242 -# simple chemical -SIMPLE_MOLECULE=247 -# chemical macromolecule -# This term is not exact but SBO does not provide something closer. -TRUNCATED=248 -# material entity of unspecified nature -UNKNOWN=285 - - -#################### -# Reaction Aliases # -#################### - -# omitted process -KNOWN_TRANSITION_OMITTED=397 -# biochemical reaction -STATE_TRANSITION=176 -# transcription -TRANSCRIPTION=183 -# translation -TRANSLATION=184 -# transport reaction -TRANSPORT=185 -# uncertain process -UNKNOWN_TRANSITION=396 -# reactant -reactant=10 -# product -product=11 - - -#################### -# Modifier Aliases # -#################### - -# catalyst -CATALYSIS=13 -# inhibitor -INHIBITION=20 -# modifier -MODULATION=19 -# potentiator -# This term is not exact but SBO does not provide something closer. -PHYSICAL_STIMULATION=21 -# stimulator -# This term is not exact but SBO does not provide something closer. -TRANSCRIPTIONAL_ACTIVATION=459 -# inhibitor -# This term is not exact but SBO does not provide something closer. -TRANSCRIPTIONAL_INHIBITION=20 -# stimulator -# This term is not exact but SBO does not provide something closer. -TRANSLATIONAL_ACTIVATION=459 -# inhibitor -# This term is not exact but SBO does not provide something closer. -TRANSLATIONAL_INHIBITION=20 -# essential activator -TRIGGER=461 -# catalyst -UNKNOWN_CATALYSIS=13 -# inhibitor -# This term is not exact but SBO does not provide something closer. -UNKNOWN_INHIBITION=20 diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/HTML_CharEncodingTable.txt b/IPK_lib/src/org/sbml/jsbml/resources/cfg/HTML_CharEncodingTable.txt deleted file mode 100644 index b0134dfed..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/HTML_CharEncodingTable.txt +++ /dev/null @@ -1,56 +0,0 @@ -# -# $Id: HTML_CharEncodingTable.txt,v 1.1 2012-11-07 14:43:38 klukas Exp $ -# $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/HTML_CharEncodingTable.txt $ -# ----------------------------------------------------------------------------- -# This file is part of JSBML. Please visit -# for the latest version of JSBML and more information about SBML. -# -# Copyright (C) 2009-2011 jointly by the following organizations: -# 1. The University of Tuebingen, Germany -# 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK -# 3. The California Institute of Technology, Pasadena, CA, USA -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation. A copy of the license agreement is provided -# in the file named "LICENSE.txt" included with this software distribution -# and also available online as . -# ----------------------------------------------------------------------------- -# -# This file provides a simple mapping of special characters to their corresponding -# UTF8 encoding in HTML. -# -\t= -!=! -#=# -$=$ -%=% -\=' -(=( -)=) -*=* -+=+ -,=, --=- -.=. -/=/ -\:=: -;=; -=== -?=? -@=@ -[=[ -\\=\ -]=] -^=^ -_=_ -`=` -{={ -|=| -}=} -~=~ -<=< ->=> -&=& -\"=" -\n=
    diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml b/IPK_lib/src/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml deleted file mode 100644 index aac7b0901..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - $Id: PackageParserNamespaces.xml,v 1.1 2012-11-07 14:43:37 klukas Exp $ - $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml $ - ---------------------------------------------------------------------------- - This file is part of JSBML. Please visit http://sbml.org/Software/JSBML - for the latest version of JSBML and more information about SBML. - - Copyright (C) 2009-2012 jointly by the following organizations: - 1. The University of Tuebingen, Germany - 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - 3. The California Institute of Technology, Pasadena, CA, USA - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation. A copy of the license agreement is provided - in the file named "LICENSE.txt" included with this software distribution - and also available online as http://sbml.org/Software/JSBML/License. - ---------------------------------------------------------------------------- - - This file maps the name spaces of the supported levels and version and other - content of SBML files to parsers for the creation of JSBML data objects. - - Version: $Rev: 1235 $ - - - - - org.sbml.jsbml.xml.parsers.MultiParser - org.sbml.jsbml.xml.parsers.GroupsParser - org.sbml.jsbml.xml.parsers.LayoutParser - org.sbml.jsbml.xml.parsers.GroupsParser - org.sbml.jsbml.xml.parsers.FBAParser - org.sbml.jsbml.xml.parsers.QualParser - org.sbml.jsbml.xml.parsers.L3LayoutParser - org.sbml.jsbml.xml.parsers.MultiParser - - - - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.SBMLCoreParser - org.sbml.jsbml.xml.parsers.StringParser - org.sbml.jsbml.xml.parsers.RDFAnnotationParser - org.sbml.jsbml.xml.parsers.CreatorParser - org.sbml.jsbml.xml.parsers.DatesParser - org.sbml.jsbml.xml.parsers.VCardParser - org.sbml.jsbml.xml.parsers.BiologicalQualifierParser - org.sbml.jsbml.xml.parsers.ModelQualifierParser - org.sbml.jsbml.xml.parsers.MathMLStaxParser - org.sbml.jsbml.xml.parsers.AnnotationParser - - diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLCoreElements.xml b/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLCoreElements.xml deleted file mode 100644 index b445f2d89..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLCoreElements.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - $Id: SBMLCoreElements.xml,v 1.1 2012-11-07 14:43:38 klukas Exp $ - $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/SBMLCoreElements.xml $ - ---------------------------------------------------------------------------- - This file is part of JSBML. Please visit http://sbml.org/Software/JSBML - for the latest version of JSBML and more information about SBML. - - Copyright (C) 2009-2011 jointly by the following organizations: - 1. The University of Tuebingen, Germany - 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - 3. The California Institute of Technology, Pasadena, CA, USA - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation. A copy of the license agreement is provided - in the file named "LICENSE.txt" included with this software distribution - and also available online as http://sbml.org/Software/JSBML/License. - ---------------------------------------------------------------------------- - - Mapping between SBML core element names and their representation - as JSBML classes. - - Version: $Rev: 792 $ - - org.sbml.jsbml.AlgebraicRule - org.sbml.jsbml.Annotation - org.sbml.jsbml.AssignmentRule - org.sbml.jsbml.Compartment - org.sbml.jsbml.CompartmentType - org.sbml.jsbml.xml.parsers.SBMLLevel1Rule - org.sbml.jsbml.Constraint - org.sbml.jsbml.Delay - org.sbml.jsbml.Event - org.sbml.jsbml.EventAssignment - org.sbml.jsbml.FunctionDefinition - org.sbml.jsbml.InitialAssignment - org.sbml.jsbml.KineticLaw - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.LocalParameter - java.lang.StringBuffer - java.lang.StringBuffer - org.sbml.jsbml.Model - org.sbml.jsbml.ModifierSpeciesReference - java.lang.StringBuffer - org.sbml.jsbml.Parameter - org.sbml.jsbml.xml.parsers.SBMLLevel1Rule - org.sbml.jsbml.Priority - org.sbml.jsbml.RateRule - org.sbml.jsbml.Reaction - org.sbml.jsbml.Species - org.sbml.jsbml.xml.parsers.SBMLLevel1Rule - org.sbml.jsbml.SpeciesReference - org.sbml.jsbml.Species - org.sbml.jsbml.xml.parsers.SBMLLevel1Rule - org.sbml.jsbml.SpeciesReference - org.sbml.jsbml.SpeciesType - org.sbml.jsbml.StoichiometryMath - org.sbml.jsbml.Trigger - org.sbml.jsbml.Unit - org.sbml.jsbml.UnitDefinition - diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLElementsLevel1Version1.xml b/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLElementsLevel1Version1.xml deleted file mode 100644 index 6a5790aab..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLElementsLevel1Version1.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - $Id: SBMLElementsLevel1Version1.xml,v 1.1 2012-11-07 14:43:38 klukas Exp $ - $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/resources/org/sbml/jsbml/resources/cfg/SBMLElementsLevel1Version1.xml $ - ---------------------------------------------------------------------------- - This file is part of JSBML. Please visit http://sbml.org/Software/JSBML - for the latest version of JSBML and more information about SBML. - - Copyright (C) 2009-2011 jointly by the following organizations: - 1. The University of Tuebingen, Germany - 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - 3. The California Institute of Technology, Pasadena, CA, USA - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation. A copy of the license agreement is provided - in the file named "LICENSE.txt" included with this software distribution - and also available online as http://sbml.org/Software/JSBML/License. - ---------------------------------------------------------------------------- - - Mapping between SBML core element names and their representation - as JSBML classes - - Version: $Rev: 792 $ - - org.sbml.jsbml.AlgebraicRule - org.sbml.jsbml.Annotation - org.sbml.jsbml.AssignmentRule - org.sbml.jsbml.Compartment - org.sbml.jsbml.AssignmentRule - org.sbml.jsbml.KineticLaw - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.Parameter - java.lang.StringBuffer - java.lang.StringBuffer - org.sbml.jsbml.Model - org.sbml.jsbml.ModifierSpeciesReference - java.lang.StringBuffer - org.sbml.jsbml.Parameter - org.sbml.jsbml.AssignmentRule - org.sbml.jsbml.RateRule - org.sbml.jsbml.Reaction - org.sbml.jsbml.Species - org.sbml.jsbml.AssignmentRule - org.sbml.jsbml.SpeciesReference - org.sbml.jsbml.Unit - org.sbml.jsbml.UnitDefinition - diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLLayoutElements.xml b/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLLayoutElements.xml deleted file mode 100644 index b224551cf..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBMLLayoutElements.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - $Id: SBMLLayoutElements.xml,v 1.1 2012-11-07 14:43:38 klukas Exp $ - $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/resources/org/sbml/jsbml/resources/cfg/SBMLLayoutElements.xml $ - ---------------------------------------------------------------------------- - This file is part of JSBML. Please visit http://sbml.org/Software/JSBML - for the latest version of JSBML and more information about SBML. - - Copyright (C) 2009-2011 jointly by the following organizations: - 1. The University of Tuebingen, Germany - 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - 3. The California Institute of Technology, Pasadena, CA, USA - - This library is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation. A copy of the license agreement is provided - in the file named "LICENSE.txt" included with this software distribution - and also available online as http://sbml.org/Software/JSBML/License. - ---------------------------------------------------------------------------- - - Mapping between SBML layout element names and their representation - as JSBML classes. - - Version: $Rev: 925 $ - - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ListOf - org.sbml.jsbml.ext.layout.CompartmentGlyph - org.sbml.jsbml.ext.layout.BoundingBox - org.sbml.jsbml.ext.layout.Dimensions - org.sbml.jsbml.ext.layout.SpeciesGlyph - org.sbml.jsbml.ext.layout.Position - org.sbml.jsbml.ext.layout.Layout - org.sbml.jsbml.ext.layout.ReactionGlyph - org.sbml.jsbml.ext.layout.Curve - org.sbml.jsbml.ext.layout.SpeciesReferenceGlyph - org.sbml.jsbml.ext.layout.CurveSegment - org.sbml.jsbml.ext.layout.CubicBezier - org.sbml.jsbml.ext.layout.Start - org.sbml.jsbml.ext.layout.End - org.sbml.jsbml.ext.layout.BasePoint1 - org.sbml.jsbml.ext.layout.BasePoint2 - org.sbml.jsbml.ext.layout.End - org.sbml.jsbml.ext.layout.CubicBezier - org.sbml.jsbml.ext.layout.TextGlyph - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBO_OBO.obo b/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBO_OBO.obo deleted file mode 100644 index f86bb8d49..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/cfg/SBO_OBO.obo +++ /dev/null @@ -1,3660 +0,0 @@ -format-version: 1.2 -date: 27:02:2012 07:00 -data-version: 09:02:2012 16:47 -saved-by: SBO community -auto-generated-by: SBO Browser (http://www.ebi.ac.uk/sbo/) -default-namespace: sbo - -[Term] -id: SBO:0000000 -name: systems biology representation -def: "Representation of an entity used in a systems biology knowledge reconstruction\, such as a model\, pathway\, network." [src_code:NR] - -[Term] -id: SBO:0000001 -name: rate law -def: "mathematical description that relates quantities of reactants to the reaction velocity." [src_code:NR] -is_a: SBO:0000064 ! mathematical expression - -[Term] -id: SBO:0000002 -name: quantitative systems description parameter -def: "A numerical value that defines certain characteristics of systems or system functions. It may be part of a calculation\, but its value is not determined by the form of the equation itself\, and may be arbitrarily assigned." [src_code:NR] -is_a: SBO:0000545 ! systems description parameter - -[Term] -id: SBO:0000003 -name: participant role -def: "The function of a physical entity\, that is its role\, in the execution of an event." [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000004 -name: modelling framework -def: "Set of assumptions that underlay a mathematical description." [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000005 -name: obsolete mathematical expression -def: "The description of a system in mathematical terms." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000006 -name: obsolete parameter -def: "A numerical value that represents the amount of some entity\, process or mathematical function of the system." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000007 -name: obsolete participant type -def: "The 'kind' of entity involved in some process\, action or reaction in the system. This may be enzyme\, simple chemical\, etc." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000008 -name: obsolete modelling framework -def: "Basic assumptions that underlie a mathematical model." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000009 -name: kinetic constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction." [src_code:NR] -synonym: "reaction rate constant" [] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000010 -name: reactant -def: "Substance consumed by a chemical reaction. Reactants react with each other to form the products of a chemical reaction. In a chemical equation the Reactants are the elements or compounds on the left hand side of the reaction equation. A reactant can be consumed and produced by the same reaction\, its global quantity remaining unchanged." [src_code:NR] -is_a: SBO:0000003 ! participant role - -[Term] -id: SBO:0000011 -name: product -def: "Substance that is produced in a reaction. In a chemical\nequation the Products are the elements or compounds on the right hand side\nof the reaction equation. A product can be produced and consumed by the\nsame reaction\, its global quantity remaining unchanged." [src_code:NR] -is_a: SBO:0000003 ! participant role - -[Term] -id: SBO:0000012 -name: mass action rate law -def: "The Law of Mass Action\, first expressed by Waage and Guldberg in 1864 (Waage\, P.\, Guldberg\, C. M. Forhandlinger\: Videnskabs-Selskabet i Christiana 1864\, 35) states that the speed of a chemical reaction is proportional to the quantity of the reacting substances. More formally\, the change of a product quantity is proportional to the product of reactant activities. In the case of a reaction occurring in a gas phase\, the activities are equal to the partial pressures. In the case of a well-stirred aqueous medium\, the activities are equal to the concentrations. In the case of discrete kinetic description\, the quantity are expressed in number of molecules and the relevant volume are implicitely embedded in the kinetic constant." [src_code:NR] -is_a: SBO:0000001 ! rate law - -[Term] -id: SBO:0000013 -name: catalyst -def: "Substance that accelerates the velocity of a chemical reaction without itself being consumed or transformed. This effect is achieved by lowering the free energy of the transition state." [src_code:NR] -is_a: SBO:0000459 ! stimulator - -[Term] -id: SBO:0000014 -name: enzyme -def: "A protein that catalyzes a chemical reaction. The word comes from en (\"at\" or \"in\") and simo (\"leaven\" or \"yeast\")." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000015 -name: substrate -def: "Molecule which is acted upon by an enzyme. The substrate binds with the enzyme's active site\, and the enzyme catalyzes a chemical reaction involving the substrate." [src_code:NR] -is_a: SBO:0000010 ! reactant - -[Term] -id: SBO:0000016 -name: unimolecular rate constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction involving only one reactant.\n" [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000017 -name: bimolecular rate constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction involving two reactants." [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000018 -name: trimolecular rate constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction involving three reactants.\n" [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000019 -name: modifier -def: "Substance that changes the velocity of a chemical reaction without\nitself being consumed or transformed by the reaction." [src_code:NR] -is_a: SBO:0000003 ! participant role - -[Term] -id: SBO:0000020 -name: inhibitor -def: "Substance that decreases the probability of a chemical reaction without\nitself being consumed or transformed by the reaction. " [src_code:NR] -is_a: SBO:0000019 ! modifier - -[Term] -id: SBO:0000021 -name: potentiator -def: "Substance that increases the probability of a chemical reaction without\nitself being consumed or transformed by the reaction. This effect is achieved by increasing the difference of free energy between the reactant(s) and the product(s)" [src_code:NR] -synonym: "activator" [] -is_a: SBO:0000459 ! stimulator - -[Term] -id: SBO:0000022 -name: forward unimolecular rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical\nreaction involving only one reactant. This parameter encompasses all the contributions to the velocity except the quantity of the reactant." [src_code:NR] -is_a: SBO:0000016 ! unimolecular rate constant -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000023 -name: forward bimolecular rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving two reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. " [src_code:NR] -is_a: SBO:0000017 ! bimolecular rate constant -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000024 -name: forward trimolecular rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical\nreaction involving three reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. " [src_code:NR] -is_a: SBO:0000018 ! trimolecular rate constant -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000025 -name: catalytic rate constant -def: "Numerical parameter that quantifies the velocity of an enzymatic reaction." [src_code:NR] -synonym: "kcat" [] -synonym: "turnover number" [] -is_a: SBO:0000035 ! forward unimolecular rate constant\, continuous case - -[Term] -id: SBO:0000026 -name: new term name -def: "none" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000027 -name: Michaelis constant -def: "Substrate concentration at which the velocity of reaction is half its maximum. Michaelis constant is an experimental parameter. According to the underlying molecular mechanism it can be interpreted differently in terms of microscopic constants." [src_code:NR] -synonym: "Km" [] -synonym: "Michaelis-Menten constant" [] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000028 -name: enzymatic rate law for irreversible non-modulated non-interacting unireactant enzymes -def: "Kinetics of enzymes that react only with one substance\, their substrate. The enzymes do not catalyse the reactions in both directions.\n\n \n kcat\n Et\n S\n Ks\n \n \n \n \n kcat\n Et\n S\n \n \n \n Ks\n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000150 ! enzymatic rate law for irreversible non-modulated non-interacting reactant enzymes -is_a: SBO:0000326 ! enzymatic rate law for non-modulated unireactant enzymes - -[Term] -id: SBO:0000029 -name: Henri-Michaelis-Menten rate law -def: "First general rate equation for reactions involving enzymes\, it was presented in \"Victor Henri. Lois Générales de l'Action des Diastases. Paris\, Hermann\, 1903.\". The reaction is assumed to be made of a reversible of the binding of the substrate to the enzyme\, followed by the breakdown of the complex generating the product. Ten years after Henri\, Michaelis and Menten presented a variant of his equation\, based on the hypothesis that the dissociation rate of the substrate was much larger than the rate of the product generation. Leonor Michaelis\, Maud Menten (1913). Die Kinetik der Invertinwirkung\, Biochem. Z. 49\:333-369.\n\n \n kcat\n Et\n S\n Ks\n \n \n \n \n kcat\n Et\n S\n \n \n \n Ks\n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000028 ! enzymatic rate law for irreversible non-modulated non-interacting unireactant enzymes - -[Term] -id: SBO:0000030 -name: Van Slyke-Cullen rate law -def: "Rate-law presented in \"Donald D. Van Slyke and Glenn E. Cullen. The mode of action of urease and of enzymes in general. J. Biol. Chem.\, Oct 1914\, 19\: 141-180\". It assumes that the enzymatic reaction occurs as two irreversible steps.E+S -> ES -> E+P. Although of the same form than the Henri-Michaelis-Menten equation\, it is semantically different since K now represents the ratio between the production rate and the association rate of the enzyme and the substrate.\n\n \n kcat\n Et\n S\n Ks\n \n \n \n \n kcat\n Et\n S\n \n \n \n Ks\n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000028 ! enzymatic rate law for irreversible non-modulated non-interacting unireactant enzymes - -[Term] -id: SBO:0000031 -name: Briggs-Haldane rate law -def: "The Briggs-Haldane rate law is a general rate equation that does not require the restriction of equilibrium of Henri-Michaelis-Menten or irreversible reactions of Van Slyke\, but instead make the hypothesis that the complex enzyme-substrate is in quasi-steady-state. Although of the same form than the Henri-Michaelis-Menten equation\, it is semantically different since Km now represents a pseudo-equilibrium constant\, and is equal to the ratio between the rate of consumption of the complex (sum of dissociation of substrate and generation of product) and the association rate of the enzyme and the substrate.\n\n \n kcat\n Et\n S\n Km\n \n \n \n \n kcat\n Et\n S\n \n \n \n Km\n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000028 ! enzymatic rate law for irreversible non-modulated non-interacting unireactant enzymes - -[Term] -id: SBO:0000032 -name: reverse unimolecular rate constant -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving only one product. This parameter encompasses all the contributions to the velocity except the quantity of the product." [src_code:NR] -is_a: SBO:0000016 ! unimolecular rate constant -is_a: SBO:0000156 ! reverse rate constant - -[Term] -id: SBO:0000033 -name: reverse bimolecular rate constant -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving only one product. This parameter encompasses all the contributions to the velocity except the quantity of the product." [src_code:NR] -is_a: SBO:0000017 ! bimolecular rate constant -is_a: SBO:0000156 ! reverse rate constant - -[Term] -id: SBO:0000034 -name: reverse trimolecular rate constant -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving three products. This parameter encompasses all the contributions to the velocity except the quantity of the products." [src_code:NR] -is_a: SBO:0000018 ! trimolecular rate constant -is_a: SBO:0000156 ! reverse rate constant - -[Term] -id: SBO:0000035 -name: forward unimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving only one reactant. This parameter encompasses all the contributions to the velocity except the quantity of the reactant. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000022 ! forward unimolecular rate constant -is_a: SBO:0000154 ! forward rate constant\, continuous case - -[Term] -id: SBO:0000036 -name: forward bimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving two reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000023 ! forward bimolecular rate constant -is_a: SBO:0000154 ! forward rate constant\, continuous case - -[Term] -id: SBO:0000037 -name: forward trimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving three reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000024 ! forward trimolecular rate constant -is_a: SBO:0000154 ! forward rate constant\, continuous case - -[Term] -id: SBO:0000038 -name: reverse unimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving only one product. This parameter encompasses all the contributions to the velocity except the quantity of the product. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000032 ! reverse unimolecular rate constant - -[Term] -id: SBO:0000039 -name: reverse bimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving only one product. This parameter encompasses all the contributions to the velocity except the quantity of the product. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000033 ! reverse bimolecular rate constant - -[Term] -id: SBO:0000040 -name: reverse trimolecular rate constant\, continuous case -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction involving three products. This parameter encompasses all the contributions to the velocity except the quantity of the products. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000034 ! reverse trimolecular rate constant - -[Term] -id: SBO:0000041 -name: mass action rate law for irreversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products." [src_code:NR] -is_a: SBO:0000012 ! mass action rate law - -[Term] -id: SBO:0000042 -name: mass action rate law for reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products." [src_code:NR] -is_a: SBO:0000012 ! mass action rate law - -[Term] -id: SBO:0000043 -name: mass action rate law for zeroth order irreversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is constant." [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000044 -name: mass action rate law for first order irreversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant." [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000045 -name: mass action rate law for second order irreversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to two reactant quantity." [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000046 -name: zeroth order rate constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction independant of the reactant quantities. This parameter encompasses all the contributions to the velocity." [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000047 -name: mass action rate law for zeroth order irreversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is constant. It is to be used in a reaction modelled using a continuous framework. \n \n \n k\n \n k\n \n \n\n" [src_code:NR] -is_a: SBO:0000043 ! mass action rate law for zeroth order irreversible reactions -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000048 -name: forward zeroth order rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction independant of the reactant quantities. This parameter encompasses all the contributions to the velocity. It is to be used in a reaction modelled using a continuous framework. " [src_code:NR] -is_a: SBO:0000154 ! forward rate constant\, continuous case -is_a: SBO:0000162 ! forward zeroth order rate constant - -[Term] -id: SBO:0000049 -name: mass action rate law for first order irreversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant. It is to be used in a reaction modelled using a continuous framework. \n\n \n k\n R\n \n \n k\n R\n \n \n\n" [src_code:NR] -is_a: SBO:0000044 ! mass action rate law for first order irreversible reactions -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000050 -name: mass action rate law for second order irreversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products\, and the change of a product quantity is proportional to the square of one reactant quantity." [src_code:NR] -is_a: SBO:0000045 ! mass action rate law for second order irreversible reactions - -[Term] -id: SBO:0000051 -name: new term name -def: "" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000052 -name: mass action rate law for second order irreversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the square of one reactant quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R\n \n \n k\n R\n R\n \n \n\n" [src_code:NR] -is_a: SBO:0000050 ! mass action rate law for second order irreversible reactions\, one reactant -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000053 -name: mass action rate law for second order irreversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of two reactants. " [src_code:NR] -is_a: SBO:0000045 ! mass action rate law for second order irreversible reactions - -[Term] -id: SBO:0000054 -name: mass action rate law for second order irreversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the product of two reactant quantities. It is to be used in a reaction modelled using a continuous framework. \n\n \n k\n R1\n R2\n \n \n k\n R1\n R2\n \n \n\n" [src_code:NR] -is_a: SBO:0000053 ! mass action rate law for second order irreversible reactions\, two reactants -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000055 -name: mass action rate law for third order irreversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to three reactant quantities." [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000056 -name: mass action rate law for third order irreversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the cube of one reactant quantity." [src_code:NR] -is_a: SBO:0000055 ! mass action rate law for third order irreversible reactions - -[Term] -id: SBO:0000057 -name: mass action rate law for third order irreversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products\, and the change of a product quantity is proportional to the cube of one reactant quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R\n \n \n k\n R\n R\n R\n \n \n\n" [src_code:NR] -is_a: SBO:0000056 ! mass action rate law for third order irreversible reactions\, one reactant -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000058 -name: mass action rate law for third order irreversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant and the square of the quantity of the other reactant." [src_code:NR] -is_a: SBO:0000055 ! mass action rate law for third order irreversible reactions - -[Term] -id: SBO:0000059 -name: mass action rate law for third order irreversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant and the square of the quantity of the other reactant. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R1\n R2\n \n \n k\n R1\n R1\n R2\n \n \n\n" [src_code:NR] -is_a: SBO:0000058 ! mass action rate law for third order irreversible reactions\, two reactants -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000060 -name: mass action rate law for third order irreversible reactions\, three reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of three reactants." [src_code:NR] -is_a: SBO:0000055 ! mass action rate law for third order irreversible reactions - -[Term] -id: SBO:0000061 -name: mass action rate law for third order irreversible reactions\, three reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products\, and the change of a product quantity is proportional to the product of three reactant quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R1\n R2\n R3\n \n \n k\n R1\n R2\n R3\n \n \n\n" [src_code:NR] -is_a: SBO:0000060 ! mass action rate law for third order irreversible reactions\, three reactants -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000062 -name: continuous framework -def: "Modelling approach where the quantities of participants are considered continuous\, and represented by real values. The associated simulation methods make use of differential equations." [src_code:NR] -is_a: SBO:0000004 ! modelling framework - -[Term] -id: SBO:0000063 -name: discrete framework -def: "Modelling approach where the quantities of participants are considered discrete\, and represented by integer values. The associated simulation methods can be deterministic or stochastic. " [src_code:NR] -is_a: SBO:0000004 ! modelling framework - -[Term] -id: SBO:0000064 -name: mathematical expression -def: "Formal representation of a calculus linking parameters and variables of a model." [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000065 -name: forward zeroth order rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction independant of the reactant quantities. This parameter encompasses all the contributions to the velocity. It is to be used in a reaction modelled using a discrete framework. " [src_code:NR] -is_a: SBO:0000155 ! forward rate constant\, discrete case -is_a: SBO:0000162 ! forward zeroth order rate constant - -[Term] -id: SBO:0000066 -name: forward unimolecular rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving only one reactant. This parameter encompasses all the contributions to the velocity except the quantity of the reactant. It is to be used in a reaction modelled using a discrete framework. \n" [src_code:NR] -is_a: SBO:0000022 ! forward unimolecular rate constant -is_a: SBO:0000155 ! forward rate constant\, discrete case - -[Term] -id: SBO:0000067 -name: forward bimolecular rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving two reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a discrete framework. " [src_code:NR] -is_a: SBO:0000023 ! forward bimolecular rate constant -is_a: SBO:0000155 ! forward rate constant\, discrete case - -[Term] -id: SBO:0000068 -name: forward trimolecular rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction involving three reactants. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a discrete framework. " [src_code:NR] -is_a: SBO:0000024 ! forward trimolecular rate constant -is_a: SBO:0000155 ! forward rate constant\, discrete case - -[Term] -id: SBO:0000069 -name: mass action rate law for zeroth order reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant." [src_code:NR] -is_a: SBO:0000042 ! mass action rate law for reversible reactions - -[Term] -id: SBO:0000070 -name: mass action rate law for zeroth order forward\, first order reverse\, reversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n P\n \n \n kf\n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000069 ! mass action rate law for zeroth order reversible reactions - -[Term] -id: SBO:0000071 -name: mass action rate law for zeroth order forward\, second order reverse\, reversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional totwo product quantities." [src_code:NR] -is_a: SBO:0000069 ! mass action rate law for zeroth order reversible reactions - -[Term] -id: SBO:0000072 -name: mass action rate law for zeroth order forward\, second order reverse\, reversible reactions\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n\n\n \n kf\n kr\n P\n \n \n kf\n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000071 ! mass action rate law for zeroth order forward\, second order reverse\, reversible reactions\, continuous scheme - -[Term] -id: SBO:0000073 -name: mass action rate law for zeroth order forward\, second order reverse\, reversible reactions\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n\n \n kf\n kr\n P1\n P2\n \n \n kf\n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000071 ! mass action rate law for zeroth order forward\, second order reverse\, reversible reactions\, continuous scheme - -[Term] -id: SBO:0000074 -name: mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to three product quantities." [src_code:NR] -is_a: SBO:0000069 ! mass action rate law for zeroth order reversible reactions - -[Term] -id: SBO:0000075 -name: mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n P\n \n \n kf\n \n \n kr\n P\n P\n P\n \n \n \n\n\n\n" [src_code:NR] -is_a: SBO:0000074 ! mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, continuous scheme - -[Term] -id: SBO:0000076 -name: mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n P1\n P2\n \n \n kf\n \n \n kr\n P1\n P2\n P2\n \n \n \n\n\n\n" [src_code:NR] -is_a: SBO:0000074 ! mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, continuous scheme - -[Term] -id: SBO:0000077 -name: mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is constant. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n P1\n P2\n P3\n \n \n kf\n \n \n kr\n P1\n P2\n P3\n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000074 ! mass action rate law for zeroth order forward\, third order reverse\, reversible reactions\, continuous scheme - -[Term] -id: SBO:0000078 -name: mass action rate law for first order reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant." [src_code:NR] -is_a: SBO:0000042 ! mass action rate law for reversible reactions - -[Term] -id: SBO:0000079 -name: mass action rate law for first order forward\, zeroth order reverse\, reversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n \n \n \n \n kf\n R\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000078 ! mass action rate law for first order reversible reactions - -[Term] -id: SBO:0000080 -name: mass action rate law for first order forward\, first order reverse\, reversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000078 ! mass action rate law for first order reversible reactions - -[Term] -id: SBO:0000081 -name: mass action rate law for first order forward\, second order reverse\, reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to two product quantities." [src_code:NR] -is_a: SBO:0000078 ! mass action rate law for first order reversible reactions - -[Term] -id: SBO:0000082 -name: mass action rate law for first order forward\, second order reverse\, reversible reactions\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000081 ! mass action rate law for first order forward\, second order reverse\, reversible reactions - -[Term] -id: SBO:0000083 -name: mass action rate law for first order forward\, second order reverse\, reversible reactions\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000081 ! mass action rate law for first order forward\, second order reverse\, reversible reactions - -[Term] -id: SBO:0000084 -name: mass action rate law for first order forward\, third order reverse\, reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to three product quantities." [src_code:NR] -is_a: SBO:0000078 ! mass action rate law for first order reversible reactions - -[Term] -id: SBO:0000085 -name: mass action rate law for first order forward\, third order reverse\, reversible reactions\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000084 ! mass action rate law for first order forward\, third order reverse\, reversible reactions - -[Term] -id: SBO:0000086 -name: mass action rate law for first order forward\, third order reverse\, reversible reactions\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000084 ! mass action rate law for first order forward\, third order reverse\, reversible reactions - -[Term] -id: SBO:0000087 -name: mass action rate law for first order forward\, third order reverse\, reversible reactions\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P1\n P2\n P3\n \n \n \n \n kf\n R\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000084 ! mass action rate law for first order forward\, third order reverse\, reversible reactions - -[Term] -id: SBO:0000088 -name: mass action rate law for second order reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to two reactant quantities." [src_code:NR] -is_a: SBO:0000042 ! mass action rate law for reversible reactions - -[Term] -id: SBO:0000089 -name: mass action rate law for second order forward\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity." [src_code:NR] -is_a: SBO:0000088 ! mass action rate law for second order reversible reactions - -[Term] -id: SBO:0000090 -name: mass action rate law for second order forward\, zeroth order reverse\, reversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n \n \n \n \n kf\n R\n R\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000089 ! mass action rate law for second order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000091 -name: mass action rate law for second order forward\, first order reverse\, reversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000089 ! mass action rate law for second order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000092 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the quantity of two products." [src_code:NR] -is_a: SBO:0000089 ! mass action rate law for second order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000093 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, one reactant\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000092 ! mass action rate law for second order forward\, second order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000094 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000092 ! mass action rate law for second order forward\, second order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000095 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the quantity of three products." [src_code:NR] -is_a: SBO:0000089 ! mass action rate law for second order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000096 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000095 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000097 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000095 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000098 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the square of one reactant quantity. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P1\n P2\n P3\n \n \n \n \n kf\n R\n R\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000095 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000099 -name: mass action rate law for second order forward\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities." [src_code:NR] -is_a: SBO:0000088 ! mass action rate law for second order reversible reactions - -[Term] -id: SBO:0000100 -name: mass action rate law for second order forward\, zeroth order reverse\, reversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n \n \n \n \n kf\n R1\n R2\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000099 ! mass action rate law for second order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000101 -name: mass action rate law for second order forward\, first order reverse\, reversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000099 ! mass action rate law for second order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000102 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the quantity of two products." [src_code:NR] -is_a: SBO:0000099 ! mass action rate law for second order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000103 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, two reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000102 ! mass action rate law for second order forward\, second order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000104 -name: mass action rate law for second order forward\, second order reverse\, reversible reactions\, two reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P1\n P2\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000102 ! mass action rate law for second order forward\, second order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000105 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the quantity of three products." [src_code:NR] -is_a: SBO:0000099 ! mass action rate law for second order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000106 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000105 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000107 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P1\n P2\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000105 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000108 -name: mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of two reactant quantities. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P1\n P2\n P3\n \n \n \n \n kf\n R1\n R2\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000105 ! mass action rate law for second order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000109 -name: mass action rate law for third order reversible reactions -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of a reactant quantity." [src_code:NR] -is_a: SBO:0000042 ! mass action rate law for reversible reactions - -[Term] -id: SBO:0000110 -name: mass action rate law for third order forward\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant." [src_code:NR] -is_a: SBO:0000109 ! mass action rate law for third order reversible reactions - -[Term] -id: SBO:0000111 -name: mass action rate law for third order forward\, zeroth order reverse\, reversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n \n \n \n \n kf\n R1\n R1\n R2\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000110 ! mass action rate law for third order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000112 -name: mass action rate law for third order forward\, first order reverse\, reversible reactions\, two reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000110 ! mass action rate law for third order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000113 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the quantity of two products." [src_code:NR] -is_a: SBO:0000110 ! mass action rate law for third order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000114 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, two reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000113 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000115 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, two reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n P1\n P2\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000113 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000116 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the quantity of three products." [src_code:NR] -is_a: SBO:0000110 ! mass action rate law for third order forward\, reversible reactions\, two reactants - -[Term] -id: SBO:0000117 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000116 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000118 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n P1\n P2\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000116 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000119 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the quantity of one reactant and the square of quantity of the other reactant. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n P1\n P2\n P3\n \n \n \n \n kf\n R1\n R1\n R2\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000116 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, two reactants - -[Term] -id: SBO:0000120 -name: mass action rate law for third order forward\, reversible reactions\, three reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities." [src_code:NR] -is_a: SBO:0000109 ! mass action rate law for third order reversible reactions - -[Term] -id: SBO:0000121 -name: mass action rate law for third order forward\, zeroth order reverse\, reversible reactions\, three reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n R3\n \n \n \n \n kf\n R1\n R2\n R3\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000120 ! mass action rate law for third order forward\, reversible reactions\, three reactants - -[Term] -id: SBO:0000122 -name: mass action rate law for third order forward\, first order reverse\, reversible reactions\, three reactants\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n R3\n P\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000120 ! mass action rate law for third order forward\, reversible reactions\, three reactants - -[Term] -id: SBO:0000123 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, three reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the quantity of two products." [src_code:NR] -is_a: SBO:0000120 ! mass action rate law for third order forward\, reversible reactions\, three reactants - -[Term] -id: SBO:0000124 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, three reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n R3\n P\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000123 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, three reactants - -[Term] -id: SBO:0000125 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, three reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n R3\n P1\n P2\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000123 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, three reactants - -[Term] -id: SBO:0000126 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the quantity of three products." [src_code:NR] -is_a: SBO:0000120 ! mass action rate law for third order forward\, reversible reactions\, three reactants - -[Term] -id: SBO:0000127 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R1\n R2\n R3\n P\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000126 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants - -[Term] -id: SBO:0000128 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n R3\n P1\n P2\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000126 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants - -[Term] -id: SBO:0000129 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the product of three reactant quantities. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R1\n R2\n R3\n P1\n P2\n P3\n \n \n \n \n kf\n R1\n R2\n R3\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000126 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, three reactants - -[Term] -id: SBO:0000130 -name: mass action rate law for third order forward\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity." [src_code:NR] -is_a: SBO:0000109 ! mass action rate law for third order reversible reactions - -[Term] -id: SBO:0000131 -name: mass action rate law for third order forward\, zeroth order reverse\, reversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is constant. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n \n \n \n \n kf\n R\n R\n R\n \n kr\n \n \n\n" [src_code:NR] -is_a: SBO:0000130 ! mass action rate law for third order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000132 -name: mass action rate law for third order forward\, first order reverse\, reversible reactions\, one reactant\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the quantity of one product. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000130 ! mass action rate law for third order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000133 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the quantity of two products." [src_code:NR] -is_a: SBO:0000130 ! mass action rate law for third order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000134 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, one reactant\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the square of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000133 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000135 -name: mass action rate law for third order forward\, second order reverse\, reversible reactions\, one reactant\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the product of two product quantities. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000133 ! mass action rate law for third order forward\, second order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000136 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the quantity of three products." [src_code:NR] -is_a: SBO:0000130 ! mass action rate law for third order forward\, reversible reactions\, one reactant - -[Term] -id: SBO:0000137 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant\, one product\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the cube of one product quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P\n P\n P\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000136 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000138 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant\, two products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the quantity of one product and the square of the quantity of the other product. It is to be used in a reaction modelled using a continuous framework. \n\n \n kf\n kr\n R\n P1\n P2\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P1\n P1\n P2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000136 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000139 -name: mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant\, three products\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does include a reverse process that creates the reactants from the products. The rate of the forward process is proportional to the cube of one reactant quantity. The rate of the reverse process is proportional to the product of three product quantities. It is to be used in a reaction modelled using a continuous framework.\n\n \n kf\n kr\n R\n P1\n P2\n P3\n \n \n \n \n kf\n R\n R\n R\n \n \n \n kr\n P1\n P2\n P3\n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000136 ! mass action rate law for third order forward\, third order reverse\, reversible reactions\, one reactant - -[Term] -id: SBO:0000140 -name: mass action rate law for zeroth order irreversible reactions\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is constant. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n \n c\n \n \n\n" [src_code:NR] -is_a: SBO:0000043 ! mass action rate law for zeroth order irreversible reactions -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000141 -name: mass action rate law for first order irreversible reactions\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R\n \n \n c\n R\n \n \n\n" [src_code:NR] -is_a: SBO:0000044 ! mass action rate law for first order irreversible reactions -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000142 -name: mass action rate law for second order irreversible reactions\, one reactant\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the square of one reactant quantity. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R\n \n \n c\n \n \n \n \n R\n \n \n R\n 1\n \n \n 2\n \n \n \n\n\n\n" [src_code:NR] -is_a: SBO:0000050 ! mass action rate law for second order irreversible reactions\, one reactant -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000143 -name: mass action rate law for second order irreversible reactions\, two reactants\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of two reactants. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R1\n R2\n \n \n c\n R1\n R2\n \n \n\n" [src_code:NR] -is_a: SBO:0000053 ! mass action rate law for second order irreversible reactions\, two reactants -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000144 -name: mass action rate law for third order irreversible reactions\, one reactant\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the cube of one reactant quantity. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R\n \n \n c\n \n \n \n \n R\n \n \n R\n 1\n \n \n \n R\n 2\n \n \n 6\n \n \n \n \n" [src_code:NR] -is_a: SBO:0000056 ! mass action rate law for third order irreversible reactions\, one reactant -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000145 -name: mass action rate law for third order irreversible reactions\, two reactants\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of one reactant and the square of the quantity of the other reactant. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R1\n R2\n \n \n c\n R1\n \n \n \n \n R2\n \n \n R2\n 1\n \n \n 2\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000058 ! mass action rate law for third order irreversible reactions\, two reactants -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000146 -name: mass action rate law for third order irreversible reactions\, three reactants\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of three reactants. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R1\n R2\n R3\n \n \n c\n R1\n R2\n R3\n \n \n\n" [src_code:NR] -is_a: SBO:0000060 ! mass action rate law for third order irreversible reactions\, three reactants -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000147 -name: thermodynamic temperature -def: "Temperature is the physical property of a system which underlies the common notions of \"hot\" and \"cold\"\, the material with the higher temperature is said to be hotter. Temperature is a quantity related to the average kinetic energy of the particles in a substance. The 10th Conference Generale des Poids et Mesures decided to define the thermodynamic temperature scale by choosing the triple point of water as the fundamental fixed point\, and assigning to it the temperature 273\,16 degrees Kelvin\, exactly (0.01 degree Celsius)." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000148 -name: temperature difference -def: "Quantity resulting from the difference between two thermodynamic temperatures. A difference or interval of temperature may be expressed in Kelvins or in degrees Celsius.\n" [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000149 -name: number of substrates -def: "Number of molecules which are acted upon by an enzyme." [src_code:NR] -is_a: SBO:0000157 ! number of reactants - -[Term] -id: SBO:0000150 -name: enzymatic rate law for irreversible non-modulated non-interacting reactant enzymes -def: "Kinetics of enzymes that react with one or several substances\, their substrates\, that bind independently. The enzymes do not catalyse the reactions in both directions. \n\n \n Et\n kp\n n\n S\n K\n \n \n \n \n Et\n kp\n \n \n i \n 1 \n n \n \n \n \n \n S\n i \n \n \n \n K\n i \n \n \n \n \n \n \n i \n \n 1 \n \n \n n \n \n \n \n 1\n \n \n \n \n S\n i \n \n \n \n K\n i \n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000268 ! enzymatic rate law - -[Term] -id: SBO:0000151 -name: enzymatic rate law for irreversible non-modulated non-interacting bireactant enzymes -def: "Kinetics of enzymes that react with two substances\, their substrates\, that bind independently. The enzymes do not catalyse the reactions in both directions. \n\n \n Et\n kp\n n\n S1\n S2\n K1\n K2\n \n \n \n \n Et\n kp\n \n \n \n \n S1 \n K1 \n \n \n \n S2 \n K2 \n \n \n \n \n \n \n \n 1\n \n \n S1 \n K1 \n \n \n \n \n 1\n \n \n S2 \n K2 \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000150 ! enzymatic rate law for irreversible non-modulated non-interacting reactant enzymes - -[Term] -id: SBO:0000152 -name: enzymatic rate law for irreversible non-modulated non-interacting trireactant enzymes -def: "Kinetics of enzymes that react with three substances\, their substrates\, that bind independently. The enzymes do not catalyse the reactions in both directions.\n\n \n Et\n kp\n n\n S1\n S2\n S3\n K1\n K2\n K3\n \n \n \n \n Et\n kp\n \n \n \n \n S1 \n K1 \n \n \n \n S2 \n K2 \n \n \n \n S3 \n K3 \n \n \n \n \n \n \n \n 1\n \n \n S1 \n K1 \n \n \n \n \n 1\n \n \n S2 \n K2 \n \n \n \n \n 1\n \n \n S3 \n K3 \n \n \n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000150 ! enzymatic rate law for irreversible non-modulated non-interacting reactant enzymes - -[Term] -id: SBO:0000153 -name: forward rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction. This parameter encompasses all the contributions to the velocity except the quantity of the reactants." [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000154 -name: forward rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000155 -name: forward rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a discrete framework." [src_code:NR] -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000156 -name: reverse rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. " [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000157 -name: number of reactants -def: "Number of different substances consumed by a chemical reaction." [src_code:NR] -is_a: SBO:0000188 ! number of biochemical items - -[Term] -id: SBO:0000158 -name: order of a reaction with respect to a reactant -def: "The order of a reaction with respect to a certain reactant is defined as the power to which its concentration term in the rate equation is raised." [src_code:NR] -is_a: SBO:0000382 ! biochemical exponential coefficient - -[Term] -id: SBO:0000159 -name: non-integral order rate constant -def: "Numerical parameter that quantifies the velocity of a chemical reaction where reactants have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the reactants." [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000160 -name: forward non-integral order rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction where reactants have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the reactants." [src_code:NR] -is_a: SBO:0000153 ! forward rate constant -is_a: SBO:0000159 ! non-integral order rate constant - -[Term] -id: SBO:0000161 -name: reverse non-integral order rate constant -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction where products have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the products." [src_code:NR] -is_a: SBO:0000156 ! reverse rate constant -is_a: SBO:0000159 ! non-integral order rate constant - -[Term] -id: SBO:0000162 -name: forward zeroth order rate constant -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction independant of the reactant quantities. This parameter encompasses all the contributions to the velocity." [src_code:NR] -is_a: SBO:0000046 ! zeroth order rate constant -is_a: SBO:0000153 ! forward rate constant - -[Term] -id: SBO:0000163 -name: mass action rate law for irreversible reactions\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n n\n mu\n R\n \n \n k\n \n \n i \n 0 \n n \n \n \n \n \n R\n i \n \n \n \n mu\n i \n \n \n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000164 -name: second order irreversible mass action kinetics\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to two reactant quantity. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R\n \n \n k\n \n \n i \n 1 \n 2 \n \n \n R\n i \n \n \n \n \n\n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000165 -name: third order irreversible mass action kinetics\, continuous scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to three reactant quantities. It is to be used in a reaction modelled using a continuous framework. \n\n \n k\n R\n \n \n k\n \n \n i \n 1 \n 3 \n \n \n R\n i \n \n \n \n \n\n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000166 -name: mass action rate law for irreversible reactions\, discrete scheme -def: "Reaction scheme where the products are created from the reactants and the change of a product quantity is proportional to the product of reactant activities. The reaction scheme does not include any reverse process that creates the reactants from the products. It is to be used in a reaction modelled using a discrete framework.\n\n \n c\n n\n mu\n R\n \n \n c\n \n \n i \n 0 \n n \n \n \n \n \n \n \n R\n i \n \n \n \n \n \n \n \n \n \n \n R\n i \n \n \n \n mu\n i \n \n \n \n \n \n \n \n mu\n i \n \n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000041 ! mass action rate law for irreversible reactions - -[Term] -id: SBO:0000231 -name: occurring entity representation -def: "Representation of an entity that manifests\, unfolds or develops through time\, such as a discrete event\, or a mutual or reciprocal action or influence that happens between participating physical entities\, and/or other occurring entities. " [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000232 -name: obsolete event -def: "A phenomenon that takes place and which may be observable\, or may be determined to have occurred as the result of an action or process." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000167 -name: biochemical or transport reaction -def: "An event involving one or more physical entities that modifies the structure\, location or free energy of at least one of the participants." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000168 -name: control -def: "Modification of the execution of an event or a process." [src_code:NR] -synonym: "modulation" [] -synonym: "regulation" [] -is_a: SBO:0000374 ! relationship - -[Term] -id: SBO:0000169 -name: inhibition -def: "Negative modulation of the execution of a process." [src_code:NR] -is_a: SBO:0000168 ! control - -[Term] -id: SBO:0000170 -name: stimulation -def: "Positive modulation of the execution of a process." [src_code:NR] -is_a: SBO:0000168 ! control - -[Term] -id: SBO:0000171 -name: necessary stimulation -def: "Control that is necessary to the execution of a process." [src_code:NR] -synonym: " absolute stimulation" [] -synonym: "trigger" [] -is_a: SBO:0000170 ! stimulation - -[Term] -id: SBO:0000172 -name: catalysis -def: "Modification of the velocity of a reaction by lowering the energy of the transition state." [src_code:NR] -is_a: SBO:0000170 ! stimulation - -[Term] -id: SBO:0000173 -name: and -def: "All the preceding events or participating entities are necessary to perform the control." [src_code:NR] -is_a: SBO:0000237 ! logical combination - -[Term] -id: SBO:0000174 -name: or -def: "Any of the preceding events or participating entities are necessary to perform the control." [src_code:NR] -is_a: SBO:0000237 ! logical combination - -[Term] -id: SBO:0000175 -name: xor -def: "Only one of the preceding events or participating entities can perform the control at one time." [src_code:NR] -synonym: "exclusive or" [] -is_a: SBO:0000237 ! logical combination - -[Term] -id: SBO:0000176 -name: biochemical reaction -def: "An event involving one or more chemical entities that modifies the electrochemical structure of at least one of the participants.\n" [src_code:NR] -is_a: SBO:0000167 ! biochemical or transport reaction - -[Term] -id: SBO:0000177 -name: non-covalent binding -def: "Interaction between several biochemical entities that results in the formation of a non-covalent complex" [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000178 -name: cleavage -def: "Rupture of a covalent bond resulting in the conversion of one physical entity into several physical entities." [src_code:NR] -is_a: SBO:0000182 ! conversion - -[Term] -id: SBO:0000179 -name: degradation -def: "Complete disappearance of a physical entity." [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000180 -name: dissociation -def: "Transformation of a non-covalent complex that results in the formation of several independent biochemical entities" [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000181 -name: conformational transition -def: "Biochemical reaction that does not result in the modification of covalent bonds of reactants\, but rather modifies the conformation of some reactants\, that is the relative position of their atoms in space." [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000182 -name: conversion -def: "Biochemical reaction that results in the modification of some covalent bonds." [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000183 -name: transcription -def: "Process through which a DNA sequence is copied to produce a complementary RNA." [src_code:NR] -is_a: SBO:0000205 ! composite biochemical process - -[Term] -id: SBO:0000184 -name: translation -def: "Process in which a polypeptide chain is produced from a messenger RNA." [src_code:NR] -is_a: SBO:0000205 ! composite biochemical process - -[Term] -id: SBO:0000185 -name: transport reaction -def: "Movement of a physical entity without modification of the structure of the entity." [src_code:NR] -is_a: SBO:0000167 ! biochemical or transport reaction - -[Term] -id: SBO:0000186 -name: maximal velocity -def: "Limiting maximal velocity of an enzymatic reaction\, reached when the substrate is in large excess and all the enzyme is complexed.\n \n Et\n kcat\n \n \n Et\n kcat\n \n \n" [src_code:NR] -synonym: "Vmax" [] -is_a: SBO:0000046 ! zeroth order rate constant - -[Term] -id: SBO:0000187 -name: Henri-Michaelis-Menten equation\, Vmax form -def: "Version of Henri-Michaelis-Menten equation where kp*\[E\]t is replaced by the maximal velocity\, Vmax\, reached when all the enzyme is active. \n\n \n Vmax\n S\n Ks\n \n \n \n \n Vmax\n S\n \n \n \n Ks\n S\n \n \n \n\n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000188 -name: number of biochemical items -def: "A number of objects of the same type\, identical or different\, involved in a biochemical event." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000189 -name: number of binding sites -def: "Number of regions on a reactant to which specific other reactants\, in this context collectively called ligands\, form a chemical bond." [src_code:NR] -is_a: SBO:0000188 ! number of biochemical items - -[Term] -id: SBO:0000190 -name: Hill coefficient -def: "Empirical parameter created by Archibald Vivian Hill to describe the cooperative binding of oxygen on hemoglobine (Hill (1910). The possible effects of the aggregation of the molecules of haemoglobin on its dissociation curves. J Physiol 40\: iv-vii)." [src_code:NR] -is_a: SBO:0000382 ! biochemical exponential coefficient - -[Term] -id: SBO:0000191 -name: Hill constant -def: "Empirical constant created by Archibald Vivian Hill to describe the cooperative binding of oxygen on hemoglobine (Hill (1910). The possible effects of the aggregation of the molecules of haemoglobin on its dissociation curves. J Physiol 40\: iv-vii). Different from a microscopic dissociation constant\, it has the dimension of concentration to the power of the Hill coefficient." [src_code:NR] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000192 -name: Hill-type rate law\, generalised form -def: "Empirical equation created by Archibald Vivian Hill to describe the cooperative binding of oxygen on hemoglobine (Hill (1910). The possible effects of the aggregation of the molecules of haemoglobin on its dissociation curves. J Physiol 40\: iv-vii).\n\n \n Vmax\n R\n K\n h\n n\n \n \n \n \n Vmax\n \n \n R\n h\n \n \n \n \n \n \n K\n n\n \n \n \n R\n h\n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000001 ! rate law - -[Term] -id: SBO:0000193 -name: equilibrium or steady-state constant -def: "Constant with the dimension of a powered concentration. It is determined at half-saturation\, half-activity etc. " [src_code:NR] -is_a: SBO:0000308 ! equilibrium or steady-state characteristic - -[Term] -id: SBO:0000194 -name: pseudo-dissociation constant -def: "Dissociation constant equivalent to an intrinsic microscopic dissociation constant\, but obtained from an averaging process\, for instance by extracting the root of a Hill constant. " [src_code:NR] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000195 -name: Hill-type rate law\, microscopic form -def: "Hill equation rewritten by creating a pseudo-microscopic constant\, equal to the Hill constant powered to the opposite of the Hill coefficient.\n\n \n Vmax\n R\n K\n h\n \n \n \n \n Vmax\n \n \n R\n h\n \n \n \n \n \n \n K\n h\n \n \n \n R\n h\n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000192 ! Hill-type rate law\, generalised form - -[Term] -id: SBO:0000196 -name: concentration of an entity pool -def: "The amount of an entity per unit of volume. " [src_code:NR] -synonym: "\[X\]" [] -is_a: SBO:0000226 ! density of an entity pool - -[Term] -id: SBO:0000197 -name: specific concentration of an entity -def: "Concentration of an object divided by the value of another parameter having the dimension of a concentration." [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000198 -name: Hill-type rate law\, reduced form -def: "Hill equation rewritten by replacing the concentration of reactant with its reduced form\, that is the concentration divide by a pseudo-microscopic constant\, equal to the Hill constant powered to the opposite of the Hill coefficient.\n\n \n Vmax\n R*\n h\n \n \n \n \n Vmax\n \n \n R*\n h\n \n \n \n \n 1\n \n \n R*\n h\n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000192 ! Hill-type rate law\, generalised form - -[Term] -id: SBO:0000199 -name: normalised enzymatic rate law for unireactant enzymes -def: "Kinetics of enzymes that react only with one substance\, their substrate. The total enzyme concentration is considered to be equal to 1\, therefore the maximal velocity equals the catalytic constant.\n\n \n kcat\n S\n Ks\n \n \n \n \n kcat\n S\n \n \n \n Ks\n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000028 ! enzymatic rate law for irreversible non-modulated non-interacting unireactant enzymes - -[Term] -id: SBO:0000200 -name: redox reaction -def: "Chemical process in which atoms have their oxidation number (oxidation state) changed." [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000201 -name: oxidation -def: "Chemical process during which a molecular entity loses electrons." [src_code:NR] -is_a: SBO:0000200 ! redox reaction - -[Term] -id: SBO:0000202 -name: reduction -def: "Chemical process in which a molecular entity gain electrons." [src_code:NR] -is_a: SBO:0000200 ! redox reaction - -[Term] -id: SBO:0000203 -name: duplication -def: "Reaction in which a reactant gives birth to two products identical to itself." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000204 -name: dna replication -def: "Process in which a DNA duplex is transformed into two identical DNA duplexes." [src_code:NR] -is_a: SBO:0000205 ! composite biochemical process - -[Term] -id: SBO:0000205 -name: composite biochemical process -def: "Process that involves the participation of chemical or biological entities and is composed of several elementary steps or reactions. " [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000206 -name: competitive inhibitor -def: "Substance that decreases the probability of a chemical reaction\, without itself being consumed or transformed by the reaction\, by stericaly hindering the interaction between reactants. " [src_code:NR] -is_a: SBO:0000020 ! inhibitor - -[Term] -id: SBO:0000207 -name: non-competitive inhibitor -def: "Substance that decreases the probability of a chemical reaction\, without itself being consumed or transformed by the reaction\, and without sterically hindering the interaction between reactants. " [src_code:NR] -is_a: SBO:0000020 ! inhibitor - -[Term] -id: SBO:0000208 -name: acid-base reaction -def: "Chemical reaction where a proton is given by a compound\, the acid\, to another one\, the base (Brønsted-Lowry definition). An alternative\, more general\, definition is a reaction where a compound\, the base\, gives a pair of electrons to another\, the acid (Lewis definition)." [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000209 -name: ionisation -def: "Ionization is the physical process of converting an atom or molecule into an ion by changing the difference between the number of protons and electrons. " [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000210 -name: addition of a chemical group -def: "Covalent reaction that results in the addition of a chemical group on a molecule." [src_code:NR] -is_a: SBO:0000182 ! conversion - -[Term] -id: SBO:0000211 -name: removal of a chemical group -def: "Covalent reaction that results in the removal of a chemical group from a molecule." [src_code:NR] -is_a: SBO:0000182 ! conversion - -[Term] -id: SBO:0000212 -name: protonation -def: "Addition of a proton (H+) to a chemical entity." [src_code:NR] -is_a: SBO:0000208 ! acid-base reaction -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000213 -name: deprotonation -def: "Removal of a proton (hydrogen ion H+) from a chemical entity." [src_code:NR] -is_a: SBO:0000208 ! acid-base reaction -is_a: SBO:0000211 ! removal of a chemical group - -[Term] -id: SBO:0000214 -name: methylation -def: "Addition of a methyl group (-CH3) to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000215 -name: acetylation -def: "Addition of an acetyl group (-COCH3) to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000216 -name: phosphorylation -def: "Addition of a phosphate group (-H2PO4) to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000217 -name: glycosylation -def: "Addition of a saccharide group to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000218 -name: palmitoylation -def: "Addition of a palmitoyl group (CH3-\[CH2\]14-CO-) to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000219 -name: myristoylation -def: "Addition of a myristoyl (CH3-\[CH2\]12-CO-) to a chemical entity." [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000220 -name: sulfation -def: "Addition of a sulfate group (SO4--) to a chemical entity. " [src_code:NR] -synonym: "sulphation" [] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000221 -name: prenylation -def: "Addition of a prenyl group (generic sense) to a chemical entity." [src_code:NR] -synonym: "isoprenylation" [] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000222 -name: farnesylation -def: "Addition of a farnesyl group (CH2-CH=C(CH3)-CH2-CH2-CH=C(CH3)-CH2-CH2-CH=C(CH3)2) to a chemical entity." [src_code:NR] -is_a: SBO:0000221 ! prenylation - -[Term] -id: SBO:0000223 -name: geranylgeranylation -def: "Addition of a geranylgeranyl group (CH2-CH=C(CH3)-CH2-CH2-CH=C(CH3)-CH2-CH2-CH=C(CH3)-CH2-CH2-CH=C(CH3)2) to a chemical entity." [src_code:NR] -is_a: SBO:0000221 ! prenylation - -[Term] -id: SBO:0000224 -name: ubiquitination -def: "Covalent linkage to the protein ubiquitin. " [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000225 -name: delay -def: "Time during which some action is awaited." [src_code:NR] -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000226 -name: density of an entity pool -def: "A quantitative measure of an amount or property of an entity expressed in terms of another dimension\, such as unit length\, area or volume." [src_code:NR] -is_a: SBO:0000360 ! quantity of an entity pool - -[Term] -id: SBO:0000227 -name: mass density of an entity -def: "The mass of an entity expressed with reference to another dimension\, such as unit length\, area or volume." [src_code:NR] -is_a: SBO:0000226 ! density of an entity pool - -[Term] -id: SBO:0000228 -name: volume density of an entity -def: "Mass of an entity per unit volume." [src_code:NR] -is_a: SBO:0000227 ! mass density of an entity - -[Term] -id: SBO:0000229 -name: area density of an entity -def: "The mass of an entity per unit of surface area." [src_code:NR] -is_a: SBO:0000227 ! mass density of an entity - -[Term] -id: SBO:0000230 -name: linear density of an entity -def: "Mass of an entity per unit length." [src_code:NR] -is_a: SBO:0000227 ! mass density of an entity - -[Term] -id: SBO:0000233 -name: hydroxylation -def: "Addition of an hydroxyl group (-OH) to a chemical entity. " [src_code:NR] -is_a: SBO:0000210 ! addition of a chemical group - -[Term] -id: SBO:0000234 -name: logical framework -def: "Modelling approach\, pioneered by Rene Thomas and Stuart Kaufman\, where the evolution of a system is described by the transitions between discrete activity states of \"genes\" that control each other." [src_code:NR] -is_a: SBO:0000004 ! modelling framework - -[Term] -id: SBO:0000235 -name: participant -def: "Entity that affects or is affected by an event." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000236 -name: physical entity representation -def: "Representation of an entity that may participate in an interaction\, a process or relationship of significance.\n" [src_code:NR] -synonym: "new synonym" [] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000237 -name: logical combination -def: "Combining the influence of several entities or events in a unique influence." [src_code:NR] -is_a: SBO:0000374 ! relationship - -[Term] -id: SBO:0000238 -name: not -def: "The preceding event or participating entity cannot participate to the control. " [src_code:NR] -is_a: SBO:0000237 ! logical combination - -[Term] -id: SBO:0000239 -name: allosteric control -def: "Regulation of the influence of a reaction participant by binding an effector to a binding site of the participant different of the site of the participant conveying the influence." [src_code:NR] -is_a: SBO:0000168 ! control - -[Term] -id: SBO:0000240 -name: material entity -def: "A real thing that is defined by its physico-chemical structure.\n" [src_code:NR] -is_a: SBO:0000236 ! physical entity representation - -[Term] -id: SBO:0000241 -name: functional entity -def: "A real thing\, defined by its properties or the actions it performs\, rather than it physico-chemical structure." [src_code:NR] -is_a: SBO:0000236 ! physical entity representation - -[Term] -id: SBO:0000242 -name: channel -def: "A component that allows another component to pass through itself\, possibly connecting different compartments." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000243 -name: gene -def: "A locatable region of genomic sequence\, corresponding to a unit of inheritance\, which is associated with regulatory regions\, transcribed regions and/or other functional sequence regions.\n\nSequence Ontology SO\:0000704" [src_code:NR] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000244 -name: receptor -def: "Participating entity that binds to a specific physical entity and initiates the response to that physical entity.The original concept of the receptor was introduced independently at the end of the 19th century by John Newport Langley (1852-1925) and Paul Ehrlich (1854-1915).\n\nLangley JN.On the reaction of cells and of nerve-endings to certain poisons\, chiefly as regards the reaction of striated muscle to nicotine and to curari. J Physiol. 1905 Dec 30\,33(4-5)\:374-413." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000245 -name: macromolecule -def: "Molecular entity mainly built-up by the repetition of pseudo-identical units.\n\nCHEBI\:33839" [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000246 -name: information macromolecule -def: "Macromolecule whose sequence is encoded in the genome of living organisms." [src_code:NR] -is_a: SBO:0000245 ! macromolecule - -[Term] -id: SBO:0000247 -name: simple chemical -def: "Simple\, non-repetitive chemical entity." [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000248 -name: chemical macromolecule -def: "Macromolecule whose sequence is not directly encoded in the genome." [src_code:NR] -is_a: SBO:0000245 ! macromolecule - -[Term] -id: SBO:0000249 -name: polysaccharide -def: "Macromolecule consisting of a large number of monosaccharide residues linked by glycosidic bonds.\n\nCHEBI\:18154" [src_code:NR] -is_a: SBO:0000248 ! chemical macromolecule - -[Term] -id: SBO:0000250 -name: ribonucleic acid -def: "Macromolecule formed by a repetition of ribonucleosides linked by phosphodiester bonds.\n\nCHEBI\:33697" [src_code:NR] -synonym: "RNA" [] -is_a: SBO:0000246 ! information macromolecule - -[Term] -id: SBO:0000251 -name: deoxyribonucleic acid -def: "Polymer composed of nucleotides containing deoxyribose and linked by phosphodiester bonds.\n\nCHEBI\:16991 " [src_code:NR] -synonym: "DNA" [] -is_a: SBO:0000246 ! information macromolecule - -[Term] -id: SBO:0000252 -name: polypeptide chain -def: "Naturally occurring macromolecule formed by the repetition of amino-acid residues linked by peptidic bonds. A polypeptide chain is synthesized by the ribosome.\n\nCHEBI\:16541" [src_code:NR] -is_a: SBO:0000246 ! information macromolecule - -[Term] -id: SBO:0000253 -name: non-covalent complex -def: "Entity composed of several independant components that are not linked by covalent bonds." [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000254 -name: electrical resistance -def: "Measure of the degree to which an object opposes the passage of an electric current. The SI unit of electrical resistance is the ohm." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000255 -name: physical characteristic -def: "Parameter characterising a physical system or the environment\, and independent of life's influence." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000256 -name: biochemical parameter -def: "Parameter that depends on the biochemical properties of a system." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000257 -name: conductance -def: "Measure of how easily electricity flows along a certain path through an electrical element. The SI derived unit of conductance is the Siemens." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000258 -name: capacitance -def: "Measure of the amount of electric charge stored (or separated) for a given electric potential. The unit of capacitance id the Farad." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000259 -name: voltage -def: "Difference of electrical potential between two points of an electrical network\, expressed in volts." [src_code:NR] -synonym: "electrical potential difference" [] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000260 -name: enzymatic rate law for simple competitive inhibition of irreversible unireactant enzymes by one inhibitor -def: "Inhibition of a unireactant enzyme by one inhibitor that binds once to the free enzyme and prevents the binding of the substrate. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I\n Ki\n \n \n \n S\n \n \n \n\n" [src_code:NR] -synonym: "simple intersecting linear competitive inhibition of unireactant enzymes" [] -is_a: SBO:0000267 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by one inhibitor -is_a: SBO:0000270 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by exclusive inhibitors - -[Term] -id: SBO:0000261 -name: inhibitory constant -def: "Dissociation constant of a compound from a target of which it inhibits the function. " [src_code:NR] -synonym: "inhibition constant" [] -synonym: "Ki" [] -is_a: SBO:0000282 ! dissociation constant - -[Term] -id: SBO:0000262 -name: enzymatic rate law for simple uncompetitive inhibition of irreversible unireactant enzymes -def: "Inhibition of a unireactant enzyme by one inhibitor that binds only to the complex enzyme-substrate and totally prevent the catalysis. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n S\n \n \n 1\n \n \n I\n Ki\n \n \n \n Ks\n \n \n \n\n" [src_code:NR] -synonym: "simple linear uncompetitive inhibition" [] -is_a: SBO:0000458 ! enzymatic rate law for simple uncompetitive inhibition of reversible unireactant enzymes - -[Term] -id: SBO:0000263 -name: relative equilibrium constant -def: "Ratio of an equilibrium constant in a given condition by the same equilibrium constant is not fullfilled." [src_code:NR] -is_a: SBO:0000308 ! equilibrium or steady-state characteristic - -[Term] -id: SBO:0000264 -name: relative inhibition constant -def: "Ratio of the dissociation constant of an inhibitor from the complex enzyme-substrate on the dissociation constant of an inhibitor from the free enzyme." [src_code:NR] -is_a: SBO:0000263 ! relative equilibrium constant - -[Term] -id: SBO:0000265 -name: enzymatic rate law for simple mixed-type inhibition of irreversible unireactant enzymes -def: "Inhibition of a unireactant enzyme by one inhibitor that can bind to the complex enzyme-substrate and the free enzyme\, possibly with different equilibrium constant\, and totally prevent the catalysis. The enzymes do not catalyse the reactions in both directions.\n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n a\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n S\n \n \n 1\n \n \n I\n \n \n a\n Ki\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I\n Ki\n \n \n \n \n \n \n\n" [src_code:NR] -synonym: "simple intersecting linear mixed-type competitive inhibition" [] -is_a: SBO:0000275 ! enzymatic rate law for mixed-type inhibition of irreversible enzymes by mutually exclusive inhibitors - -[Term] -id: SBO:0000266 -name: enzymatic rate law for simple irreversible non-competitive inhibition of unireactant enzymes -def: "Inhibition of a unireactant enzyme by one inhibitor that can bind to the complex enzyme-substrate and the free enzyme with the same equilibrium constant\, and totally prevent the catalysis.\n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n S\n \n \n 1\n \n \n I\n Ki\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I\n Ki\n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000442 ! enzymatic rate law for simple reversible non-competitive inhibition of unireactant enzymes - -[Term] -id: SBO:0000267 -name: enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by one inhibitor -def: "Inhibition of a unireactant enzyme by one inhibitor that can bind one or several times to the free enzyme\, and prevent the binding of the substrate. The enzymes do not catalyse the reactions in both directions.\n\n\n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n S\n \n \n Ks\n \n \n \n \n 1\n \n \n I\n Ki\n \n \n n\n \n \n \n \n \n\n" [src_code:NR] -synonym: "multiple competitive inhibition by one inhibitor of unireactant enzymes" [] -is_a: SBO:0000273 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by non-exclusive non-cooperative inhibitors - -[Term] -id: SBO:0000268 -name: enzymatic rate law -def: "Enzyme kinetics is the study of the rates of chemical reactions that are catalysed by enzymes\, how this rate is controlled\, and how drugs and poisons can inhibit its activity. " [src_code:NR] -is_a: SBO:0000001 ! rate law - -[Term] -id: SBO:0000269 -name: enzymatic rate law for unireactant enzymes -def: "Kinetics of enzymes that catalyse the transformation of only one substrate. " [src_code:NR] -is_a: SBO:0000268 ! enzymatic rate law - -[Term] -id: SBO:0000270 -name: enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by exclusive inhibitors -def: "Inhibition of a unireactant enzyme by inhibitors that bind to the free enzyme on the same binding site than the substrate. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n i \n 1 \n n \n \n \n \n \n I\n i \n \n \n \n Ki\n i \n \n \n \n \n \n S\n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000271 -name: enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by two exclusive inhibitors -def: "Inhibition of a unireactant enzyme by two inhibitors that bind to the free enzyme on the same binding site than the substrate. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I1\n I2\n Ks\n Ki1\n Ki2\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n S\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000270 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by exclusive inhibitors - -[Term] -id: SBO:0000272 -name: number of inhibitors -def: "Number of entities that inhibit a reaction. " [src_code:NR] -is_a: SBO:0000188 ! number of biochemical items - -[Term] -id: SBO:0000273 -name: enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by non-exclusive non-cooperative inhibitors -def: "Inhibition of a unireactant enzyme by inhibitors that bind independently to the free enzyme and preclude the binding of the substrate. The enzymes do not catalyse the reactions in both directions.\n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n n\n m\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n i \n 1 \n n \n \n \n \n \n 1\n \n \n \n \n I\n i \n \n \n \n Ki\n i \n \n \n \n \n \n m\n i \n \n \n \n \n S\n \n \n \n\n\n" [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000274 -name: enzymatic rate law for simple competitive inhibition of irreversible unireactant enzymes by two non-exclusive\, non-cooperative inhibitors -def: "Inhibition of a unireactant enzyme by two inhibitors that can bind independently once to the free enzyme and preclude the binding of the substrate. The enzymes do not catalyse the reactions in both directions.\n \n \n kcat\n Et\n S\n I1\n I2\n Ks\n Ki1\n Ki2\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n \n \n I1\n I2\n \n \n \n Ki1\n Ki2\n \n \n \n \n S\n \n \n \n \n " [src_code:NR] -is_a: SBO:0000273 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by non-exclusive non-cooperative inhibitors -is_a: SBO:0000379 ! enzymatic rate law for simple competitive inhibition of irreversible unireactant enzymes by two non-exclusive inhibitors - -[Term] -id: SBO:0000275 -name: enzymatic rate law for mixed-type inhibition of irreversible enzymes by mutually exclusive inhibitors -def: "Inhibition of a unireactant enzyme by inhibitors that can bind to the complex enzyme-substrate and the free enzyme\, possibly with different equilibrium constants\, and totally prevent the catalysis. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I\n Ks\n Ki\n a\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n i \n 1 \n n \n \n \n \n \n I\n i \n \n \n \n Ki\n i \n \n \n \n \n \n \n \n S\n \n \n 1\n \n \n i \n 1 \n n \n \n \n \n \n I\n i \n \n \n \n \n \n a\n i \n \n \n \n Ki\n i \n \n \n \n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000276 -name: enzymatic rate law for mixed-type inhibition of irreversible unireactant enzymes by two inhibitors -def: "Inhibition of unireactant enzymes by two inhibitors that can bind to the complex enzyme-substrate and the free enzyme\, possibly with different equilibrium constant\, and totally prevent the catalysis. The enzymes do not catalyse the reactions in both directions. \n\n \n kcat\n Et\n S\n I1\n I2\n Ks\n Ki1\n Ki2\n a\n b\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n S\n \n \n 1\n \n \n I1\n \n \n a\n Ki1\n \n \n \n \n I2\n \n \n b\n Ki2\n \n \n \n \n \n \n Ks\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000275 ! enzymatic rate law for mixed-type inhibition of irreversible enzymes by mutually exclusive inhibitors - -[Term] -id: SBO:0000277 -name: enzymatic rate law for non-competitive inhibition of irreversible unireactant enzymes by two exclusively binding inhibitors -def: "Inhibition of unireactant enzymes by two inhibitors that can bind to the complex enzyme-substrate and the free enzyme with the same equilibrium constant and totally prevent the catalysis. \n\n \n kcat\n Et\n S\n I1\n I2\n Ks\n Ki1\n Ki2\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n S\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000276 ! enzymatic rate law for mixed-type inhibition of irreversible unireactant enzymes by two inhibitors - -[Term] -id: SBO:0000278 -name: messenger RNA -def: "A messenger RNA is a ribonucleic acid synthesized during the transcription of a gene\, and that carries the information to encode one or several proteins." [src_code:NR] -synonym: "mRNA" [] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000279 -name: pressure -def: "Pressure (symbol\: p) is the force per unit area applied on a surface in a direction perpendicular to that surface. The unit of pressure is the Pascal (Pa)\, that is equal to 1 Newton per square meter." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000280 -name: ligand -def: "In biochemistry\, a ligand is an effector\, a physical entity that binds to a site on a receptor's surface by intermolecular forces." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000281 -name: equilibrium constant -def: "Quantity characterizing a chemical equilibrium in a chemical reaction\, which is a useful tool to determine the concentration of various reactants or products in a system where chemical equilibrium occurs." [src_code:NR] -synonym: "Keq" [] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000282 -name: dissociation constant -def: "Equilibrium constant that measures the propensity of a larger object to separate (dissociate) reversibly into smaller components\, as when a complex falls apart into its component molecules\, or when a salt splits up into its component ions. The dissociation constant is usually denoted Kd and is the inverse of the affinity constant.\n \n koff\n Kon\n \n \n koff\n Kon\n \n \n\n" [src_code:NR] -synonym: "Kd" [] -is_a: SBO:0000281 ! equilibrium constant -is_a: SBO:0000309 ! dissociation characteristic - -[Term] -id: SBO:0000283 -name: acid dissociation constant -def: "Equilibrium constant that indicates the extent of dissociation of hydrogen ions from an acid. The equilibrium is that of a proton transfer from an acid\, HA\, to water\, H2O. The term for the concentration of water\, \[H2O\]\, is omitted from the general equilibrium constant expression. Ka=(\[H3O+\]*\[A-\])/(HA)" [src_code:NR] -synonym: "Ka" [] -is_a: SBO:0000282 ! dissociation constant -is_a: SBO:0000310 ! acid dissociation characteristic - -[Term] -id: SBO:0000284 -name: transporter -def: "Participating entity that facilitates the movement of another physical entity from a defined subset of the physical environment (for instance a cellular compartment) to another. " [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000285 -name: material entity of unspecified nature -def: "Material entity whose nature is unknown or irrelevant." [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000286 -name: multimer -def: "Non-covalent association of identical\, or pseudo-identical\, entities. By pseudo-identical entities\, we mean biochemical elements that differ chemically\, although remaining globally identical in structure and/or function. Examples are homologous subunits in an hetero-oligomeric receptor." [src_code:NR] -is_a: SBO:0000253 ! non-covalent complex - -[Term] -id: SBO:0000287 -name: EC50 -def: "Concentration of an active compound at which 50% of its maximal effect is observed. The EC50 is not a pure characteristic of the compound but depends on the conditions or the measurement." [src_code:NR] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000288 -name: IC50 -def: "Also called half maximal inhibitory concentration\, it represents the concentration of an inhibitor substance that is required to suppress 50% of an effect. " [src_code:NR] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000289 -name: functional compartment -def: "Logical or physical subset of the event space that contains pools\, that is sets of participants considered identical when it comes to the event they are involved into. A compartment can have any number of dimensions\, including 0\, and be of any size including null." [src_code:NR] -is_a: SBO:0000003 ! participant role - -[Term] -id: SBO:0000290 -name: physical compartment -def: "Specific location of space\, that can be bounded or not. A physical compartment can have 1\, 2 or 3 dimensions." [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000291 -name: empty set -def: "Entity defined by the absence of any actual object. An empty set is often used to represent the source of a creation process or the result of a degradation process. " [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000292 -name: spatial continuous framework -def: "Modelling approach where the quantities of participants are considered continuous\, and represented by real values. The associated simulation methods make use of differential equations. The models take into account the distribution of the entities and describe the spatial fluxes. " [src_code:NR] -is_a: SBO:0000062 ! continuous framework - -[Term] -id: SBO:0000293 -name: non-spatial continuous framework -def: "Modelling approach where the quantities of participants are considered continuous\, and represented by real values. The associated simulation methods make use of differential equations. The models do not take into account the distribution of the entities and describe only the temporal fluxes. " [src_code:NR] -is_a: SBO:0000062 ! continuous framework - -[Term] -id: SBO:0000294 -name: spatial discrete framework -def: "Modelling approach where the quantities of participants are considered discrete\, and represented by integer values. The associated simulation methods can be deterministic or stochastic. The models take into account the distribution of the entities and describe the spatial fluxes. " [src_code:NR] -is_a: SBO:0000063 ! discrete framework - -[Term] -id: SBO:0000295 -name: non-spatial discrete framework -def: "Modelling approach where the quantities of participants are considered discrete\, and represented by integer values. The associated simulation methods can be deterministic or stochastic.The models do not take into account the distribution of the entities and describe only the temporal fluxes. \n" [src_code:NR] -is_a: SBO:0000063 ! discrete framework - -[Term] -id: SBO:0000296 -name: macromolecular complex -def: "Non-covalent complex of one or more macromolecules and zero or more simple chemicals." [src_code:NR] -is_a: SBO:0000253 ! non-covalent complex - -[Term] -id: SBO:0000297 -name: protein complex -def: "Macromolecular complex containing one or more polypeptide chains possibly associated with simple chemicals.\n\nCHEBI\:36080" [src_code:NR] -is_a: SBO:0000296 ! macromolecular complex - -[Term] -id: SBO:0000298 -name: synthetic chemical compound -def: "Chemical entity that is engineered by a human-designed process ex-vivo rather than a produced by a living entity." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000299 -name: metabolite -def: "Substance produced by metabolism or by a metabolic process." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000300 -name: total concentration of enzyme -def: "Total amount of enzyme catalysing a reaction\, divided by the volume of reaction. " [src_code:NR] -synonym: "Et" [] -is_obsolete: true - -[Term] -id: SBO:0000301 -name: total catalytic efficiency -def: "Constant representing the actual efficiency of an enzyme at a given concentration\, taking into account its microscopic catalytic activity and the rates of substrate binding and dissociation.\n\nNB. The symbol Vmax and the names maximum rate and maximum velocity are in widespread use although under normal circumstances there is no finite substrate concentration at which v = V and hence no maximum in the mathematical sense (Eur. J. Biochem. 128\:281-291).\n \n Vmax\n Km\n \n \n Vmax\n Km\n \n \n\n" [src_code:NR] -is_a: SBO:0000035 ! forward unimolecular rate constant\, continuous case - -[Term] -id: SBO:0000302 -name: catalytic efficiency -def: "Constant representing the actual efficiency of an enzyme\, taking into account its microscopic catalytic activity and the rates of substrate binding and dissociation.\n \n kcat\n Km\n \n \n kcat\n Km\n \n \n" [src_code:NR] -is_a: SBO:0000036 ! forward bimolecular rate constant\, continuous case - -[Term] -id: SBO:0000303 -name: biochemical potential -def: "Derivative of a biochemical energy per a substance." [src_code:NR] -synonym: "chemical potential" [] -is_a: SBO:0000308 ! equilibrium or steady-state characteristic - -[Term] -id: SBO:0000304 -name: pH -def: "Negative logarithm (base 10) of the activity of hydrogen in a solution. Ina diluted solution\, this activity is equal to the concentration of protons (in fact of ions H3O+). The pH is proportional to the chemical potential of hydrogen\, by the relation\: pH = -µH ÷ 2.3RT. (with µH=-RTln\[H+\])." [src_code:NR] -synonym: "potential of hydrogen" [] -is_a: SBO:0000303 ! biochemical potential - -[Term] -id: SBO:0000305 -name: pOH -def: "Negative logarithm (base 10) of the activity of hydroxyde in a solution. In a diluted solution\, this activity is equal to the concentration of ions HO-." [src_code:NR] -is_a: SBO:0000303 ! biochemical potential - -[Term] -id: SBO:0000306 -name: pK -def: "negative logarithm (base 10) of a dissociation constant.\n \n K\n \n \n \n \n K\n \n \n \n" [src_code:NR] -synonym: "dissociation potential" [] -is_a: SBO:0000303 ! biochemical potential -is_a: SBO:0000309 ! dissociation characteristic - -[Term] -id: SBO:0000307 -name: pKa -def: "negative logarithm (base 10) of an acid dissociation constant.\n \n Ka\n \n \n \n \n Ka\n \n \n \n" [src_code:NR] -synonym: "potential of acid" [] -is_a: SBO:0000306 ! pK -is_a: SBO:0000310 ! acid dissociation characteristic - -[Term] -id: SBO:0000308 -name: equilibrium or steady-state characteristic -def: "Quantitative parameter that characterises a biochemical equilibrium. " [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000309 -name: dissociation characteristic -def: "Quantitative parameter that characterises a dissociation. " [src_code:NR] -is_a: SBO:0000308 ! equilibrium or steady-state characteristic - -[Term] -id: SBO:0000310 -name: acid dissociation characteristic -def: "Quantitative parameter that characterises an acid-base reaction." [src_code:NR] -is_a: SBO:0000309 ! dissociation characteristic - -[Term] -id: SBO:0000311 -name: heterogeneous nuclear RNA -def: "Incompletely processed single strand of messenger ribonucleic acid (mRNA)\, synthesized from a DNA template in the nucleus of a cell by transcription and containing copies of the introns and exons of a gene." [src_code:NR] -synonym: "pre-mRNA" [] -synonym: "Precursor mRNA" [] -is_a: SBO:0000278 ! messenger RNA - -[Term] -id: SBO:0000312 -name: mature messenger RNA -def: "Completely processed single strand of messenger ribonucleic acid (mRNA)\, synthesized from a DNA template in the nucleus of a cell by transcription and containing copies of only the exons of a gene." [src_code:NR] -is_a: SBO:0000278 ! messenger RNA - -[Term] -id: SBO:0000313 -name: transfer RNA -def: "Small RNA chain (73-93 nucleotides) that transfers a specific amino acid to a growing polypeptide chain at the ribosomal site of protein synthesis during translation. It has a site for amino acid attachment and a three-base region called the anticodon that recognizes the corresponding three-base codon region on mRNA via complementary base pairing. Each type of tRNA molecule can be attached to only one type of amino acid\, but because the genetic code is degenerate - that is\, it contains multiple codons that specify the same amino acid - multiple types of tRNA molecules bearing different anticodons may carry the same amino acid." [src_code:NR] -synonym: "tRNA" [] -is_a: SBO:0000334 ! non-coding RNA - -[Term] -id: SBO:0000314 -name: ribosomal RNA -def: "Type of RNA that is the central component of the ribosome\, the protein manufacturing machinery of all living cells." [src_code:NR] -synonym: "rRNA" [] -is_a: SBO:0000334 ! non-coding RNA - -[Term] -id: SBO:0000315 -name: ribozyme -def: "RNA molecule that catalyzes a chemical reaction." [src_code:NR] -synonym: "ribonucleic acid enzyme" [] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000316 -name: microRNA -def: "Single-stranded RNA molecules thought to regulate the expression of other genes. miRNAs are encoded by genes that are transcribed from DNA but not translated into protein (non-coding RNA)." [src_code:NR] -synonym: "miRNA" [] -is_a: SBO:0000334 ! non-coding RNA - -[Term] -id: SBO:0000317 -name: small interfering RNA -def: "siRNA are 20-25 nucleotide-long double-stranded RNA molecules involved in the regulation of the expression of specific genes\, antiviral mechanisms\, shaping the chromatin structure of a genome etc. " [src_code:NR] -synonym: "siRNA" [] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000318 -name: small nuclear RNA -def: "Small RNA molecules that are found within the nucleus of eukaryotic cells. They are involved in a variety of important processes such as RNA splicing (removal of introns from heterogeneous nuclear RNA)\, regulation of transcription factors or RNA polymerase II and maintaining the telomeres. They are always associated with specific proteins\, and the complexes are referred to as small nuclear ribonucleoproteins (snRNP)." [src_code:NR] -synonym: "snRNA" [] -is_a: SBO:0000334 ! non-coding RNA - -[Term] -id: SBO:0000319 -name: small nucleolar RNA -def: "Small RNA molecules that guide chemical modifications (methylation or pseudouridylation) of ribosomal RNAs (rRNAs) and other RNA genes. They are frequently encoded in the introns of ribosomal proteins and are synthesized by RNA polymerase II\, but can also be transcribed as independent (sometimes polycistronic) transcriptional units. snoRNAs are a component in the small nucleolar ribonucleoprotein (snoRNP)\, which contains snoRNA and proteins. " [src_code:NR] -synonym: "snoRNA" [] -is_a: SBO:0000334 ! non-coding RNA - -[Term] -id: SBO:0000320 -name: product catalytic rate constant -def: "Numerical parameter that quantifies the velocity of product creation by a reversible enzymatic reaction. \n" [src_code:NR] -synonym: "kcatp" [] -is_a: SBO:0000025 ! catalytic rate constant - -[Term] -id: SBO:0000321 -name: substrate catalytic rate constant -def: "Numerical parameter that quantifies the velocity of substrate creation by a reversible enzymatic reaction. " [src_code:NR] -synonym: "kcats" [] -is_a: SBO:0000025 ! catalytic rate constant - -[Term] -id: SBO:0000322 -name: Michaelis constant for substrate -def: "Substrate concentration at which the velocity of product production by the forward activity of a reversible enzyme is half its maximum. " [src_code:NR] -synonym: "Kms" [] -is_a: SBO:0000027 ! Michaelis constant - -[Term] -id: SBO:0000323 -name: Michaelis constant for product -def: "Product concentration at which the velocity of substrate production by the reverse activity of a reversible enzyme is half its maximum. " [src_code:NR] -synonym: "Kmp" [] -is_a: SBO:0000027 ! Michaelis constant - -[Term] -id: SBO:0000324 -name: forward maximal velocity -def: "Limiting maximal velocity of the forward reaction of a reversible enzyme\, reached when the substrate is in large excess and all the enzyme is complexed.\n \n Et\n kcatp\n \n \n Et\n kcatp\n \n \n" [src_code:NR] -synonym: "Vmaxf" [] -is_a: SBO:0000186 ! maximal velocity -is_a: SBO:0000350 ! forward reaction velocity - -[Term] -id: SBO:0000325 -name: reverse maximal velocity -def: "Limiting maximal velocity of the reverse reaction of a reversible enzyme\, reached when the product is in large excess and all the enzyme is complexed.\n \n Et\n kcats\n \n \n Et\n kcats\n \n \n" [src_code:NR] -synonym: "Vmaxr" [] -is_a: SBO:0000186 ! maximal velocity -is_a: SBO:0000353 ! reverse reaction velocity - -[Term] -id: SBO:0000326 -name: enzymatic rate law for non-modulated unireactant enzymes -def: "Kinetics of enzymes that react only with one substance\, their substrate\, and are not modulated by other compounds." [src_code:NR] -is_a: SBO:0000269 ! enzymatic rate law for unireactant enzymes - -[Term] -id: SBO:0000327 -name: non-macromolecular ion -def: "Chemical entity having a net electric charge." [src_code:NR] -is_a: SBO:0000247 ! simple chemical - -[Term] -id: SBO:0000328 -name: non-macromolecular radical -def: "chemical entity possessing an unpaired electron." [src_code:NR] -is_a: SBO:0000247 ! simple chemical - -[Term] -id: SBO:0000329 -name: transcription start site -def: "First nucleotide of a gene that is copied in the transcribed RNA.\n\nSequence Ontology SO\:0000315" [src_code:NR] -synonym: "TSS" [] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000330 -name: dephosphorylation -def: "Removal of a phosphate group (-H2PO4) from a chemical entity. " [src_code:NR] -is_a: SBO:0000211 ! removal of a chemical group - -[Term] -id: SBO:0000331 -name: half-life -def: "Time interval over which a quantified entity is reduced to half its original value." [src_code:NR] -is_a: SBO:0000009 ! kinetic constant -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000332 -name: half-life of an exponential decay -def: "Time taken by a quantity decreasing according to a mono-exponential decay to be divided by two. Sometimes called t1/2.\n \n l\n \n \n \n \n 2\n \n l\n \n \n\n" [src_code:NR] -is_a: SBO:0000331 ! half-life - -[Term] -id: SBO:0000333 -name: monoexponential decay rate law -def: "Monotonic decrease of a quantity proportionally to its value.\n\n \n l\n R\n \n \n R\n l\n \n \n\n" [src_code:NR] -is_a: SBO:0000049 ! mass action rate law for first order irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000334 -name: non-coding RNA -def: "RNA molecule that is not translated into a protein. \n\nSequence Ontology SO\:0000655" [src_code:NR] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000335 -name: gene coding region -def: "Portion of DNA or RNA that is transcribed into another RNA\, such as a messenger RNA or a non-coding RNA (for instance a transfert RNA or a ribosomal RNA)." [src_code:NR] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000336 -name: interactor -def: "Entity participating in a physical or functional interaction." [src_code:NR] -is_a: SBO:0000010 ! reactant - -[Term] -id: SBO:0000337 -name: association constant -def: "Equilibrium constant that measures the propensity of two objects to assemble (associate) reversibly into a larger component. The association constant is usually denoted Ka and is the inverse of the dissociation constant. \n \n koff\n Kon\n \n \n kon\n Koff\n \n \n\n" [src_code:NR] -synonym: "affinity constant" [] -synonym: "Ka" [] -is_a: SBO:0000281 ! equilibrium constant - -[Term] -id: SBO:0000338 -name: dissociation rate constant -def: "Rate with which a complex dissociates into its components." [src_code:NR] -synonym: "kd" [] -is_a: SBO:0000035 ! forward unimolecular rate constant\, continuous case -is_a: SBO:0000038 ! reverse unimolecular rate constant\, continuous case - -[Term] -id: SBO:0000339 -name: bimolecular association rate constant -def: "Rate with which two components associate into a complex." [src_code:NR] -is_a: SBO:0000036 ! forward bimolecular rate constant\, continuous case -is_a: SBO:0000341 ! association rate constant - -[Term] -id: SBO:0000340 -name: trimolecular association rate constant -def: "Rate with which three components associate into a complex." [src_code:NR] -is_a: SBO:0000037 ! forward trimolecular rate constant\, continuous case -is_a: SBO:0000341 ! association rate constant - -[Term] -id: SBO:0000341 -name: association rate constant -def: "Rate with which components associate into a complex." [src_code:NR] -is_a: SBO:0000154 ! forward rate constant\, continuous case - -[Term] -id: SBO:0000342 -name: molecular or genetic interaction -def: "Mutual or reciprocal action or influence between molecular entities." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000343 -name: genetic interaction -def: "A phenomenon whereby an observed phenotype\, qualitative or quantative\, is not explainable by the simple additive effects of the individual gene pertubations alone. Genetic interaction between perturbed genes is usually expected to generate a 'defective' phenotype. The level of defectiveness is often used to sub-classify this phenomenon.\n" [src_code:NR] -is_a: SBO:0000342 ! molecular or genetic interaction - -[Term] -id: SBO:0000344 -name: molecular interaction -def: "Relationship between molecular entities\, based on contacts\, direct or indirect. " [src_code:NR] -is_a: SBO:0000342 ! molecular or genetic interaction - -[Term] -id: SBO:0000345 -name: time -def: "Fundmental quantity of the measuring system used to sequence events\, to compare the durations of events and the intervals between them\, and to quantify the motions or the transformation of entities. The SI base unit for time is the SI second. The second is the duration of\n9\,192\,631\,770 periods of the radiation corresponding to the transition\nbetween the two hyperfine levels of the ground state of the caesium 133\natom." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000346 -name: temporal measure -def: "Fundamental quantity of the measuring system used to sequence events\, to compare the durations of events and the intervals between them\, and to quantify the motions or the transformation of entities. The SI base unit for time is the SI second. The second is the duration of 9\,192\,631\,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium 133 atom." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000347 -name: duration -def: "Amount of time during which an event persists." [src_code:NR] -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000348 -name: exponential time constant -def: "Time that it takes for an exponential decay to reach 1/e (about 37%) of the original value. This characterises the frequency response of a first-order\, linear time-invariant system. This is also the average lifetime of an element in the decaying set. It is the inverse of the exponential decay constant. \n \n l\n \n \n 1\n l\n \n \n\n" [src_code:NR] -synonym: "mean lifetime" [] -is_a: SBO:0000009 ! kinetic constant -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000349 -name: inactivation rate constant -def: "Kinetic constant describing the rate of an irreversible enzyme inactivation\nby decay of the active enzyme into its inactive form." [src_code:NR] -synonym: "kinact" [] -is_a: SBO:0000035 ! forward unimolecular rate constant\, continuous case - -[Term] -id: SBO:0000350 -name: forward reaction velocity -def: "The speed of an enzymatic reaction at a defined concentration of substrate(s) and enzyme." [src_code:NR] -is_a: SBO:0000048 ! forward zeroth order rate constant\, continuous case - -[Term] -id: SBO:0000352 -name: reverse zeroth order rate constant -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction independant of the reactant quantities. This parameter encompasses all the contributions to the velocity. It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000046 ! zeroth order rate constant -is_a: SBO:0000156 ! reverse rate constant - -[Term] -id: SBO:0000353 -name: reverse reaction velocity -def: "The speed of an enzymatic reaction at a defined concentration of substrate(s) and enzyme. " [src_code:NR] -is_a: SBO:0000352 ! reverse zeroth order rate constant - -[Term] -id: SBO:0000354 -name: informational molecule segment -def: "Fragment of a macromolecule that carries genetic information." [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000355 -name: conservation law -def: "Mathematical expression stating that a quantity is conserved in a system\, whatever happens within the boundaries of that system. " [src_code:NR] -is_a: SBO:0000064 ! mathematical expression - -[Term] -id: SBO:0000356 -name: decay constant -def: "Kinetic constant characterising a mono-exponential decay. It is the inverse of the mean lifetime of the continuant being decayed. Its unit is \"per time\". \n \n t\n \n \n 1\n t\n \n \n\n" [src_code:NR] -is_a: SBO:0000035 ! forward unimolecular rate constant\, continuous case - -[Term] -id: SBO:0000357 -name: biological effect of a perturbation -def: "Biochemical networks can be affected by external influences. Those influences can be well-defined physical perturbations\, such as a light pulse\, or a change in temperature but also more complex of not well defined phenomena\, for instance a biological process\, an experimental setup\, or a mutation." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000358 -name: phenotype -def: "A biochemical network can generate phenotypes or affects biological processes. Such processes can take place at different levels and are independent of the biochemical network itself.\n" [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000359 -name: mass conservation law -def: "A chemical moiety that exists under different forms but is not created nor destroyed in a biochemical system. In any given system such a conserved moiety is characterized by a finite number of particles that exist in the system and is invariant.\n\n \n a\n n\n S\n \n \n i \n 0 \n n \n \n \n \n \n a\n i \n \n \n \n S\n i \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000355 ! conservation law - -[Term] -id: SBO:0000360 -name: quantity of an entity pool -def: "The enumeration of co-localised\, identical biochemical entities of a specific state\, which constitute a pool. The form of enumeration may be purely numerical\, or may be given in relation to another dimension such as length or volume." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000361 -name: amount of an entity pool -def: "A numerical measure of the quantity\, or of some property\, of the entities that constitute the entity pool. \n" [src_code:NR] -is_a: SBO:0000360 ! quantity of an entity pool - -[Term] -id: SBO:0000362 -name: concentration conservation law -def: "If all forms of a moiety exist in a single compartment and the size of that compartment is fixed then the Mass Conservation is also a Concentration Conservation.\n\n\n \n a\n n\n S\n \n \n i \n 0 \n n \n \n \n \n \n a\n i \n \n \n \n S\n i \n \n \n \n \n\n" [src_code:NR] -is_a: SBO:0000359 ! mass conservation law - -[Term] -id: SBO:0000363 -name: activation constant -def: "Dissociation constant of a potentiator (activator) from a target (e.g. an\nenzyme) of which it activates the function." [src_code:NR] -synonym: "Kx" [] -is_a: SBO:0000282 ! dissociation constant - -[Term] -id: SBO:0000364 -name: multimer cardinality -def: "Number of monomers composing a multimeric entity." [src_code:NR] -is_a: SBO:0000188 ! number of biochemical items - -[Term] -id: SBO:0000365 -name: forward non-integral order rate constant\, continuous case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction where reactants have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the reactants.It is to be used in a reaction modelled using a continuous framework." [src_code:NR] -is_a: SBO:0000154 ! forward rate constant\, continuous case -is_a: SBO:0000160 ! forward non-integral order rate constant - -[Term] -id: SBO:0000366 -name: forward non-integral order rate constant\, discrete case -def: "Numerical parameter that quantifies the forward velocity of a chemical reaction where reactants have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the reactants. It is to be used in a reaction modelled using a discrete framework. " [src_code:NR] -is_a: SBO:0000155 ! forward rate constant\, discrete case -is_a: SBO:0000160 ! forward non-integral order rate constant - -[Term] -id: SBO:0000367 -name: reverse non-integral order rate constant\, discrete case -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction where products have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the products. It is to be used in a reaction modelled using a discrete framework.\n" [src_code:NR] -is_a: SBO:0000161 ! reverse non-integral order rate constant - -[Term] -id: SBO:0000368 -name: reverse non-integral order rate constant\, continuous case -def: "Numerical parameter that quantifies the reverse velocity of a chemical reaction where products have non-integral orders. This parameter encompasses all the contributions to the velocity except the quantity of the products. It is to be used in a reaction modelled using a continuous framework. " [src_code:NR] -is_a: SBO:0000161 ! reverse non-integral order rate constant - -[Term] -id: SBO:0000369 -name: gene regulatory region -def: "Region of a gene that is involved in the modulation of the expression of the gene. " [src_code:NR] -is_a: SBO:0000404 ! unit of genetic information - -[Term] -id: SBO:0000370 -name: Michaelis constant in non-equilibrium situation -def: "Michaelis constant derived or experimentally measured under non-equilibrium conditions." [src_code:NR] -is_a: SBO:0000027 ! Michaelis constant - -[Term] -id: SBO:0000371 -name: Michaelis constant in quasi-steady state situation -def: "Michaelis constant derived using a steady-state assumption for enzyme-substrate and enzyme-product intermediates. For example see Briggs-Haldane equation (SBO\:0000031)." [src_code:NR] -is_a: SBO:0000370 ! Michaelis constant in non-equilibrium situation - -[Term] -id: SBO:0000372 -name: Michaelis constant in irreversible situation -def: "Michaelis constant derived assuming enzyme-substrate and enzyme-product intermediates are formed in consecutive irreversible reactions. The constant K is the ratio of the forward rate constants. For example see Van Slyke-Cullen equation (SBO\:0000030)." [src_code:NR] -is_a: SBO:0000370 ! Michaelis constant in non-equilibrium situation - -[Term] -id: SBO:0000373 -name: Michaelis constant in fast equilibrium situation -def: "Michaelis constant as determined in a reaction where the formation of the enzyme-substrate complex occurs at a much faster rate than subsequent steps\, and so are assumed to be in a quasi-equilibrium situation. K is equivalent to an equilibrium constant. For example see Henri-Michaelis-Menten equation (SBO\:0000029)." [src_code:NR] -is_a: SBO:0000027 ! Michaelis constant - -[Term] -id: SBO:0000374 -name: relationship -def: "connectedness between entities and/or interactions representing their relatedness or influence." [src_code:NR] -is_a: SBO:0000231 ! occurring entity representation - -[Term] -id: SBO:0000375 -name: process -def: "A sequential series of actions\, motions\, or occurrences\, such as chemical reactions\, that affect one or more entities in a phenomenologically characteristic manner." [src_code:NR] -is_a: SBO:0000231 ! occurring entity representation - -[Term] -id: SBO:0000376 -name: hydrolysis -def: "Decomposition of a compound by reaction with water\, where the hydroxyl and H groups are incorporated into different products" [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000377 -name: isomerisation -def: "A reaction in which the principal reactant and principal product are isomers of each other" [src_code:NR] -is_a: SBO:0000176 ! biochemical reaction - -[Term] -id: SBO:0000378 -name: enzymatic rate law for inhibition of irreversible unireactant enzymes by competing substrates -def: "Inhibition of a unireactant enzyme by competing substrates (Sa) that bind to the free enzyme on the same binding site. The enzyme does not catalyse the reactions in both directions.\n\n\n\n\n\n\n \n kcat\n Et\n S\n Sa\n Ks\n Ksa\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n i \n 1 \n n \n \n \n \n \n Sa\n i \n \n \n \n Ksa\n i \n \n \n \n \n \n S\n \n \n \n\n\n\n" [src_code:NR] -is_a: SBO:0000270 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by exclusive inhibitors - -[Term] -id: SBO:0000379 -name: enzymatic rate law for simple competitive inhibition of irreversible unireactant enzymes by two non-exclusive inhibitors -def: "Inhibition of a unireactant enzyme by two inhibitors that can bind once to the free enzyme and preclude the binding of the substrate. Binding of one inhibitor may affect binding of the other\, or not. The enzymes do not catalyse the reactions in both directions.\n \n \n kcat\n Et\n S\n I1\n I2\n a\n Ks\n Ki1\n Ki2\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n I1\n Ki1\n \n \n \n I2\n Ki2\n \n \n \n \n \n I1\n I2\n \n \n \n a \n Ki1\n Ki2\n \n \n \n \n S\n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000380 -name: biochemical coefficient -def: "number used as a multiplicative or exponential factor for quantities\, expressions or functions" [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000381 -name: biochemical proportionality coefficient -def: "A multiplicative factor for quantities\, expressions or functions " [src_code:NR] -is_a: SBO:0000380 ! biochemical coefficient - -[Term] -id: SBO:0000382 -name: biochemical exponential coefficient -def: "number used as an exponential factor for quantities\, expressions or functions " [src_code:NR] -is_a: SBO:0000380 ! biochemical coefficient - -[Term] -id: SBO:0000383 -name: biochemical cooperative inhibition coefficient -def: "The coefficient used to quantify the effect on inhibition constants of multiple inhibitors binding non-exclusively to the enzyme." [src_code:NR] -is_a: SBO:0000381 ! biochemical proportionality coefficient - -[Term] -id: SBO:0000384 -name: biochemical inhibitory proportionality coefficient -def: "Coefficient that quantifies the effect on inhibition constants of either binding of multiple substrates or inhibitors." [src_code:NR] -is_a: SBO:0000381 ! biochemical proportionality coefficient - -[Term] -id: SBO:0000385 -name: biochemical cooperative inhibitor substrate coefficient -def: "The coefficient that describes the proportional change of Ks or Ki when inhibitor or substrate is bound\, respectively\, to the enzyme." [src_code:NR] -is_a: SBO:0000381 ! biochemical proportionality coefficient - -[Term] -id: SBO:0000386 -name: enzymatic rate law for inhibition of irreversible unireactant enzymes by single competing substrate -def: "Inhibition of a unireactant enzyme by a competing substrate (Sa) that binds to the free enzyme on the same binding site. The enzyme does not catalyse the reactions in both directions.\n\n \n kcat\n Et\n S\n Sa\n Ks\n Ksa\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n Sa\n Ksa\n \n \n \n S\n \n \n \n\n \n" [src_code:NR] -is_a: SBO:0000378 ! enzymatic rate law for inhibition of irreversible unireactant enzymes by competing substrates - -[Term] -id: SBO:0000387 -name: enzymatic rate law for competitive inhibition of irreversible unireactant enzyme by product -def: "Inhibition of a unireactant enzyme by a competing product (P) that binds to the free enzyme on the same binding site. The enzyme does not catalyse the reactions in both directions.\n\n\n \n kcat\n Et\n S\n P\n Ks\n Kp\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n P\n Kp\n \n \n \n S\n \n \n \n\n \n\n" [src_code:NR] -is_a: SBO:0000270 ! enzymatic rate law for competitive inhibition of irreversible unireactant enzymes by exclusive inhibitors - -[Term] -id: SBO:0000388 -name: enzymatic rate law for inhibition of irreversible unireactant enzymes by single competing substrate with product inhibition -def: "Inhibition of a unireactant enzyme by a competing substrate (Sa) that binds to the free enzyme on the same binding site\, and competitive inhibition by a product (P) and an alternative product (Pa). The enzyme does not catalyse the reactions in both directions.\n \n\n \n kcat\n Et\n S\n Sa\n Ks\n Ksa\n Kp\n Kpa\n P\n Pa\n n\n \n \n \n \n kcat\n Et\n S\n \n \n \n \n \n Ks\n \n \n 1\n \n \n Sa\n Ksa\n \n \n \n P\n Kpa\n \n \n \n Pa\n Kpa\n \n \n \n S\n \n \n \n\n \n" [src_code:NR] -is_a: SBO:0000378 ! enzymatic rate law for inhibition of irreversible unireactant enzymes by competing substrates - -[Term] -id: SBO:0000389 -name: switch value -def: "A parameter value taken by a switch\, which has a discrete set of values which can be alternated or switched between." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000390 -name: boolean switch -def: "A parameter that has precisely two discrete values which may be switched between. Usually for the boolean parameter these are indicated as '0 or 1' or 'True or False'." [src_code:NR] -synonym: "binary switch" [] -is_a: SBO:0000389 ! switch value - -[Term] -id: SBO:0000391 -name: steady state expression -def: "A mathematical expression that describes a steady state situation" [src_code:NR] -is_a: SBO:0000064 ! mathematical expression - -[Term] -id: SBO:0000392 -name: equivalence -def: "Term to signify those material or conceptual entities that are identical in some respect within a frame of reference" [src_code:NR] -is_a: SBO:0000374 ! relationship - -[Term] -id: SBO:0000393 -name: production -def: "Generation of a material or conceptual entity. " [src_code:NR] -is_a: SBO:0000168 ! control - -[Term] -id: SBO:0000394 -name: consumption -def: "Decrease in amount of a material or conceptual entity. " [src_code:NR] -is_a: SBO:0000168 ! control - -[Term] -id: SBO:0000395 -name: encapsulating process -def: "An aggregation of interactions and entities into a single process." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000396 -name: uncertain process -def: "An equivocal or conjectural process\, whose existence is assumed but not proven." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000397 -name: omitted process -def: "One or more processes that are not represented in certain representations or interpretations of a model." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000398 -name: logical relationship -def: "Relationship between entities (material or conceptual) and logical operators\, or between logical operators themselves. " [src_code:NR] -is_a: SBO:0000374 ! relationship - -[Term] -id: SBO:0000399 -name: decarboxylation -def: "A process in which a carboxyl group (COOH) is removed from a molecule as carbon dioxide." [src_code:NR] -is_a: SBO:0000211 ! removal of a chemical group - -[Term] -id: SBO:0000400 -name: decarbonylation -def: "Removal of a carbonyl group (-C-O-) from a molecule\, usually as carbon monoxide" [src_code:NR] -is_a: SBO:0000211 ! removal of a chemical group - -[Term] -id: SBO:0000401 -name: deamination -def: "Removal of an amine group from a molecule\, often under the addition of water" [src_code:NR] -is_a: SBO:0000211 ! removal of a chemical group - -[Term] -id: SBO:0000402 -name: transfer of a chemical group -def: "Covalent reaction that results in the transfer of a chemical group from one molecule to another." [src_code:NR] -is_a: SBO:0000182 ! conversion - -[Term] -id: SBO:0000403 -name: transamination -def: "The transfer of an amino group between two molecules. Commonly in biology this is restricted to reactions between an amino acid and an alpha-keto carbonic acid\, whereby the reacting amino acid is converted into an alpha-keto acid\, and the alpha-keto acid reactant into an amino acid." [src_code:NR] -is_a: SBO:0000402 ! transfer of a chemical group - -[Term] -id: SBO:0000404 -name: unit of genetic information -def: "Functional entity associated with or derived from a unit of inheritance." [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000405 -name: perturbing agent -def: "A material entity that is responsible for a perturbing effect" [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000406 -name: observable -def: "An entity that can be measured quantitatively" [src_code:NR] -is_a: SBO:0000240 ! material entity - -[Term] -id: SBO:0000407 -name: absolute inhibition -def: "Control that precludes the execution of a process." [src_code:NR] -is_a: SBO:0000169 ! inhibition - -[Term] -id: SBO:0000408 -name: biological activity -def: "Effect of a biological entity on biological structures or processes." [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000409 -name: interaction outcome -def: "Entity that results from the interaction between other entities." [src_code:NR] -is_a: SBO:0000236 ! physical entity representation - -[Term] -id: SBO:0000410 -name: implicit compartment -def: "A compartment whose existence is inferred due to the presence of known material entities which must be bounded\, allowing the creation of material entity pools." [src_code:NR] -is_a: SBO:0000290 ! physical compartment - -[Term] -id: SBO:0000411 -name: absolute stimulation -def: "Control that always triggers the controlled process." [src_code:NR] -is_a: SBO:0000170 ! stimulation - -[Term] -id: SBO:0000412 -name: biological activity -def: "The potential action that a biological entity has on other entities. Example are enzymatic activity\, binding activity etc." [src_code:NR] -is_a: SBO:0000231 ! occurring entity representation - -[Term] -id: SBO:0000413 -name: positional relationship -def: "The connectedness between entities as related by their position\n" [src_code:NR] -is_a: SBO:0000374 ! relationship - -[Term] -id: SBO:0000414 -name: cis -def: "Positional relationship between entities on the same strand (e.g. in DNA)\, or on the same side.\n" [src_code:NR] -is_a: SBO:0000413 ! positional relationship - -[Term] -id: SBO:0000415 -name: trans -def: "Positional relationship between entities on different sides\, or strands" [src_code:NR] -is_a: SBO:0000413 ! positional relationship - -[Term] -id: SBO:0000416 -name: true -def: "One of the two values possible from a boolean switch\, which equates to '1'\, 'on' or 'input'." [src_code:NR] -is_a: SBO:0000390 ! boolean switch - -[Term] -id: SBO:0000417 -name: false -def: "One of the two values possible from a boolean switch\, which equates to '0'\, 'off' or 'no input'." [src_code:NR] -is_a: SBO:0000390 ! boolean switch - -[Term] -id: SBO:0000418 -name: multimer of complexes -def: "Non-covalent association between several independant complexes" [src_code:NR] -is_a: SBO:0000286 ! multimer - -[Term] -id: SBO:0000419 -name: multimer of informational molecule segment -def: "Non-covalent association between portions of macromolecules that carry genetic information" [src_code:NR] -is_a: SBO:0000286 ! multimer - -[Term] -id: SBO:0000420 -name: multimer of macromolecules -def: "Non-covalent association between several macromolecules" [src_code:NR] -is_a: SBO:0000286 ! multimer -is_a: SBO:0000296 ! macromolecular complex - -[Term] -id: SBO:0000421 -name: multimer of simple chemicals -def: "Non-covalent association between several simple chemicals" [src_code:NR] -is_a: SBO:0000286 ! multimer - -[Term] -id: SBO:0000422 -name: isoinhibition constant -def: "Inhibitory constant for the binding of a given ligand with an isomeric form of an enzyme.\n" [src_code:NR] -is_a: SBO:0000261 ! inhibitory constant - -[Term] -id: SBO:0000423 -name: pseudo-dissociation constant for product -def: "In reversible reactions this is the concentration of product that is required to achieve half activation or inhibition in Hill-type kinetics\, in the absence of the substrate. " [src_code:NR] -is_a: SBO:0000194 ! pseudo-dissociation constant - -[Term] -id: SBO:0000424 -name: pseudo-dissociation constant for substrate -def: "In reversible reactions this is the concentration of substrate that is required to achieve half activation or inhibition in Hill-type kinetics\, in the absence of the product. " [src_code:NR] -is_a: SBO:0000194 ! pseudo-dissociation constant - -[Term] -id: SBO:0000425 -name: reversible Hill-type enzymatic rate law -def: "Reversible Hill-type kinetics represents the situation where a single substrate and product bind cooperatively and reversibly to the enzyme. Co-operativity is seen if the Hill coefficient (h) is greater than 1\, indicating that the binding of one substrate (or product) molecule facilitates the binding of the next. The opposite effect is evident with a coefficient less than 1. " [src_code:NR] -is_a: SBO:0000268 ! enzymatic rate law - -[Term] -id: SBO:0000426 -name: modulated reversible Hill-type rate law -def: "Reversible Hill-type kinetics in the presence of at least one modifier whose binding is affected by the presence of the substrate or product." [src_code:NR] -is_a: SBO:0000425 ! reversible Hill-type enzymatic rate law - -[Term] -id: SBO:0000427 -name: modulated reversible Hill-type rate law with one modifier -def: "The modifier can be either an activator or inhibitor depending on the value of alpha (activator for values larger than 1\, inhibitor for values smaller than 1\, no effect if exactly 1). This reflects the effect of the presence of substrate and product on the binding of the modifier. The equation\, derived by Hofmeyr and Cornish-Bowden (Comput. Appl. Biosci. 13\, 377 - 385 (1997) \n \n \n \n substrate\n \n \n \n product\n \n \n \n Modifier\n \n \n \n Keq\n \n \n \n Vf\n \n \n \n Ks\n \n \n \n Kp\n \n \n \n h\n \n \n \n Mhalf\n \n \n \n alpha\n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Ks \n \n \n \n 1 \n \n \n product \n \n \n substrate \n Keq \n \n \n \n \n \n \n \n \n \n substrate \n Ks \n \n \n \n product \n Kp \n \n \n \n \n h \n 1 \n \n \n \n \n \n \n \n \n \n 1 \n \n \n \n \n Modifier \n Mhalf \n \n h \n \n \n \n \n 1 \n \n \n alpha \n \n \n \n \n Modifier \n Mhalf \n \n h \n \n \n \n \n \n \n \n \n \n \n substrate \n Ks \n \n \n \n product \n Kp \n \n \n h \n \n \n \n \n \n \n" [src_code:NR] -is_a: SBO:0000426 ! modulated reversible Hill-type rate law - -[Term] -id: SBO:0000428 -name: modulated reversible Hill-type rate law with two modifiers -def: "The modifiers can be either activators or inhibitors depending on the values of and alpha (activators for values larger than 1\, inhibitors for values smaller than 1\, no effect if exactly 1). The assumption is that the binding of one modifier affects the binding of the second. Modifiers are assumed to bind at different sites. The synergetic effects of the two modifiers depend on the parameter alpha (if unity then they are independent\, if zero they compete for the same binding site). and reflect the effect of the presence of substrate and product on the binding of modifier A or modifier B. alphaA and alphaB factors account for the effect of substrate and product binding on the binding of modifier A and modifier B respectively. alphaAB accounts for the interaction of the modifiers on each others binding.\n (if < 1 Ma is inhibitor\, if > 1 activator)\nalpha_2 \t\: factor accounting for the effect of S and P on the binding of Mb\n (if < 1 Mb is inhibitor\, if > 1 activator)\nalpha_3 \t\: factor accounting for interaction of Ma to Mb binding to the enzyme (and v. v.).\n \n \n \n substrate\n \n \n product\n \n \n ModifierA\n \n \n ModifierB\n \n \n Keq\n \n \n Vf\n \n \n Shalve\n \n \n Phalve\n \n \n h\n \n \n MAhalf\n \n \n alphaA\n \n \n MBhalf\n \n \n alphaB\n \n \n alphaAB\n \n \n \n \n \n \n \n \n \n Vf\n substrate\n \n Ks\n \n \n \n 1\n \n \n product\n \n \n substrate\n Keq\n \n \n \n \n \n \n \n \n \n substrate\n Ks\n \n \n \n product\n Kp\n \n \n \n \n h\n 1\n \n \n \n \n \n \n \n \n \n 1\n \n \n \n \n ModifierA\n MAhalf\n \n h\n \n \n \n \n \n ModifierB\n MBhalf\n \n h\n \n \n \n \n 1\n \n \n alphaA\n \n \n \n \n ModifierA\n MAhalf\n \n h\n \n \n \n \n alphaB\n \n \n \n \n ModifierB\n MBhalf\n \n h\n \n \n \n \n alphaA\n alphaB\n alphaAB\n \n \n \n \n ModifierA\n MAhalf\n \n h\n \n \n \n \n \n ModifierB\n MBhalf\n \n h\n \n \n \n \n \n \n \n \n \n \n substrate\n Ks\n \n \n \n product\n Kp\n \n \n h\n \n \n \n \n \n" [src_code:NR] -is_a: SBO:0000426 ! modulated reversible Hill-type rate law - -[Term] -id: SBO:0000429 -name: enzymatic rate law for multireactant enzymes -def: "Kinetics of enzyme-catalysed reactions with 2 or more substrates or products\n" [src_code:NR] -is_a: SBO:0000268 ! enzymatic rate law - -[Term] -id: SBO:0000430 -name: enzymatic rate law for modulated unireactant enzymes -def: "Kinetics of enzymes that react with one substance\, and whose activity may be positively or negatively modulated." [src_code:NR] -is_a: SBO:0000269 ! enzymatic rate law for unireactant enzymes - -[Term] -id: SBO:0000431 -name: unmodulated reversible Hill-type rate law -def: "Reversible equivalent of Hill kinetics\, where substrate and product bind co-operatively to the enzyme. A Hill coefficient (h) of greater than 1 indicates positive co-operativity between substrate and product\, while h values below 1 indicate negative co-operativity. \n \n \n \n \n substrate\n \n \n \n product\n \n \n \n Keq\n \n \n \n Vf\n \n \n \n Ks\n \n \n \n Kp\n \n \n \n h\n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Ks\n \n \n \n 1 \n \n \n product \n \n \n substrate \n Keq \n \n \n \n \n \n \n \n \n \n substrate \n Ks\n \n \n \n product \n Kp \n \n \n \n \n h \n 1 \n \n \n \n \n \n 1 \n \n \n \n \n \n \n substrate \n Ks\n \n \n \n product \n Kp \n \n \n h \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000425 ! reversible Hill-type enzymatic rate law - -[Term] -id: SBO:0000432 -name: irreversible Michaelis Menten rate law for two substrates -def: "Enzymatic rate law for an irreversible reaction involving two substrates and one product. \n\t\n \n \n A \n \n \n B \n \n \n KmA \n \n \n KmB \n \n \n KiA \n \n \n Et \n \n \n kcat \n \n\t \n\t \n\t \n\t\t\n\t\t Et \n\t\t kcat \n\t\t A \n\t\t B \n\t \n\t \n\t\t\n\t\t\n\t\t \n\t\t KiA \n\t\t KmB \n\t\t\n\t\t\n\t\t \n\t\t KmB \n\t\t A \n\t\t\n\t\t\n\t\t \n\t\t KmA \n\t\t B \n\t\t\n\t\t\n\t\t \n\t\t A \n\t\t B \n\t\t\n\t \n\t \n \n\t\n " [src_code:NR] -is_a: SBO:0000429 ! enzymatic rate law for multireactant enzymes - -[Term] -id: SBO:0000433 -name: Ordered Bi-Bi mechanism rate law -def: "Enzymatic rate law for a reaction involving two substrates and two products. The products P and then Q are released strictly in order\, while the substrates are bound strictly in the order A and then B. \n \n \n \n Sa\n \n \n Sb\n \n \n Pp\n \n \n Pq\n \n \n Keq \n \n \n Vf \n \n \n Vr \n \n \n Kma \n \n \n Kmb \n \n \n Kmp \n \n \n Kmq \n \n \n Kia \n \n \n Kib \n \n \n Kip \n \n \n \n \n \n Vf \n \n \n \n \n Sa\n Sb\n \n \n \n \n \n Pp\n Pq\n \n Keq \n \n \n \n \n \n \n \n Sa\n Sb\n \n \n 1 \n \n \n Pp\n Kip \n \n \n \n \n \n Kma \n Sb\n \n \n \n Kmb \n \n \n Sa\n Kia \n \n \n \n \n \n \n Vf \n \n \n Vr \n Keq \n \n \n \n \n \n \n Kmq \n Pp\n \n \n 1 \n \n \n Sa\n Kia \n \n \n \n \n \n Pq\n \n \n \n \n Kmp \n \n \n 1 \n \n \n \n \n Kma \n Sb\n \n \n \n Kia \n Kmb \n \n \n \n \n \n \n Pp\n \n \n 1 \n \n \n Sb\n Kib \n \n \n \n \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000429 ! enzymatic rate law for multireactant enzymes - -[Term] -id: SBO:0000434 -name: Ordered Bi-Uni mechanism rate law -def: "Enzymatic rate for a reaction involving two substrates and one product. The substrates A and then B are bound strictly in order. \n \t\n \n \n Sa\n \n \n Sb\n \n \n P\n \n \n Kma \n \n \n Kmb \n \n \n Kmp \n \n \n Kia \n \n \n Keq \n \n \n Vf \n \n \n Vr \n \n \n \n \n \n Vf \n \n \n \n \n Sa\n Sb\n \n \n \n P\n Keq \n \n \n \n \n \n \n \n Sa\n Sb\n \n \n \n Kma \n Sb\n \n \n \n Kmb \n Sa\n \n \n \n \n \n Vf \n \n \n Vr \n Keq \n \n \n \n \n Kmp \n \n \n P\n \n \n 1 \n \n \n Sa\n Kia \n \n \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000429 ! enzymatic rate law for multireactant enzymes - -[Term] -id: SBO:0000435 -name: Ordered Uni-Bi mechanism rate law -def: "Enzymatic rate law for a reaction with one substrate and two products. The products P and then Q are released in the strict order P and then Q. \n \n \n \n substrate \n \n \n productp \n \n \n productq \n \n \n Kms \n \n \n Kmq \n \n \n Kmp \n \n \n Kip \n \n \n Keq \n \n \n Vf \n \n \n Vr \n \n \n \n \n \n Vf \n \n \n substrate \n \n \n \n \n productp \n productq \n \n Keq \n \n \n \n \n \n Kms \n \n \n substrate \n \n \n 1 \n \n \n productp \n Kip \n \n \n \n \n \n \n \n Vf \n \n \n Vr \n Keq \n \n \n \n \n \n \n Kmq \n productp \n \n \n \n Kmp \n productq \n \n \n \n productp \n productq \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000429 ! enzymatic rate law for multireactant enzymes - -[Term] -id: SBO:0000436 -name: Ping Pong Bi-Bi mechanism rate law -def: "Enzymatic rate law for a reaction involving two substrates and two products. The first product (P) is released after the first substrate (A) has been bound. The second product (Q) is released after the second substrate (B) has been bound. \n \n \n \n Sa\n \n \n Sb\n \n \n Pp\n \n \n Pq\n \n \n Keq \n \n \n Vf \n \n \n Vr \n \n \n Kma \n \n \n Kmb \n \n \n Kmp \n \n \n Kmq \n \n \n Kia \n \n \n Kiq \n \n \n \n \n \n Vf \n \n \n \n \n Sa\n Sb\n \n \n \n \n \n Pp\n Pq\n \n Keq \n \n \n \n \n \n \n \n Sa\n Sb\n \n \n \n Kmb \n Sa\n \n \n \n Kma \n Sb\n \n \n 1 \n \n \n Pq\n Kiq \n \n \n \n \n \n \n \n Vf \n \n \n Vr \n Keq \n \n \n \n \n \n \n Kmq \n Pp\n \n \n 1 \n \n \n Sa\n Kia \n \n \n \n \n \n Pq\n \n \n Kmp \n Pp\n \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000429 ! enzymatic rate law for multireactant enzymes - -[Term] -id: SBO:0000437 -name: reversible Iso Uni-Uni -def: "Enzyme catalysed reaction involving one substrate and one product. Unlike the reversible uni-uni mechanism (SBO\:0000326)\, the mechanism assumes an enzyme intermediate. Therefore\, the free enzyme generated after the release of product from enzyme-product complex is not the same form as that which bind the substrate to form enzyme-substrate complex. Some permeases are thought to follow this mechanism\, such that isomerization in the membrane may be accomplished through re-orientation in the membrane. \n \n \n \n substrate\n \n \n \n product\n \n \n \n Kms\n \n \n \n Kmp\n \n \n \n Kii\n \n \n \n Vf\n \n \n \n Keq\n \n \n \n \n \n \n Vf \n \n \n substrate \n \n \n product \n Keq \n \n \n \n \n \n \n \n substrate \n \n \n 1 \n \n \n product \n Kii \n \n \n \n \n \n Kms \n \n \n 1 \n \n \n product \n Kmp \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000326 ! enzymatic rate law for non-modulated unireactant enzymes - -[Term] -id: SBO:0000438 -name: reversible Uni-Uni -def: "The reversible equivalent of the Henri-Michaelis-Menten rate law (SBO\:0000029). \n\n \n \n substrate \n \n \n product \n \n \n Kms \n \n \n Kmp \n \n \n Et \n \n \n kcatp \n \n \n kcats \n \n \n \n \n \n Et \n \n \n \n \n \n \n kcatp \n substrate \n \n Kms \n \n \n \n \n \n kcats \n product \n \n Kmp \n \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n\n " [src_code:NR] -synonym: "Reversible Michaelis Menten" [] -synonym: "Uni-Uni Reversible Simple Michaelis-Menten" [] -is_a: SBO:0000326 ! enzymatic rate law for non-modulated unireactant enzymes - -[Term] -id: SBO:0000439 -name: Uni-Uni Reversible using Haldane relationship -def: "Enzyme catalysed reaction involving one substrate and one product. It is a modification of SBO\:0000326 that directly incorporates the equilibrium constant in the rate law.\n\n\t\n \n \n substrate \n \n \n product \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Keq \n \n \n \n \n \n Vf \n \n \n substrate \n \n \n product \n Keq \n \n \n \n \n \n substrate \n \n \n Kms \n \n \n 1 \n \n \n product \n Kmp \n \n \n \n \n \n \n\t \n " [src_code:NR] -synonym: "Uni-Uni" [] -is_a: SBO:0000326 ! enzymatic rate law for non-modulated unireactant enzymes - -[Term] -id: SBO:0000440 -name: enzymatic rate law for irreversible allosteric inhibition -def: "Enzymatic rate law which follows from the allosteric concerted model (symmetry model or MWC model).This states that enzyme subunits can assume one of two conformational states (relaxed or tense)\, and that the state of one subunit is shared or enforced on the others. The binding of a ligand to a site other than that bound by the substrate (active site) can shift the conformation from one state to the other. L represents the equilibrium constant between active and inactive states of the enzyme\, and n represents the number of binding sites for the substrate and inhibitor. \n \n \n \n substrate \n \n \n Inhibitor \n \n \n V \n \n \n Ks \n \n \n n \n \n \n L \n \n \n Ki \n \n \n \n \n \n V \n substrate \n \n \n \n \n Ks \n substrate \n \n \n \n n \n 1 \n \n \n \n \n \n \n \n L \n \n \n \n \n Ks \n \n \n 1 \n \n \n Inhibitor \n Ki \n \n \n \n n \n \n \n \n \n \n \n Ks \n substrate \n \n n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000441 -name: enzymatic rate law for mixed-type inhibition of reversible enzymes by mutually exclusive inhibitors -def: "Reversible inhibition of a unireactant enzyme by inhibitors that can bind to the enzyme-substrate complex and to the free enzyme with the same equilibrium constant. The inhibitor is noncompetitive with the substrate. \n \n \n \n substrate \n \n \n product\n \n \n Inhibitor\n \n \n Kms\n \n \n Kmp\n \n \n Vf\n \n \n Vr\n \n \n Kis\n \n \n Kic\n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n Inhibitor \n Kis \n \n \n \n \n \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n 1 \n \n \n Inhibitor \n Kic \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000275 ! enzymatic rate law for mixed-type inhibition of irreversible enzymes by mutually exclusive inhibitors - -[Term] -id: SBO:0000442 -name: enzymatic rate law for simple reversible non-competitive inhibition of unireactant enzymes -def: "Reversible inhibition of a unireactant enzyme by one inhibitor that can bind to the enzyme-substrate complex and to the free enzyme with the same equilibrium constant. The inhibitor is noncompetitive with the substrate.\n \n \n \n \n substrate \n \n \n product \n \n \n Inhibitor \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ki \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n 1 \n \n \n Inhibitor \n Ki \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000265 ! enzymatic rate law for simple mixed-type inhibition of irreversible unireactant enzymes - -[Term] -id: SBO:0000443 -name: enzymatic rate law for reversible essential activation -def: "Enzymatic rate law where the free enzyme\, in the absence of the activator\, is unable to bind substrate and has no activity." [src_code:NR] -synonym: " compulsory activation" [] -synonym: "specific activation" [] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000444 -name: enzymatic rate law for reversible mixed activation -def: "Enzymatic rate law where the activator enhances the rate of reaction through specific and catalytic effects\, which increase the apparent limiting rate and decrease apparent Michaelis constant. The activator can bind reversibly both the free enzyme and enzyme-substrate complex\, while the substrate can bind only to enzyme-activator complex. Catalytic activity is seen only when enzyme\, substrate and activator are complexed. \n \n \n \n substrate \n \n \n product \n \n \n Activator \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Kas \n \n \n Kac \n \n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n Activator \n \n \n \n Kas \n Activator \n \n \n \n \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n Kac \n Activator \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000443 ! enzymatic rate law for reversible essential activation - -[Term] -id: SBO:0000445 -name: enzymatic rate law for irreversible substrate activation -def: "This enzymatic rate law is available only for irreversible reactions\, with one substrate and one product. There is a second binding site for the enzyme which\, when occupied\, activates the enzyme. Substrate binding at either site can occur at random.\n \n \n \n \n substrate \n \n \n V \n \n \n Ksc \n \n \n Ksa \n \n \n \n \n \n V \n \n \n \n \n substrate \n Ksa \n \n 2 \n \n \n \n \n 1 \n \n \n substrate \n Ksc \n \n \n \n substrate \n Ksa \n \n \n \n \n \n substrate \n Ksa \n \n 2 \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000444 ! enzymatic rate law for reversible mixed activation - -[Term] -id: SBO:0000446 -name: enzymatic rate law for irrreversible mixed activation -def: "Enzymatic rate law where the activator enhances the rate of reaction through specific and catalytic effects\, which increase the apparent limiting rate and decrease apparent Michaelis constant. The activator can bind irreversibly both free enzyme and enzyme-substrate complex\, while the substrate can bind only to enzyme-activator complex. Catalytic activity is seen only when enzyme\, substrate and activator are complexed. \n \n \n \n substrate \n \n \n Activator \n \n \n Kms \n \n \n V \n \n \n Kas \n \n \n Kac \n \n \n \n \n \n V \n substrate \n Activator \n \n \n \n \n \n Kms \n \n \n Kas \n Activator \n \n \n \n \n substrate \n \n \n Kac \n Activator \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000444 ! enzymatic rate law for reversible mixed activation - -[Term] -id: SBO:0000447 -name: enzymatic rate law for reversible catalytic activation with one activator -def: "Enzymatic rate law where an activator enhances the rate of reaction by increasing the apparent limiting rate\, The reversible binding of the activator to the enzyme-substrate complex is required for enzyme catalytic activity (to generate the product). \n \n \n \n \n substrate \n \n \n product \n \n \n Activator \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ka \n \n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n Activator \n \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n Ka \n Activator \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000444 ! enzymatic rate law for reversible mixed activation - -[Term] -id: SBO:0000448 -name: enzymatic rate law for reversible specific activation -def: "Enzymatic rate law for one substrate\, one product and one modifier which acts as an activator. The activator enhances the rate of reaction by decreasing the apparent Michaelis constant. The activator reversibly binds to the enzyme before the enzyme can bind the substrate. \n \n \n \n substrate \n \n \n product \n \n \n Activator \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ka \n \n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n Activator \n \n \n \n Ka \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n Activator \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000444 ! enzymatic rate law for reversible mixed activation - -[Term] -id: SBO:0000449 -name: enzymatic rate law for irreversible catalytic activation with one activator -def: "Enzymatic rate law where an activator enhances the rate of reaction by increasing the apparent limiting rate\, The activator binding to the enzyme-substrate complex (irreversibly) is required for enzyme catalytic activity (to generate the product). \n \n \n \n substrate \n \n \n Activator \n \n \n Kms \n \n \n V \n \n \n Ka \n \n \n \n \n \n V \n substrate \n Activator \n \n \n \n \n \n Kms \n substrate \n \n \n \n Ka \n Activator \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000447 ! enzymatic rate law for reversible catalytic activation with one activator - -[Term] -id: SBO:0000450 -name: enzymatic rate law for irreversible specific activation -def: "Enzymatic rate law for one substrate\, one product and one modifier which acts as an activator. The activator enhances the rate of reaction by decreasing the apparent Michaelis constant. The activator must bind to the enzyme before the enzyme can bind the substrate. \n \n \n \n substrate\n \n \n Activator\n \n \n Kms\n \n \n V\n \n \n Ka\n \n \n \n \n \n V \n substrate \n Activator \n \n \n \n \n \n Kms \n Ka \n \n \n \n \n \n Kms \n substrate \n \n Activator \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000448 ! enzymatic rate law for reversible specific activation - -[Term] -id: SBO:0000451 -name: enzymatic rate law for reversible reactions with competitive inhibition -def: "This enzymatic rate law involves one substrate\, one product and one or more modifiers. The modifiers act as competitive inhibitors of the substrate at the enzyme binding site\, The modifiers (inhibitors) reversibly bound to the enzyme block access to the substrate. The inhibitors have the effect of increasing the apparent Km\, and bind exclusively to the enzymes. \n \n \n \n substrate \n \n \n product \n \n \n Inhibitor \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ki \n \n \n n\n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n i \n \n \n 1 \n \n \n n \n \n \n \n \n \n I\n i \n \n \n \n Ki\n i \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000452 -name: enzymatic rate law for reversible competitive inhibition by one inhibitor -def: "This enzymatic rate law involves one substrate\, one product and one modifier. The modifier acts as a competitive inhibitor with the substrate at the enzyme binding site\, The modifier (inhibitor) reversibly bound to the enzyme blocks access to the substrate. The inhibitor has the effect of increasing the apparent Km. \n \n \n \n substrate \n \n \n product \n \n \n Inhibitor \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ki \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n Inhibitor \n Ki \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000451 ! enzymatic rate law for reversible reactions with competitive inhibition - -[Term] -id: SBO:0000453 -name: enzymatic rate law for reversible empirical allosteric inhibition by one inhibitor -def: "Enzymatic rate law where the reversible binding of one ligand decreases the affinity for substrate at other active sites. The ligand does not bind the same site as the substrate on the enzyme. This is an empirical equation\, where n represents the Hill coefficient. \n \n \n \n substrate \n \n \n product \n \n \n Inhibitor \n \n \n Vf \n \n \n Vr \n \n \n Kms \n \n \n Kmp \n \n \n n \n \n \n Ki \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n \n Inhibitor \n Ki \n \n n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000451 ! enzymatic rate law for reversible reactions with competitive inhibition - -[Term] -id: SBO:0000454 -name: enzymatic rate law for reversible substrate inhibition -def: "Enzymatic rate law where the substrate for an enzyme also acts as a reversible inhibitor. This may entail a second (non-active) binding site for the enzyme. The inhibition constant is then the dissociation constant for the substrate from this second site. \n \n \n \n substrate \n \n \n product \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ki \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n \n substrate \n Ki \n \n 2 \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000455 -name: enzymatic rate law for irreversible substrate inhibition -def: "Enzymatic rate law where the substrate for an enzyme also acts as an irreversible inhibitor. This may entail a second (non-active) binding site for the enzyme. The inhibition constant is then the dissociation constant for the substrate from this second site.\n \n \n \n \n substrate \n \n \n Km \n \n \n V \n \n \n Ki \n \n \n \n \n \n V \n substrate \n \n \n \n Km \n substrate \n \n \n Km \n \n \n \n \n substrate \n Ki \n \n 2 \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000454 ! enzymatic rate law for reversible substrate inhibition - -[Term] -id: SBO:0000456 -name: enzymatic rate law for reversible unireactant enzyme with a single hyperbolic modulator -def: "Enzymatic rate law where the modifier can act as an activator or inhibitor\, depending upon the values of the kinetic constants. The modifier can bind reversibly to all forms of the enzyme and all enzyme-substrate complexes are reactive. \n'a' represents the ratio of dissociation constant of the elementary step Enzyme-Substrate complex + Modifier = Enzyme-Substrate-Modifier complex over that of Enzyme + Modifier = Enzyme-Modifier complex.\n'b' represents ratio of the rate constant of elementary step Enzyme-Substrate-Modifier complex -> Enzyme-Modifier complex + Product over that of Enzyme-Substrate complex -> Enzyme + Product.\n \n \n \n \n substrate \n \n \n product \n \n \n Modifier \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Kd \n \n \n a \n \n \n b \n \n \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n \n \n b \n Modifier \n \n \n \n a \n Kd \n \n \n \n \n \n \n 1 \n \n \n Modifier \n Kd \n \n \n \n \n \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n 1 \n \n \n Modifier \n \n \n a \n Kd \n \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000457 -name: enzymatic rate law for irreversible unireactant enzyme with a single hyperbolic modulator -def: "Enzymatic rate law where the modifier can act as an activator or inhibitor\, depending upon the values of the kinetic constants. The modifier can bind irreversibly to all forms of the enzyme and all enzyme-substrate complexes are reactive. \n'a' represents the ratio of dissociation constant of the elementary step Enzyme-Substrate complex + Modifier = Enzyme-Substrate-Modifier complex) over that of Enzyme + Modifier = Enzyme-Modifier complex.\n'b' represents ratio of the rate constant of elementary step Enzyme-Substrate-Modifier complex -> Enzyme-Modifier complex + Product over that of Enzyme-Substrate complex -> Enzyme + Product.\n \n \n \n \n substrate \n \n \n Modifier \n \n \n Km \n \n \n V \n \n \n Kd \n \n \n a \n \n \n b \n \n \n \n \n \n V \n substrate \n \n \n 1 \n \n \n \n \n b \n Modifier \n \n \n \n a \n Kd \n \n \n \n \n \n \n \n \n Km \n \n \n 1 \n \n \n Modifier \n Kd \n \n \n \n \n \n substrate \n \n \n 1 \n \n \n Modifier \n \n \n a \n Kd \n \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000456 ! enzymatic rate law for reversible unireactant enzyme with a single hyperbolic modulator - -[Term] -id: SBO:0000458 -name: enzymatic rate law for simple uncompetitive inhibition of reversible unireactant enzymes -def: "Reversible inhibition of a unireactant enzyme by one inhibitor\, which binds to the enzyme-substrate complex. The inhibitor is uncompetitive with the substrate.\n \n \n \n \n substrate \n \n \n product \n \n \n Inhibitor \n \n \n Kms \n \n \n Kmp \n \n \n Vf \n \n \n Vr \n \n \n Ki \n \n \n \n \n \n \n \n \n \n Vf \n substrate \n \n Kms \n \n \n \n \n \n Vr \n product \n \n Kmp \n \n \n \n \n 1 \n \n \n \n \n \n \n substrate \n Kms \n \n \n \n product \n Kmp \n \n \n \n \n 1 \n \n \n Inhibitor \n Ki \n \n \n \n \n \n \n \n " [src_code:NR] -is_a: SBO:0000430 ! enzymatic rate law for modulated unireactant enzymes - -[Term] -id: SBO:0000459 -name: stimulator -def: "Substance that accelerates the velocity of a chemical reaction without itself being consumed or transformed. " [src_code:NR] -synonym: "activator" [] -is_a: SBO:0000019 ! modifier - -[Term] -id: SBO:0000460 -name: enzymatic catalyst -def: "A substance that accelerates the velocity of a chemical reaction without itself being consumed or transformed\, by lowering the free energy of the transition state. The substance acting as a catalyst is an enzyme." [src_code:NR] -is_a: SBO:0000013 ! catalyst - -[Term] -id: SBO:0000461 -name: essential activator -def: "A substance that is absolutely required for occurrence and stimulation of a reaction." [src_code:NR] -synonym: "necessary stimulator" [] -is_a: SBO:0000459 ! stimulator - -[Term] -id: SBO:0000462 -name: non-essential activator -def: "An activator which is not necessary for an enzymatic reaction\, but whose presence will further increase enzymatic activity. " [src_code:NR] -is_a: SBO:0000459 ! stimulator - -[Term] -id: SBO:0000463 -name: standard biochemical potential -def: "The biochemical potential of a substance measured at standard concentrations and under standard conditions." [src_code:NR] -synonym: "standard chemical potential" [] -is_a: SBO:0000303 ! biochemical potential - -[Term] -id: SBO:0000464 -name: state variable assignment -def: "Assignment of a state or a value to a state variable\, characteristic or property\, of a biological entity." [src_code:NR] -is_a: SBO:0000375 ! process - -[Term] -id: SBO:0000465 -name: spatial measure -def: "The measurable dimensions of an object which are minimally required to define the space that an object occupies." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000466 -name: length -def: "The length of an object is the longest measurable distance between its extremities. " [src_code:NR] -is_a: SBO:0000465 ! spatial measure - -[Term] -id: SBO:0000467 -name: area -def: "The area of an object is a quantity expressing its two-dimensional size\, usually part or all of its surface. " [src_code:NR] -is_a: SBO:0000465 ! spatial measure - -[Term] -id: SBO:0000468 -name: volume -def: "A quantity representing the three-dimensional space occupied by all or part of an object." [src_code:NR] -is_a: SBO:0000465 ! spatial measure - -[Term] -id: SBO:0000469 -name: containment -def: "An entity that is a subset of another entity or object." [src_code:NR] -synonym: "inclusion" [] -is_a: SBO:0000413 ! positional relationship - -[Term] -id: SBO:0000470 -name: mass fraction -def: "For a given substance\, A\, its mass fraction (x A) is defined as the ratio of its mass (m A) to the total mass (m total) in which it is present\, where the sum of all mass fractions is equal to 1. This provides a means to express concentration in a dimensionless size. " [src_code:NR] -is_a: SBO:0000540 ! fraction of an entity pool - -[Term] -id: SBO:0000471 -name: molal concentration of an entity -def: "Molality denotes the number of moles of solute per kilogram of solvent (not solution). The term molal solution is used as a shorthand for a \"one molal solution\"\, i.e. a solution which contains one mole of the solute per kilogram of the solvent. The SI unit for molality is mol/kg." [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000472 -name: molar concentration of an entity -def: "Molarity\, or molar concentration\, denotes the number of moles of a given substance per litre of solution. The unit of measure of molarity is mol/L\, molar\, or the capital letter M as an abbreviated form." [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000473 -name: denotement -def: "Term to signify where a material or conceptual entity is represented or denoted by a symbol or by some other abbreviated form. " [src_code:NR] -is_a: SBO:0000552 ! reference annotation - -[Term] -id: SBO:0000474 -name: convenience function -def: "Mathematical function commonly used in biological modeling\, which enable simplification of more complex expressions" [src_code:NR] -is_a: SBO:0000064 ! mathematical expression - -[Term] -id: SBO:0000475 -name: periodic forcing function -def: "Function that enables the modeling of cyclic inputs with on and off phases\, such as the light and dark phases in circadian rhythm. It includes parameters for the 'on' period (Tp)\, the cycle period (Tc)\, and the time taken to move or 'ramp' between 'on' and 'off' stages (Tw). Theta0 and Theta1 represent the minimal offset and maximal values of 'on' stage\, respectively. Small values of Tw result in step-like changes. Phi is the time of the phase shift offset. In the case of light forcing\, Tp represents 'light' period\, Tc the cycle period\, and Tw the 'twilight' timescale. Theta0 is the light value at the off state\, and Theta1 the additional value at the on phase. \n \n \n time \n Theta0 \n Theta1 \n Phi \n Tp \n Tc \n Tw \n \n \n Theta0 \n \n \n 0.5 \n Theta1 \n \n \n \n \n \n \n 1 \n \n \n \n \n \n \n \n \n time \n Phi \n \n \n \n Tc \n \n \n \n \n \n \n time \n Phi \n \n Tc \n \n \n \n \n Tw \n \n \n \n \n \n 1 \n \n \n \n \n \n \n \n \n \n \n time \n Phi \n \n \n \n Tc \n \n \n \n \n \n \n time \n Phi \n \n Tc \n \n \n \n \n Tp \n \n Tw \n \n \n \n \n 1 \n \n \n \n \n \n \n \n \n \n \n time \n Phi \n \n \n \n Tc \n \n \n \n \n \n \n time \n Phi \n \n Tc \n \n \n \n \n Tc \n \n Tw \n \n \n \n \n \n \n \n" [src_code:NR] -synonym: "input signal step function" [] -is_a: SBO:0000474 ! convenience function - -[Term] -id: SBO:0000476 -name: period -def: "The period is the duration of one cycle in a repeating event. \[wikipedia\]" [src_code:NR] -is_a: SBO:0000347 ! duration - -[Term] -id: SBO:0000477 -name: phase shift -def: "The measurable amount of time by which a periodic or cyclic is shifted or offset from defined reference point." [src_code:NR] -synonym: "temporal offset" [] -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000478 -name: powered product of Michaelis constant -def: "The product of the Michaelis constants\, to the power of their respective stoichiometric coefficients\, for either substrates or products.\n \n Km\n x\n n\n \n \n i \n 1 \n x \n \n\t\n\t\n\t \n\t Km\n\t i \n\t\n\t\n\t \n\t n\n\t i \n\t\n \n \n \n" [src_code:NR] -is_a: SBO:0000193 ! equilibrium or steady-state constant - -[Term] -id: SBO:0000479 -name: powered product of substrate Michaelis constants -def: "The product of the substrate Michaelis constants\, to the power of their respective stoichiometric coefficients.\n \n Kms\n x\n n\n \n \n i \n 1 \n x \n \n\t\n\t\n\t \n\t Kms\n\t i \n\t\n\t\n\t \n\t n\n\t i \n\t\n \n \n \n\n" [src_code:NR] -is_a: SBO:0000478 ! powered product of Michaelis constant - -[Term] -id: SBO:0000480 -name: powered product of product Michaelis constants -def: "The product of the product Michaelis constants\, to the power of their respective stoichiometric coefficients.\n \n Km\n x\n n\n \n \n i \n 1 \n x \n \n\t\n\t\n\t \n\t Km\n\t i \n\t\n\t\n\t \n\t n\n\t i \n\t\n \n \n \n" [src_code:NR] -is_a: SBO:0000478 ! powered product of Michaelis constant - -[Term] -id: SBO:0000481 -name: stoichiometric coefficient -def: "The stoichiometric coefficient represents the degree to which a chemical species participates in a reaction. It corresponds to the number of molecules of a reactant that are consumed or produced with each occurrence of a reaction event." [src_code:NR] -is_a: SBO:0000380 ! biochemical coefficient - -[Term] -id: SBO:0000482 -name: geometric mean rate constant -def: "The geometric mean turnover rate of an enzyme in either forward or backward direction for a reaction\, measured per second.\n \n k\n n\n \n \n n \n \n \n\t\n\t i \n\t 1 \n\t n \n\t\n\t \n\t k\n\t i \n\t\n \n \n \n" [src_code:NR] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000483 -name: forward geometric mean rate constant -def: "The geometric mean turnover rate of an enzyme in the forward direction for a reaction\, measured per second.\n \n kf\n n\n \n \n n \n \n \n\t\n\t i \n\t 1 \n\t n \n\t\n\t \n\t kf\n\t i \n\t\n \n \n \n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000484 -name: reverse geometric mean rate constant -def: "The geometric mean turnover rate of an enzyme in the reverse direction for a reaction\, measured per second.\n \n kr\n n\n \n \n n \n \n \n\t\n\t i \n\t 1 \n\t n \n\t\n\t \n\t kr\n\t i \n\t\n \n \n \n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000485 -name: basal rate constant -def: "The minimal velocity observed under defined conditions\, which may or may not include the presence of an effector. For example in an inhibitory system\, this would be the residual velocity observed under full inhibition. In non-essential activation\, this would be the velocity in the absence of any activator." [src_code:NR] -is_a: SBO:0000046 ! zeroth order rate constant - -[Term] -id: SBO:0000486 -name: relative basal rate constant -def: "The ratio of the basal activity to the maximal velocity of a reaction. The values range between 0 and 1.\n \n b \n vmax\n \n \n b \n vmax \n \n \n " [src_code:NR] -is_a: SBO:0000381 ! biochemical proportionality coefficient - -[Term] -id: SBO:0000487 -name: relative activity function -def: "Function which ranges from 0 to 1\, to describe the relative activation or inhibition of a reaction or process\, actual or conceptual. " [src_code:NR] -is_a: SBO:0000474 ! convenience function - -[Term] -id: SBO:0000488 -name: relative activation function -def: "Function which ranges from 0 to 1\, to describe the relative activation of a reaction or process\, actual or conceptual. " [src_code:NR] -is_a: SBO:0000487 ! relative activity function - -[Term] -id: SBO:0000489 -name: relative inhibition function -def: "Function which ranges from 0 to 1\, to describe the relative inhibition of a reaction or process\, actual or conceptual. " [src_code:NR] -is_a: SBO:0000487 ! relative activity function - -[Term] -id: SBO:0000490 -name: number of products -def: "Number of molecules which are generated by an enzyme." [src_code:NR] -is_a: SBO:0000188 ! number of biochemical items - -[Term] -id: SBO:0000491 -name: diffusion coefficient -def: "A proportionality constant representing the amount of substance diffusing across a unit area through a unit concentration gradient in unit time. The higher the diffusion coefficient (of one substance with respect to another)\, the faster they diffuse into each other. This coefficient has an SI unit of m²/s (length²/time)." [src_code:NR] -synonym: "diffusivity" [] -is_a: SBO:0000009 ! kinetic constant - -[Term] -id: SBO:0000492 -name: amplitude -def: "Amplitude is the magnitude of change in the oscillating variable\, with each oscillation\, within an oscillating system. " [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000493 -name: functional domain -def: "A spatial region of an entity that confers a function" [src_code:NR] -is_a: SBO:0000241 ! functional entity - -[Term] -id: SBO:0000494 -name: binding site -def: "A specific domain of a spatio-temporal entity to which another spatio-temporal entity is able to bind\, forming chemical bonds. " [src_code:NR] -is_a: SBO:0000493 ! functional domain - -[Term] -id: SBO:0000495 -name: catalytic site -def: "A catalytic site is the region which confers specificity of a substrate for the binding entity\, and where specific reactions take place in the conversion of the substrate to the product. " [src_code:NR] -is_a: SBO:0000493 ! functional domain - -[Term] -id: SBO:0000496 -name: transmembrane domain -def: "A transmembrane domain is any three-dimensional protein structure which is thermodynamically stable in a membrane. This may be a single alpha helix\, a stable complex of several transmembrane alpha helices\, a transmembrane beta barrel\, a beta-helix of gramicidin A\, or any other structure.\n\n" [src_code:NR] -is_a: SBO:0000493 ! functional domain - -[Term] -id: SBO:0000497 -name: ternary switch -def: "A parameter that has three discrete values which may be alternated between. " [src_code:NR] -is_a: SBO:0000389 ! switch value - -[Term] -id: SBO:0000498 -name: relative activity -def: "Value which ranges from 0 to 1\, to describe the relative activity of a process or reaction. " [src_code:NR] -is_a: SBO:0000381 ! biochemical proportionality coefficient - -[Term] -id: SBO:0000499 -name: genetic interaction -def: "A phenomenon whereby an observed phenotype\, qualitative or quantative\, is not explainable by the simple additive effects of the individual gene pertubations alone. Genetic interaction between perturbed genes is usually expected to generate a 'defective' phenotype. The level of defectiveness is often used to sub-classify this phenomenon.\n" [src_code:NR] -is_obsolete: true - -[Term] -id: SBO:0000500 -name: genetic suppression -def: "Genetic suppression is said to have occurred when the phenotypic effect of an initial mutation in a gene is less severe\, or entirely negated\, by a subsequent mutation. \n" [src_code:NR] -is_a: SBO:0000343 ! genetic interaction - -[Term] -id: SBO:0000501 -name: genetic enhancement -def: "Genetic enhancement is said to have occurred when the phenotypic effect of an initial mutation in a gene is made increasingly severe by a subsequent mutation." [src_code:NR] -is_a: SBO:0000343 ! genetic interaction - -[Term] -id: SBO:0000502 -name: synthetic lethality -def: "Synthetic lethality is said to have occurred where gene mutations\, each of which map to a separate locus\, fail to complement in an offspring to correct a phenotype\, as would be expected.\n\n" [src_code:NR] -is_a: SBO:0000343 ! genetic interaction - -[Term] -id: SBO:0000503 -name: number of entity pool constituents -def: "The numerical quantification of an entity pool. This may be expressed as\, for example\, the number of molecules or the number of moles of identical entities of which an specific entity pool is comprised." [src_code:NR] -is_a: SBO:0000361 ! amount of an entity pool - -[Term] -id: SBO:0000504 -name: mass of an entity pool -def: "The mass that comprises an entity pool." [src_code:NR] -is_a: SBO:0000361 ! amount of an entity pool - -[Term] -id: SBO:0000505 -name: concentration of enzyme -def: "Amount of enzyme present per unit of volume. The participant role 'enzymatic catalyst' is defined in SBO\:0000460." [src_code:NR] -is_a: SBO:0000518 ! concentration of modifier - -[Term] -id: SBO:0000506 -name: mass of enzyme -def: "Amount\, expressed as a mass\, of an enzyme. The participant role 'enzymatic catalyst' is defined in SBO\:0000460." [src_code:NR] -is_a: SBO:0000504 ! mass of an entity pool - -[Term] -id: SBO:0000507 -name: number of an enzyme -def: "Amount\, expressed as a number\, of a specific enzyme comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'enzymatic catalyst' is defined in SBO\:0000460." [src_code:NR] -is_a: SBO:0000517 ! number of a modifier - -[Term] -id: SBO:0000508 -name: number of a reactant -def: "The amount\, expressed as a number\, of a specific reactant comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'reactant' is defined in SBO\:0000010. " [src_code:NR] -is_a: SBO:0000503 ! number of entity pool constituents - -[Term] -id: SBO:0000509 -name: concentration of reactant -def: "The amount of a specific entity pool reactant present per unit of volume. The participant role 'reactant' is defined in SBO\:0000010.\n" [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000510 -name: mass of reactant -def: "The amount\, expressed as a mass\, of a specific reactant entity pool. The participant role 'reactant' is defined in SBO\:0000010." [src_code:NR] -is_a: SBO:0000504 ! mass of an entity pool - -[Term] -id: SBO:0000511 -name: number of a product -def: "The amount\, expressed as a number\, of a specific product comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'product' is defined in SBO\:0000011." [src_code:NR] -is_a: SBO:0000503 ! number of entity pool constituents - -[Term] -id: SBO:0000512 -name: concentration of product -def: "The amount of a specific entity pool product present per unit of volume. The participant role 'product' is defined in SBO\:0000011." [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000513 -name: mass of product -def: "The amount\, expressed as a mass\, of a specific product entity pool. The participant role 'product' is defined in SBO\:0000011." [src_code:NR] -is_a: SBO:0000504 ! mass of an entity pool - -[Term] -id: SBO:0000514 -name: number of a substrate -def: "The amount\, expressed as a number\, of a specific substrate comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'substrate' is defined in SBO\:0000015." [src_code:NR] -is_a: SBO:0000508 ! number of a reactant - -[Term] -id: SBO:0000515 -name: concentration of substrate -def: "The amount of a specific entity pool substrate present per unit of volume. The participant role 'substrate' is defined in SBO\:0000015." [src_code:NR] -is_a: SBO:0000509 ! concentration of reactant - -[Term] -id: SBO:0000516 -name: mass of substrate -def: "The amount\, expressed as a mass\, of a specific substrate entity pool. The participant role 'substrate' is defined in SBO\:0000015." [src_code:NR] -is_a: SBO:0000510 ! mass of reactant - -[Term] -id: SBO:0000517 -name: number of a modifier -def: "The amount\, expressed as a number\, of a specific modifier comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'modifier' is defined in SBO\:0000019." [src_code:NR] -is_a: SBO:0000503 ! number of entity pool constituents - -[Term] -id: SBO:0000518 -name: concentration of modifier -def: "The amount of a specific modifier entity pool present per unit of volume. The participant role 'modifier' is defined in SBO\:0000019." [src_code:NR] -is_a: SBO:0000196 ! concentration of an entity pool - -[Term] -id: SBO:0000519 -name: mass of modifier -def: "The amount\, expressed as a mass\, of a specific modifier entity pool. The participant role 'modifier' is defined in SBO\:0000019." [src_code:NR] -is_a: SBO:0000504 ! mass of an entity pool - -[Term] -id: SBO:0000520 -name: number of an inhibitor -def: "The amount\, expressed as a number\, of a specific inhibitor comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'inhibitor' is defined in SBO\:0000020." [src_code:NR] -is_a: SBO:0000517 ! number of a modifier - -[Term] -id: SBO:0000521 -name: concentration of inhibitor -def: "The amount of a specific inhibitor entity pool present per unit of volume. The participant role 'inhibitor' is defined in SBO\:0000020.\n" [src_code:NR] -is_a: SBO:0000518 ! concentration of modifier - -[Term] -id: SBO:0000522 -name: mass of inhibitor -def: "The amount\, expressed as a mass\, of a specific inhibitor entity pool. The participant role 'inhibitor' is defined in SBO\:0000020." [src_code:NR] -is_a: SBO:0000519 ! mass of modifier - -[Term] -id: SBO:0000523 -name: number of an activator -def: "The amount\, expressed as a number\, of a specific activator comprising an entity pool. This may be expressed\, for example\, as the number of molecules\, or the number of moles. The participant role 'activator' is defined in SBO\:0000459. " [src_code:NR] -is_a: SBO:0000517 ! number of a modifier - -[Term] -id: SBO:0000524 -name: concentration of activator -def: "The amount of a specific activator entity pool present per unit of volume. The participant role 'activator' is defined in SBO\:0000459." [src_code:NR] -is_a: SBO:0000518 ! concentration of modifier - -[Term] -id: SBO:0000525 -name: mass of activator -def: "The amount\, expressed as a mass\, of a specific activator entity pool. The participant role 'activator' is defined in SBO\:0000459." [src_code:NR] -is_a: SBO:0000519 ! mass of modifier - -[Term] -id: SBO:0000526 -name: protein complex formation -def: "The process by which two or more proteins interact non-covalently to form a protein complex (SBO\:0000297)." [src_code:NR] -is_a: SBO:0000344 ! molecular interaction - -[Term] -id: SBO:0000527 -name: modular rate law -def: "Modular rate laws are a set of rate laws that provide a means to parameterise a system in a manner that is a compromise between mathematical abstraction and biochemical detail. They share the same common form\:\n\nv = u f (T/(D + Dreg))\n\nThe individual numerator and denominator terms can substituted with alternative forms\, depending on reaction details and model formulation\, to generate specific modular rate laws. The terms represented are\,\nv\, reaction rate\,\nu\, enzyme amount\,\nT\, modular term derived from stoichiometries\, metabolite concentrations and reactant constants\,\nD\, modular term for polynomial of scaled concentrations\,\nDreg\, competitive regulation binding states term\,\nf\, modular term for regulation factor." [src_code:NR] -is_a: SBO:0000001 ! rate law - -[Term] -id: SBO:0000528 -name: common modular rate law -def: "The common modular rate law is a generalised form of reversible Michaelis Menten kinetics\, using a denominator where each binding state of the enzyme is represented. It is assumed that substrates and products bind independently and randomly\, and that substrates and products cannot be bound at the same time." [src_code:NR] -is_a: SBO:0000527 ! modular rate law - -[Term] -id: SBO:0000529 -name: direct binding modular rate law -def: "The direct binding modular rate law makes the assumption that both substrates and products bind simultaneously and in a single step\, hence the total binding states possible enumerate to 3\, nothing bound\, substrates bound\, and products bound. Substrates and products cannot be bound at the same time." [src_code:NR] -is_a: SBO:0000527 ! modular rate law - -[Term] -id: SBO:0000530 -name: simultaneous binding modular rate law -def: "The simultaneous binding modular rate law makes the assumption that substrates and products can be bound simultaneously\, and in any combination." [src_code:NR] -is_a: SBO:0000527 ! modular rate law - -[Term] -id: SBO:0000531 -name: power-law modular rate law -def: "For the power-law rate law\, the denominator is set to be a constant\, and the rate law does not saturate." [src_code:NR] -is_a: SBO:0000527 ! modular rate law - -[Term] -id: SBO:0000532 -name: force-dependent modular rate law -def: "Modular rate law where the D term is given by the square root of the product of\nterms (c/KM)^m where c\, KM\, and m denote the concentrations\, Michaelis constants\, and molecularities\, respectively\, and the product is taken over all reactants and products involved in the reaction." [src_code:NR] -is_a: SBO:0000527 ! modular rate law - -[Term] -id: SBO:0000533 -name: specific activator -def: "An essential activator that affects the apparent value of the specificity\nconstant. Mechanistically\, the activator would need to be bound before\nreactant and product binding can take place." [src_code:NR] -is_a: SBO:0000461 ! essential activator - -[Term] -id: SBO:0000534 -name: catalytic activator -def: "An essential activator that affects the apparent value of the catalytic\nconstant." [src_code:NR] -is_a: SBO:0000461 ! essential activator - -[Term] -id: SBO:0000535 -name: binding activator -def: "An essential activator that affects the apparent value of the Michaelis\nconstant(s)." [src_code:NR] -is_a: SBO:0000461 ! essential activator - -[Term] -id: SBO:0000536 -name: partial inhibitor -def: "Substance that\, when bound\, decreases enzymatic activity to a lower\,\nnonzero value\, without itself being consumed or transformed by the\nreaction\, and without sterically hindering the interaction between\nreactants. The enzyme-inhibitor complex does retain some basal level of activity." [src_code:NR] -is_a: SBO:0000207 ! non-competitive inhibitor - -[Term] -id: SBO:0000537 -name: complete inhibitor -def: "Substance that\, when bound\, completely negates enzymatic activity\, without\nitself being consumed or transformed by the reaction\, and without\nsterically hindering the interaction between reactants. The inhibitor\nbinds to all enzyme species independently and with the same affinity\,\ncompletely inhibiting any enzymatic activity." [src_code:NR] -is_a: SBO:0000207 ! non-competitive inhibitor - -[Term] -id: SBO:0000538 -name: ionic permeability -def: "A parameter that represents the permeability of an ion channel with respect to a particular ion." [src_code:NR] -synonym: "membrane permeability" [] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000539 -name: probabilistic parameter -def: "A quantitative parameter that represents a probability value\, assigned to a specific event." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000540 -name: fraction of an entity pool -def: "A ratio that represents the quantity of a defined constituent entity over the total number of all constituent entities present. " [src_code:NR] -is_a: SBO:0000360 ! quantity of an entity pool - -[Term] -id: SBO:0000541 -name: mole fraction -def: "The number of moles of a constituent entity\, divided by the total number of all constituent entities present in a system. " [src_code:NR] -is_a: SBO:0000540 ! fraction of an entity pool - -[Term] -id: SBO:0000542 -name: basic reproductive ratio -def: "An epidemiological term representing the mean number of secondary cases which result from a single infection\, where the population under consideration has no immunity\, and no intervention is performed." [src_code:NR] -synonym: "basic reproduction number" [] -synonym: "basic reproductive rate" [] -synonym: "R0" [] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000543 -name: protein aggregate -def: "A nonspecific coalescence of misfolded proteins which may or may not form a precipitate\, depending upon particle size." [src_code:NR] -is_a: SBO:0000296 ! macromolecular complex - -[Term] -id: SBO:0000544 -name: metadata representation -def: "Supplementary information relating to a primary item of data\, traditionally termed 'data about data'. It can describe\, for example\, the location or type of the data\, or its relationship to other data." [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000545 -name: systems description parameter -def: "A value\, numerical or symbolic\, that defines certain characteristics of systems or system functions\, or is necessary in their derivation." [src_code:NR] -is_a: SBO:0000000 ! systems biology representation - -[Term] -id: SBO:0000546 -name: qualitative systems description parameter -def: "A non-numerical value that defines certain characteristics of systems or system functions." [src_code:NR] -is_a: SBO:0000545 ! systems description parameter - -[Term] -id: SBO:0000547 -name: boolean logical framework -def: "Equationally defined algebraic framework usually interpreted as a two-valued logic using the basic Boolean operations (conjunction\, disjunction and negation)\, together with the constants '0' and '1' denoting false and true values\, respectively." [src_code:NR] -is_a: SBO:0000234 ! logical framework - -[Term] -id: SBO:0000548 -name: multi-valued logical framework -def: "Extension of the boolean logical framework which associates a defined number of possible integer values (states) with the variables." [src_code:NR] -is_a: SBO:0000547 ! boolean logical framework - -[Term] -id: SBO:0000549 -name: fuzzy logical framework -def: "Extension of the Boolean logical framework which allows intermediate or undetermined values for the logical variables." [src_code:NR] -is_a: SBO:0000547 ! boolean logical framework - -[Term] -id: SBO:0000550 -name: annotation -def: "Supplementary information that does not modify the semantics of the presented information." [src_code:NR] -is_a: SBO:0000544 ! metadata representation - -[Term] -id: SBO:0000551 -name: controlled short label -def: "The use of an abbreviated name\, taken from a controlled vocabulary of terms\, which is used to represent some information about the entity to which it is attached." [src_code:NR] -is_a: SBO:0000555 ! controlled annotation - -[Term] -id: SBO:0000552 -name: reference annotation -def: "Additional information that supplements existing data\, usually in a document\, by providing a link to more detailed information\, which is held externally\, or elsewhere." [src_code:NR] -is_a: SBO:0000550 ! annotation - -[Term] -id: SBO:0000553 -name: bibliographical reference -def: "An annotation which directs one to information contained within a published body of knowledge\, usually a book or scientific journal." [src_code:NR] -is_a: SBO:0000552 ! reference annotation - -[Term] -id: SBO:0000554 -name: database cross reference -def: "An annotation which directs one to information contained within a database." [src_code:NR] -synonym: "database cross-reference" [] -synonym: "db xref" [] -is_a: SBO:0000552 ! reference annotation - -[Term] -id: SBO:0000555 -name: controlled annotation -def: "Annotation which complies with the full set of defined rules in its construction." [src_code:NR] -is_a: SBO:0000557 ! embedded annotation - -[Term] -id: SBO:0000556 -name: uncontrolled annotation -def: "Annotation which does not comply with\, or is not restricted by\, any rules in its construction. Examples would include free text annotations." [src_code:NR] -is_a: SBO:0000557 ! embedded annotation - -[Term] -id: SBO:0000557 -name: embedded annotation -def: "Annotation that directly incorporates information into the body of a document." [src_code:NR] -is_a: SBO:0000550 ! annotation - -[Term] -id: SBO:0000558 -name: specific activity -def: "A measure of enzyme activity under standard conditions\, at a specific substrate concentration (usually saturation)\, expressed as the amount of product formed per unit time\, per amount of enzyme. This is often expressed as micromol per min per mg\, rather than the less practical official unit\, Katal (1 mol per second)." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000559 -name: enzyme activity -def: "A measure of the amount of active enzyme present\, expressed under specified conditions. This is often expressed as micromol per min (also known as enzyme unit\, U)\, rather than the less practical official SI unit\, Katal (1 mol per second). Enzyme activity normally refers to the natural substrate for the enzyme\, but can also be given for standardised substrates such as gelatin\, where it is then referred to as GDU (Gelatin Digesting Units)." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000560 -name: mass action rate law for first order irreversible reactions\, single essential stimulator\, continuous scheme -def: "Reaction scheme in which the reaction velocity is direct proportional to the activity or concentration of a single molecular species. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of the stimulator. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n A\n \n \n k\n A\n \n \n\n " [src_code:NR] -is_a: SBO:0000163 ! mass action rate law for irreversible reactions\, continuous scheme - -[Term] -id: SBO:0000561 -name: mass action rate law for first order irreversible reactions\, single essential stimulator\, discrete scheme -def: "Reaction scheme in which the reaction velocity is direct proportional to the activity or quantity of a single molecular species. The reaction scheme does not include any reverse process that creates the reactants from the products. The change of a product quantity is proportional to the quantity of the stimulator. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n A\n \n \n c\n A\n \n \n\n" [src_code:NR] -is_a: SBO:0000166 ! mass action rate law for irreversible reactions\, discrete scheme - -[Term] -id: SBO:0000562 -name: mass action like rate law for second order irreversible reactions\, one reactant\, one essential stimulator -def: "Reaction scheme where the products are created from a reactant and the change of a product quantity is proportional to the product of the reactant and the stimulator activities. The reaction scheme does not include any reverse process that creates the reactant from the products. The change of a product quantity is proportional to the quantity of the reactant and the stimulator. " [src_code:NR] -is_a: SBO:0000045 ! mass action rate law for second order irreversible reactions - -[Term] -id: SBO:0000563 -name: mass action like rate law for second order irreversible reactions\, one reactant\, one essential stimulator\, continuous scheme -def: "Reaction scheme where the products are created from a reactant and the change of a product quantity is proportional to the product of the reactant and the stimulator activities. The reaction scheme does not include any reverse process that creates the reactant from the products. The change of a product quantity is proportional to the quantity of the reactant and the stimulator. It is to be used in a reaction modelled using a continuous framework.\n\n \n k\n R\n A\n \n \n k\n R\n A\n \n \n\n " [src_code:NR] -is_a: SBO:0000562 ! mass action like rate law for second order irreversible reactions\, one reactant\, one essential stimulator - -[Term] -id: SBO:0000564 -name: mass action like rate law for second order irreversible reactions\, one reactant\, one essential stimulator\, discrete scheme -def: "Reaction scheme where the products are created from a reactant and the change of a product quantity is proportional to the product of the reactant and the stimulator quantities. The reaction scheme does not include any reverse process that creates the reactant from the products. The change of a product quantity is proportional to the quantity of the reactant and the stimulator. It is to be used in a reaction modelled using a discrete framework.\n \n \n c\n R\n A\n \n \n c\n R\n A\n \n \n\n" [src_code:NR] -is_a: SBO:0000562 ! mass action like rate law for second order irreversible reactions\, one reactant\, one essential stimulator - -[Term] -id: SBO:0000565 -name: systems description constant -def: "A physical constant that is required in the calculation of a system parameter. " [src_code:NR] -is_a: SBO:0000545 ! systems description parameter - -[Term] -id: SBO:0000566 -name: relative permeability -def: "The permeability of an ion through a channel or membrane expressed in relation to the reference ion\, which is given the value 1. For example\, if a membrane is most permeable to K+\, then that is assigned the reference permeability value of 1\, and the value for Na+ may be 0.05." [src_code:NR] -is_a: SBO:0000538 ! ionic permeability - -[Term] -id: SBO:0000567 -name: universal gas constant -def: "A physical constant featured in many fundamental equations in the physical sciences. It is equivalent to the Boltzmann constant\, but expressed in units of energy per temperature increment per mole (rather than energy per temperature increment per particle). It has the value 8.314 J.K-1.mol-1 and is denoted by the symbol R." [src_code:NR] -synonym: "gas constant" [] -synonym: "ideal gas constant" [] -synonym: "molar gas constant" [] -is_a: SBO:0000565 ! systems description constant - -[Term] -id: SBO:0000568 -name: Faraday constant -def: "Named after Michael Faraday\, it is the magnitude of electric charge per mole of electrons. It has the value 96\,485.3365 C/mol (Coulombs per Mole)\, and the symbol F." [src_code:NR] -is_a: SBO:0000565 ! systems description constant - -[Term] -id: SBO:0000569 -name: Goldman equation -def: "Expression to determine the equilibrium potential (membrane potential) across a cellular membrane\, taking into consideration all the ions on either side of the membrane\, and their permeability through the membrane. Permeability values are often recorded as relative permeability\, with the most permeable ion being given a reference value of 1. The unit of measure for membrane potential is Volts\, though values are typically reported as millivolts (mV).\n\nThe given formula represents the voltage equation for 'C' monovalent cations\, and 'A' monovalent anions\, assuming that C is the most permeable\, and thereby reporting all other permeabilities as a proportion of the reference value\, of 1. 'P' represents the membrane permeability of C (assumed reference molecule\, value 1)\, 'p'\, the relative permeability of each non-reference molecule\, 'C'\, the external monovalent cation\, 'c'\, the internal monovalent cation concentration\, 'A'\, the external monovalent anion\, 'a'\, the internal monovalent anion concentration\, 'R'\, the universal gas constant\, 'T'\, the temperature in Kelvin\, 'F' the Faraday constant.\n \n \n R\n \n \n T\n \n \n F\n \n \n P\n \n \n p\n \n \n C\n \n \n c\n \n \n A\n \n \n a\n \n \n \n \n \n \n \n R\n T\n \n \n F\n \n \n \n \n \n \n \n \n \n \n \n A\n p\n \n \n \n \n \n \n c\n P\n \n \n \n \n \n \n \n \n \n \n a\n p\n \n \n \n \n \n \n C\n P\n \n \n \n \n \n \n \n \n" [src_code:NR] -synonym: "Goldman-Hodgkin-Katz voltage equation" [] -is_a: SBO:0000391 ! steady state expression - -[Term] -id: SBO:0000570 -name: Nernst potential -def: "The membrane potential at which there is no net flow of an ions across a biological membrane. In a single ion system\, this is equal to the equilibrium potential and can be calculated from the Nernst equation. It takes into consideration the charge\, z\, of the ion\, as well as its concentration inside (x) and outside (X) the membrane.\n \n \n R\n \n \n T\n \n \n F\n \n \n z\n \n \n X\n \n \n x\n \n \n \n \n \n \n R\n T\n \n \n \n z\n F\n \n \n \n \n \n \n \n X\n \n x\n \n \n \n \n" [src_code:NR] -synonym: "reversal potential" [] -is_a: SBO:0000569 ! Goldman equation - -[Term] -id: SBO:0000571 -name: thermodynamic parameter -def: "Parameters used in the study of thermodynamics\, a physical science that\npertains to the relationship between heat and other forms of energy such\nas 'work done' in material bodies." [src_code:NR] -is_a: SBO:0000002 ! quantitative systems description parameter - -[Term] -id: SBO:0000572 -name: enthalpy -def: "A thermodynamic potential whose natural variables are entropy (S) and\npressure (p). The enthalpy of a system\, measured in Joules (J)\, is defined\nas H = U + pV (where H is enthalpy\, U is the internal energy\, p is the\npressure at the system boundary\, and V is the system volume).\nsymbol\: H" [src_code:NR] -is_a: SBO:0000571 ! thermodynamic parameter - -[Term] -id: SBO:0000573 -name: enthalpy change -def: "Change in enthalpy observed in the constituents of a thermodynamic system\nwhen undergoing a transformation or chemical reaction. This is the\npreferred way of expressing the energy changes to a system at constant\npressure\, since enthalpy itself cannot be directly measured. The enthalpy\nchange is positive in endothermic reactions\, negative in exothermic\nreactions\, and is defined as the difference between the final and initial enthalpy of the system under study\: ΔH = Hf - Hi. The standard unit of measure is J. Symbol\: ΔH" [src_code:NR] -is_a: SBO:0000572 ! enthalpy - -[Term] -id: SBO:0000574 -name: standard enthalpy of formation -def: "The enthalpy change observed in a constituent of a thermodynamic system\nwhen one mole of a compound\, in its standard state\, is formed from its\nelementary antecedents\, in their standard state(s)\, under standard\nconditions (1 bar). The standard unit of measure is kJ/mol.\nSymbol\: DeltaHf0\, DeltafH0" [src_code:NR] -is_a: SBO:0000573 ! enthalpy change - -[Term] -id: SBO:0000575 -name: standard enthalpy of reaction -def: "The enthalpy change observed in a constituent of a thermodynamic system\nwhen one mole of substance reacts completely\, under standard conditions (1\nbar). The standard unit of measure is kJ/mol.\nSymbol\: DeltaHr0\, DeltarH0" [src_code:NR] -is_a: SBO:0000573 ! enthalpy change - -[Term] -id: SBO:0000576 -name: entropy -def: "A thermodynamic property which acts as a measure of the state of disorder\nof a system. Its natural variables are the internal energy (U) and the\nvolume (V). It is defined by dS = (1/T)dU + (p/T)dV. The second law of\nthermodynamics states that in an isolated system\, natural processes tend\nto increase in disorder or entropy. The standard unit of measure is Joules\nper Kelvin (J/K).\nsymbol\: S" [src_code:NR] -is_a: SBO:0000571 ! thermodynamic parameter - -[Term] -id: SBO:0000577 -name: entropy change -def: "The increase or decrease of the entropy of a system. For values greater\nthan zero\, there is an implied increase in the disorder of a system\, for\nexample during a reaction\, and decreased disorder where the values are\nless than zero. The entropy change of a process is defined as the initial\nsystem entropy value minus the final entropy value\: DeltaS = Sf - Si. The\nstandard unit of measure is J/K.\nsymbol\: DeltaS" [src_code:NR] -is_a: SBO:0000576 ! entropy - -[Term] -id: SBO:0000578 -name: standard entropy of reaction -def: "The entropy change observed in a thermodynamic system when one mole of\nsubstance reacts completely\, under standard conditions (1 bar). The\nstandard unit of measure is kJ/(mol K). This can be calculated using the\nentropies for products and reactants\: DeltaS(reaction)=sum DeltaS (products) - sum DeltaS reactants. The standard unit of measure is kJ/(mol K).\nsymbol\: DeltaSro" [src_code:NR] -is_a: SBO:0000577 ! entropy change - -[Term] -id: SBO:0000579 -name: standard entropy of formation -def: "The change in entropy associated with the formation of one mole of a\nsubstance from its elements in their standard states under standard\nconditions (1 bar). The standard unit of measure is kJ/(mol K).\nsymbol\: DeltaSfo" [src_code:NR] -is_a: SBO:0000577 ! entropy change - -[Term] -id: SBO:0000580 -name: Gibbs free energy -def: "A thermodynamic potential that measures the useful work obtainable from a\nthermodynamic system at constant pressure and temperature. Its natural\nvariables are pressure (p) and temperature (T) and the definition is\: G =\nH - TS. Gibbs free energy is minimised when a system reaches equilibrium\nat constant pressure and temperature. The standard unit of measure is\nkJ/mol.\nsymbol\: G" [src_code:NR] -synonym: "free enthalpy" [] -synonym: "Gibbs energy" [] -synonym: "Gibbs function" [] -is_a: SBO:0000571 ! thermodynamic parameter - -[Term] -id: SBO:0000581 -name: Gibbs free energy change -def: "The increase or decrease of the Gibbs free energy of a system. During a\nreaction\, this is equal to the change in enthalpy of the system minus the\nchange in the product of the temperature times the entropy of the system\: \nDeltaG = DeltaH - T DeltaS\nA negative value indicates that the reaction will be favoured and will\nrelease energy. The magnitude of the value indicates how far the reaction\nis from equilibrium\, where there will be no free energy change. The\nstandard unit of measure is kJ/mol.\nsymbol\: DeltaG" [src_code:NR] -is_a: SBO:0000580 ! Gibbs free energy - -[Term] -id: SBO:0000582 -name: standard Gibbs energy of formation -def: "The change in Gibbs free energy associated with the formation of 1 mole of\nsubstance from elements in their standard states under standard conditions\n(1 bar). The standard unit of measure is kJ/mol.\nsymbol\: DeltafG(degree)" [src_code:NR] -is_a: SBO:0000581 ! Gibbs free energy change - -[Term] -id: SBO:0000583 -name: standard Gibbs energy of reaction -def: "The Gibbs free energy change observed in a thermodynamic system when one\nmole of substance reacts completely\, under standard conditions (1 bar).\nThe standard unit of measure is kJ/mol.\nsymbol\: ΔGËš" [src_code:NR] -is_a: SBO:0000581 ! Gibbs free energy change - -[Term] -id: SBO:0000584 -name: temporal offset -def: "A duration of time after which a phase shift occurs." [src_code:NR] -is_a: SBO:0000346 ! temporal measure - -[Term] -id: SBO:0000585 -name: simulation duration -def: "The total length of time over which a model is simulated\, where the time scale is indicated within the model simulation. " [src_code:NR] -is_a: SBO:0000347 ! duration - -[Term] -id: SBO:0000586 -name: model time -def: "A conceptualisation of time which is intrinsic to a mathematical model\, and which can be used to describe other variables or parameters of the model." [src_code:NR] -is_a: SBO:0000346 ! temporal measure - -[Typedef] -id: is_a -name: is_a - diff --git a/IPK_lib/src/org/sbml/jsbml/resources/package.html b/IPK_lib/src/org/sbml/jsbml/resources/package.html deleted file mode 100644 index 69346f3fd..000000000 --- a/IPK_lib/src/org/sbml/jsbml/resources/package.html +++ /dev/null @@ -1,4 +0,0 @@ - - Contains classes to deal with and to manage non-Java resources, such as configuration - files. - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParser.java b/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParser.java deleted file mode 100644 index c1e1a3510..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParser.java +++ /dev/null @@ -1,800 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParser.java */ -package org.sbml.jsbml.text.parser; -import java.io.IOException; -import java.util.ArrayList; -import java.util.InvalidPropertiesFormatException; -import java.util.Properties; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.resources.Resource; - -/** - * - * @since 0.8 - * @version $Rev: 950 $ - */ -public class FormulaParser implements FormulaParserConstants { - private void checkSize(ArrayList < ASTNode > arguments, int i) throws ParseException - { - if (arguments.size() > i) - { - throw new ParseException(); - } - } - - private Integer getInteger(ASTNode node) - { - if (node.isUMinus()) - { - if (node.getChild(0).isInteger()) - { - return - node.getChild(0).getInteger(); - } - else - { - return null; - } - } - else - { - if (node.isInteger()) - { - return node.getInteger(); - } - else - { - return null; - } - } - } - - final public Token string() throws ParseException { - Token t; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LOG: - t = jj_consume_token(LOG); - break; - case STRING: - t = jj_consume_token(STRING); - break; - default: - jj_la1[0] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - return t; - } - - final public ASTNode parse() throws ParseException { - ASTNode node = null; - node = Expression(); - return node; - } - - final private ASTNode Expression() throws ParseException { - ASTNode value = null; - value = TermLvl1(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 0: - jj_consume_token(0); - break; - case EOL: - jj_consume_token(EOL); - break; - default: - jj_la1[1] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - return value; - } - - final private ASTNode TermLvl3() throws ParseException { - ASTNode rightChild; - ASTNode leftChild; - ASTNode node = null; - leftChild = Primary(); - label_1: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case POWER: - case FACTORIAL: - ; - break; - default: - jj_la1[2] = jj_gen; - break label_1; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case POWER: - jj_consume_token(POWER); - rightChild = Primary(); - node = new ASTNode(Type.POWER); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - case FACTORIAL: - jj_consume_token(FACTORIAL); - node = new ASTNode(Type.FUNCTION_FACTORIAL); - node.addChild(leftChild); - leftChild = node; - break; - default: - jj_la1[3] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - return leftChild; - } - - final private ASTNode TermLvl2() throws ParseException { - ASTNode rightChild; - ASTNode leftChild; - ASTNode node = null; - leftChild = TermLvl3(); - label_2: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TIMES: - case DIVIDE: - ; - break; - default: - jj_la1[4] = jj_gen; - break label_2; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case TIMES: - jj_consume_token(TIMES); - rightChild = TermLvl3(); - node = new ASTNode('*'); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - case DIVIDE: - jj_consume_token(DIVIDE); - rightChild = TermLvl3(); - Integer left, right; - left = getInteger(leftChild); - right = getInteger(rightChild); - if (left != null && right != null) - { - node = new ASTNode(); - node.setValue(left, right); - leftChild = node; - } - else - { - node = new ASTNode('/'); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - } - break; - default: - jj_la1[5] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - return leftChild; - } - - final private ASTNode TermLvl1() throws ParseException { - ASTNode rightChild = null; - ASTNode leftChild; - ASTNode node = null; - Token t; - String s; - Type type = null; - leftChild = TermLvl2(); - label_3: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - case MINUS: - case COMPARISON: - case BOOLEAN_LOGIC: - ; - break; - default: - jj_la1[6] = jj_gen; - break label_3; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PLUS: - jj_consume_token(PLUS); - rightChild = TermLvl2(); - node = new ASTNode('+'); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - case MINUS: - jj_consume_token(MINUS); - rightChild = TermLvl2(); - node = new ASTNode('-'); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - case BOOLEAN_LOGIC: - t = jj_consume_token(BOOLEAN_LOGIC); - rightChild = TermLvl2(); - s = t.image; - if (s.equalsIgnoreCase("or")) - { - type = ASTNode.Type.LOGICAL_OR; - } - else if (s.equalsIgnoreCase("and")) - { - type = ASTNode.Type.LOGICAL_AND; - } - else if (s.equalsIgnoreCase("xor")) - { - type = ASTNode.Type.LOGICAL_XOR; - } - node = new ASTNode(type); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - case COMPARISON: - t = jj_consume_token(COMPARISON); - rightChild = TermLvl2(); - s = t.image; - if (s.equalsIgnoreCase("<")) - { - type = ASTNode.Type.RELATIONAL_LT; - } - else if (s.equalsIgnoreCase(">")) - { - type = ASTNode.Type.RELATIONAL_GT; - } - else if (s.equalsIgnoreCase("==")) - { - type = ASTNode.Type.RELATIONAL_EQ; - } - else if (s.equalsIgnoreCase("!=")) - { - type = ASTNode.Type.RELATIONAL_NEQ; - } - else if (s.equalsIgnoreCase(">=")) - { - type = ASTNode.Type.RELATIONAL_GEQ; - } - else if (s.equalsIgnoreCase("<=")) - { - type = ASTNode.Type.RELATIONAL_LEQ; - } - node = new ASTNode(type); - node.addChild(leftChild); - node.addChild(rightChild); - leftChild = node; - break; - default: - jj_la1[7] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - return leftChild; - } - - final private ASTNode Primary() throws ParseException, NumberFormatException { - Token t; - double d; - int i; - ASTNode node = new ASTNode(); - ASTNode child, furtherChild; - String s; - String vals [ ]; - ArrayList < ASTNode > arguments = new ArrayList < ASTNode > (); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INTEGER: - t = jj_consume_token(INTEGER); - i = Integer.parseInt(t.image); - node.setValue(i); - return node; - case NUMBER: - t = jj_consume_token(NUMBER); - d = Double.parseDouble(t.image); - node.setValue(d); - return node; - case EXPNUMBER: - t = jj_consume_token(EXPNUMBER); - s = t.image; - vals = s.toLowerCase().split("e"); - if (vals [ 1 ].startsWith("+")) - { - i = Integer.parseInt(vals [ 1 ].substring(1)); - } - else - { - i = Integer.parseInt(vals [ 1 ]); - } - node.setValue(Double.parseDouble(vals [ 0 ]), i); - return node; - default: - jj_la1[9] = jj_gen; - if (jj_2_1(2)) { - t = string(); - jj_consume_token(OPEN_PAR); - child = TermLvl1(); - label_4: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case SLPITTER: - ; - break; - default: - jj_la1[8] = jj_gen; - break label_4; - } - jj_consume_token(SLPITTER); - furtherChild = TermLvl1(); - arguments.add(furtherChild); - } - jj_consume_token(CLOSE_PAR); - s = t.image; - Type type = null; - Properties stringToType = new Properties(); - String path = "cfg/ASTNodeTokens.xml"; - try - { - stringToType.loadFromXML(Resource.class.getResourceAsStream(path)); - } - catch (InvalidPropertiesFormatException e) - { - throw new RuntimeException("Invalid configuration file entries in file " + Resource.class.getResource(path), e); - } - catch (IOException e) - { - throw new RuntimeException("Could not read configuration file " + Resource.class.getResource(path), e); - } - if (stringToType.containsKey(s.toLowerCase())) - { - type = ASTNode.Type.valueOf(stringToType.getProperty(s.toLowerCase()).toUpperCase()); - } - if (s.equalsIgnoreCase("pow")) - { - checkSize(arguments, 1); - node.addChild(child); - } - else if (s.equalsIgnoreCase("sqr")) - { - checkSize(arguments, 0); - node.addChild(child); - node.addChild(new ASTNode(2)); - } - else if (s.equalsIgnoreCase("sqrt")) - { - checkSize(arguments, 0); - node.addChild(new ASTNode(2)); - node.addChild(child); - } - else if (s.equalsIgnoreCase("not")) - { - checkSize(arguments, 0); - node.addChild(child); - type = Type.LOGICAL_NOT; - } - else if (s.equalsIgnoreCase("ln")) - { - checkSize(arguments, 0); - node.addChild(child); - type = Type.FUNCTION_LN; - } - else if (s.equalsIgnoreCase("lambda")) - { - node.addChild(child); - type = Type.LAMBDA; - } - else if (s.equalsIgnoreCase("piecewise")) - { - node.addChild(child); - type = Type.FUNCTION_PIECEWISE; - } - else - { - node.addChild(child); - } - if (type != null) - { - node.setType(type); - } - else - { - node.setName(s); - } - for (ASTNode argument : arguments) - { - node.addChild(argument); - } - return node; - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case OPEN_PAR: - jj_consume_token(OPEN_PAR); - node = TermLvl1(); - jj_consume_token(CLOSE_PAR); - return node; - case MINUS: - jj_consume_token(MINUS); - node = Primary(); - ASTNode uiMinus = new ASTNode('-'); - uiMinus.addChild(node); - return uiMinus; - case NOT: - jj_consume_token(NOT); - node = TermLvl1(); - ASTNode not = new ASTNode(Type.LOGICAL_NOT); - not.addChild(node); - return not; - case LOG: - jj_consume_token(LOG); - child = Primary(); - node = new ASTNode(Type.FUNCTION_LN); - node.addChild(child); - return node; - case STRING: - t = jj_consume_token(STRING); - s = t.image; - if (s.equalsIgnoreCase("true")) - { - node = new ASTNode(Type.CONSTANT_TRUE); - } - else if (s.equalsIgnoreCase("false")) - { - node = new ASTNode(Type.CONSTANT_FALSE); - } - else if (s.equalsIgnoreCase("pi")) - { - node = new ASTNode(Type.CONSTANT_PI); - } - else if (s.equalsIgnoreCase("avogadro")) - { - node = new ASTNode(Type.NAME_AVOGADRO); - } - else if (s.equalsIgnoreCase("time")) - { - node = new ASTNode(Type.NAME_TIME); - } - else if (s.equalsIgnoreCase("exponentiale")) - { - node = new ASTNode(Type.CONSTANT_E); - } - else if (s.equalsIgnoreCase("-infinity")) - { - node = new ASTNode(Double.NEGATIVE_INFINITY); - } - else if (s.equalsIgnoreCase("infinity")) - { - node = new ASTNode(Double.POSITIVE_INFINITY); - } - else - { - node = new ASTNode(s); - } - if (true) {return node;} - break; - default: - jj_la1[10] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - } - throw new Error("Missing return statement in function"); - } - - private boolean jj_2_1(int xla) { - jj_la = xla; jj_lastpos = jj_scanpos = token; - try { return !jj_3_1(); } - catch(LookaheadSuccess ls) { return true; } - finally { jj_save(0, xla); } - } - - private boolean jj_3_1() { - if (jj_3R_5()) return true; - if (jj_scan_token(OPEN_PAR)) return true; - return false; - } - - private boolean jj_3R_5() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(22)) { - jj_scanpos = xsp; - if (jj_scan_token(23)) return true; - } - return false; - } - - /** Generated Token Manager. */ - public FormulaParserTokenManager token_source; - SimpleCharStream jj_input_stream; - /** Current token. */ - public Token token; - /** Next token. */ - public Token jj_nt; - private int jj_ntk; - private Token jj_scanpos, jj_lastpos; - private int jj_la; - private int jj_gen; - final private int[] jj_la1 = new int[11]; - static private int[] jj_la1_0; - static { - jj_la1_init_0(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0xc00000,0x4000001,0x2200,0x2200,0x1800,0x1800,0x30500,0x30500,0x80,0x68,0xe04400,}; - } - final private JJCalls[] jj_2_rtns = new JJCalls[1]; - private boolean jj_rescan = false; - private int jj_gc = 0; - - /** Constructor with InputStream. */ - public FormulaParser(java.io.InputStream stream) { - this(stream, null); - } - /** Constructor with InputStream and supplied encoding */ - public FormulaParser(java.io.InputStream stream, String encoding) { - try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source = new FormulaParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream) { - ReInit(stream, null); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream stream, String encoding) { - try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Constructor. */ - public FormulaParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new FormulaParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader stream) { - jj_input_stream.ReInit(stream, 1, 1); - token_source.ReInit(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Constructor with generated Token Manager. */ - public FormulaParser(FormulaParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - /** Reinitialise. */ - public void ReInit(FormulaParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); - } - - private Token jj_consume_token(int kind) throws ParseException { - Token oldToken; - if ((oldToken = token).next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - if (token.kind == kind) { - jj_gen++; - if (++jj_gc > 100) { - jj_gc = 0; - for (int i = 0; i < jj_2_rtns.length; i++) { - JJCalls c = jj_2_rtns[i]; - while (c != null) { - if (c.gen < jj_gen) c.first = null; - c = c.next; - } - } - } - return token; - } - token = oldToken; - jj_kind = kind; - throw generateParseException(); - } - - static private final class LookaheadSuccess extends java.lang.Error { - - /** - * - */ - private static final long serialVersionUID = -6125196619039674231L; } - final private LookaheadSuccess jj_ls = new LookaheadSuccess(); - private boolean jj_scan_token(int kind) { - if (jj_scanpos == jj_lastpos) { - jj_la--; - if (jj_scanpos.next == null) { - jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); - } else { - jj_lastpos = jj_scanpos = jj_scanpos.next; - } - } else { - jj_scanpos = jj_scanpos.next; - } - if (jj_rescan) { - int i = 0; Token tok = token; - while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } - if (tok != null) jj_add_error_token(kind, i); - } - if (jj_scanpos.kind != kind) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; - return false; - } - - -/** Get the next Token. */ - final public Token getNextToken() { - if (token.next != null) token = token.next; - else token = token.next = token_source.getNextToken(); - jj_ntk = -1; - jj_gen++; - return token; - } - -/** Get the specific Token. */ - final public Token getToken(int index) { - Token t = token; - for (int i = 0; i < index; i++) { - if (t.next != null) t = t.next; - else t = t.next = token_source.getNextToken(); - } - return t; - } - - private int jj_ntk() { - if ((jj_nt=token.next) == null) - return (jj_ntk = (token.next=token_source.getNextToken()).kind); - else - return (jj_ntk = jj_nt.kind); - } - - private java.util.List jj_expentries = new java.util.ArrayList(); - private int[] jj_expentry; - private int jj_kind = -1; - private int[] jj_lasttokens = new int[100]; - private int jj_endpos; - - private void jj_add_error_token(int kind, int pos) { - if (pos >= 100) return; - if (pos == jj_endpos + 1) { - jj_lasttokens[jj_endpos++] = kind; - } else if (jj_endpos != 0) { - jj_expentry = new int[jj_endpos]; - for (int i = 0; i < jj_endpos; i++) { - jj_expentry[i] = jj_lasttokens[i]; - } - jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { - int[] oldentry = (int[])(it.next()); - if (oldentry.length == jj_expentry.length) { - for (int i = 0; i < jj_expentry.length; i++) { - if (oldentry[i] != jj_expentry[i]) { - continue jj_entries_loop; - } - } - jj_expentries.add(jj_expentry); - break jj_entries_loop; - } - } - if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; - } - } - - /** Generate ParseException. */ - public ParseException generateParseException() { - jj_expentries.clear(); - boolean[] la1tokens = new boolean[27]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 11; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1< jj_gen) { - jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; - switch (i) { - case 0: jj_3_1(); break; - } - } - p = p.next; - } while (p != null); - } catch(LookaheadSuccess ls) { } - } - jj_rescan = false; - } - - private void jj_save(int index, int xla) { - JJCalls p = jj_2_rtns[index]; - while (p.gen > jj_gen) { - if (p.next == null) { p = p.next = new JJCalls(); break; } - p = p.next; - } - p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; - } - - static final class JJCalls { - int gen; - Token first; - int arg; - JJCalls next; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserConstants.java b/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserConstants.java deleted file mode 100644 index b28bf473f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserConstants.java +++ /dev/null @@ -1,98 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParserConstants.java */ -package org.sbml.jsbml.text.parser; - - -/** - * Token literal values and constants. - * Generated by org.javacc.parser.OtherFilesGen#start() - * @since 0.8 - * @version $Rev: 635 $ - */ -public interface FormulaParserConstants { - - /** End of File. */ - int EOF = 0; - /** RegularExpression Id. */ - int INTEGER = 3; - /** RegularExpression Id. */ - int DIGIT = 4; - /** RegularExpression Id. */ - int NUMBER = 5; - /** RegularExpression Id. */ - int EXPNUMBER = 6; - /** RegularExpression Id. */ - int SLPITTER = 7; - /** RegularExpression Id. */ - int PLUS = 8; - /** RegularExpression Id. */ - int POWER = 9; - /** RegularExpression Id. */ - int MINUS = 10; - /** RegularExpression Id. */ - int TIMES = 11; - /** RegularExpression Id. */ - int DIVIDE = 12; - /** RegularExpression Id. */ - int FACTORIAL = 13; - /** RegularExpression Id. */ - int OPEN_PAR = 14; - /** RegularExpression Id. */ - int CLOSE_PAR = 15; - /** RegularExpression Id. */ - int COMPARISON = 16; - /** RegularExpression Id. */ - int BOOLEAN_LOGIC = 17; - /** RegularExpression Id. */ - int AND = 18; - /** RegularExpression Id. */ - int OR = 19; - /** RegularExpression Id. */ - int XOR = 20; - /** RegularExpression Id. */ - int NOT = 21; - /** RegularExpression Id. */ - int LOG = 22; - /** RegularExpression Id. */ - int STRING = 23; - /** RegularExpression Id. */ - int IDCHAR = 24; - /** RegularExpression Id. */ - int LETTER = 25; - /** RegularExpression Id. */ - int EOL = 26; - - /** Lexical state. */ - int DEFAULT = 0; - - /** Literal token values. */ - String[] tokenImage = { - "", - "\" \"", - "\"\\t\"", - "", - "", - "", - "", - "", - "\"+\"", - "\"^\"", - "\"-\"", - "\"*\"", - "\"/\"", - "\"!\"", - "\"(\"", - "\")\"", - "", - "", - "", - "", - "", - "", - "\"log\"", - "", - "", - "", - "", - }; - -} diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserTokenManager.java b/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserTokenManager.java deleted file mode 100644 index 737dc49d6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/FormulaParserTokenManager.java +++ /dev/null @@ -1,708 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. FormulaParserTokenManager.java */ -package org.sbml.jsbml.text.parser; - -/** Token Manager. - * @since 0.8 - * @version $Rev: 950 $ - */ -public class FormulaParserTokenManager implements FormulaParserConstants -{ - - /** Debug output. */ - public java.io.PrintStream debugStream = System.out; - /** Set debug output. */ - public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopStringLiteralDfa_0(int pos, long active0) -{ - switch (pos) - { - case 0: - if ((active0 & 0x400000L) != 0L) - { - jjmatchedKind = 23; - return 59; - } - if ((active0 & 0x2000L) != 0L) - return 11; - if ((active0 & 0x400L) != 0L) - return 7; - return -1; - case 1: - if ((active0 & 0x400000L) != 0L) - { - jjmatchedKind = 23; - jjmatchedPos = 1; - return 59; - } - return -1; - default : - return -1; - } -} -private final int jjStartNfa_0(int pos, long active0) -{ - return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); -} -private int jjStopAtPos(int pos, int kind) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - return pos + 1; -} -private int jjMoveStringLiteralDfa0_0() -{ - switch(curChar) - { - case 33: - return jjStartNfaWithStates_0(0, 13, 11); - case 40: - return jjStopAtPos(0, 14); - case 41: - return jjStopAtPos(0, 15); - case 42: - return jjStopAtPos(0, 11); - case 43: - return jjStopAtPos(0, 8); - case 45: - return jjStartNfaWithStates_0(0, 10, 7); - case 47: - return jjStopAtPos(0, 12); - case 94: - return jjStopAtPos(0, 9); - case 108: - return jjMoveStringLiteralDfa1_0(0x400000L); - default : - return jjMoveNfa_0(0, 0); - } -} -private int jjMoveStringLiteralDfa1_0(long active0) -{ - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(0, active0); - return 1; - } - switch(curChar) - { - case 111: - return jjMoveStringLiteralDfa2_0(active0, 0x400000L); - default : - break; - } - return jjStartNfa_0(0, active0); -} -private int jjMoveStringLiteralDfa2_0(long old0, long active0) -{ - if (((active0 &= old0)) == 0L) - return jjStartNfa_0(0, old0); - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { - jjStopStringLiteralDfa_0(1, active0); - return 2; - } - switch(curChar) - { - case 103: - if ((active0 & 0x400000L) != 0L) - return jjStartNfaWithStates_0(2, 22, 59); - break; - default : - break; - } - return jjStartNfa_0(1, active0); -} -private int jjStartNfaWithStates_0(int pos, int kind, int state) -{ - jjmatchedKind = kind; - jjmatchedPos = pos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return pos + 1; } - return jjMoveNfa_0(state, pos + 1); -} -private int jjMoveNfa_0(int startState, int curPos) -{ - int startsAt = 0; - jjnewStateCnt = 59; - int i = 1; - jjstateSet[0] = startState; - int kind = 0x7fffffff; - for (;;) - { - if (++jjround == 0x7fffffff) - ReInitRounds(); - if (curChar < 64) - { - long l = 1L << curChar; - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x3ff000000000000L & l) != 0L) - { - if (kind > 3) - kind = 3; - jjCheckNAddStates(0, 5); - } - else if ((0x7000000200000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; - else if ((0x2400L & l) != 0L) - { - if (kind > 26) - kind = 26; - } - else if (curChar == 46) - jjCheckNAddTwoStates(30, 8); - else if (curChar == 44) - { - if (kind > 7) - kind = 7; - } - else if (curChar == 45) - jjCheckNAddTwoStates(1, 7); - if ((0x3ff000000000000L & l) != 0L) - { - if (kind > 24) - kind = 24; - } - else if ((0x7000000000000000L & l) != 0L) - { - if (kind > 16) - kind = 16; - } - break; - case 7: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(6, 8); - else if (curChar == 46) - jjCheckNAdd(8); - break; - case 59: - case 16: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 23) - kind = 23; - jjCheckNAdd(16); - break; - case 1: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddStates(6, 8); - break; - case 2: - if (curChar == 46) - jjCheckNAdd(3); - break; - case 3: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(3, 4); - break; - case 5: - if ((0x280000000000L & l) != 0L) - jjCheckNAdd(6); - break; - case 6: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 6) - kind = 6; - jjCheckNAdd(6); - break; - case 8: - if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(8, 4); - break; - case 9: - if (curChar == 44) - kind = 7; - break; - case 10: - if ((0x7000000200000000L & l) != 0L) - jjstateSet[jjnewStateCnt++] = 11; - break; - case 11: - if ((0x7000000000000000L & l) != 0L && kind > 16) - kind = 16; - break; - case 17: - if ((0x3ff000000000000L & l) != 0L && kind > 24) - kind = 24; - break; - case 19: - if ((0x2400L & l) != 0L) - kind = 26; - break; - case 24: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 3) - kind = 3; - jjCheckNAddStates(0, 5); - break; - case 25: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 3) - kind = 3; - jjCheckNAdd(25); - break; - case 26: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 5) - kind = 5; - jjCheckNAddTwoStates(26, 27); - break; - case 27: - if (curChar == 46) - jjCheckNAdd(28); - break; - case 28: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 5) - kind = 5; - jjCheckNAdd(28); - break; - case 29: - if (curChar == 46) - jjCheckNAddTwoStates(30, 8); - break; - case 30: - if ((0x3ff000000000000L & l) == 0L) - break; - if (kind > 5) - kind = 5; - jjCheckNAdd(30); - break; - default : break; - } - } while(i != startsAt); - } - else if (curChar < 128) - { - long l = 1L << (curChar & 077); - do - { - switch(jjstateSet[--i]) - { - case 0: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 24) - kind = 24; - } - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 23) - kind = 23; - jjCheckNAddTwoStates(15, 16); - } - if ((0x7fffffe07fffffeL & l) != 0L) - { - if (kind > 25) - kind = 25; - } - if (curChar == 65) - jjAddStates(9, 12); - else if (curChar == 79) - jjCheckNAddStates(13, 16); - else if (curChar == 88) - jjAddStates(17, 20); - else if (curChar == 120) - jjAddStates(21, 22); - else if (curChar == 111) - jjCheckNAddTwoStates(37, 38); - else if (curChar == 97) - jjAddStates(23, 24); - else if (curChar == 78) - jjAddStates(25, 26); - else if (curChar == 110) - jjstateSet[jjnewStateCnt++] = 13; - break; - case 59: - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 23) - kind = 23; - jjCheckNAdd(16); - } - if ((0x7fffffe87fffffeL & l) != 0L) - { - if (kind > 23) - kind = 23; - jjCheckNAddTwoStates(15, 16); - } - break; - case 4: - if ((0x2000000020L & l) != 0L) - jjAddStates(27, 28); - break; - case 12: - if (curChar == 116 && kind > 21) - kind = 21; - break; - case 13: - case 23: - if (curChar == 111) - jjCheckNAdd(12); - break; - case 14: - if (curChar == 110) - jjstateSet[jjnewStateCnt++] = 13; - break; - case 15: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 23) - kind = 23; - jjCheckNAddTwoStates(15, 16); - break; - case 16: - if ((0x7fffffe87fffffeL & l) == 0L) - break; - if (kind > 23) - kind = 23; - jjCheckNAdd(16); - break; - case 17: - if ((0x7fffffe87fffffeL & l) != 0L && kind > 24) - kind = 24; - break; - case 18: - if ((0x7fffffe07fffffeL & l) != 0L && kind > 25) - kind = 25; - break; - case 20: - if (curChar == 78) - jjAddStates(25, 26); - break; - case 21: - if (curChar == 84 && kind > 21) - kind = 21; - break; - case 22: - if (curChar == 79) - jjstateSet[jjnewStateCnt++] = 21; - break; - case 31: - if (curChar == 97) - jjAddStates(23, 24); - break; - case 32: - if (curChar == 100 && kind > 17) - kind = 17; - break; - case 33: - case 55: - if (curChar == 110) - jjCheckNAdd(32); - break; - case 34: - if (curChar == 100 && kind > 18) - kind = 18; - break; - case 35: - case 56: - if (curChar == 110) - jjCheckNAdd(34); - break; - case 36: - if (curChar == 111) - jjCheckNAddTwoStates(37, 38); - break; - case 37: - if (curChar == 114 && kind > 17) - kind = 17; - break; - case 38: - if (curChar == 114 && kind > 19) - kind = 19; - break; - case 39: - if (curChar == 120) - jjAddStates(21, 22); - break; - case 40: - case 44: - if (curChar == 111) - jjCheckNAdd(37); - break; - case 41: - if (curChar == 114 && kind > 20) - kind = 20; - break; - case 42: - case 49: - if (curChar == 111) - jjCheckNAdd(41); - break; - case 43: - if (curChar == 88) - jjAddStates(17, 20); - break; - case 45: - if (curChar == 82 && kind > 17) - kind = 17; - break; - case 46: - if (curChar == 79) - jjCheckNAdd(45); - break; - case 47: - if (curChar == 82 && kind > 20) - kind = 20; - break; - case 48: - if (curChar == 79) - jjstateSet[jjnewStateCnt++] = 47; - break; - case 50: - if (curChar == 79) - jjCheckNAddStates(13, 16); - break; - case 51: - if (curChar == 82 && kind > 19) - kind = 19; - break; - case 52: - if (curChar == 65) - jjAddStates(9, 12); - break; - case 53: - if (curChar == 68 && kind > 17) - kind = 17; - break; - case 54: - if (curChar == 78) - jjstateSet[jjnewStateCnt++] = 53; - break; - case 57: - if (curChar == 68 && kind > 18) - kind = 18; - break; - case 58: - if (curChar == 78) - jjstateSet[jjnewStateCnt++] = 57; - break; - default : break; - } - } while(i != startsAt); - } - else - { - do - { - switch(jjstateSet[--i]) - { - default : break; - } - } while(i != startsAt); - } - if (kind != 0x7fffffff) - { - jjmatchedKind = kind; - jjmatchedPos = curPos; - kind = 0x7fffffff; - } - ++curPos; - if ((i = jjnewStateCnt) == (startsAt = 59 - (jjnewStateCnt = startsAt))) - return curPos; - try { curChar = input_stream.readChar(); } - catch(java.io.IOException e) { return curPos; } - } -} -static final int[] jjnextStates = { - 25, 26, 27, 1, 2, 4, 1, 2, 4, 54, 55, 56, 58, 37, 45, 51, - 38, 44, 46, 48, 49, 40, 42, 33, 35, 22, 23, 5, 6, -}; - -/** Token literal values. */ -public static final String[] jjstrLiteralImages = { -"", null, null, null, null, null, null, null, "\53", "\136", "\55", "\52", -"\57", "\41", "\50", "\51", null, null, null, null, null, null, "\154\157\147", null, -null, null, null, }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "DEFAULT", -}; -static final long[] jjtoToken = { - 0x7fffff9L, -}; -static final long[] jjtoSkip = { - 0x6L, -}; -protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[59]; -private final int[] jjstateSet = new int[118]; -protected char curChar; -/** Constructor. */ -public FormulaParserTokenManager(SimpleCharStream stream){ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; -} - -/** Constructor. */ -public FormulaParserTokenManager(SimpleCharStream stream, int lexState){ - this(stream); - SwitchTo(lexState); -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 59; i-- > 0;) - jjrounds[i] = 0x80000000; -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} - -/** Switch to specified lex state. */ -public void SwitchTo(int lexState) -{ - if (lexState >= 1 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - -protected Token jjFillToken() -{ - final Token t; - final String curTokenImage; - final int beginLine; - final int endLine; - final int beginColumn; - final int endColumn; - String im = jjstrLiteralImages[jjmatchedKind]; - curTokenImage = (im == null) ? input_stream.GetImage() : im; - beginLine = input_stream.getBeginLine(); - beginColumn = input_stream.getBeginColumn(); - endLine = input_stream.getEndLine(); - endColumn = input_stream.getEndColumn(); - t = Token.newToken(jjmatchedKind, curTokenImage); - - t.beginLine = beginLine; - t.endLine = endLine; - t.beginColumn = beginColumn; - t.endColumn = endColumn; - - return t; -} - -int curLexState = 0; -int defaultLexState = 0; -int jjnewStateCnt; -int jjround; -int jjmatchedPos; -int jjmatchedKind; - -/** Get the next Token. */ -public Token getNextToken() -{ - Token matchedToken; - int curPos = 0; - - EOFLoop : - for (;;) - { - try - { - curChar = input_stream.BeginToken(); - } - catch(java.io.IOException e) - { - jjmatchedKind = 0; - matchedToken = jjFillToken(); - return matchedToken; - } - - try { input_stream.backup(0); - while (curChar <= 32 && (0x100000200L & (1L << curChar)) != 0L) - curChar = input_stream.BeginToken(); - } - catch (java.io.IOException e1) { continue EOFLoop; } - jjmatchedKind = 0x7fffffff; - jjmatchedPos = 0; - curPos = jjMoveStringLiteralDfa0_0(); - if (jjmatchedKind != 0x7fffffff) - { - if (jjmatchedPos + 1 < curPos) - input_stream.backup(curPos - jjmatchedPos - 1); - if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) - { - matchedToken = jjFillToken(); - return matchedToken; - } - else - { - continue EOFLoop; - } - } - int error_line = input_stream.getEndLine(); - int error_column = input_stream.getEndColumn(); - String error_after = null; - boolean EOFSeen = false; - try { input_stream.readChar(); input_stream.backup(1); } - catch (java.io.IOException e1) { - EOFSeen = true; - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - if (curChar == '\n' || curChar == '\r') { - error_line++; - error_column = 0; - } - else - error_column++; - } - if (!EOFSeen) { - input_stream.backup(1); - error_after = curPos <= 1 ? "" : input_stream.GetImage(); - } - throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); - } -} - -private void jjCheckNAdd(int state) -{ - if (jjrounds[state] != jjround) - { - jjstateSet[jjnewStateCnt++] = state; - jjrounds[state] = jjround; - } -} -private void jjAddStates(int start, int end) -{ - do { - jjstateSet[jjnewStateCnt++] = jjnextStates[start]; - } while (start++ != end); -} -private void jjCheckNAddTwoStates(int state1, int state2) -{ - jjCheckNAdd(state1); - jjCheckNAdd(state2); -} - -private void jjCheckNAddStates(int start, int end) -{ - do { - jjCheckNAdd(jjnextStates[start]); - } while (start++ != end); -} - -} diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/ParseException.java b/IPK_lib/src/org/sbml/jsbml/text/parser/ParseException.java deleted file mode 100644 index 469467752..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/ParseException.java +++ /dev/null @@ -1,189 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ -/* JavaCCOptions:KEEP_LINE_COL=null */ -package org.sbml.jsbml.text.parser; - -/** - * This exception is thrown when parse errors are encountered. You can - * explicitly create objects of this exception type by calling the method - * generateParseException in the generated parser. - * - * You can modify this class to customize your error reporting mechanisms so - * long as you retain the public fields. - * - * @since 0.8 - * @version $Rev: 635 $ - */ -public class ParseException extends Exception { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - */ - private static final long serialVersionUID = 1L; - - /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. - */ - public ParseException(Token currentTokenVal, - int[][] expectedTokenSequencesVal, - String[] tokenImageVal - ) - { - super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); - currentToken = currentTokenVal; - expectedTokenSequences = expectedTokenSequencesVal; - tokenImage = tokenImageVal; - } - - /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. - */ - - public ParseException() { - super(); - } - - /** Constructor with message. */ - public ParseException(String message) { - super(message); - } - - - /** - * This is the last token that has been consumed successfully. If - * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. - */ - public Token currentToken; - - /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. - */ - public int[][] expectedTokenSequences; - - /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. - */ - public String[] tokenImage; - - /** - * It uses "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser) the correct error message - * gets displayed. - */ - private static String initialise(Token currentToken, - int[][] expectedTokenSequences, - String[] tokenImage) { - String eol = System.getProperty("line.separator", "\n"); - StringBuffer expected = new StringBuffer(); - int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); - } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected.append("..."); - } - expected.append(eol).append(" "); - } - String retval = "Encountered \""; - Token tok = currentToken.next; - for (int i = 0; i < maxSize; i++) { - if (i != 0) retval += " "; - if (tok.kind == 0) { - retval += tokenImage[0]; - break; - } - retval += " " + tokenImage[tok.kind]; - retval += " \""; - retval += add_escapes(tok.image); - retval += " \""; - tok = tok.next; - } - retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn; - retval += "." + eol; - if (expectedTokenSequences.length == 1) { - retval += "Was expecting:" + eol + " "; - } else { - retval += "Was expecting one of:" + eol + " "; - } - retval += expected.toString(); - return retval; - } - - /** - * The end of line string for this machine. - */ - protected String eol = System.getProperty("line.separator", "\n"); - - /** - * Used to convert raw characters to their escaped version - * when these raw version cannot be used as part of an ASCII - * string literal. - */ - static String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - -} -/* JavaCC - OriginalChecksum=0991f265cfc04a8c5a752e12bcb1d54d (do not edit this line) */ diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/SimpleCharStream.java b/IPK_lib/src/org/sbml/jsbml/text/parser/SimpleCharStream.java deleted file mode 100644 index 32fc8d7a7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/SimpleCharStream.java +++ /dev/null @@ -1,472 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ -/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package org.sbml.jsbml.text.parser; - -/** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). - * @since 0.8 - * @version $Rev: 635 $ - */ -public class SimpleCharStream -{ -/** Whether parser is static. */ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; -/** Position in buffer. */ - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 8; - - protected void setTabSize(int i) { tabSize = i; } - protected int getTabSize(int i) { return tabSize; } - - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); - } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos -= tokenBegin); - } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); - } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); - } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - -/** Start. */ - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; - } - else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (tabSize - (column % tabSize)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - -/** Read a character. */ - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return c; - } - - @Deprecated - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - @Deprecated - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - /** Get token end column number. */ - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - /** Get token end line number. */ - public int getEndLine() { - return bufline[bufpos]; - } - - /** Get token beginning column number. */ - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - /** Get token beginning line number. */ - public int getBeginLine() { - return bufline[tokenBegin]; - } - -/** Backup a number of characters. */ - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, 1, 1, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - /** Get token literal value. */ - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - /** Get the suffix. */ - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - /** Reset buffer when finished. */ - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; - } - } - - line = bufline[j]; - column = bufcolumn[j]; - } - -} -/* JavaCC - OriginalChecksum=051033b43684fd8db42c683c6f183bbb (do not edit this line) */ diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/Token.java b/IPK_lib/src/org/sbml/jsbml/text/parser/Token.java deleted file mode 100644 index f37ba834d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/Token.java +++ /dev/null @@ -1,134 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ -/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ -package org.sbml.jsbml.text.parser; - -/** - * Describes the input token stream. - * @since 0.8 - * @version $Rev: 635 $ - */ - -public class Token implements java.io.Serializable { - - /** - * The version identifier for this Serializable class. - * Increment only if the serialized form of the - * class changes. - * - */ - private static final long serialVersionUID = 1L; - - /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. - */ - public int kind; - - /** The line number of the first character of this Token. */ - public int beginLine; - /** The column number of the first character of this Token. */ - public int beginColumn; - /** The line number of the last character of this Token. */ - public int endLine; - /** The column number of the last character of this Token. */ - public int endColumn; - - /** - * The string image of the token. - */ - public String image; - - /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. - */ - public Token next; - - /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. - */ - public Token specialToken; - - /** - * An optional attribute value of the Token. - * Tokens which are not used as syntactic sugar will often contain - * meaningful values that will be used later on by the compiler or - * interpreter. This attribute value is often different from the image. - * Any subclass of Token that actually wants to return a non-null value can - * override this method as appropriate. - */ - public Object getValue() { - return null; - } - - /** - * No-argument constructor - */ - public Token() {} - - /** - * Constructs a new token for the specified Image. - */ - public Token(int kind) - { - this(kind, null); - } - - /** - * Constructs a new token for the specified Image and Kind. - */ - public Token(int kind, String image) - { - this.kind = kind; - this.image = image; - } - - /** - * Returns the image. - */ - public String toString() - { - return image; - } - - /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simply add something like : - * - * case MyParserConstants.ID : return new IDToken(ofKind, image); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use sit in your lexical actions. - */ - public static Token newToken(int ofKind, String image) - { - switch(ofKind) - { - default : return new Token(ofKind, image); - } - } - - public static Token newToken(int ofKind) - { - return newToken(ofKind, null); - } - -} -/* JavaCC - OriginalChecksum=6cae073343d97705e58043994f9addf9 (do not edit this line) */ diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/TokenMgrError.java b/IPK_lib/src/org/sbml/jsbml/text/parser/TokenMgrError.java deleted file mode 100644 index 752897bb2..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/TokenMgrError.java +++ /dev/null @@ -1,152 +0,0 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ -/* JavaCCOptions: */ -package org.sbml.jsbml.text.parser; - -/** - * Token Manager Error. - * - * @since 0.8 - * @version $Rev: 635 $ - */ -public class TokenMgrError extends Error -{ - - /** - * The version identifier for this Serializable class. Increment only if the - * serialized form of the class changes. - * - */ - private static final long serialVersionUID = 1L; - - /* - * Ordinals for various reasons why an Error of this type can be thrown. - */ - - /** - * Lexical error occurred. - */ - static final int LEXICAL_ERROR = 0; - - /** - * An attempt was made to create a second instance of a static token manager. - */ - static final int STATIC_LEXER_ERROR = 1; - - /** - * Tried to change to an invalid lexical state. - */ - static final int INVALID_LEXICAL_STATE = 2; - - /** - * Detected (and bailed out of) an infinite loop in the token manager. - */ - static final int LOOP_DETECTED = 3; - - /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. - */ - int errorCode; - - /** - * Replaces unprintable characters by their escaped (or unicode escaped) - * equivalents in the given string - */ - protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); - char ch; - for (int i = 0; i < str.length(); i++) { - switch (str.charAt(i)) - { - case 0 : - continue; - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); - } else { - retval.append(ch); - } - continue; - } - } - return retval.toString(); - } - - /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character - * Note: You can customize the lexical error message by modifying this method. - */ - protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { - return("Lexical error at line " + - errorLine + ", column " + - errorColumn + ". Encountered: " + - (EOFSeen ? " " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + - "after : \"" + addEscapes(errorAfter) + "\""); - } - - /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. - */ - public String getMessage() { - return super.getMessage(); - } - - /* - * Constructors of various flavors follow. - */ - - /** No arg constructor. */ - public TokenMgrError() { - } - - /** Constructor with message and reason. */ - public TokenMgrError(String message, int reason) { - super(message); - errorCode = reason; - } - - /** Full Constructor. */ - public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { - this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); - } -} -/* JavaCC - OriginalChecksum=b0c0fb80c2c379ad4ed44d98b4a05a2b (do not edit this line) */ diff --git a/IPK_lib/src/org/sbml/jsbml/text/parser/package.html b/IPK_lib/src/org/sbml/jsbml/text/parser/package.html deleted file mode 100644 index c753cadc3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/text/parser/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - Provides classes to parse formula - Strings and to convert these into abstract syntax tree data structures. - All these classes are generated automatically using JavaCC. The JSBML - source code distribution contains the grammar specification necessary - for this in the files folder (FormulaParser.jj). - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/util/Detail.java b/IPK_lib/src/org/sbml/jsbml/util/Detail.java deleted file mode 100644 index 5f8f95802..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/Detail.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.sbml.jsbml.util; - -public class Detail { - - private int category; - private int severity; - - public int getCategory() { - return category; - } - public void setCategory(int category) { - this.category = category; - } - public int getSeverity() { - return severity; - } - public void setSeverity(int severity) { - this.severity = severity; - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/DocumentFactory.java b/IPK_lib/src/org/sbml/jsbml/util/DocumentFactory.java deleted file mode 100644 index d69577a9f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/DocumentFactory.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * $Id: DocumentFactory.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/DocumentFactory.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.InputStream; -import java.io.Reader; - -import org.w3c.dom.Document; -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; - -/** - * - * An interface for XML DOM document factories. - * - * @author Marco Donizelli - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface DocumentFactory { - - /** - * - * Creates an XML DOM document by parsing the content of the specified byte - * stream as XML, using a nonvalidating parser. - * - * @param byteStream - * The byte stream whose content is parsed as XML to create the - * XML DOM document. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the byteStream XML - * content. - * @throws SAXException - * - */ - public Document create(InputStream byteStream, boolean namespaceAware) throws SAXException; - - /** - * - * Creates an XML DOM document by parsing the content of the specified byte - * stream as XML, using a validating parser. - * - * @param byteStream - * The byte stream whose content is parsed as XML to create the - * XML DOM document. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an exception is most likely to be - * thrown by the underlying implementation. - * @param handler - * The error handler to be used to report errors occurred while - * parsing the byteStream XML content. Setting this - * to null will result in the underlying - * implementation using it's own default implementation and - * behavior. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the byteStream XML - * content. - * @throws SAXException - * - */ - public Document create(InputStream byteStream, Object[] schemas, - ErrorHandler handler) throws SAXException; - - /** - * - * Creates an XML DOM document by parsing the content of the specified - * character stream as XML, using a nonvalidating parser. - * - * @param characterStream - * The character stream whose content is parsed as XML to create - * the XML DOM document. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the characterStream - * XML content. - * @throws SAXException - * - */ - public Document create(Reader characterStream, boolean namespaceAware) throws SAXException; - - /** - * - * Creates an XML DOM document by parsing the content of the specified - * character stream as XML, using a validating parser. - * - * @param characterStream - * The character stream whose content is parsed as XML to create - * the XML DOM document. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an exception is most likely to be - * thrown by the underlying implementation. - * @param handler - * The error handler to be used to report errors occurred while - * parsing the characterStream XML content. Setting - * this to null will result in the underlying - * implementation using it's own default implementation and - * behavior. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the characterStream - * XML content. - * - */ - public Document create(Reader characterStream, Object[] schemas, - ErrorHandler handler); -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/IOProgressListener.java b/IPK_lib/src/org/sbml/jsbml/util/IOProgressListener.java deleted file mode 100644 index 7e495b637..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/IOProgressListener.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * $Id: IOProgressListener.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/IOProgressListener.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.util.EventListener; - -/** - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface IOProgressListener extends EventListener { - - /** - * Method to report progress when reading or writing the current object has - * been finished. - * - * @param currObject - * the object that has just been written or read. - */ - void ioProgressOn(Object currObject); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/JAXPFacade.java b/IPK_lib/src/org/sbml/jsbml/util/JAXPFacade.java deleted file mode 100644 index b08ec84c7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/JAXPFacade.java +++ /dev/null @@ -1,694 +0,0 @@ -/* - * $Id: JAXPFacade.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/JAXPFacade.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * - * A convenient Facade to parse and write byte and character streams with - * XML content using the interfaces and classes defined by the JAXP - * specification. - * - * @author Marco Donizelli - * @see DocumentFactory - * @see SAX2Parser - * @see NodeWriter - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class JAXPFacade implements DocumentFactory, SAX2Parser, NodeWriter { - - /** - * - */ - private static JAXPFacade instance_; - /** - * - */ - private static TransformerFactory transformer_factory; - - // - // - // Static initializer. - // - // - static { - - instance_ = new JAXPFacade(); - - try { - transformer_factory = TransformerFactory.newInstance(); - } catch (Exception e) { - throw new ExceptionInInitializerError(e); - } - } - - /** - * - * Creates and returns a new JAXPFacade. - * - * @return A new JAXPFacade. - * - */ - public static JAXPFacade getInstance() { - return instance_; - } - - /** - * - * Writes an XML DOM node to the specified character stream, using a - * javax.xml.transform.Transformer instance created from - * streamSource. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to characterStream. - * @param characterStream - * The character stream where node is to be written. - * @param streamSource - * An object that holds an URI, input stream, etc. - * @param indent - * Flag to indicate whether the output should be indented or not. - * @throws NullPointerException - * If node or characterStream are - * null. - * @throws RuntimeException - * If any error occurs (transformer configuration errors, - * transformer errors). - * - */ - public static void write(Node node, Writer characterStream, - StreamSource streamSource, boolean indent) { - - if (node == null || characterStream == null) { - throw new NullPointerException(); - } - - try { - Transformer transformer = streamSource == null ? transformer_factory - .newTransformer() - : transformer_factory.newTransformer(streamSource); - transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" - : "no"); - transformer.transform(new DOMSource(node), new StreamResult( - characterStream)); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } - - // - // - // Prevents the generation of the default constructor. - // - // - private JAXPFacade() { - } - - /** - * - * Creates an XML DOM document by parsing the content of the specified byte - * stream as XML, using a nonvalidating parser. - * - * @param byteStream - * The byte stream which content is parsed as XML to create the - * XML DOM document. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the byteStream XML - * content. - * @throws SAXException - * @throws NullPointerException - * If byteStream is null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public Document create(InputStream byteStream, boolean namespaceAware) - throws SAXException { - - if (byteStream == null) { - throw new NullPointerException(); - } - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - factory.setNamespaceAware(namespaceAware); - factory.setValidating(false); - DocumentBuilder builder = factory.newDocumentBuilder(); - return builder.parse(byteStream); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw e; - } - } - - /** - * - * Creates an XML DOM document by parsing the content of the specified byte - * stream as XML, using a validating parser. - * - * @param byteStream - * The byte stream whose content is parsed as XML to create the - * XML DOM document. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an - * org.xml.sax.SAXParseException is thrown. - * @param handler - * The error handler to be used to report errors occurred while - * parsing the byteStream XML content. Setting this - * to null will result in the underlying - * implementation using it's own default implementation and - * behavior. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the byteStream XML - * content. - * @throws SAXException - * @throws NullPointerException - * If byteStream is null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public Document create(InputStream byteStream, Object[] schemas, - ErrorHandler handler) throws SAXException { - - if (byteStream == null) { - throw new NullPointerException(); - } - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - factory.setNamespaceAware(true); - factory.setValidating(true); - factory.setAttribute( - "http://java.sun.com/xml/jaxp/properties/schemaLanguage", - "http://www.w3.org/2001/XMLSchema"); - if (schemas != null) { - factory.setAttribute( - "http://java.sun.com/xml/jaxp/properties/schemaSource", - schemas); - } - DocumentBuilder builder = factory.newDocumentBuilder(); - if (handler != null) { - builder.setErrorHandler(handler); - } - return builder.parse(byteStream); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw e; - } - } - - /** - * - * Creates an XML DOM document by parsing the content of the specified - * character stream as XML, using a nonvalidating parser. - * - * @param characterStream - * The character stream whose content is parsed as XML to create - * the XML DOM document. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the characterStream - * XML content. - * @throws SAXException - * @throws NullPointerException - * If characterStream is null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public Document create(Reader characterStream, boolean namespaceAware) - throws SAXException { - - if (characterStream == null) { - throw new NullPointerException(); - } - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - factory.setNamespaceAware(namespaceAware); - factory.setValidating(false); - DocumentBuilder builder = factory.newDocumentBuilder(); - return builder.parse(new InputSource(characterStream)); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw e; - } - } - - /** - * - * Creates an XML DOM document by parsing the content of the specified - * character stream as XML, using a validating parser. - * - * @param characterStream - * The character stream whose content is parsed as XML to create - * the XML DOM document. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an - * org.xml.sax.SAXParseException is thrown. - * @param handler - * The error handler to be used to report errors occurred while - * parsing the characterStream XML content. Setting - * this to null will result in the underlying - * implementation using it's own default implementation and - * behavior. - * @return The org.w3c.dom.Document instance representing the - * XML DOM document created from the characterStream - * XML content. - * @throws NullPointerException - * If characterStream is null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public Document create(Reader characterStream, Object[] schemas, - ErrorHandler handler) { - - if (characterStream == null) { - throw new NullPointerException(); - } - - try { - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - factory.setNamespaceAware(true); - factory.setValidating(true); - factory.setAttribute( - "http://java.sun.com/xml/jaxp/properties/schemaLanguage", - "http://www.w3.org/2001/XMLSchema"); - if (schemas != null) { - factory.setAttribute( - "http://java.sun.com/xml/jaxp/properties/schemaSource", - schemas); - } - DocumentBuilder builder = factory.newDocumentBuilder(); - if (handler != null) { - builder.setErrorHandler(handler); - } - return builder.parse(new InputSource(characterStream)); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Parses the content of a byte stream as XML, using a nonvalidating - * parser and the specified SAX2 default event handler. - * - * @param byteStream - * The byte stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * byteStream. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @throws NullPointerException - * If byteStream or handler are - * null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public void parse(InputStream byteStream, DefaultHandler handler, - boolean namespaceAware) { - - if (byteStream == null || handler == null) { - throw new NullPointerException(); - } - - try { - SAXParserFactory sax_parser_factory = SAXParserFactory - .newInstance(); - sax_parser_factory.setNamespaceAware(namespaceAware); - sax_parser_factory.setValidating(false); - SAXParser sax_parser = sax_parser_factory.newSAXParser(); - sax_parser.parse(byteStream, handler); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (SAXNotRecognizedException e) { - throw new RuntimeException(e); - } catch (SAXNotSupportedException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Parses the content of a byte stream as XML, using a validating - * parser and the specified SAX2 default event handler. - * - * @param byteStream - * The byte stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * byteStream. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an - * org.xml.sax.SAXParseException is thrown. - * @throws NullPointerException - * If byteStream or handler are - * null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public void parse(InputStream byteStream, DefaultHandler handler, - Object[] schemas) { - - if (byteStream == null || handler == null) { - throw new NullPointerException(); - } - - try { - SAXParserFactory sax_parser_factory = SAXParserFactory - .newInstance(); - sax_parser_factory.setNamespaceAware(true); - sax_parser_factory.setValidating(true); - SAXParser sax_parser = sax_parser_factory.newSAXParser(); - sax_parser.setProperty( - "http://java.sun.com/xml/jaxp/properties/schemaLanguage", - "http://www.w3.org/2001/XMLSchema"); - if (schemas != null) { - sax_parser.setProperty( - "http://java.sun.com/xml/jaxp/properties/schemaSource", - schemas); - } - sax_parser.parse(byteStream, handler); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (SAXNotRecognizedException e) { - throw new RuntimeException(e); - } catch (SAXNotSupportedException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Parses the content of a character stream as XML, using a - * nonvalidating parser and the specified SAX2 default event handler. - * - * @param characterStream - * The character stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * characterStream. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * @throws NullPointerException - * If characterStream or handler are - * null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public void parse(Reader characterStream, DefaultHandler handler, - boolean namespaceAware) { - - if (characterStream == null || handler == null) { - throw new NullPointerException(); - } - - try { - SAXParserFactory sax_parser_factory = SAXParserFactory - .newInstance(); - sax_parser_factory.setNamespaceAware(namespaceAware); - sax_parser_factory.setValidating(false); - javax.xml.parsers.SAXParser sax_parser = sax_parser_factory - .newSAXParser(); - sax_parser.parse(new InputSource(characterStream), handler); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (SAXNotRecognizedException e) { - throw new RuntimeException(e); - } catch (SAXNotSupportedException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Parses the content of a character stream as XML, using a - * validating parser and the specified SAX2 default event handler. - * - * @param characterStream - * The character stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * characterStream. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an - * org.xml.sax.SAXParseException is thrown. - * @throws NullPointerException - * If characterStream or handler are - * null. - * @throws RuntimeException - * If any error occurs (parser configuration errors, I/O errors, - * SAX parsing errors). - * - */ - public void parse(Reader characterStream, DefaultHandler handler, - Object[] schemas) { - - if (characterStream == null || handler == null) { - throw new NullPointerException(); - } - - try { - SAXParserFactory sax_parser_factory = SAXParserFactory - .newInstance(); - sax_parser_factory.setNamespaceAware(true); - sax_parser_factory.setValidating(true); - SAXParser sax_parser = sax_parser_factory.newSAXParser(); - sax_parser.setProperty( - "http://java.sun.com/xml/jaxp/properties/schemaLanguage", - "http://www.w3.org/2001/XMLSchema"); - if (schemas != null) { - sax_parser.setProperty( - "http://java.sun.com/xml/jaxp/properties/schemaSource", - schemas); - } - sax_parser.parse(new InputSource(characterStream), handler); - } catch (ParserConfigurationException e) { - throw new RuntimeException(e); - } catch (SAXNotRecognizedException e) { - throw new RuntimeException(e); - } catch (SAXNotSupportedException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Writes an XML DOM node to the specified byte stream. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to byteStream. - * @param byteStream - * The byte stream where node is to be written. - * @param indent - * Flag to indicate whether the output should be indented or not. - * @throws NullPointerException - * If node or byteStream are - * null. - * @throws RuntimeException - * If any error occurs (transformer configuration errors, - * transformer errors). - * - */ - public void write(Node node, OutputStream byteStream, boolean indent) { - - write(node, byteStream, null, indent); - } - - /** - * - * Writes an XML DOM node to the specified byte stream, using a - * javax.xml.transform.Transformer instance created from - * streamSource. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to byteStream. - * @param byteStream - * The byte stream where node is to be written. - * @param streamSource - * An object that holds an URI, input stream, etc. - * @param indent - * Flag to indicate whether the output should be indented or not. - * @throws NullPointerException - * If node or byteStream are - * null. - * @throws RuntimeException - * If any error occurs (transformer configuration errors, - * transformer errors). - * - */ - public void write(Node node, OutputStream byteStream, - StreamSource streamSource, boolean indent) { - - if (node == null || byteStream == null) { - throw new NullPointerException(); - } - - try { - Transformer transformer = streamSource == null ? transformer_factory - .newTransformer() - : transformer_factory.newTransformer(streamSource); - transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" - : "no"); - transformer.transform(new DOMSource(node), new StreamResult( - byteStream)); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } catch (TransformerException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Writes an XML DOM node to the specified character stream. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to characterStream. - * @param characterStream - * The character stream where node is to be written. - * @param indent - * Flag to indicate whether the output should be indented or not. - * @throws NullPointerException - * If node or characterStream are - * null. - * @throws RuntimeException - * If any error occurs (transformer configuration errors, - * transformer errors). - * - */ - public void write(Node node, Writer characterStream, boolean indent) { - - write(node, characterStream, null, indent); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/Location.java b/IPK_lib/src/org/sbml/jsbml/util/Location.java deleted file mode 100644 index 32e2e7e46..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/Location.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * $Id: Location.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/Location.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -/** - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class Location { - - /** - * - */ - private int line; - /** - * - */ - private int column; - - /** - * - */ - public Location() { - } - - /** - * - * @param line - * @param column - */ - public Location(int line, int column) { - this.line = line; - this.column = column; - } - - /** - * - * @return - */ - public int getColumn() { - return column; - } - - /** - * - * @return - */ - public int getLine() { - return line; - } - - /** - * - * @param column - */ - public void setColumn(int column) { - this.column = column; - } - - /** - * - * @param line - */ - public void setLine(int line) { - this.line = line; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Location [column=" + column + ", line=" + line + "]"; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/Maths.java b/IPK_lib/src/org/sbml/jsbml/util/Maths.java deleted file mode 100644 index cc523cf50..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/Maths.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * $Id: Maths.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/Maths.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.text.MessageFormat; - -/** - * This class provides several static methods for mathematical operations such - * as faculty, logarithms and several trigonometric functions, which are not - * part of standard Java, but necessary to evaluate the content of SBML files. - * - * @author Andreas Dräger - * @author Diedonné Mosu Wouamba - * @author Alexander Dörr - * @date 2007-10-29 - * @since 0.8 - * @version $Rev: 1207 $ - */ -public class Maths { - - /** - * Avogadro's constant of 6.02214179 ⋅ 1023 - * mol-1. The standard deviation of this constant is approximately - * 36 ⋅ - * 1016 mol-1. See Mohr, P. J., Taylor, B. N., and - * Newell, D. B. (2008). CODATA Recommended Values of the Fundamental - * 22 Physical Constants: 2006. Reviews of Modern Physics, 80:633-731. Note - * that in SBML this number is treated as a dimensionless quantity. - * The suffix of the variable's name (L3V1) suggests that in later SBML values - * new experimentally determined values for this constant could be determined. - */ - public static final double AVOGADRO_L3V1 = 6.02214179 * Math.pow(10, 23); - - /** - * Universal gas constant of 8.314472 J ⋅ mol-1 ⋅ - * K-1 according to D. R. Linde, CRC Handbook of Chemistry and - * PHysics, 81st ed., CRC Press, Boca Raton, Florida, 2000. - */ - public static final double R = 8.314472; - - /** - * This method computes the arccosh of n - * - * @param n - * @return - */ - public static final double arccosh(double n) { - return Math.log(n + (Math.sqrt(Math.pow(n, 2) - 1))); - } - - /** - * This method computes the arcus-cotangens of a double value. - * - * @param x - * @return - */ - public static final double arccot(double x) { - if (x == 0) { - return Math.PI/2; - } - return Math.atan(1 / x); - } - - /** - * This method computes the arccoth of n - * - * @param n - * @return - */ - public static final double arccoth(double n) { - if (n == 0) { - throw new ArithmeticException("arccoth(0) undefined"); - } - return (Math.log(1 + (1 / n)) - Math.log(1 - (1 / n))) / 2; - } - - /** - * This method computes the arccosecant of a double value - * - * @param x - * @return - */ - public static final double arccsc(double x) { - if (x == 0) { - throw new ArithmeticException(MessageFormat.format("arccsc({0,number}) undefined", x)); - } - double asin = Math.asin(1d / x); - return asin; - } - - /** - * This method computes the arccsch of n - * - * @param n - * @return - */ - public static final double arccsch(double n) { - if (n == 0) { - throw new ArithmeticException("arccsch(0) undefined"); - } - return Math.log(1 / n + Math.sqrt(Math.pow(1 / n, 2) + 1)); - } - - /** - * This method computes the arcsecant of a double value - * - * @param x - * @return - */ - public static final double arcsec(double x) { - if (x == 0) { - throw new ArithmeticException(MessageFormat.format("arccsc({0,number}) undefined", x)); - } - double acos = Math.acos(1d / x); - return acos; - } - - /** - * This method computes the arcsech of n - * - * @param n - * @return - */ - public static final double arcsech(double n) { - if (n == 0) { - throw new ArithmeticException("arcsech(0) undefined"); - } - return Math.log((1 / n) + (Math.sqrt(Math.pow(1 / n, 2) - 1))); - } - - /** - * This method computes the arcsinh of n - * - * @param n - * @return - */ - public static final double arcsinh(double n) { - return Math.log(n + Math.sqrt(Math.pow(n, 2) + 1)); - } - - /** - * This method computes the arctanh of n - * - * @param n - * @return - */ - public static final double arctanh(double n) { - return (Math.log(1 + n) - Math.log(1 - n)) / 2; - } - - /** - * This method computes the cot of n - * - * @param n - * @return - */ - public static final double cot(double n) { - double sin = Math.sin(n); - if (sin == 0) { - throw new ArithmeticException(MessageFormat.format("cot({0,number}) undefined", n)); - } - return Math.cos(n) / sin; - } - - /** - * This method computes the coth of n - * - * @param n - * @return - */ - public static final double coth(double n) { - double sinh = Math.sinh(n); - if (sinh == 0) { - throw new ArithmeticException(MessageFormat.format("coth({0,number}) undefined", n)); - } - return Math.cosh(n) / sinh; - } - - /** - * This method computes the csc of n - * - * @param n - * @return - */ - public static final double csc(double n) { - double sin = Math.sin(n); - if (sin == 0) { - throw new ArithmeticException(MessageFormat.format("csc({0,number}) undefined", n)); - } - return 1 / sin; - } - - /** - * This method computes the csch of n - * - * @param n - * @return - */ - public static final double csch(double n) { - double sinh = Math.sinh(n); - if (sinh == 0) { - throw new ArithmeticException(MessageFormat.format("csch({0,number}) undefined", n)); - } - return 1 / sinh; - } - - /** - * This method computes the factorial! function. - * - * @param n - * @return - */ - public static final long factorial(int n) { - if (n < 0) { - throw new IllegalArgumentException(MessageFormat.format( - "Cannot compute factorial for values {0,number,integer} < 0", n)); - } - if ((n == 0) || (n == 1)) { - return 1; - } - return n * factorial(n - 1); - } - - /** - * Checks if the given argument represents an integer number, i.e., if it can - * be casted to int without loosing information. - * - * @param x - * @return - */ - public static final boolean isInt(double x) { - return x - ((int) x) == 0d; - } - - // TODO: implement Gamma function for non-integer cases. - - /** - * This method computes the ln of n - * - * @param n - * @return - */ - public static final double ln(double n) { - return Math.log(n); - } - - /** - * This method computes the log of n to the base 10 - * - * @param n - * @return - */ - public static final double log(double n) { - return Math.log10(n); - } - - /** - * This method computes the logarithm of a number x to a giving base b. - * - * @param number - * @param base - * @return - */ - public static final double log(double number, double base) { - double denominator = Math.log(base); - if (denominator == 0) { - throw new ArithmeticException(MessageFormat.format("log_e({0,number}) undefined", base)); - } - return Math.log(number) / denominator; - } - - /** - * This method computes the rootExponent-th root of the radiant - * - * @param radiant - * @param rootExponent - * @return - */ - public static final double root(double radiant, double rootExponent) { - if (rootExponent != 0) { - return Math.pow(radiant, 1 / rootExponent); - } - throw new ArithmeticException("Root exponent must not be zero."); - } - - /** - * This method computes the secant of a double value. - * - * @param x - * @return - */ - public static final double sec(double x) { - return 1d / Math.cos(x); - } - - /** - * This method computes the sech of n - * - * @param n - * @return - */ - public static final double sech(double n) { - double cosh = Math.cosh(n); - if (cosh == 0) { - throw new ArithmeticException(MessageFormat.format("sech({0,number}) undefined", n)); - } - return 1 / cosh; - } - - /** - * Constructor that should not be used; this class provides static methods - * only. - */ - private Maths() { - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/Message.java b/IPK_lib/src/org/sbml/jsbml/util/Message.java deleted file mode 100644 index 8740deb56..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/Message.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * $Id: Message.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/Message.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -/** - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class Message { - - /** - * - */ - private String lang; - /** - * - */ - private String message; - - /** - * - */ - public Message() { - } - - /** - * - * @return - */ - public String getLang() { - return lang; - } - - /** - * - * @return - */ - public String getMessage() { - return message; - } - - /** - * - * @param lang - */ - public void setLang(String lang) { - this.lang = lang; - } - - /** - * - * @param messageContent - */ - public void setMessage(String messageContent) { - this.message = messageContent; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return StringTools.concat("Message [lang=", lang, ", messageContent=", - message, "]").toString(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/NodeWriter.java b/IPK_lib/src/org/sbml/jsbml/util/NodeWriter.java deleted file mode 100644 index 5babc1d67..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/NodeWriter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * $Id: NodeWriter.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/NodeWriter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.OutputStream; -import java.io.Writer; - -import org.w3c.dom.Node; - -/** - * - * A writer for XML DOM nodes. - * - * @author Marco Donizelli - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface NodeWriter { - - /** - * - * Writes an XML DOM node to a byte stream. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to byteStream. - * @param byteStream - * The byte stream where node is to be written. - * @param indent - * Flag to indicate whether the output should be indented or not. - * - */ - public void write(Node node, OutputStream byteStream, boolean indent); - - /** - * - * Writes an XML DOM node to a character stream. - * - * @param node - * The org.w3c.dom.Node instance representing the - * XML DOM node to be written to characterStream. - * @param characterStream - * The character stream where node is to be written. - * @param indent - * Flag to indicate whether the output should be indented or not. - * - */ - public void write(Node node, Writer characterStream, boolean indent); -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/NotImplementedException.java b/IPK_lib/src/org/sbml/jsbml/util/NotImplementedException.java deleted file mode 100644 index 5db01c722..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/NotImplementedException.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * $Id: NotImplementedException.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/NotImplementedException.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -/** - * This kind of {@link Exception} indicates currently missing functionality in - * JSBML. This class will be removed as soon JSBML has implemented all features. - * - * @author Andreas Dräger - * @date 2010-10-21 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class NotImplementedException extends Error { - - /** - * Generated serial version identifier - */ - private static final long serialVersionUID = 8871684506701754580L; - - /** - * - */ - public NotImplementedException() { - super(); - } - - /** - * @param message - */ - public NotImplementedException(String message) { - super(message); - } - - /** - * @param cause - */ - public NotImplementedException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public NotImplementedException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/Option.java b/IPK_lib/src/org/sbml/jsbml/util/Option.java deleted file mode 100644 index 354ba2549..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/Option.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * $Id: Option.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/Option.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -/** - * Stores the options sent by the SBML online validator. - * - *

    - * see the SBML Online Validator web API page. - * - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class Option { - - /** - * - */ - private String name; - /** - * - */ - private String status; - - /** - * - */ - public Option() { - } - - /** - * - * @param name - * @param status - */ - public Option(String name, String status) { - this.name = name; - this.status = status; - } - - /** - * - * @return - */ - public String getName() { - return name; - } - - /** - * - * @return - */ - public String getStatus() { - return status; - } - - /** - * - * @param name - */ - public void setName(String name) { - this.name = name; - } - - /** - * - * @param status - */ - public void setStatus(String status) { - this.status = status; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Option [name=" + name + ", status=" + status + "]"; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/SAX2Parser.java b/IPK_lib/src/org/sbml/jsbml/util/SAX2Parser.java deleted file mode 100644 index aade2456f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/SAX2Parser.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * $Id: SAX2Parser.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/SAX2Parser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.InputStream; -import java.io.Reader; - -import org.xml.sax.helpers.DefaultHandler; - -/** - * - * An interface for XML SAX2 parsers. - * - * @author Marco Donizelli - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface SAX2Parser { - - /** - * - * Parses the content of a byte stream as XML, using a nonvalidating - * parser and the specified SAX2 default event handler. - * - * @param byteStream - * The byte stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * byteStream. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * - */ - public void parse(InputStream byteStream, DefaultHandler handler, - boolean namespaceAware); - - /** - * - * Parses the content of a byte stream as XML, using a validating - * parser and the specified SAX2 default event handler. - * - * @param byteStream - * The byte stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * byteStream. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an exception is most likely to be - * thrown by the underlying implementation. - * - */ - public void parse(InputStream byteStream, DefaultHandler handler, - Object[] schemas); - - /** - * - * Parses the content of a character stream as XML, using a - * nonvalidating parser and the specified SAX2 default event handler. - * - * @param characterStream - * The character stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * characterStream. - * @param namespaceAware - * A flag to indicate whether the parser should know about - * namespaces or not. - * - */ - public void parse(Reader characterStream, DefaultHandler handler, - boolean namespaceAware); - - /** - * - * Parses the content of a character stream as XML, using a - * validating parser and the specified SAX2 default event handler. - * - * @param characterStream - * The character stream which content has to be parsed as XML. - * @param handler - * The SAX2 default event handler to use for parsing - * characterStream. - * @param schemas - * An optional array of either java.io.File - * instances containing the abstract pathnames, or of - * java.io.String instances containing the URIs, - * pointing to the schemas to use in the validation process. If - * set to null, the schemas defined in the data set - * will be used. If set to null and no schemas are - * found in the data set, an exception is most likely to be - * thrown by the underlying implementation. - * - */ - public void parse(Reader characterStream, DefaultHandler handler, - Object[] schemas); -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/SimpleTreeNodeChangeListener.java b/IPK_lib/src/org/sbml/jsbml/util/SimpleTreeNodeChangeListener.java deleted file mode 100644 index d3a14adaa..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/SimpleTreeNodeChangeListener.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * $Id: SimpleTreeNodeChangeListener.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/SimpleTreeNodeChangeListener.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.beans.PropertyChangeEvent; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; - -/** - * This very simple implementation of an {@link TreeNodeChangeListener} writes all - * the events to the standard out stream. - * - * @author Andreas Dräger - * @date 2010-11-16 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class SimpleTreeNodeChangeListener implements TreeNodeChangeListener { - - /** - * - */ - private Logger logger; - - /** - * Creates an {@link TreeNodeChangeListener} that writes all events to the - * standard output. - */ - public SimpleTreeNodeChangeListener() { - super(); - logger = Logger.getLogger(SimpleTreeNodeChangeListener.class); - } - - /** - * @return the logger - */ - public Logger getLogger() { - return logger; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeChangeListener#nodeAdded(javax.swing.tree.TreeNode) - */ - public void nodeAdded(TreeNode sb) { - if (logger.isDebugEnabled()) { - logger.debug(String.format("[ADD]\t%s", sb)); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.TreeNodeChangeListener#nodeRemoved(javax.swing.tree.TreeNode) - */ - public void nodeRemoved(TreeNode sb) { - if (logger.isDebugEnabled()) { - logger.debug(String.format("[DEL]\t%s", sb)); - } - } - - /* - * (non-Javadoc) - * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent ev) { - if (logger.isDebugEnabled()) { - logger.debug(String.format("[CHG]\t%s", ev)); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/StringTools.java b/IPK_lib/src/org/sbml/jsbml/util/StringTools.java deleted file mode 100644 index d17c261c7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/StringTools.java +++ /dev/null @@ -1,559 +0,0 @@ -/* - * $Id: StringTools.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/StringTools.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.IOException; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Arrays; -import java.util.Locale; -import java.util.Properties; -import java.util.StringTokenizer; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.resources.Resource; - -/** - * This class provides a collection of convenient methods for manipulating - * Strings. - * - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Clemens Wrzodek - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class StringTools { - - /** - * - */ - public static final String DECIMAL_FORMAT = "#.###########################################"; - /** - * New line separator of this operating system - */ - private static final String newLine = "\n"; - /** - * - */ - public static final String REAL_FORMAT = "#.###############################################"; - /** - * - */ - public static final String SCIENTIFIC_FORMAT = "#.###########################################E0"; - - /** - * The {@link Character} '_' as a {@link String}. - */ - public static final String underscore = Character.valueOf('_').toString(); - - /** - * Takes the given StringBuffer as input and appends every further Object to - * it. - * - * @param k - * @param things - * @return - */ - public static final StringBuffer append(StringBuffer k, Object... things) { - for (Object t : things) { - k.append(t); - } - return k; - } - - - /** - * - * @param sb - * @param elems - */ - public static void append(StringBuilder sb, Object... elems) { - for (Object e : elems) { - sb.append(e); - } - } - - /** - * This method concatenates two or more {@link Object} {@link String}s - * (obtained by calling {@link Object#toString()} if the current - * {@link Object} is not null) into a new {@link StringBuffer}. - * - * @param things - * to be concatenated - * @return a new {@link StringBuffer} containing all the - * string-representations of all given {@link Object}s. - */ - public static final StringBuffer concat(Object... things) { - StringBuffer res = new StringBuffer(); - for (Object thing : things) { - if (thing != null) { - res.append(thing.toString()); - } - } - return res; - } - - /** - * This method concatenates two or more {@link Object} {@link String}s - * (obtained by calling {@link Object#toString()} if the current - * {@link Object} is not null) into a new {@link StringBuilder}. - * - * @param things - * to be concatenated - * @return a new {@link StringBuilder} containing all the - * string-representations of all given {@link Object}s. - */ - public static final StringBuilder concatStringBuilder(Object... things) { - StringBuilder res = new StringBuilder(); - for (Object thing : things) { - if (thing != null) { - res.append(thing.toString()); - } - } - return res; - } - - /** - * - * @param string - * @return - */ - public static final String encodeForHTML(String string) { - final StringBuilder result = new StringBuilder(); - try { - Properties p = Resource - .readProperties("org/sbml/jsbml/resources/cfg/HTML_CharEncodingTable.txt"); - for (char character : string.toCharArray()) { - if (p.containsKey(String.valueOf(character))) { - result.append(p.get(String.valueOf(character))); - } else { - result.append(character); - } - } - } catch (IOException e) { - e.printStackTrace(); - result.append(string); - } - return result.toString(); - } - - /** - * Returns a String whose first letter is now in lower case. - * - * @param name - * @return - */ - public static final String firstLetterLowerCase(String name) { - char c = name.charAt(0); - if (Character.isLetter(c)) - c = Character.toLowerCase(c); - if (name.length() > 1) - name = Character.toString(c) + name.substring(1); - else - return Character.toString(c); - return name; - } - - /** - * Returns a String who's first letter is now in upper case. - * - * @param name - * @return - */ - public static final String firstLetterUpperCase(String name) { - char c = name.charAt(0); - if (Character.isLetter(c)) { - c = Character.toUpperCase(c); - } - if (name.length() > 1) { - name = Character.toString(c) + name.substring(1); - } else { - return Character.toString(c); - } - return name; - } - - /** - * Returns the number as an English word. Zero is converted to "no". Only - * positive numbers from 1 to twelve can be converted. All other numbers are - * just converted to a String containing the number. - * - * @param number - * @return - */ - public static String getWordForNumber(long number) { - if ((number < Integer.MIN_VALUE) || (Integer.MAX_VALUE < number)) - return Long.toString(number); - switch ((int) number) { - case 0: - return "no"; - case 1: - return "one"; - case 2: - return "two"; - case 3: - return "three"; - case 4: - return "four"; - case 5: - return "five"; - case 6: - return "six"; - case 7: - return "seven"; - case 8: - return "eight"; - case 9: - return "nine"; - case 10: - return "ten"; - case 11: - return "eleven"; - case 12: - return "twelve"; - default: - return Long.toString(number); - } - } - - /** - * This method creates a {@link String} representation of the given number and - * inserts as many zero characters as the prefix of this {@link String} as - * needed - * to result in a {@link String} of the given length. - * - * @param length - * the total desired length of the given number {@link String}. - * @param number - * @return a {@link String} of the given length consisting of a suffix defined - * by the given number and as many leading zeros as necessary to reach - * the desired length. - */ - public static String leadingZeros(int length, int number) { - return fill(length, '0', Integer.toString(number)); - } - - /** - * - * @param length the desired length of the resulting {@link String} - * @param symbol the symbol to be inserted at the beginning of the initial {@link String} multiple times. - * @param initialString can be null or empty. - * @return - */ - public static String fill(int length, char symbol, String initialString) { - StringBuilder sb = new StringBuilder(); - if (initialString != null) { - if (initialString.length() > length) { - throw new IllegalArgumentException(String.format( - "Initial String %s is already longer than %d digits.", initialString, - length)); - } - sb.append(initialString); - } - return fill(length, symbol, sb); - } - - /** - * - * @param length - * @param symbol - * @return - */ - public static String fill(int length, char symbol) { - return fill(length, symbol, new StringBuilder()); - } - - /** - * Ensures a minimum size of length for the given - * stringBuilder. Therefore, the given - * symbol will be put at the beginning of the - * string, until it reaches the given length. - * @param length - * @param symbol - * @param stringBuilder - * @return - */ - private static String fill(int length, char symbol, StringBuilder sb) { - if (length<=sb.length()) { - return sb.toString(); - } - - // Create a char array of given length with native methods - char[] ret = new char[length]; - Arrays.fill(ret, symbol); - - // Copy previous content at the end of the array - if(sb.length()>0) { - char[] sbArray = sb.toString().toCharArray(); - System.arraycopy(sbArray, 0, ret, length-sb.length(), sbArray.length); - } - - return new String(ret); - } - - - /** - * - * @return - */ - public static final String newLine() { - return newLine; - } - - /** - * Parses a String into a boolean following the rules of the SBML - * specifications, section 3.1.2. - * - * @param valueAsStr - * a boolean as a String - * @return the String as a boolean. If the String is not a valid boolean, - * false is returned. - */ - public static boolean parseSBMLBoolean(String valueAsStr) { - - String toTest = valueAsStr.trim(); - - // Test for true/false ignoring case. - boolean value = Boolean.parseBoolean(toTest); - - if (toTest.equals("0")) { - value = false; // this test would not be needed as the value is - // already false but it is there for completion. - } else if (toTest.equals("1")) { - value = true; - } else if (!(toTest.equalsIgnoreCase("true") - || toTest.equalsIgnoreCase("false"))) - { - Logger logger = Logger.getLogger(StringTools.class); - logger.warn("Could not create a boolean from the string " + valueAsStr); - } - - return value; - } - - /** - * Parses a String into a double number following the rules of the SBML - * specifications, section 3.1.5. - * - * @param valueAsStr - * a double as a String - * @return the String as a double. If the String is not a valid double - * number, {@link Double.NaN} is returned. - */ - public static double parseSBMLDouble(String valueAsStr) { - - double value = Double.NaN; - String toTest = valueAsStr.trim(); - - try { - value = Double.parseDouble(toTest); - } catch (NumberFormatException e) { - if (toTest.equalsIgnoreCase("INF")) { - value = Double.POSITIVE_INFINITY; - } else if (toTest.equalsIgnoreCase("-INF")) { - value = Double.NEGATIVE_INFINITY; - } else { - Logger logger = Logger.getLogger(StringTools.class); - logger.warn("Could not create a double from the string " + valueAsStr); - } - } - - return value; - } - - /** - * Parses a {@link String} into an int number following the rules of the SBML - * specifications, section 3.1.3. - * - * @param valueAsStr - * an int as a {@link String} - * @return the {@link String} as an int. If the {@link String} is not a valid int number, 0 - * is returned. - */ - public static int parseSBMLInt(String valueAsStr) { - int value = 0; - try { - value = Integer.parseInt(valueAsStr.trim()); - } catch (NumberFormatException e) { - Logger logger = Logger.getLogger(StringTools.class); - logger.warn("Could not create an integer from the string " + valueAsStr); - } - return value; - } - - /** - * Parses a {@link String} into an short number following the rules of the - * SBML specifications, section 3.1.3. - * - * @param value - * an int as a String - * @return the {@link String} as an short. If the {@link String} is not a - * valid short number, 0 is returned. - */ - public static int parseSBMLShort(String value) { - short v = 0; - try { - v = Short.parseShort(value.trim()); - } catch (NumberFormatException e) { - Logger logger = Logger.getLogger(StringTools.class); - logger.warn("Could not create a short from the string " + value); - } - return v; - } - - /** - * Returns a HTML formated String, in which each line is at most lineBreak - * symbols long. - * - * @param string - * @return - */ - public static String toHTML(String string) { - return toHTML(string, Integer.MAX_VALUE); - } - - /** - * Returns a HTML formated String, in which each line is at most lineBreak - * symbols long. - * - * @param string - * @param lineBreak - * @return - */ - public static String toHTML(String string, int lineBreak) { - StringTokenizer st = new StringTokenizer(string != null ? string : "", - " "); - StringBuilder sb = new StringBuilder(); - if (st.hasMoreElements()) - sb.append(st.nextElement().toString()); - int length = sb.length(); - sb.insert(0, ""); - while (st.hasMoreElements()) { - if (length >= lineBreak && lineBreak < Integer.MAX_VALUE) { - sb.append("
    "); - length = 0; - } else - sb.append(' '); - String tmp = st.nextElement().toString(); - length += tmp.length() + 1; - sb.append(tmp); - } - sb.append(""); - return sb.toString(); - } - - /** - * Returns a {@link String} from the given value that does not contain a - * point zero at the end if the given value represents an integer number. - * The returned {@link String} displays the number in a {@link Locale} - * -dependent way, i.e., the decimal separator and the symbols to represent - * the digits are chosen from the system's configuration. Furthermore, a - * scientific style including 'E' will be used if the value is smaller than - * 1E-5 or greater than 1E5. - * - * @param value - * @return - */ - public static final String toString(double value) { - return toString(Locale.getDefault(), value); - } - - /** - * Allows for {@link Locale}-dependent number formatting. - * @param locale - * @param value - * @return - */ - public static final String toString(Locale locale, double value) { - if (Double.isNaN(value)) { - return "NaN"; - } else if (Double.isInfinite(value)) { - // TODO: make this locale dependent ? - String infinity = "INF"; - return value < 0 ? '-' + infinity : infinity; - } - - if (((int) value) - value == 0) { - return String.format("%d", Integer.valueOf((int) value)); - } - - if ((Math.abs(value) < 1E-4) || (1E4 < Math.abs(value))) { - DecimalFormat df = new DecimalFormat(SCIENTIFIC_FORMAT, - new DecimalFormatSymbols(locale)); - return df.format(value); - } - - DecimalFormat df = new DecimalFormat(DECIMAL_FORMAT, - new DecimalFormatSymbols(locale)); - return df.format(value); - } - - /** - * Checks whether a given {@link String} fits into the definition of the XML - * notes {@link String} in SBML. If not, this method will surround the given - * {@link String} with the minimal definition of a valid notes - * {@link String}. - * - * @param notes - * the {@link String} to be checked and possibly modified. - * @return A {@link String} that will be surrounded by the XML definition of - * a notes {@link String} in SBML, i.e., - * - *

    -	 * <notes>
    -	 *   <body xmlns="http://www.w3.org/1999/xhtml">
    -	 *     <p>the original notes</p>
    -	 *   </body>
    -	 * 
    - * - * If the given argument already suffices the definition of XML - * {@link String}s in SBML, nothing will be changed. - */ - public static String toXMLNotesString(String notes) { - // TODO : We need to perform plenty of check to see of which form are the notes given to this method - // and perform the necessary conversion to append or set the notes correctly. - - if (!notes.trim().startsWith("<")) { // we assume that this is free text - StringBuilder sb = new StringBuilder(); - sb.append("\n"); - sb.append(" \n "); - sb.append("

    "); - sb.append(notes); - sb.append("

    \n"); - sb.append(" \n"); - sb.append("
    "); - return sb.toString(); - } else if (!notes.trim().startsWith(" XML tag is missing - StringBuilder sb = new StringBuilder(); - sb.append("\n "); - sb.append(notes); - sb.append("\n"); - return sb.toString(); - } - return notes; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/SubModel.java b/IPK_lib/src/org/sbml/jsbml/util/SubModel.java deleted file mode 100644 index 2940115d1..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/SubModel.java +++ /dev/null @@ -1,864 +0,0 @@ -/* - * $Id: SubModel.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/SubModel.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.CompartmentType; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.ExplicitRule; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesType; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.util.filters.SpeciesReferenceFilter; - - -/** - * Generates a sub-{@link Model} containing the elements passed as argument and all - * the necessary dependencies. - * - *

    You do not need to fill all of the parameter arrays. Here is how the sub-{@link Model} generation works: - *

  • If you give some {@link Compartment} ids, all the species inside these {@link Compartment} are included. - *
  • If you give some {@link Species} ids (and all added {@link Species} from the {@link Compartment}s), all the {@link Reaction}s where one of these {@link Species} is present are included - *
  • All the {@link Species} involved in the {@link Reaction}s given as parameter or added automatically from the given {@link Species} are included. - *
  • All {@link Compartment}s where one of the included species is present is included. - *
  • All needed {@link UnitDefinition}s, {@link SpeciesType}s and {@link CompartmentType}s are included. - *
  • All the {@link Rule}s and events passed as parameter along the one needed are included. - *
  • All the global {@link Parameter}s are added automatically at the moment, without checking if there are used or not. - *
  • All the {@link FunctionDefinition}s used in the included MathML are added automatically. - * - * @author Nicolas Rodriguez - * @author chenli - * @since 0.8 - * @version $Rev: 1177 $ - */ -@SuppressWarnings("deprecation") -public class SubModel { - - /** - * Generates a sub-model containing the elements passed as argument and all - * the necessary dependencies. - * - * @param model - * @param compartmentsIds - * @param speciesIds - * @param reactsIds - * @return - */ - public static SBMLDocument generateSubModel( - Model model, - String[] compartmentsIds, - String[] speciesIds, - String[] reactsIds) { - return generateSubModel(model, compartmentsIds, speciesIds, reactsIds, null, null, true, true, true, false, false); - } - - /** - * Generates a sub-model containing the elements passed as argument and all - * the necessary dependencies. - * - *

    You do not need to fill all of the parameter arrays. Here is how the sub-{@link Model} generation works: - *

  • If you give some {@link Compartment} ids, all the species inside these {@link Compartment} are included. - *
  • If you give some {@link Species} ids (and all added {@link Species} from the {@link Compartment}s), all the {@link Reaction}s where one of these {@link Species} is present are included - *
  • All the {@link Species} involved in the {@link Reaction}s given as parameter or added automatically from the given {@link Species} are included. - *
  • All {@link Compartment}s where one of the included species is present is included. - *
  • All needed {@link UnitDefinition}s, {@link SpeciesType}s and {@link CompartmentType}s are included. - *
  • All the {@link Rule}s and events passed as parameter along the one needed are included. - *
  • All the global {@link Parameter}s are added automatically at the moment, without checking if there are used or not. - *
  • All the {@link FunctionDefinition}s used in the included MathML are added automatically. - * - *

    - * @param model the SBML model where we want to extract a sub-model. - * @param compartmentsIds the list of compartment to keep - * @param speciesIds the list of species to keep - * @param reactsIds the list of reactions to keep - * @param rulesIds the list of rules to keep - * @param eventsIds the list of events to keep - * @return a sub-model containing the elements passed as argument and all - * the necessary dependencies. - */ - public static SBMLDocument generateSubModel( - Model model, - String[] compartmentsIds, - String[] speciesIds, - String[] reactsIds, - String[] rulesIds, - String[] eventsIds) - { - return generateSubModel(model, compartmentsIds, speciesIds, reactsIds, rulesIds, eventsIds, true, true, true, true, true); - } - - /** - * Creates a sub-model with the option to ignore certain items. - * - * @param model - * @param compartmentsIds - * @param speciesIds - * @param reactsIds - * @param rulesIds - * @param eventsIds - * @param inclComp - * @param inclSpecies - * @param inclReact - * @param inclRules - * @param inclEvents - * @return - */ - private static SBMLDocument generateSubModel( - Model model, - String[] compartmentsIds, - String[] speciesIds, - String[] reactsIds, - String[] rulesIds, - String[] eventsIds, - boolean inclComp, boolean inclSpecies, boolean inclReact, boolean inclRules, boolean inclEvents) { - - // TODO : need to be sure that all needed elements have a metaid, likes rules, events, ... - - // TODO : would probably be easier to use only ArrayList, instead of arrays. Not sure if it would be better to store the Objects instead of the ids. - - // TODO : need to check for InitialAssignment and Constraint - - // - // initial - // - - // submodel id - Calendar current = Calendar.getInstance(); - String subModelId = "SUBMODEL" + Long.toString(current.getTimeInMillis()); - - int modelLevel = model.getLevel(); - int modelVersion = model.getVersion(); - - // SBMLDocument object for submodel - SBMLDocument subModelSbmlDocument = new SBMLDocument(modelLevel, modelVersion); - - // creating submodel object - Model subModel = subModelSbmlDocument.createModel(subModelId); - subModel.setMetaId(subModelId); - - if (!inclComp) { - compartmentsIds = null; - } - if (inclComp && inclSpecies) { - speciesIds = getRelatedSpecies(model, null, compartmentsIds, speciesIds); - reactsIds = getRelatedReactions(model, reactsIds, speciesIds); - } else { - speciesIds = reactsIds = null; - } - - Set relatedFunctionsIdSet = new HashSet(); - Set allFunctionsIdSet = new HashSet(); - Map unitsMap = new HashMap(); - - for (FunctionDefinition functionDefinition : model.getListOfFunctionDefinitions()) { - allFunctionsIdSet.add(functionDefinition.getId()); - } - - // TODO : the added rules or events can contain some species, compartment or speciesReferences (for L3) that could - // not be present in the list of included elements !!! - - // - // annotations - // - - // TODO : set annotations - -// setAnnotations(subModel, -// null, -// null, -// new ArrayList(), -// DatetimeProcessor.instance.convertToGMT(current.getTime()), -// DatetimeProcessor.instance.convertToGMT(current.getTime()), -// null, -// Publication.UNPUBL); - - - // - // Reactions. - // - - if (reactsIds != null) { - for (int i = 0; i < reactsIds.length; i++) { - Reaction relatedReaction = model.getReaction(reactsIds[i]); - - subModel.addReaction(relatedReaction.clone()); - - if (relatedReaction.getKineticLaw() != null) { - // TODO: Parameters! - getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, relatedReaction.getKineticLaw().getMath()); - processUnitsMap(unitsMap, model, relatedReaction.getKineticLaw()); - } - } - } - - - // - // compartments and compartments type - // - - speciesIds = getRelatedSpecies(model, reactsIds, compartmentsIds, speciesIds); - compartmentsIds = getRelatedCompartments(model, compartmentsIds, speciesIds); - - if (compartmentsIds != null) { - for (int i = 0; i < compartmentsIds.length; i++) { - Compartment relatedCompartment = model.getCompartment(compartmentsIds[i]); - - subModel.addCompartment(relatedCompartment.clone()); - processUnitsMap(unitsMap, model, relatedCompartment.getUnits()); - - // check compartment type - if ((relatedCompartment.getCompartmentTypeInstance() != null) - && (subModel.getCompartmentType(relatedCompartment.getCompartmentType()) == null)) { - subModel.addCompartmentType(relatedCompartment.getCompartmentTypeInstance().clone()); - } - } - } - - - // - // species and species type - // - - if (speciesIds != null) { - for (int i = 0; i < speciesIds.length; i++) { - Species relatedSpecies = model.getSpecies(speciesIds[i]); - subModel.addSpecies(relatedSpecies.clone()); - processUnitsMap(unitsMap, model, relatedSpecies.getSubstanceUnits()); - - // check species type - if ((relatedSpecies.getSpeciesTypeInstance() != null) - && (subModel.getSpeciesType(relatedSpecies.getSpeciesType()) == null)) { - subModel.addSpeciesType(relatedSpecies.getSpeciesTypeInstance().clone()); - } - } - } - - - // - // rules - // - - if (inclRules) { - rulesIds = getRelatedRules(model, rulesIds, compartmentsIds, speciesIds); - - if ((rulesIds != null) && (rulesIds.length > 0)) { - for (String ruleId : rulesIds) { - for (Rule modelRule : model.getListOfRules()) { - if (modelRule.getMetaId().equals(ruleId)) { - subModel.addRule(modelRule.clone()); - if (modelRule.getMath() != null) { - getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, modelRule.getMath()); - } - } - } - } - } - } - - // - // events - // - - if (inclEvents) { - eventsIds = getRelatedEvents(model, eventsIds, compartmentsIds, speciesIds); - - if ((eventsIds != null) && (eventsIds.length > 0)) { - for (int i = 0; i < eventsIds.length; i++) { - for (Event modelEvent : model.getListOfEvents()) { - if (modelEvent.getMetaId().equals(eventsIds[i])) { - subModel.addEvent(modelEvent.clone()); - if (modelEvent.getTrigger() != null) { - getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, modelEvent.getTrigger().getMath()); - } - if (modelEvent.getDelay() != null) { - getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, modelEvent.getDelay().getMath()); - } - } - } - } - } - } - - - // - // parameters. - // - - // TODO : try not to add all the parameters !! - // When we do getRelatedFunctions, we could search for the related species and parameter !! - - for (Parameter parameter : model.getListOfParameters()) { - subModel.addParameter(parameter.clone()); - processUnitsMap(unitsMap, model, parameter.getUnits()); - } - - - // - // units - // - - for (UnitDefinition unitDefinition : unitsMap.values()) { - subModel.addUnitDefinition(unitDefinition.clone()); - } - - - // - // FunctionDefinition - // - // TODO : if a function need an other function that in turn need an other function, the generated model will be invalid - // with the current code - - for (String functionDefinitionId : relatedFunctionsIdSet) { - FunctionDefinition func = model.getFunctionDefinition(functionDefinitionId); - getRelatedFunctionsId(relatedFunctionsIdSet, allFunctionsIdSet, func.getMath()); - } - for (String functionDefinitionId : relatedFunctionsIdSet) { - subModel.addFunctionDefinition(model.getFunctionDefinition(functionDefinitionId).clone()); - } - - return subModelSbmlDocument; - } - - /** - * - * @param unitsMap - * @param model the original model from which a sub-model is to be created. - * @param elementUnits - */ - private static void processUnitsMap(Map unitsMap, Model model, String elementUnits) { - - Logger debugLogger = Logger.getLogger(SubModel.class); - debugLogger.debug("processUnitsMap called with " + elementUnits); - - UnitDefinition unit = model.getUnitDefinition(elementUnits); - - debugLogger.debug("processUnitsMap : unit = " + elementUnits); - - if (unit != null && !unitsMap.containsKey(unit.getId())) { - unitsMap.put(unit.getId(), unit); - } - } - - /** - * - * @param unitsMap - * @param model the original model from which a sub-model is to be created. - * @param kineticLaw - */ - private static void processUnitsMap(Map unitsMap, Model model, KineticLaw kineticLaw) { - - if (kineticLaw.getLocalParameterCount() > 0) { - for (LocalParameter parameter : kineticLaw.getListOfLocalParameters()) { - processUnitsMap(unitsMap, model, parameter.getUnits()); - } - } - - // TODO : the mathML can have some units as well, on the cn element in SBML L3V1 - } - // - // - // - // - // - - /** - * - * @param speciesReferences - * @param species - * @return - */ - private static boolean contains(ListOf speciesReferences, Species species) { - return speciesReferences.firstHit(new SpeciesReferenceFilter(species)) != null; - } - - /** - * - * @param model the original model from which a sub-model is to be created. - * @param compartmentsIds - * @param speciesIds - * @return - */ - public static String[] getRelatedCompartments( - Model model, - String[] compartmentsIds, - String[] speciesIds) { - - Logger debugLogger = Logger.getLogger(SubModel.class); - debugLogger.debug("getRelatedCompartments"); - - // get all related compartments - List relatedCompartmentsList = new ArrayList(); - - if ((compartmentsIds != null) || (speciesIds != null)) { - for (Compartment compartment : model.getListOfCompartments()) { - - String compartmentId = compartment.getId(); - - boolean thisCompartmentSelected = false; - - if (compartmentsIds != null) { - for (int j = 0; (j < compartmentsIds.length) && !thisCompartmentSelected; j++) { - if (compartmentId.equals(compartmentsIds[j])) { - thisCompartmentSelected = true; - } - } - } - - if (!thisCompartmentSelected && (speciesIds != null)) { - for (int j = 0; (j < speciesIds.length) && !thisCompartmentSelected; j++) { - Species species = model.getSpecies(speciesIds[j]); - thisCompartmentSelected = species.getCompartment().equals(compartmentId); - } - } - - if (thisCompartmentSelected) { - relatedCompartmentsList.add(compartmentId); - } - } - } - // convert to array - if ((relatedCompartmentsList == null) || relatedCompartmentsList.isEmpty()) { - compartmentsIds = null; - - debugLogger.debug("getRelatedCompartments : related compartmentsIds is empty !!!!\n\n"); - - } else { - compartmentsIds = relatedCompartmentsList.toArray(new String[relatedCompartmentsList.size()]); - - debugLogger.debug("getRelatedCompartments : related compartmentsIds = " + Arrays.toString(compartmentsIds) + "\n\n"); - - } - - return compartmentsIds; - } - - - // - // - // - // - // - - /** - * - * @param model the original model from which a sub-model is to be created. - * @param reactsIds - * @param compartmentsIds - * @param speciesIds - * @return an array of related species id or null if no related species are found. - */ - public static String[] getRelatedSpecies( - Model model, - String[] reactsIds, - String[] compartmentsIds, - String[] speciesIds) - { - - Logger debugLogger = Logger.getLogger(SubModel.class); - debugLogger.debug("getRelatedSpecies "); - debugLogger.debug("getRelatedSpecies : reactsIds : " + Arrays.toString(reactsIds)); - debugLogger.debug("getRelatedSpecies : compartmentsIds : " + Arrays.toString(compartmentsIds)); - debugLogger.debug("getRelatedSpecies : speciesIds : " + Arrays.toString(speciesIds) + "\n"); - - // get the related species - List selectedSpecies = new ArrayList(); - - if ((speciesIds != null) || (compartmentsIds != null) || (reactsIds != null)) { - - for (Species species : model.getListOfSpecies()) { - - String speciesId = species.getId(); - boolean thisSpeciesSelected = false; - - if (speciesIds != null) { - for (int j = 0; j < speciesIds.length; j++) { - if (speciesId.equals(speciesIds[j])) { - thisSpeciesSelected = true; - break; - } - } - } - - if (!thisSpeciesSelected && (compartmentsIds != null)) { - for (int j = 0; j < compartmentsIds.length; j++) { - if ((species.getCompartment()).equals(compartmentsIds[j])) { - thisSpeciesSelected = true; - break; - } - } - } - - if (!thisSpeciesSelected && (reactsIds != null)) { - for (int j = 0; j < reactsIds.length; j++) { - Reaction reaction = model.getReaction(reactsIds[j]); - - thisSpeciesSelected = contains(reaction.getListOfReactants(), species); - - if (!thisSpeciesSelected) { - thisSpeciesSelected = contains(reaction.getListOfProducts(), species); - } - if (!thisSpeciesSelected) { - thisSpeciesSelected = contains(reaction.getListOfModifiers(), species); - } - - if (thisSpeciesSelected) { - break; - } - } - } - - if (thisSpeciesSelected) { - selectedSpecies.add(speciesId); - } - } - } - // convert to array - if ((selectedSpecies == null) || selectedSpecies.isEmpty()) { - speciesIds = null; - - debugLogger.debug("getRelatedSpecies : related speciesIds is empty !!!!! \n\n"); - - } else { - speciesIds = selectedSpecies.toArray(new String[selectedSpecies.size()]); - - debugLogger.debug("\ngetRelatedSpecies : related speciesIds = " + Arrays.toString(speciesIds) + "\n\n"); - - } - - return speciesIds; - } - - /** - * - * @param model the original model from which a sub-model is to be created. - * @param rulesIds - * @param compartmentsIds - * @param speciesIds - * @return - */ - private static String[] getRelatedRules( - Model model, - String[] rulesIds, - String[] compartmentsIds, - String[] speciesIds) - { - Logger debugLogger = Logger.getLogger(SubModel.class); - debugLogger.debug("getRelatedRules "); - debugLogger.debug("getRelatedRules : rulesIds : " + Arrays.toString(rulesIds)); - debugLogger.debug("getRelatedRules : compartmentsIds : " + Arrays.toString(compartmentsIds)); - debugLogger.debug("getRelatedRules : speciesIds : " + Arrays.toString(speciesIds) + "\n"); - - // get the related rules - List selectedRules = new ArrayList(); - - if (rulesIds != null) { - for (String ruleId : rulesIds) { - selectedRules.add(ruleId); - } - } - - for (Rule rule : model.getListOfRules()) { - - if (rule instanceof ExplicitRule) { - - String variableId = ((ExplicitRule) rule).getVariable(); - - if (speciesIds != null) { - for (String speciesId : speciesIds) { - if (speciesId.equals(variableId)) { - selectedRules.add(rule.getMetaId()); - } - } - } - if (compartmentsIds != null) { - for (String compartmentId : compartmentsIds) { - if (compartmentId.equals(variableId)) { - selectedRules.add(rule.getMetaId()); - } - } - } - for (Parameter parameter : model.getListOfParameters()) { - if (parameter.getId().equals(variableId)) { - selectedRules.add(rule.getMetaId()); - } - } - - } else { - String ruleId = rule.getMetaId(); - if (ruleId != null) { - selectedRules.add(ruleId); - } - } - } - - // TODO : check the math of rule to check if we need to add any more species or compartment - - // convert to array - if ((selectedRules == null) || selectedRules.isEmpty()) { - rulesIds = null; - - debugLogger.debug("getRelatedRules : related RulesIds is empty !!!!! \n\n"); - - } else { - rulesIds = selectedRules.toArray(new String[selectedRules.size()]); - - debugLogger.debug("\ngetRelatedRules : related RulesIds = " + Arrays.toString(rulesIds) + "\n\n"); - - } - - return rulesIds; - } - - /** - * - * @param model the original model from which a sub-model is to be created. - * @param eventsIds - * @param compartmentsIds - * @param speciesIds - * @return - */ - private static String[] getRelatedEvents( - Model model, - String[] eventsIds, - String[] compartmentsIds, - String[] speciesIds) - { - Logger debugLogger = Logger.getLogger(SubModel.class); - debugLogger.debug("getRelatedEvents "); - debugLogger.debug("getRelatedEvents : eventsIds : " + Arrays.toString(eventsIds)); - debugLogger.debug("getRelatedEvents : compartmentsIds : " + Arrays.toString(compartmentsIds)); - debugLogger.debug("getRelatedEvents : speciesIds : " + Arrays.toString(speciesIds) + "\n"); - - // get the related events - ArrayList selectedEvents = new ArrayList(); - - if (eventsIds != null) { - for (String eventId : eventsIds) { - selectedEvents.add(eventId); - } - } - - for (Event event : model.getListOfEvents()) { - - // TODO : check the trigger math - // TODO : check the delay math - - for (EventAssignment eventAssigment : event.getListOfEventAssignments()) { - - String variableId = null; eventAssigment.getVariable(); - - for (String speciesId : speciesIds) { - if (speciesId.equals(variableId)) { - selectedEvents.add(event.getMetaId()); - } - } - for (String compartmentId : compartmentsIds) { - if (compartmentId.equals(variableId)) { - selectedEvents.add(event.getMetaId()); - } - } - for (Parameter parameter : model.getListOfParameters()) { - if (parameter.getId().equals(variableId)) { - selectedEvents.add(event.getMetaId()); - } - } - } - - } - - // convert to array - if ((selectedEvents == null) || selectedEvents.isEmpty()) { - eventsIds = null; - - debugLogger.debug("getRelatedEvents : related EventsIds is empty !!!!! \n\n"); - - } else { - eventsIds = selectedEvents.toArray(new String[selectedEvents.size()]); - - debugLogger.debug("\ngetRelatedEvents : related EventsIds = " + Arrays.toString(eventsIds) + "\n\n"); - - } - - return eventsIds; - } - - - // - // - // - // - // - - /** - * Returns an array of reaction id related to the reactsIds or speciesIds. - * - * All the reactions in reactsIds should be part of the result if - * the function is called properly with valid reacionId. - *
    - * The {@link Reaction}s, where the {@link Species} in the speciesIds array are involved as reactant, - * product or modifier, are added in the returned reaction id array. - * - * @param model the original model from which a sub-model is to be created. - * @param reactsIds the list of {@link Reaction}s selected by the user to create a sub-model - * @param speciesIds the list of {@link Species} selected by the user to create a sub-model - * @return an array of related {@link Reaction}s id or null if no related reactions are found. - */ - public static String[] getRelatedReactions( - Model model, - String[] reactsIds, - String[] speciesIds) { - - Logger debugLogger = Logger.getLogger(SubModel.class); - - debugLogger.debug("getRelatedReactions "); - debugLogger.debug("getRelatedReactions : selected reactsIds : " + Arrays.toString(reactsIds)); - debugLogger.debug("getRelatedReactions : selected speciesIds : " + Arrays.toString(speciesIds) + "\n"); - - // get all related reactions - List relatedReactsList = new ArrayList(reactsIds.length); - - if ((reactsIds != null) || (speciesIds != null)) { - - for (Reaction reaction : model.getListOfReactions()) { - - String reactionId = reaction.getId(); - - debugLogger.debug("getRelatedReactions : reaction = " + reactionId); - - boolean thisReactionSelected = false; - - if (reactsIds != null) { - for (int j = 0; (j < reactsIds.length) && !thisReactionSelected; j++) { - if (reactionId.equals(reactsIds[j])) { - thisReactionSelected = true; - } - } - } - - if (!thisReactionSelected && (speciesIds != null)) { - for (int j = 0; (j < speciesIds.length) && !thisReactionSelected; j++) { - - Species species = model.getSpecies(speciesIds[j]); - - // debugLogger.debug("getRelatedReactions : speciesId = " + speciesIds[j]); - // debugLogger.debug("getRelatedReactions : reactant = " + Arrays.toString(reaction.getReactants().toArray())); - // debugLogger.debug("getRelatedReactions : product = " + Arrays.toString(reaction.getProducts().toArray())); - // debugLogger.debug("getRelatedReactions : modifier = " + Arrays.toString(reaction.getModifiers().toArray())); - - // thisReactionSelected = reaction.getReactants().contains(species); // not working !! to investigate may be !! - thisReactionSelected = contains(reaction.getListOfReactants(), species); - - // debugLogger.debug("getRelatedReactions : contains.own = " + contains(reaction.getReactants(), species)); - - if (!thisReactionSelected) { - thisReactionSelected = contains(reaction.getListOfProducts(), species); - } - if (!thisReactionSelected) { - thisReactionSelected = contains(reaction.getListOfModifiers(), species); - } - } - } - - if (thisReactionSelected) { - relatedReactsList.add(reactionId); - } - } - } - - // convert to array - if ((relatedReactsList == null) || relatedReactsList.isEmpty()) { - debugLogger.debug("getRelatedReactions : related reactsIds is empty !!!!\n\n"); - - return null; - } - - debugLogger.debug("getRelatedReactions : related reactsIds : " + Arrays.toString(reactsIds) + "!!!!\n\n"); - - return relatedReactsList.toArray(new String[relatedReactsList.size()]); - } - - // - // - // - // - // - - /** - * - * @param relatedFunctionsSet - * @param allFunctionsIdSet - * @param mathNode - */ - private static void getRelatedFunctionsId(Set relatedFunctionsSet, Set allFunctionsIdSet, ASTNode mathNode) { - getRelatedFunctions(relatedFunctionsSet, allFunctionsIdSet, mathNode); - } - - // - // - // - // - // - - /** - * - * @param relatedFunctionsSet - * @param allFunctionsIdSet - * @param mathNode - */ - private static void getRelatedFunctions(Set relatedFunctionsSet, Set allFunctionsIdSet, ASTNode mathNode) { - - if ((mathNode.isName() || mathNode.isFunction()) - && allFunctionsIdSet.contains(mathNode.getName().trim()) - && !relatedFunctionsSet.contains(mathNode.getName().trim())) { - - relatedFunctionsSet.add(mathNode.getName().trim()); - - return; - } - - for (int i = 0; i < mathNode.getChildCount(); i++) { - getRelatedFunctions(relatedFunctionsSet, allFunctionsIdSet, mathNode.getChild(i)); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeAdapter.java b/IPK_lib/src/org/sbml/jsbml/util/TreeNodeAdapter.java deleted file mode 100644 index 43094a11d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeAdapter.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * $Id: TreeNodeAdapter.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/TreeNodeAdapter.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.swing.tree.MutableTreeNode; -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractTreeNode; -import org.sbml.jsbml.ListOf; - -/** - *

    - * This class is a wrapper element for any {@link Object} that should be linked - * into a tree data structure as represented by {@link AbstractTreeNode}, but - * that might by itself not be an instance of {@link TreeNode}, i.e., not - * compatible with the remaining tree data structure. In analogy to - * {@link MutableTreeNode} we call this {@link Object} userObject - * (see {@link #getUserObject()} and {@link #setUserObject(Object)}). - *

    - *

    - * This wrapper distinguishes the following special cases depending on the type - * of userObject when accessing the i-th child of this - * {@link TreeNode}. The userObject is an instance of - *

      - *
    • {@link TreeNode}: recursive operations are continued at this element
    • - *
    • {@link Collection}: recursion leads to the i-th element in the - * {@link Iterator}
    • - *
    • {@link Map}: the key set is sorted (only possible if the keys implement - * the {@link Comparable} interface) and recursion continues at the i-th key.
    • - *
    - *

    - * - * @author Andreas Dräger - * @version $Rev: 1204 $ - * @since 0.8 - * @date 19.07.2011 - */ -public class TreeNodeAdapter extends AbstractTreeNode { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -6818272462908634740L; - - /** - * The object to be wrapped. - */ - private Object userObject; - - /** - * Creates a new {@link TreeNode} wrapper for the given {@link #userObject} - * that will be linked to the given {@link #parent} within an exisiting - * tree. - * - * @param userObject - * the element to be wrapped in a {@link TreeNode}; may be null. - * @param parent - * the parent {@link TreeNode} of this new node, i.e., the - * position within an existing tree where to link this new node. - * May be null. - */ - public TreeNodeAdapter(Object userObject, TreeNode parent) { - super(); - this.userObject = userObject; - this.parent = parent; - if (parent instanceof AbstractTreeNode) { - this.addAllChangeListeners(((AbstractTreeNode) parent) - .getListOfTreeNodeChangeListeners()); - } - } - - /** - * Copy constructor for the given node. Note that the pointer to the parent - * will not be cloned. - * - * @param node - */ - public TreeNodeAdapter(TreeNodeAdapter node) { - super(node); - this.userObject = node.getUserObject(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#clone() - */ - public TreeNode clone() { - return new TreeNodeAdapter(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - boolean equals = super.equals(object); - if (equals) { - TreeNodeAdapter node = (TreeNodeAdapter) object; - equals &= node.isUserObjectRecursiveDataType() == isUserObjectRecursiveDataType(); - if (equals && isSetUserObjects() && !isUserObjectRecursiveDataType()) { - equals &= node.getUserObject().equals(getUserObject()); - } - } - return equals; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - if (isSetUserObjects() && (userObject instanceof Collection)) { - return true; - } - return false; - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public TreeNode getChildAt(int childIndex) { - if (childIndex < 0) { - throw new IndexOutOfBoundsException(childIndex + " < 0"); - } - if (isSetUserObjects()) { - if (userObject instanceof TreeNode) { - return ((TreeNode) userObject).getChildAt(childIndex); - } - Object child = null; - if (userObject instanceof Map) { - Map map = (Map) userObject; - Object keys[] = map.keySet().toArray(); - Arrays.sort(keys); - child = map.get(keys[childIndex]); - } - if ((userObject instanceof List)) { - child = ((List) userObject).get(childIndex); - } else if ((userObject instanceof Collection)) { - Iterator iterator = ((Collection) userObject).iterator(); - for (int pos = 0; pos < childIndex - 1; pos++) { - iterator.next(); - } - child = iterator.next(); - } - if (child != null) { - if (child instanceof TreeNode) { - return (TreeNode) child; - } else { - return new TreeNodeAdapter(child, this); - } - } - } - throw new IndexOutOfBoundsException(String.format("Index %d >= %d", - childIndex, getChildCount())); - } - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - if (isSetUserObjects()) { - if (userObject instanceof Collection) { - return ((Collection) userObject).size(); - } - if (userObject instanceof Map) { - return ((Map) userObject).size(); - } - } - return 0; - } - - /** - * @return - */ - public Object getUserObject() { - return userObject; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 7; - int hashCode = super.hashCode(); - if (!isUserObjectRecursiveDataType()) { - /* - * We only have to check the user's object in case that it does not - * belong to the things that would be returned by the getChildAt - * method. - */ - hashCode += prime * userObject.hashCode(); - } - return hashCode; - } - - /** - * @return - */ - public boolean isSetUserObjects() { - return userObject != null; - } - - /** - * Checks whether or not the user's object has been set (see - * {@link #isSetUserObjects()}) and if so if it belongs to those elements - * returned by the method {@link #getChildAt(int)}. - * - * @return true if the user's object has been defined and - * belongs to those classes that are returned by the method - * {@link #getChildAt(int)}. - * @see #getChildAt(int) - * @see #isSetUserObjects() - */ - public boolean isUserObjectRecursiveDataType() { - return isSetUserObjects() - && ((userObject instanceof Collection) - || (userObject instanceof Map) || (userObject instanceof TreeNode)); - } - - /** - * - * @param object - */ - public void setUserObject(Object object) { - this.userObject = object; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#toString() - */ - @Override - public String toString() { - if (isSetUserObjects()) { - if (userObject instanceof Collection) { - Collection collection = (Collection) userObject; - if (ListOf.isDebugMode()) { - return collection.toString(); - } else { - if (collection.size() > 0) { - String name = collection.iterator().next().getClass() - .getSimpleName(); - if (!name.endsWith("s")) { - name += "s"; - } - String type = collection instanceof List ? "listOf" - : "collectionOf"; - return type + name; - } - return collection.getClass().getSimpleName(); - } - } else if (userObject instanceof Map) { - Map map = (Map) userObject; - if (ListOf.isDebugMode()) { - return map.toString(); - } else { - if (map.size() > 0) { - Map.Entry entry = map.entrySet().iterator() - .next(); - String name = entry.getKey().getClass().getSimpleName() - + "To" - + entry.getValue().getClass().getSimpleName(); - return "mapOf" + name; - } - } - } - return userObject.toString(); - } - return super.toString(); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeEvent.java b/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeEvent.java deleted file mode 100644 index 5f345751d..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeEvent.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * $Id: TreeNodeChangeEvent.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/TreeNodeChangeEvent.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.beans.PropertyChangeEvent; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBase; - -/** - * This event tells an {@link TreeNodeChangeListener} which values have been - * changed in an {@link SBase} and also provides the old and the new value. - * - * @author Andreas Dräger - * @date 2010-11-14 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class TreeNodeChangeEvent extends PropertyChangeEvent { - - /** - * Generated serial version identifier - */ - private static final long serialVersionUID = 1669574491009205844L; - - /* - * Property names that can change in the life time of an SBML document. - */ - public static final String addExtension="addExtension"; - public static final String addNamespace="addNamespace"; - public static final String addDeclaredNamespace="addDeclaredNamespace"; - public static final String namespace = "namespace"; - public static final String notes="notes"; - public static final String setAnnotation="setAnnotation"; - public static final String level = "level"; - public static final String version="version"; - public static final String metaId = "metaId"; - public static final String notesBuffer = "notesBuffer"; - public static final String parentSBMLObject = "parentSBMLObject"; - public static final String sboTerm = "sboTerm"; - public static final String annotation = "annotation"; - public static final String unsetCVTerms = "unsetCVTerms"; - public static final String currentList = "currentList"; - public static final String symbol = "symbol"; - public static final String math = "math"; - public static final String name = "name"; - public static final String id = "id"; - public static final String compartmentType = "compartmentType"; - public static final String outside = "outside"; - public static final String message = "message"; - public static final String messageBuffer = "messageBuffer"; - public static final String timeUnits = "timeUnits"; - public static final String useValuesFromTriggerTime = "useValuesFromTriggerTime"; - public static final String variable = "variable"; - public static final String units = "units"; - public static final String baseListType = "baseListType"; - public static final String areaUnits = "areaUnits"; - public static final String conversionFactor = "conversionFactor"; - public static final String extentUnits = "extentUnits"; - public static final String lengthUnits = "lengthUnits"; - public static final String substanceUnits = "substanceUnits"; - public static final String volumeUnits = "volumeUnits"; - public static final String value = "value"; - public static final String compartment = "compartment"; - public static final String fast = "fast"; - public static final String reversible = "reversible"; - public static final String species = "species"; - public static final String boundaryCondition = "boundaryCondition"; - public static final String charge = "charge"; - public static final String hasOnlySubstanceUnits = "hasOnlySubstanceUnits"; - public static final String initialAmount = "initialAmount"; - public static final String spatialSizeUnits = "spatialSizeUnits"; - public static final String speciesType = "speciesType"; - public static final String denominator = "denominator"; - public static final String stoichiometry = "stoichiometry"; - public static final String constant = "constant"; - public static final String exponent = "exponent"; - public static final String kind = "kind"; - public static final String multiplier = "multiplier"; - public static final String offset = "offset"; - public static final String scale = "scale"; - public static final String listOfUnits = "listOfUnits"; - public static final String priority = "priority"; - public static final String initialValue = "initialValue"; - public static final String persistent = "persistent"; - public static final String SBMLDocumentAttributes = "SBMLDocumentAttributes"; - public static final String model = "model"; - public static final String kineticLaw = "kineticLaw"; - public static final String spatialDimensions = "spatialDimensions"; - public static final String formula = "formula"; - public static final String size = "size"; - public static final String volume = "volume"; - public static final String className = "className"; - public static final String definitionURL = "definitionURL"; - public static final String childNode = "childNode"; - public static final String numerator = "numerator"; - public static final String mantissa = "mantissa"; - public static final String type = "type"; - public static final String style = "style"; - public static final String isSetNumberType = "isSetNumberType"; - public static final String encoding = "encoding"; - public static final String xmlTriple = "xmlTriple"; - public static final String isEOF = "isEOF"; - public static final String resource = "resource"; - public static final String qualifier = "qualifier"; - public static final String modified = "modified"; - public static final String created = "created"; - public static final String creator = "creator"; - public static final String isExplicitlySetConstant = "isExplicitlySetConstant"; - - - /* - * Annotation - */ - public static final String about = "about"; - public static String nonRDFAnnotation = "nonRDFAnnotation"; - public static String annotationNameSpaces = "annotationNameSpaces"; - public static String history = "history"; - public static String rdfAnnotationNamespaces = "rdfAnnotationNamespaces"; - public static String addCVTerm = "addCVTerm"; - - /* - * ASTNode - */ - public static String userObject = "userObject"; - - public static final String email = "email"; - public static final String familyName = "familyName"; - public static final String givenName = "givenName"; - public static final String organisation = "organisation"; - - public static final String text = "text"; - - /** - * @param source - * @param newValue - * @param oldValue - * @param propertyName - */ - public TreeNodeChangeEvent(TreeNode source, String propertyName, - Object oldValue, Object newValue) { - super(source, propertyName, oldValue, newValue); - } - - /** - * - * @param treeNodeChangeEvent - */ - public TreeNodeChangeEvent(TreeNodeChangeEvent treeNodeChangeEvent) { - this((TreeNode) treeNodeChangeEvent.getSource(), treeNodeChangeEvent - .getPropertyName(), treeNodeChangeEvent.getOldValue(), - treeNodeChangeEvent.getNewValue()); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public TreeNodeChangeEvent clone() { - return new TreeNodeChangeEvent(this); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object object) { - if (object.getClass().equals(getClass())) { - TreeNodeChangeEvent tnce = (TreeNodeChangeEvent) object; - boolean equals = tnce.isSetSource() == isSetSource(); - if (equals && isSetSource()) { - equals &= tnce.getSource().equals(getSource()); - } - equals &= tnce.isSetOldValue() == isSetOldValue(); - if (equals && isSetOldValue()) { - equals &= tnce.getOldValue().equals(getOldValue()); - } - equals &= tnce.isSetNewValue() == isSetNewValue(); - if (equals && isSetNewValue()) { - equals &= tnce.getNewValue().equals(getNewValue()); - } - return equals; - } - return false; - } - - /* (non-Javadoc) - * @see java.util.EventObject#getSource() - */ - @Override - public TreeNode getSource() { - return (TreeNode) super.getSource(); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 7; - int hashCode = getClass().getName().hashCode(); - if (isSetSource()) { - hashCode += prime * getSource().hashCode(); - } - if (isSetOldValue()) { - hashCode += prime * getOldValue().hashCode(); - } - if (isSetNewValue()) { - hashCode += prime * getNewValue().hashCode(); - } - return hashCode; - } - - /** - * - * @return - */ - public boolean isSetNewValue() { - return getNewValue() != null; - } - - /** - * - * @return - */ - public boolean isSetOldValue() { - return getOldValue() != null; - } - - /** - * - * @return - */ - public boolean isSetSource() { - return getSource() != null; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeListener.java b/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeListener.java deleted file mode 100644 index 15158355b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeChangeListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * $Id: TreeNodeChangeListener.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/TreeNodeChangeListener.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.beans.PropertyChangeListener; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.SBMLDocument; - -/** - * A listener interface that allows applications to get notified if the state of - * any {@link TreeNode} object changes. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface TreeNodeChangeListener extends PropertyChangeListener { - - /** - * The {@link T} passed to this method has just been added to the - * {@link SBMLDocument} or another containing element. - * - * @param node - * This element is now part of the {@link SBMLDocument}. - */ - public void nodeAdded(TreeNode node); - - /** - * The {@link T} passed to this method has been removed from a - * containing parent and does hence no longer belong to the - * {@link SBMLDocument} anymore. - * - * @param node - * This element is not longer part of the {@link SBMLDocument}. - */ - public void nodeRemoved(TreeNode node); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeWithChangeSupport.java b/IPK_lib/src/org/sbml/jsbml/util/TreeNodeWithChangeSupport.java deleted file mode 100644 index 4c4572238..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/TreeNodeWithChangeSupport.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * $Id: TreeNodeWithChangeSupport.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/TreeNodeWithChangeSupport.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util; - -import java.io.Serializable; -import java.util.Collection; -import java.util.List; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.AbstractTreeNode; -import org.sbml.jsbml.util.filters.Filter; - -/** - * This interface extends the regular recursively defined {@link TreeNode} by - * adding methods to keep track of changes within the tree, such as - * adding/removing, or exchanging of child nodes or the change of any other - * attributes. - * - * @author Andreas Dräger - * @version $Rev: 1116 $ - * @since 0.8 - * @date 2011-09-15 - */ -public interface TreeNodeWithChangeSupport extends Cloneable, TreeNode, - Serializable { - - /** - * Adds recursively all given {@link TreeNodeChangeListener} instances to - * this element. - * - * @param listeners - * the set of listeners to add - * @return true if the set of listeners is added with success. - * - */ - public boolean addAllChangeListeners( - Collection listeners); - - /** - * Adds recursively a listener to the {@link AbstractTreeNode} object and - * all of its sub-elements. - * - * @param listener - * the listener to add - */ - public void addTreeNodeChangeListener(TreeNodeChangeListener listener); - - /** - * Filters this tree data structure recursively and returns a list of all - * {@link TreeNode}s that are accepted by the {@link Filter}. Although - * internal nodes that do not satisfy the filter criterion by themselves - * are not contained in the resulting list, the recursion continues at - * their children. - * - * @param filter - * A criterion to select a sub-set of nodes of this tree. - * @return A {@link List} of {@link TreeNode}s that do all satisfy the - * criterion of the given {@link Filter}. - * @see #filter(Filter, boolean) - */ - public List filter(Filter filter); - - /** - * Filters this tree data structure recursively and returns a list of all - * {@link TreeNode}s that are accepted by the {@link Filter}. The second - * argument decides whether or not internal nodes that do not by themselves - * satisfy the filter criterion should still be retained in the result list. - * - * @param filter - * A criterion to select a sub-set of nodes of this tree. - * @param retainInternalNodes - * Decides if internal nodes should also be included in the resulting - * {@link List} if they do not by themselves satisfy the {@link Filter} - * but if these do have child elements that do so. This might be useful - * in order to obtain a complete tree path to interesting sub-elements. - * @return - * @see #filter(Filter) - */ - public List filter(Filter filter, boolean retainInternalNodes); - - /** - * All {@link TreeNodeChangeListener} instances linked to this - * {@link TreeNode} are informed about the adding of this {@link Object} to - * an owning parent {@link Object}. - */ - public void fireNodeAddedEvent(); - - /** - * All {@link TreeNodeChangeListener} instances linked to this - * {@link TreeNode} are informed about the deletion of this {@link TreeNode} - * from a parent {@link Object}. - */ - public void fireNodeRemovedEvent(); - - /** - * All {@link TreeNodeChangeListener}s are informed about the change in this - * {@link AbstractTreeNode}. - * - * @param propertyName - * Tells the {@link TreeNodeChangeListener} the name of the - * property whose value has been changed. - * @param oldValue - * This is the value before the change. - * @param newValue - * This gives the new value that is now the new value for the - * given property.. - */ - public void firePropertyChange(String propertyName, Object oldValue, - Object newValue); - - /** - * Returns all {@link TreeNodeChangeListener}s that are assigned to this - * element. - * - * @return all {@link TreeNodeChangeListener}s that are assigned to this - * element. - */ - public List getListOfTreeNodeChangeListeners(); - - /** - * Removes all SBase change listeners from this element. - */ - public void removeAllTreeNodeChangeListeners(); - - /** - * Removes recursively the given change listener from this element. - * - * @param l the listener to remove. - */ - public void removeTreeNodeChangeListener(TreeNodeChangeListener l); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/ValuePair.java b/IPK_lib/src/org/sbml/jsbml/util/ValuePair.java deleted file mode 100644 index de44ce21c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/ValuePair.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * $Id: ValuePair.java,v 1.1 2012-11-07 14:43:37 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/ValuePair.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util; - -import java.io.Serializable; - -/** - * A pair of two values with type parameters. This data object is useful - * whenever exactly two values are required for a specific task. - * - * @author Andreas Dräger - * @date 2010-09-01 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class ValuePair, V extends Comparable> - implements Cloneable, Comparable>, Serializable { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -4230267902609475128L; - /** - * - */ - private L l; - /** - * - */ - private V v; - - /** - * Creates a new {@link ValuePair} with both attributes set to null. - */ - public ValuePair() { - this(null, null); - } - - /** - * - * @param l - * @param v - */ - public ValuePair(L l, V v) { - this.setL(l); - this.setV(v); - } - - /** - * - * @param valuePair - */ - public ValuePair(ValuePair valuePair) { - this.l = valuePair.getL(); - this.v = valuePair.getV(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - @Override - public ValuePair clone() { - return new ValuePair(this); - } - - /** - * Convenient method to compare two values to this {@link ValuePair}. - * - * @param l - * @param v - * @return a negative integer, zero, or a positive integer as this - * {@link ValuePair} is less than, equal to, or greater than the - * combination of the two given values. - * @see #compareTo(ValuePair) - */ - public int compareTo(L l, V v) { - return compareTo(new ValuePair(l, v)); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - public int compareTo(ValuePair v) { - if (equals(v)) { - return 0; - } - if (!isSetL()) { - return Integer.MIN_VALUE; - } - if (!v.isSetL()) { - return Integer.MAX_VALUE; - } - int comp = getL().compareTo(v.getL()); - if (comp == 0) { - if (!isSetV()) { - return -1; - } - if (!v.isSetV()) { - return 1; - } - return getV().compareTo(v.getV()); - } - return comp; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @SuppressWarnings("unchecked") - @Override - public boolean equals(Object object) { - if (object.getClass().equals(getClass())) { - try { - ValuePair v = (ValuePair) object; - boolean equal = isSetL() == v.isSetL(); - equal &= isSetV() == v.isSetV(); - if (equal && isSetL() && isSetV()) { - equal &= v.getL().equals(getL()) && v.getV().equals(getV()); - } - return equal; - } catch (ClassCastException exc) { - return false; - } - } - return false; - } - - /** - * @return the a - */ - public L getL() { - return l; - } - - /** - * @return the b - */ - public V getV() { - return v; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return l.hashCode() + v.hashCode(); - } - - /** - * - * @return - */ - public boolean isSetL() { - return l != null; - } - - /** - * - * @return - */ - public boolean isSetV() { - return v != null; - } - - /** - * @param l - * the l to set - */ - public void setL(L l) { - this.l = l; - } - - /** - * @param v - * the v to set - */ - public void setV(V v) { - this.v = v; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("[%s, %s]", getL().toString(), getV().toString()); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeCompiler.java deleted file mode 100644 index 67a77e898..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeCompiler.java +++ /dev/null @@ -1,703 +0,0 @@ -/* - * $Id: ASTNodeCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/ASTNodeCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.util.List; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.UnitDefinition; - -/** - * A compiler for abstract syntax trees. This compiler evaluates the values - * represented by {@link ASTNode}s. It defines how to perform mathematical or - * other operations on these data types. Recursion can be performed as follows: - * - *
    - *   public ASTNodeValue doSomeThing(ASTNode ast) {
    - *     ...
    - *     ASTNodeValue child = ast.compile(this);
    - *     ...
    - *     return new ASTNodeValue(doSomeThing(child), this);
    - *   }
    - * 
    - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface ASTNodeCompiler { - - /** - * The absolute value represented by the given {@link ASTNode}. - * - * @param value - * Must be interpretable as a {@link Number}. - * @return - * @throws SBMLException - */ - public ASTNodeValue abs(ASTNode value) throws SBMLException; - - /** - * - * @param values - * @return - * @throws SBMLException - */ - public ASTNodeValue and(List values) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccos(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccosh(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccot(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccoth(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccsc(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arccsch(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arcsec(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arcsech(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arcsin(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arcsinh(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arctan(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue arctanh(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue ceiling(ASTNode value) throws SBMLException; - - /** - * - * @param c - * @return - */ - public ASTNodeValue compile(Compartment c); - - /** - * Creates an {@link ASTNodeValue} that represents a real number in - * scientific notation, i.e., mantissa * 10^exponent, and the given units. - * - * @param mantissa - * The number to be multiplied with ten to the power of the given - * exponent. - * @param exponent - * The exponent for the multiplier ten. - * @param units - * The identifier of the units object associated with the number - * represented by this element. Can be null if no units have been - * defined. - * @return - */ - public ASTNodeValue compile(double mantissa, int exponent, String units); - - /** - * - * @param real - * @param units - * A String representing the {@link Unit} of the given number. - * This can be the identifier of a {@link UnitDefinition} in the - * model or a literal in {@link Kind}. Can be null if no units - * have been defined. - * @return - */ - public ASTNodeValue compile(double real, String units); - - /** - * - * @param integer - * @param units - * A String representing the {@link Unit} of the given number. - * This can be the identifier of a {@link UnitDefinition} in the - * model or a literal in {@link Kind}. Can be null if no units - * have been defined. - * @return - */ - public ASTNodeValue compile(int integer, String units); - - /** - * - * @param variable - * @return - * @throws SBMLException - */ - public ASTNodeValue compile(CallableSBase variable) - throws SBMLException; - - /** - * A compiler will also have to deal with a name. The meaning of this can be - * various. For instance, the name may refer to a {@link Species} in the - * system. In case of numerical computation, the {@link ASTNodeCompiler} - * must create an {@link ASTNodeValue} representing the current value of - * this {@link Species}. - * - * @param name - * @return - */ - public ASTNodeValue compile(String name); - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue cos(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue cosh(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue cot(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue coth(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue csc(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue csch(ASTNode value) throws SBMLException; - - /** - * Evaluates delay functions. - * - * @param delayName - * the name of this delay function. - * @param x - * @param delay - * an expression of a positive duration time (the amoutn of - * delay) - * @param timeUnits - * the units for the delay. - * @return - * @throws SBMLException - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, - String timeUnits) throws SBMLException; - - /** - * Equal. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue exp(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue factorial(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue floor(ASTNode value) throws SBMLException; - - /** - * Fraction of two {@link ASTNode}s - * - * @param numerator - * @param denominator - * @return - * @throws SBMLException - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws SBMLException; - - /** - * A fraction of two int values. - * - * @param numerator - * @param denominator - * @return - */ - public ASTNodeValue frac(int numerator, int denominator) - throws SBMLException; - - /** - * - * @param functionDefinition - * @param args - * Values to be inserted into the parameter list of the - * function. - * @return - * @throws SBMLException - */ - public ASTNodeValue function(FunctionDefinition functionDefinition, - List args) throws SBMLException; - - /** - * - * @param functionDefinition name - * @param args - * Values to be inserted into the parameter list of the - * function. - * @return - * @throws SBMLException - */ - public ASTNodeValue function(String functionDefinitionName, - List args) throws SBMLException; - - /** - * Greater equal. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException; - - /** - * Creates an {@link ASTNodeValue} that represent's Avogadro's number. - * Optionally, the compiler may associate the given name with this number. - * - * @param name - * An optional name for Avogadro's number. - * @return - */ - public ASTNodeValue getConstantAvogadro(String name); - - /** - * - * @return - */ - public ASTNodeValue getConstantE(); - - /** - * - * @return - */ - public ASTNodeValue getConstantFalse(); - - /** - * - * @return - */ - public ASTNodeValue getConstantPi(); - - /** - * - * @return - */ - public ASTNodeValue getConstantTrue(); - - /** - * - * @return - * @throws SBMLException - */ - public ASTNodeValue getNegativeInfinity() throws SBMLException; - - /** - * - * @return - */ - public ASTNodeValue getPositiveInfinity(); - - /** - * Greater than. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException; - - /** - * The body of a {@link FunctionDefinition}. - * - * @param values - * Place holders for arguments. - * @return - * @throws SBMLException - */ - public ASTNodeValue lambda(List values) throws SBMLException; - - /** - * Less equal. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException; - - /** - * Natural logarithm. - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue ln(ASTNode value) throws SBMLException; - - /** - * Logarithm of the given value to base 10. - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue log(ASTNode value) throws SBMLException; - - /** - * Logarithm of the given value to the given base. - * - * @param base - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue log(ASTNode base, ASTNode value) throws SBMLException; - - /** - * Less than. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException; - - /** - * Subtraction. - * - * @param values - * @return - * @throws SBMLException - */ - public ASTNodeValue minus(List values) throws SBMLException; - - /** - * Not equal. - * - * @param left - * @param right - * @return - * @throws SBMLException - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException; - - /** - * - * @param value - * This value must be interpretable as a {@link Boolean}. - * @return - * @throws SBMLException - */ - public ASTNodeValue not(ASTNode value) throws SBMLException; - - /** - * - * @param values - * These values must be interpretable as a {@link Boolean}. - * @return - * @throws SBMLException - */ - public ASTNodeValue or(List values) throws SBMLException; - - /** - * - * @param values - * @return - * @throws SBMLException - */ - public ASTNodeValue piecewise(List values) throws SBMLException; - - /** - * - * @param values - * @return - * @throws SBMLException - */ - public ASTNodeValue plus(List values) throws SBMLException; - - /** - * - * @param base - * @param exponent - * @return - * @throws SBMLException - */ - public ASTNodeValue pow(ASTNode base, ASTNode exponent) - throws SBMLException; - - /** - * - * @param rootExponent - * @param radiant - * @return - * @throws SBMLException - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws SBMLException; - - /** - * - * @param rootExponent - * @param radiant - * @return - * @throws SBMLException - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue sec(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue sech(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue sin(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue sinh(ASTNode value) throws SBMLException; - - /** - * Square root. - * - * @param radiant - * This value must be interpretable as a {@link Number}. - * @return - * @throws SBMLException - */ - public ASTNodeValue sqrt(ASTNode radiant) throws SBMLException; - - /** - * The simulation time. - * - * @param time - * The name of the time symbol. - * @return An {@link ASTNodeValue} that represents the current time. - */ - public ASTNodeValue symbolTime(String time); - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue tan(ASTNode value) throws SBMLException; - - /** - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue tanh(ASTNode value) throws SBMLException; - - /** - * Product of all given {@link ASTNode}s. - * - * @param values - * These values must be interpretable to {@link Number}. - * @return - * @throws SBMLException - */ - public ASTNodeValue times(List values) throws SBMLException; - - /** - * Unary minus, i.e., negation of the given {@link ASTNode}. - * - * @param value - * @return - * @throws SBMLException - */ - public ASTNodeValue uMinus(ASTNode value) throws SBMLException; - - /** - * Dealing with a malformed {@link ASTNode}. - * - * @return - * @throws SBMLException - */ - public ASTNodeValue unknownValue() throws SBMLException; - - /** - * Exclusive or. - * - * @param values - * It must be possible to evaluate the given values to - * {@link Boolean}. - * @return - * @throws SBMLException - */ - public ASTNodeValue xor(List values) throws SBMLException; - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeValue.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeValue.java deleted file mode 100644 index 3834b9a27..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/ASTNodeValue.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * $Id: ASTNodeValue.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/ASTNodeValue.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.io.IOException; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.xml.parsers.MathMLParser; -import org.w3c.dom.Node; - -/** - * When interpreting {@link ASTNode}s, the {@link ASTNodeCompiler} takes - * elements of this class as arguments and performs its operations on it. Hence, - * this class represents the union of all possible types to which an abstract - * syntax tree can be evaluated, i.e., {@link Boolean}, - * {@link CallableSBase}, {@link Number}, or {@link String}. This - * class does not define what to do with these values or how to perform any - * operations on it. It is just the container of a value. The type of this value - * tells the {@link ASTNodeCompiler} which operation was performed to obtain the - * value stored in this object. - * - * @author Andreas Dräger - * @date 2010-04-30 - * @since 0.8 - * @version $Rev: 1204 $ - */ -@SuppressWarnings("deprecation") -public class ASTNodeValue { - - /** - * An {@link ASTNodeCompiler} that is needed in the case that this - * {@link ASTNodeValue} contains a derivative of - * {@link CallableSBase} as value to translate this value into a - * double. If the compiler does not convert instances of - * {@link CallableSBase} to double numbers, a - * {@link ClassCastException} will be thrown.. - */ - private ASTNodeCompiler compiler; - /** - * The level of the underlying {@link SBMLDocument}. - */ - private int level; - /** - * The type of the underlying {@link ASTNode}. - */ - private Type type; - /** - * Flag to indicate whether the underlying {@link ASTNode} was an unary - * node. - */ - private boolean uFlag; - /** - * The unit associated to the value of this object. - */ - private UnitDefinition unitDef; - /** - * The actual value of this element. This is an {@link Object}, but indeed - * we restrict the possibilities to store only certain types here. - */ - private Object value; - /** - * The version of the underlying {@link SBMLDocument}. - */ - private int version; - - /** - * - */ - public ASTNodeValue(ASTNodeCompiler compiler) { - type = Type.UNKNOWN; - value = null; - unitDef = null; - uFlag = true; - this.compiler = compiler; - } - - /** - * - * @param value - */ - public ASTNodeValue(boolean value, ASTNodeCompiler compiler) { - this(compiler); - setValue(Boolean.valueOf(value)); - } - - /** - * - * @param value - */ - public ASTNodeValue(double value, ASTNodeCompiler compiler) { - this(compiler); - setValue(Double.valueOf(value)); - } - - /** - * - * @param value - */ - public ASTNodeValue(float value, ASTNodeCompiler compiler) { - this(compiler); - setValue(Float.valueOf(value)); - } - - /** - * - * @param value - * @param compiler - */ - public ASTNodeValue(long value, ASTNodeCompiler compiler) { - this(compiler); - setValue(Long.valueOf(value)); - } - - /** - * - * @param value - */ - public ASTNodeValue(int value, ASTNodeCompiler compiler) { - this(compiler); - setValue(Integer.valueOf(value)); - } - - /** - * - * @param value - */ - public ASTNodeValue(CallableSBase value, - ASTNodeCompiler compiler) { - this(compiler); - setValue(value); - } - - /** - * - * @param node - * @param compiler - */ - public ASTNodeValue(Node node, ASTNodeCompiler compiler) { - this(compiler); - setValue(node); - } - - /** - * - * @param value - */ - public ASTNodeValue(Number value, ASTNodeCompiler compiler) { - this(compiler); - setValue(value); - } - - /** - * - * @param value - */ - public ASTNodeValue(String value, ASTNodeCompiler compiler) { - this(compiler); - setValue(value); - } - - /** - * - * @param type - */ - ASTNodeValue(Type type, ASTNodeCompiler compiler) { - this(compiler); - setType(type); - } - - /** - * - * @param unit - */ - public ASTNodeValue(UnitDefinition unit, ASTNodeCompiler compiler) { - this(compiler); - setUnits(unit); - } - - /** - * Flag to indicate whether or not units have been fully declared for this - * value. - * - * @return - */ - public boolean containsUndeclaredUnits() { - return !isSetUnit() || (getUnits().getUnitCount() == 0); - } - - /** - * Returns the level of the SBML document that was the basis to create this - * {@link ASTNodeValue}. - * - * @return - */ - public int getLevel() { - return level; - } - - /** - * - * @return - */ - public Type getType() { - return type; - } - - /** - * - * @return - */ - public UnitDefinition getUnits() { - if (!isSetUnit()) { - unitDef = new UnitDefinition(level, version); - unitDef.createUnit(); - } - return unitDef; - } - - /** - * - * @return - */ - public Object getValue() { - return value; - } - - /** - * @return the version - */ - public int getVersion() { - return version; - } - - /** - * - * @return - */ - public boolean isBoolean() { - return (value != null) && (value instanceof Boolean); - } - - /** - * - * @return - */ - public boolean isDifference() { - return type == Type.MINUS; - } - - /** - * - * @return - */ - public boolean isCallableSBase() { - return (value != null) && (value instanceof CallableSBase); - } - - /** - * Checks whether the value encapsulated in this {@link ASTNodeValue} is an - * instance of {@link Node}. - * - * @return - */ - public boolean isNode() { - if (value == null) { - return false; - } - return value instanceof Node; - } - - /** - * - * @return - */ - public boolean isNumber() { - return (value != null) && (value instanceof Number); - } - - /** - * Test if this value can be evaluated to a {@link UnitDefinition} - * - * @return - */ - public boolean isSetUnit() { - return unitDef != null; - } - - /** - * - * @return - */ - public boolean isString() { - return (value != null) && (value instanceof String); - } - - /** - * - * @return - */ - public boolean isSum() { - return type == Type.PLUS; - } - - /** - * - * @return - */ - public boolean isUMinus() { - return isDifference() && uFlag; - } - - /** - * - * @return - */ - public boolean isUnary() { - return uFlag; - } - - /** - * - * @return - */ - public String printValueAndUnit() { - StringBuilder sb = new StringBuilder(); - if (value != null) { - sb.append(value.toString()); - } else { - sb.append('?'); - } - sb.append(' '); - sb.append(UnitDefinition.printUnits(getUnits(), true)); - return sb.toString(); - } - - /** - * @param level - * the level to set - */ - public void setLevel(int level) { - this.level = level; - if (isSetUnit() && !getUnits().isSetLevel()) { - getUnits().setLevel(level); - } - } - - /** - * - * @param type - */ - public void setType(Type type) { - this.type = type; - } - - /** - * - * @param uiFlag - */ - public void setUIFlag(boolean uiFlag) { - this.uFlag = uiFlag; - } - - /** - * - * @param unit - */ - public void setUnits(UnitDefinition unit) { - this.unitDef = (unit != null) ? unit.simplify() : unit; - } - - /** - * - * @param value - */ - public void setValue(boolean value) { - setValue(Boolean.valueOf(value)); - } - - /** - * - * @param value - */ - public void setValue(Boolean value) { - this.value = value; - } - - /** - * - * @param d - */ - public void setValue(double d) { - setValue(Double.valueOf(d)); - } - - /** - * - * @param i - */ - public void setValue(int i) { - setValue(Integer.valueOf(i)); - } - - /** - * - * @param l - */ - public void setValue(long l) { - setValue(Long.valueOf(l)); - } - - /** - * - * @param value - */ - public void setValue(CallableSBase value) { - this.value = value; - } - - /** - * - * @param value - */ - public void setValue(Node value) { - this.value = value; - } - - /** - * - * @param value - */ - public void setValue(Number value) { - this.value = value; - } - - /** - * - * @param s - */ - public void setValue(short s) { - setValue(Short.valueOf(s)); - } - - /** - * - * @param value - */ - public void setValue(String value) { - this.value = value; - } - - /** - * @param version - * the version to set - */ - public void setVersion(int version) { - this.version = version; - if (isSetUnit() && !getUnits().isSetVersion()) { - getUnits().setVersion(version); - } - } - - /** - * Analog to the toDouble() method but this method tries to evaluate the - * value contained in this object to a boolean value. In case of numbers, - * one is considered true, all other values represent false. - * - * @return A boolean representing the value of this container. Note that if - * the value is an instance of {@link CallableSBase}, it - * can only be converted into a boolean value if the - * {@link ASTNodeCompiler} associated with this object compiles this - * value to an {@link ASTNodeValue} that contains a boolean or at - * least a {@link Number} value. - * @throws SBMLException - */ - public boolean toBoolean() throws SBMLException { - if (isBoolean()) { - return ((Boolean) getValue()).booleanValue(); - } - if (isCallableSBase()) { - ASTNodeValue value = compiler - .compile((CallableSBase) getValue()); - if (value.isBoolean()) { - return ((Boolean) value.getValue()).booleanValue(); - } else if (value.isNumber()) { - return 1 == ((Number) value.getValue()).doubleValue(); - } - } - if (isNumber()) { - return 1 == ((Number) getValue()).doubleValue(); - } - return Boolean.parseBoolean(toString()); - } - - /** - * - * @return - * @throws SBMLException - */ - public double toDouble() throws SBMLException { - return toNumber().doubleValue(); - } - - /** - * - * @return - * @throws SBMLException - */ - public float toFloat() throws SBMLException { - return toNumber().floatValue(); - } - - /** - * This method is analog to the toDouble method but tries to convert this - * value into an integer. - * - * @param compiler - * @return - * @throws SBMLException - */ - public int toInteger() throws SBMLException { - return toNumber().intValue(); - } - - /** - * - * @return - * @throws SBMLException - */ - public long toLong() throws SBMLException { - return toNumber().longValue(); - } - - /** - * - * @return - */ - public CallableSBase toCallableSBase() { - if (isCallableSBase()) { - return (CallableSBase) getValue(); - } - if (isString()) { - // actually no way to to obtain the namedSBase from a model - // because no reference to the model is stored here. - ASTNodeValue value = compiler.compile(toString()); - if (value.isCallableSBase()) { - return (CallableSBase) value; - } - } - return null; - } - - /** - * - * @return - */ - public Node toNode() { - if (isNode()) { - return (Node) value; - } - return null; - } - - /** - * Tries to convert the value contained in this object into a double number. - * - * @return The number value represented by this given {@link ASTNodeValue}. - * In case this {@link ASTNodeValue} contains an instance of - * {@link Boolean}, zero is returned for false and one for true. If - * the value is null or cannot be converted to any number, - * {@link Double.NaN} will be returned. Note that if the value of - * this container is an instance of - * {@link CallableSBase}, the value can only be - * converted to a number if the compiler associated with this - * {@link ASTNodeValue} compiles this - * {@link CallableSBase} to an {@link ASTNodeValue} that - * contains a {@link Number}. - * @throws SBMLException - */ - public Number toNumber() throws SBMLException { - if (isNumber()) { - return (Number) getValue(); - } - if (isBoolean()) { - return Double.valueOf(((Boolean) getValue()).booleanValue() ? 1d - : 0d); - } - if (isCallableSBase()) { - ASTNodeValue value = compiler - .compile((CallableSBase) getValue()); - if (value.isNumber()) { - return ((Number) value.getValue()).doubleValue(); - } - } - if (isString()) { - return Double.valueOf(toString()); - } - return Double.valueOf(Double.NaN); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - if (isNode()) { - try { - return MathMLParser.toMathML(MathMLParser - .createMathMLDocumentFor(toNode(), getLevel()), true, - true, 2); - } catch (IOException e) { - e.printStackTrace(); - } catch (SBMLException e) { - e.printStackTrace(); - } - } - String val = (value != null) ? value.toString() : super.toString(); - if (isSetUnit()) { - val += ' ' + UnitDefinition.printUnits(getUnits(), true); - } - return val; - } - - /** - * Removes the unit of this element, i.e., the unit will become invalid. - */ - public void unsetUnit() { - unitDef = null; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java deleted file mode 100644 index d6ba67426..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java +++ /dev/null @@ -1,588 +0,0 @@ -/* - * $Id: FindUnitsCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/FindUnitsCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util.compilers; - -import java.util.List; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.SBMLException; - -/** - * Finds if an ASTNode is using any units attribute. - * - * This {@link ASTNodeCompiler} is basically empty, only methods related to - * 'cn' elements are implemented - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - * - */ -public class FindUnitsCompiler implements ASTNodeCompiler { - - private boolean isUnitsDefined = false; - private final ASTNodeValue dummyValue = new ASTNodeValue("dummy", null); - - public boolean isUnitsDefined() { - return isUnitsDefined; - } - - public void reset() { - isUnitsDefined = false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue abs(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) - */ - public ASTNodeValue and(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccos(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccosh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccot(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccoth(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccsc(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccsch(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsec(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsech(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsin(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsinh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arctan(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arctanh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ceiling(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.Compartment) - */ - public ASTNodeValue compile(Compartment c) { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, java.lang.String) - */ - public ASTNodeValue compile(double mantissa, int exponent, String units) { - - if (units != null && units.length() > 0) { - isUnitsDefined = true; - throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); - } - - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, java.lang.String) - */ - public ASTNodeValue compile(double real, String units) { - - if (units != null && units.length() > 0) { - isUnitsDefined = true; - throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); - } - - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, java.lang.String) - */ - public ASTNodeValue compile(int integer, String units) { - - if (units != null && units.length() > 0) { - isUnitsDefined = true; - throw new SBMLException("Stopping the recursion, a units has been found and the SBML namespace is needed."); - } - - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) - */ - public ASTNodeValue compile(CallableSBase variable) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) - */ - public ASTNodeValue compile(String name) { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cos(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cosh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cot(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue coth(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csc(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csch(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode, java.lang.String) - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, - String timeUnits) throws SBMLException { - - // TODO : to check but I don't think that units are allowed in this case. - // There are allowed only on the cn elements. - - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue exp(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue factorial(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue floor(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(int, int) - */ - public ASTNodeValue frac(int numerator, int denominator) - throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(org.sbml.jsbml.FunctionDefinition, java.util.List) - */ - public ASTNodeValue function(FunctionDefinition functionDefinition, - List args) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(java.lang.String, java.util.List) - */ - public ASTNodeValue function(String functionDefinitionName, - List args) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java.lang.String) - */ - public ASTNodeValue getConstantAvogadro(String name) { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantE() - */ - public ASTNodeValue getConstantE() { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantFalse() - */ - public ASTNodeValue getConstantFalse() { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantPi() - */ - public ASTNodeValue getConstantPi() { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantTrue() - */ - public ASTNodeValue getConstantTrue() { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getNegativeInfinity() - */ - public ASTNodeValue getNegativeInfinity() throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getPositiveInfinity() - */ - public ASTNodeValue getPositiveInfinity() { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#gt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lambda(java.util.List) - */ - public ASTNodeValue lambda(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#leq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ln(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode base, ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#minus(java.util.List) - */ - public ASTNodeValue minus(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue not(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#or(java.util.List) - */ - public ASTNodeValue or(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) - */ - public ASTNodeValue piecewise(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#plus(java.util.List) - */ - public ASTNodeValue plus(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue pow(ASTNode base, ASTNode exponent) - throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sec(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sech(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sin(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sinh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sqrt(ASTNode radiant) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String) - */ - public ASTNodeValue symbolTime(String time) { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tan(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tanh(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#times(java.util.List) - */ - public ASTNodeValue times(List values) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue uMinus(ASTNode value) throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#unknownValue() - */ - public ASTNodeValue unknownValue() throws SBMLException { - return dummyValue; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) - */ - public ASTNodeValue xor(List values) throws SBMLException { - return dummyValue; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java deleted file mode 100644 index 45e2e2f80..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java +++ /dev/null @@ -1,1206 +0,0 @@ -/* - * $Id: FormulaCompiler.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util.compilers; - -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.IllegalFormatException; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Vector; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.util.StringTools; - -/** - * This class creates C-like infix formula {@link String}s that represent the - * content of {@link ASTNode}s. These can be used to save equations in SBML with - * older than Level 2. - * - * @author Alexander Dörr - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ - -/* - * - * - * // TODO : check if we can improve the writing of brackets or wrote a method - * to minimized the bracket, they are few differences with libSBML both way - * anyway. - * - * BIOMODEL 162 : - * - * - * KineticLaw (ER_leak_fluxD) MathContainer : infix formula output differ. JSBML - * formula : - * (-ERDensity_D_ERM*vL*(1+-0.00166112956810631*Ca_D_Cytosol*1/(0.00166112956810631 - * *Ca_D_ER)))*ERM*1*1/KMOLE // False, should put - instead of +- ? libSBML - * formula :-(ERDensity_D_ERM*vL*(1+-(0.00166112956810631*Ca_D_Cytosol*(1/( - * 0.00166112956810631*Ca_D_ER)))))*ERM*1*(1/KMOLE) // False - */ - -public class FormulaCompiler extends StringTools implements ASTNodeCompiler { - - /** - * Basic method which links several elements with a mathematical operator. - * All empty StringBuffer object are excluded. - * - * @param operator - * @param elements - * @return - */ - private static final StringBuffer arith(char operator, Object... elements) { - List vsb = new Vector(); - for (Object sb : elements) { - if (sb != null && sb.toString().length() > 0) { - vsb.add(sb); - } - } - StringBuffer equation = new StringBuffer(); - if (vsb.size() > 0) { - equation.append(vsb.get(0)); - } - Character op = Character.valueOf(operator); - for (int count = 1; count < vsb.size(); count++) { - append(equation, op, vsb.get(count)); - } - return equation; - } - - /** - * - * @param sb - * @return - */ - public static final StringBuffer brackets(Object sb) { - return concat(Character.valueOf('('), sb, Character.valueOf(')')); - } - - /** - * Tests whether the String representation of the given object contains any - * arithmetic symbols and if the given object is already sorrounded by - * brackets. - * - * @param something - * @return True if either brackets are set around the given object or the - * object does not contain any symbols such as +, -, *, /. - */ - private static boolean containsArith(Object something) { - boolean arith = false; - String d = something.toString(); - if (d.length() > 0) { - char c; - for (int i = 0; (i < d.length()) && !arith; i++) { - c = d.charAt(i); - arith = ((c == '+') || (c == '-') || (c == '*') || (c == '/')); - } - } - return arith; - } - - /** - * Returns the difference of the given elements as StringBuffer. - * - * @param subtrahents - * @return - */ - public static final StringBuffer diff(Object... subtrahents) { - if (subtrahents.length == 1) { - return brackets(concat(Character.valueOf('-'), subtrahents)); - } - return brackets(arith('-', subtrahents)); - } - - /** - * Returns a fraction with the given elements as numerator and denominator. - * - * @param numerator - * @param denominator - * @return - */ - public static final StringBuffer frac(Object numerator, Object denominator) { - return brackets(arith('/', - (containsArith(numerator) ? brackets(numerator) : numerator), - containsArith(denominator) ? brackets(denominator) - : denominator)); - } - - /** - * Returns the id of a PluginSpeciesReference object's belonging species as - * an object of type StringBuffer. - * - * @param ref - * @return - */ - protected static final StringBuffer getSpecies(SpeciesReference ref) { - return new StringBuffer(ref.getSpecies()); - } - - /** - * Returns the value of a PluginSpeciesReference object's stoichiometry - * either as a double or, if the stoichiometry has an integer value, as an - * int object. - * - * @param ref - * @return - */ - protected static final double getStoichiometry(SpeciesReference ref) { - double stoich = ref.getStoichiometry(); - return stoich; - } - - /** - * Returns the basis to the power of the exponent as StringBuffer. Several - * special cases are treated. - * - * @param basis - * @param exponent - * @return - */ - public static final StringBuffer pow(Object basis, Object exponent) { - try { - if (Double.parseDouble(exponent.toString()) == 0f) { - return new StringBuffer("1"); - } - if (Double.parseDouble(exponent.toString()) == 1f) { - return basis instanceof StringBuffer ? (StringBuffer) basis - : new StringBuffer(basis.toString()); - } - } catch (NumberFormatException exc) { - } - String b = basis.toString(); - if (b.contains("*") || b.contains("-") || b.contains("+") - || b.contains("/") || b.contains("^")) { - basis = brackets(basis); - } - String e = exponent.toString(); - if (e.contains("*") || e.contains("-") || e.contains("+") - || e.contains("/") || e.contains("^")) { - exponent = brackets(e); - } - return arith('^', basis, exponent); - } - - /** - * Returns the exponent-th root of the basis as StringBuffer. - * - * @param exponent - * @param basis - * @return - * @throws IllegalFormatException - * If the given exponent represents a zero. - */ - public static final StringBuffer root(Object exponent, Object basis) - throws NumberFormatException { - if (Double.parseDouble(exponent.toString()) == 0f) { - throw new NumberFormatException( - "Cannot extract a zeroth root of anything"); - } - if (Double.parseDouble(exponent.toString()) == 1f) { - return new StringBuffer(basis.toString()); - } - return concat("root(", exponent, Character.valueOf(','), basis, - Character.valueOf(')')); - } - - /** - * - * @param basis - * @return - */ - public static final StringBuffer sqrt(Object basis) { - try { - return root(Integer.valueOf(2), basis); - } catch (IllegalFormatException e) { - return pow(basis, frac(Integer.valueOf(1), Integer.valueOf(2))); - } - } - - /** - * Returns the sum of the given elements as StringBuffer. - * - * @param summands - * @return - */ - public static final StringBuffer sum(Object... summands) { - return brackets(arith('+', summands)); - } - - /** - * Returns the product of the given elements as StringBuffer. - * - * @param factors - * @return - */ - public static final StringBuffer times(Object... factors) { - return arith('*', factors); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue abs(ASTNode node) throws SBMLException { - return function("abs", node); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) - */ - public ASTNodeValue and(List nodes) throws SBMLException { - return logicalOperation(" and ", nodes); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccos(ASTNode node) throws SBMLException { - return function("acos", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccosh(ASTNode node) throws SBMLException { - return function("acosh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccot(ASTNode node) throws SBMLException { - return function("acot", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccoth(ASTNode node) throws SBMLException { - return function("acoth", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccsc(ASTNode node) throws SBMLException { - return function("acsc", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccsch(ASTNode node) throws SBMLException { - return function("acsch", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arcsec(ASTNode node) throws SBMLException { - return function("asec", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arcsech(ASTNode node) throws SBMLException { - return function("asech", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arcsin(ASTNode node) throws SBMLException { - return function("asin", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arcsinh(ASTNode node) throws SBMLException { - return function("asinh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arctan(ASTNode node) throws SBMLException { - return function("atan", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arctanh(ASTNode node) throws SBMLException { - return function("atanh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue ceiling(ASTNode node) throws SBMLException { - return function("ceil", node); - } - - /** - * Creates brackets if needed. - * - * @param node - * @return - * @throws SBMLException - */ - private String checkBrackets(ASTNode node) throws SBMLException { - String term = node.compile(this).toString(); - - if (node.isSum() || node.isDifference() || node.isUMinus()) { - term = brackets(term).toString(); - } else if (node.isReal()) { - if (node.getReal() < 0.0) { - term = brackets(term).toString(); - } - } - - return term; - } - - /** - * Creates brackets if needed. - * - * @param nodes - * @return - * @throws SBMLException - */ - private String checkDenominatorBrackets(ASTNode nodes) throws SBMLException { - String term = nodes.compile(this).toString(); - if (nodes.isSum() || nodes.isDifference() || nodes.isUMinus() - || nodes.getType() == Type.TIMES) { - term = brackets(term).toString(); - } - return term; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml. - * Compartment) - */ - public ASTNodeValue compile(Compartment c) { - return new ASTNodeValue(c.getId(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, - * java.lang.String) - */ - public ASTNodeValue compile(double mantissa, int exponent, String units) { - if (exponent == 0) { - return new ASTNodeValue(mantissa, this); - } - - return new ASTNodeValue(concat( - (new DecimalFormat(StringTools.REAL_FORMAT, - new DecimalFormatSymbols(Locale.ENGLISH))) - .format(mantissa), "E", exponent).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, - * java.lang.String) - */ - public ASTNodeValue compile(double real, String units) { - return new ASTNodeValue(toString(Locale.ENGLISH, real), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, - * java.lang.String) - */ - public ASTNodeValue compile(int integer, String units) { - return new ASTNodeValue(integer, this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) - */ - public ASTNodeValue compile(CallableSBase variable) { - return new ASTNodeValue(variable.getId(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) - */ - public ASTNodeValue compile(String name) { - return new ASTNodeValue(name, this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cos(ASTNode node) throws SBMLException { - return function("cos", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue cosh(ASTNode node) throws SBMLException { - return function("cosh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cot(ASTNode node) throws SBMLException { - return function("cot", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue coth(ASTNode node) throws SBMLException { - return function("coth", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csc(ASTNode node) throws SBMLException { - return function("csc", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue csch(ASTNode node) throws SBMLException { - return function("csch", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, - * org.sbml.jsbml.ASTNode, double, java.lang.String) - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode y, - String timeUnits) throws SBMLException { - return new ASTNodeValue(concat("delay(", x.compile(this), ", ", - y.compile(this), ")").toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " == ", right), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue exp(ASTNode node) throws SBMLException { - return function("exp", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml - * .ASTNode) - */ - public ASTNodeValue factorial(ASTNode node) { - return new ASTNodeValue(append(brackets(node), Character.valueOf('!')) - .toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue floor(ASTNode node) throws SBMLException { - return function("floor", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws SBMLException { - return new ASTNodeValue(concat(checkBrackets(numerator), - Character.valueOf('/'), checkDenominatorBrackets(denominator)) - .toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(int, int) - */ - public ASTNodeValue frac(int numerator, int denominator) { - return new ASTNodeValue(concat( - numerator < 0 ? brackets(compile(numerator, null)) : compile( - numerator, null), - Character.valueOf('/'), - denominator < 0 ? brackets(compile(denominator, null)) - : compile(denominator, null)).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(org.sbml.jsbml - * .FunctionDefinition, java.util.List) - */ - public ASTNodeValue function(FunctionDefinition func, List nodes) - throws SBMLException { - return function(func.getId(), nodes); - } - - /** - * - * @param name - * @param nodes - * @return - * @throws SBMLException - */ - protected ASTNodeValue function(String name, ASTNode... nodes) - throws SBMLException { - LinkedList l = new LinkedList(); - for (ASTNode node : nodes) { - l.add(node); - } - return new ASTNodeValue(concat(name, brackets(lambdaBody(l))) - .toString(), this); - } - - /** - * - * @param name - * @param nodes - * @return - * @throws SBMLException - */ - public ASTNodeValue function(String name, List nodes) - throws SBMLException - { - return new ASTNodeValue(concat(name, brackets(lambdaBody(nodes))) - .toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " >= ", right), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java - * .lang.String) - */ - public ASTNodeValue getConstantAvogadro(String name) { - return new ASTNodeValue("avogadro", this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantE() - */ - public ASTNodeValue getConstantE() { - return new ASTNodeValue(Character.toString('e'), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantFalse() - */ - public ASTNodeValue getConstantFalse() { - return new ASTNodeValue(false, this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantPi() - */ - public ASTNodeValue getConstantPi() { - return new ASTNodeValue("pi", this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantTrue() - */ - public ASTNodeValue getConstantTrue() { - return new ASTNodeValue(true, this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getNegativeInfinity() - */ - public ASTNodeValue getNegativeInfinity() { - return new ASTNodeValue(Double.NEGATIVE_INFINITY, this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getPositiveInfinity() - */ - public ASTNodeValue getPositiveInfinity() { - return new ASTNodeValue(Double.POSITIVE_INFINITY, this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#gt(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " > ", right), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lambda(java.util.List) - */ - public ASTNodeValue lambda(List nodes) throws SBMLException { - return new ASTNodeValue(StringTools.concat("lambda", - brackets(lambdaBody(nodes))).toString(), this); - } - - /** - * Creates the body of a lambda function, i.e., the argument list and the - * actual mathematical operation, all comma separated and surrounded in - * brackets. - * - * @param nodes - * @return - * @throws SBMLException - */ - private String lambdaBody(List nodes) throws SBMLException { - StringBuffer lambda = new StringBuffer(); - for (int i = 0; i < nodes.size(); i++) { - if (i > 0) { - lambda.append(", "); - } - lambda.append(nodes.get(i).compile(this)); - } - return lambda.toString(); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#leq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " <= ", right), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ln(ASTNode node) throws SBMLException { - return function("log", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode node) throws SBMLException { - return function("log10", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode left, ASTNode right) throws SBMLException { - return function("log", left, right); - } - - /** - * - * @param operator - * @param nodes - * @return - * @throws SBMLException - */ - private ASTNodeValue logicalOperation(String operator, List nodes) - throws SBMLException { - StringBuffer value = new StringBuffer(); - boolean first = true; - for (ASTNode node : nodes) { - if (!first) { - value.append(operator); - } else { - first = false; - } - if (node.getChildCount() > 0) { - append(value, Character.valueOf('('), node.compile(this) - .toString(), Character.valueOf(')')); - } else { - value.append(node.compile(this).toString()); - } - } - return new ASTNodeValue(value.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#lt(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " < ", right), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#minus(java.util.List) - */ - public ASTNodeValue minus(List nodes) throws SBMLException { - if (nodes.size() == 0) { - return new ASTNodeValue("", this); - } - - StringBuffer minus = new StringBuffer(); - - minus.append(nodes.get(0)); - - for (int i = 1; i < nodes.size(); i++) { - if (i > 0) { - minus.append('-'); - } - minus.append(checkBrackets(nodes.get(i))); - } - return new ASTNodeValue(minus.toString(), this); - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " != ", right), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue not(ASTNode node) throws SBMLException { - return function("not", node); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#or(java.util.List) - */ - public ASTNodeValue or(List nodes) throws SBMLException { - return logicalOperation(" or ", nodes); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) - */ - public ASTNodeValue piecewise(List nodes) throws SBMLException { - return function("piecewise", nodes); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#plus(java.util.List) - */ - public ASTNodeValue plus(List nodes) throws SBMLException { - StringBuffer plus = new StringBuffer(); - if (nodes.size() == 0) { - return new ASTNodeValue("", this); - } - - plus.append(nodes.get(0)); - - for (int i = 1; i < nodes.size(); i++) { - plus.append('+'); - - plus.append(checkBrackets(nodes.get(i))); - - } - return new ASTNodeValue(plus.toString(), this); - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue pow(ASTNode left, ASTNode right) throws SBMLException { - - // Adding brackets all the time for the exponent/right ASTNode - - if (left.getChildCount() < 2) { - return new ASTNodeValue(StringTools.concat(left.compile(this), "^", "(", - right.compile(this), ")").toString(), this); - } else { - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - left.compile(this), Character.valueOf(')'), "^", "(", - right.compile(this), ")").toString(), this); - } - - } - - /** - * - * @param left - * @param symbol - * @param right - * @return - * @throws SBMLException - */ - private String relation(ASTNode left, String symbol, ASTNode right) - throws SBMLException { - - return concat((left.isRelational()) ? brackets(left) : left, symbol, - (right.isRelational()) ? brackets(right) : right).toString(); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws SBMLException - { - // Writing the root function as '(radiant)^(1/(rootExponent))' - // TODO : need to reduce the number of parenthesis when possible - - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - radiant.compile(this), Character.valueOf(')'), "^", "(1/(", - rootExponent.compile(this), "))").toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException - { - // Writing the root function as '(radiant)^(1/rootExponent)' - - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - radiant.compile(this), Character.valueOf(')'), "^", "(1/", - rootExponent, ")").toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sec(ASTNode node) throws SBMLException { - return function("sec", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sech(ASTNode node) throws SBMLException { - return function("sech", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sin(ASTNode node) throws SBMLException { - return function("sin", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sinh(ASTNode node) throws SBMLException { - return function("sinh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sqrt(ASTNode node) throws SBMLException { - return new ASTNodeValue(StringTools.concat(Character.valueOf('('), - node.compile(this), Character.valueOf(')'), "^", "(0.5)").toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String - * ) - */ - public ASTNodeValue symbolTime(String time) { - return new ASTNodeValue(time, this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tan(ASTNode node) throws SBMLException { - return function("tan", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue tanh(ASTNode node) throws SBMLException { - return function("tanh", node); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#times(java.util.List) - */ - public ASTNodeValue times(List nodes) throws SBMLException { - Object n[] = new ASTNodeValue[nodes.size()]; - for (int i = 0; i < nodes.size(); i++) { - ASTNode ast = nodes.get(i); - n[i] = new ASTNodeValue(checkBrackets(ast).toString(), this); - } - return new ASTNodeValue(times(n).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue uMinus(ASTNode node) throws SBMLException { - return new ASTNodeValue(concat(Character.valueOf('-'), - checkBrackets(node)).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#unknownValue() - */ - public ASTNodeValue unknownValue() throws SBMLException { - throw new SBMLException( - "cannot write unknown syntax tree nodes to a formula String"); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) - */ - public ASTNodeValue xor(List nodes) throws SBMLException { - return logicalOperation(" xor ", nodes); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java deleted file mode 100644 index d1b525289..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * $Id: FormulaCompilerNoPiecewise.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/FormulaCompilerNoPiecewise.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util.compilers; - -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.util.StringTools; - -/** - * Produces an infix formula like {@link FormulaCompiler} but removes all the - * piecewise functions. They are replaced by an id that is unique if you are - * using the same {@link FormulaCompilerNoPiecewise} instance. The content of - * the piecewise function is put in a {@link Map} and is transformed to use - * if/then/else. - * - * This class is used for example to create an SBML2XPP converter where (in XPP) - * the piecewise operator is not supported. - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class FormulaCompilerNoPiecewise extends FormulaCompiler { - - /** - * - */ - private Map piecewiseMap = new LinkedHashMap(); - /** - * - */ - private String andReplacement = " & "; - /** - * - */ - private String orReplacement = " | "; - - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) - */ - public ASTNodeValue piecewise(List nodes) throws SBMLException { - - // create the piecewise output with if/then/else - // We need to compile each nodes, in case they contain some other piecewise - String piecewiseStr = ""; - - int nbChildren = nodes.size(); - int nbIfThen = nbChildren / 2; - boolean otherwise = (nbChildren % 2) == 1; - - for (int i = 0; i < nbIfThen; i++) { - int index = i * 2; - if (i > 0) { - piecewiseStr += "("; - } - piecewiseStr = StringTools.concat(piecewiseStr, "if (", nodes.get( - index + 1).compile(this).toString(), ") then (", nodes.get( - index).compile(this).toString(), ") else ").toString(); - } - - if (otherwise) { - piecewiseStr += "(" + nodes.get(nbChildren - 1).compile(this).toString() + ")"; - } - - // closing the opened parenthesis - if (nbIfThen > 1) { - for (int i = 1; i < nbIfThen; i++) { - piecewiseStr += ")"; - } - } - - if (andReplacement != null) { - piecewiseStr = piecewiseStr.replaceAll(" and ", andReplacement); - } - if (orReplacement != null) { - piecewiseStr = piecewiseStr.replaceAll(" or ", orReplacement); - } - - // get a unique identifier for the piecewise expression in this compiler. - int id = piecewiseMap.size() + 1; - String piecewiseId = "piecew" + id; - - // Adding the piecewise to the list of piecewise - piecewiseMap.put(piecewiseId, piecewiseStr); - - return new ASTNodeValue(" " + piecewiseId + " ", this); - } - - - /** - * Gets a {@link Map} of the piecewise expressions that have been - * transformed. - * - * @return a {@link Map} of the piecewise expressions that have been - * transformed. - */ - public Map getPiecewiseMap() { - return piecewiseMap; - } - - - /** - * Gets the String that will be used to replace ' and ' (the mathML - * <and> element) in the boolean expressions. - * - * @return the {@link String} that will be used to replace ' and ' (the - * mathML <and> element) in the boolean expressions. - */ - public String getAndReplacement() { - return andReplacement; - } - - - /** - * Sets the {@link String} that will be used to replace ' and ' (the mathML - * <and> element) in the boolean expressions. The default value used - * is ' & '. If null is given, no replacement will be performed. - * - * @param andReplacement - */ - public void setAndReplacement(String andReplacement) { - this.andReplacement = andReplacement; - } - - - /** - * Gets the String that will be used to replace ' or ' (the mathML - * <or> element) in the boolean expressions. - * - * @return the {@link String} that will be used to replace ' or ' (the - * mathML <or> element) in the boolean expressions. - */ - public String getOrReplacement() { - return orReplacement; - } - - - /** - * Sets the {@link String} that will be used to replace ' or ' (the mathML - * <or> element) in the boolean expressions. The default value is ' - * | '. If null is given, no replacement will be performed. - * - * @param orReplacement - */ - public void setOrReplacement(String orReplacement) { - this.orReplacement = orReplacement; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/HTMLFormula.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/HTMLFormula.java deleted file mode 100644 index c0f0f96dd..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/HTMLFormula.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * $Id: HTMLFormula.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/HTMLFormula.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.util.List; -import java.util.Vector; - -import javax.xml.stream.XMLStreamException; - -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.util.StringTools; - -/** - * @author Andreas Dräger - * @date 2010-04-08 - * @since 0.8 - * @version $Rev: 1139 $ - */ -public class HTMLFormula extends MathMLCompiler { - - /** - * HTML code for the empty set symbol “∅”. - */ - public static final String EMPTY_SET = "∅"; - - /** - * HTML code for the reversible reaction arrow whose upper side is directed - * to the right “⇌”. - */ - public static final String REVERSIBLE_REACTION_ARROW = "⇌"; - - /** - * HTML code for the right arrow “→”. - */ - public static final String RIGHT_ARROW = "→"; - - /** - * Multiplication symbol “⋅”. - */ - public static final String C_DOT = "⋅"; - - /** - * Basic method which links several elements with a mathematical operator. - * All empty StringBuffer object are excluded. - * - * @param operator - * @param elements - * @return - */ - private static final StringBuffer arith(Object operator, Object... elements) { - List vsb = new Vector(); - for (Object sb : elements) - if (sb != null && sb.toString().length() > 0) - vsb.add(sb); - StringBuffer equation = new StringBuffer(); - if (vsb.size() > 0) - equation.append(vsb.get(0)); - String op = operator.toString(); - for (int count = 1; count < vsb.size(); count++) { - StringTools.append(equation, op, vsb.get(count)); - } - return equation; - } - - /** - * - * @param arith - * @return - */ - private static StringBuffer brackets(Object arith) { - return StringTools.concat("(", arith, ")"); - } - - /** - * Returns the basis to the power of the exponent as StringBuffer. Several - * special cases are treated. - * - * @param basis - * @param exponent - * @return - */ - public static final StringBuffer pow(Object basis, Object exponent) { - try { - if (Double.parseDouble(exponent.toString()) == 0d) { - return new StringBuffer("1"); - } - if (Double.parseDouble(exponent.toString()) == 1d) { - return basis instanceof StringBuffer ? (StringBuffer) basis - : new StringBuffer(basis.toString()); - } - } catch (NumberFormatException exc) { - } - String b = basis.toString(); - if (b.contains(C_DOT) || b.contains("-") || b.contains("+") - || b.contains("/") || b.contains("")) { - basis = brackets(basis); - } - String e = exponent.toString(); - if (e.contains(C_DOT) || e.substring(1).contains("-") - || e.contains("+") || e.contains("/") || e.contains("")) { - exponent = brackets(e); - } - return StringTools.concat(basis, "", exponent, ""); - } - - /** - * Returns the sum of the given elements as StringBuffer. - * - * @param summands - * @return - */ - public static final StringBuffer sum(Object... summands) { - return brackets(arith(Character.valueOf('+'), summands)); - } - - /** - * Returns the product of the given elements as StringBuffer. - * - * @param factors - * @return - */ - public static final StringBuffer times(Object... factors) { - return arith(C_DOT, factors); - } - - /** - * - * @return - */ - @SuppressWarnings("deprecation") - public static String toHTML(Unit u) { - StringBuffer times = new StringBuffer(); - if (u.getMultiplier() != 0) { - if (u.getMultiplier() != 1) - times.append(StringTools.toString(u.getMultiplier())); - StringBuffer pow = new StringBuffer(); - pow.append(u.getKind().getSymbol()); - String prefix = u.getPrefix(); - if (prefix.length() > 0 && !prefix.startsWith("10")) { - pow.insert(0, prefix); - } else if (u.getScale() != 0) { - pow.insert(0, ' '); - pow = HTMLFormula.times(HTMLFormula.pow(Integer.valueOf(10), u - .getScale()), pow); - } - times = HTMLFormula.times(times, pow); - } - if (u.getOffset() != 0) { - times = HTMLFormula.sum(StringTools.toString(u.getOffset()), times); - } - return HTMLFormula.pow(times, StringTools.toString(u.getExponent())) - .toString(); - } - - /** - * Creates an HTML string representation of this UnitDefinition. - * - * @return - */ - public static String toHTML(UnitDefinition ud) { - StringBuilder sb = new StringBuilder(); - if (ud != null) { - for (int i = 0; i < ud.getUnitCount(); i++) { - Unit unit = ud.getUnit(i); - if (i > 0) { - sb.append(' '); - sb.append(C_DOT); - sb.append(' '); - } - sb.append(toHTML(unit)); - } - } - return sb.toString(); - } - - /** - * @throws XMLStreamException - */ - public HTMLFormula() throws XMLStreamException { - super(); - } - - /** - * @param reaction - * @return - * @throws SBMLException - */ - @SuppressWarnings("deprecation") - public String reactionEquation(Reaction reaction) throws SBMLException { - StringBuilder reactionEqn = new StringBuilder(); - int count = 0; - for (SpeciesReference reactant : reaction.getListOfReactants()) { - if (count > 0) { - reactionEqn.append(" + "); - } - if (reactant.isSetStoichiometryMath()) { - reactionEqn.append(reactant.getStoichiometryMath().getMath() - .compile(this)); - } else if (reactant.getStoichiometry() != 1d) { - reactionEqn.append(reactant.getStoichiometry()); - } - reactionEqn.append(' '); - reactionEqn - .append(StringTools.encodeForHTML(reactant.getSpecies())); - count++; - } - if (reaction.getReactantCount() == 0) { - reactionEqn.append(EMPTY_SET); - } - reactionEqn.append(' '); - reactionEqn.append(reaction.getReversible() ? RIGHT_ARROW - : REVERSIBLE_REACTION_ARROW); - reactionEqn.append(' '); - count = 0; - for (SpeciesReference product : reaction.getListOfProducts()) { - if (count > 0) { - reactionEqn.append(" + "); - } - if (product.isSetStoichiometryMath()) { - reactionEqn.append(product.getStoichiometryMath().getMath() - .compile(this)); - } else if (product.getStoichiometry() != 1d) { - reactionEqn.append(product.getStoichiometry()); - } - reactionEqn.append(' '); - reactionEqn.append(StringTools.encodeForHTML(product.getSpecies())); - count++; - } - if (reaction.getProductCount() == 0) { - reactionEqn.append(EMPTY_SET); - } - return StringTools.toHTML(reactionEqn.toString()); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/LaTeXCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/LaTeXCompiler.java deleted file mode 100644 index 126190ad7..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/LaTeXCompiler.java +++ /dev/null @@ -1,1726 +0,0 @@ -/* - * $Id: LaTeXCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/LaTeXCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.util.List; -import java.util.Locale; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.NamedSBase; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.util.StringTools; - -/** - * Converts {@link ASTNodeValue} objects into a LaTeX {@link String} to be - * included into scientific writings or to be displayed in a GUI. - * - * @author Andreas Dräger - * @date 2009-01-03 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class LaTeXCompiler extends StringTools implements ASTNodeCompiler { - - /** - * Requires LaTeX package booktabs. Produces a fancy line at the bottom of a - * table. This variable also includes the end{longtable} - * command and a new line. - */ - public static final String bottomrule = "\\bottomrule\\end{longtable}" - + newLine(); - - /** - * The constant pi - */ - public static final String CONSTANT_PI = "\\pi"; - - /** - * Surrounded by new line symbols. The begin of a description environment in - * LaTeX. - */ - public static final String descriptionBegin = "\\begin{description}" - + newLine(); - - /** - * Surrounded by new line symbols. The end of a description environment. - */ - public static final String descriptionEnd = "\\end{description}" - + newLine(); - - /** - * Surrounded by new line symbols. Begin equation. This type of equation - * requires the LaTeX package breqn. It will produce equations with - * automatic line breaks (LaTeX will compute the optimal place for line - * breaks). Unfortunately, this does not work for very long denominators. - */ - public static final String eqBegin = newLine() + "\\begin{dmath}" - + newLine(); // equation - - /** - * End equation; cf. eqBegin. Surrounded by new line symbols. - */ - public static final String eqEnd = newLine() + "\\end{dmath}" + newLine(); // equation - - /** - * Left parenthesis. - */ - public static final String leftBrace = "\\left("; - - /** - * An opening quotation mark. - */ - public static final String leftQuotationMark = "``"; - - /** - * This is a LaTeX line break. The line break symbol double backslash - * followed by a new line symbol of the operating system. - */ - public static final String lineBreak = "\\\\" + newLine(); - - /** - * Produces a fancy line in tables. Requires LaTeX package booktabs. Starts - * and ends with a new line. - */ - public static final String midrule = newLine() + "\\midrule" + newLine(); - - /** - * - */ - public static final String NEGATIVE_ININITY = "-\\infty"; - - /** - * - */ - public static final String or = "\\lor "; - - /** - * - */ - public static final String POSITIVE_INFINITY = "\\infty"; - - /** - * - */ - public static final String rightBrace = "\\right)"; - - /** - * An closing quotation mark. - */ - public static final String rightQuotationMark = "\""; - - /** - * Needed for the beginning of a table. Requires LaTeX package booktabs. - * Surrounded by new line symbols. - */ - public static final String toprule = newLine() + "\\toprule" + newLine(); - - /** - * - */ - public static final String wedge = "\\wedge "; - - /** - * - */ - public static final String xor = "\\oplus "; - - /** - * - * @param command - * @param what - * @return - */ - private static StringBuilder command(String command, Object what) { - StringBuilder sb = new StringBuilder("\\"); - sb.append(command); - sb.append('{'); - sb.append(what); - sb.append('}'); - return sb; - } - - /** - * - * @param command - * @param first - * @param second - * @return - */ - private static StringBuilder command(String command, Object first, - Object second) { - StringBuilder sb = command(command, first); - sb.append('{'); - sb.append(second); - sb.append('}'); - return sb; - } - - /** - * - * @param number - * @return - */ - public static String getNumbering(long number) { - if ((Integer.MIN_VALUE < number) && (number < Integer.MAX_VALUE)) - switch ((int) number) { - case 1: - return "first"; - case 2: - return "second"; - case 3: - return "third"; - case 5: - return "fifth"; - case 13: - return "thirteenth"; - default: - if (number < 13) { - String word = StringTools.getWordForNumber(number); - return word.endsWith("t") ? word + 'h' : word + "th"; - } - break; - } - String numberWord = Long.toString(number); - switch (numberWord.charAt(numberWord.length() - 1)) { - case '1': - return StringTools.getWordForNumber(number) - + "\\textsuperscript{st}"; - case '2': - return StringTools.getWordForNumber(number) - + "\\textsuperscript{nd}"; - case '3': - return StringTools.getWordForNumber(number) - + "\\textsuperscript{rd}"; - default: - return StringTools.getWordForNumber(number) - + "\\textsuperscript{th}"; - } - } - - /** - * Creates head lines. - * - * @param kind - * E.g., section, subsection, subsubsection, paragraph etc. - * @param title - * The title of the heading. - * @param numbering - * If true a number will be placed in front of the title. - * @return - */ - private static StringBuffer heading(String kind, String title, - boolean numbering) { - StringBuffer heading = new StringBuffer(newLine()); - heading.append("\\"); - heading.append(kind); - if (!numbering) - heading.append('*'); - heading.append('{'); - heading.append(title); - heading.append('}'); - heading.append(newLine()); - return heading; - } - - /** - * Masks all special characters used by LaTeX with a backslash including - * hyphen symbols. - * - * @param string - * @return - */ - public static String maskSpecialChars(String string) { - return maskSpecialChars(string, true); - } - - /** - * - * @param string - * @param hyphen - * if true a hyphen symbol is introduced at each position where a - * special character has to be masked anyway. - * @return - */ - public static String maskSpecialChars(String string, boolean hyphen) { - StringBuilder masked = new StringBuilder(); - for (int i = 0; i < string.length(); i++) { - char atI = string.charAt(i); - if (atI == '<') { - masked.append("$<$"); - } else if (atI == '>') { - masked.append("$>$"); - } else { - if ((atI == '_') || (atI == '\\') || (atI == '$') - || (atI == '&') || (atI == '#') || (atI == '{') - || (atI == '}') || (atI == '~') || (atI == '%') - || (atI == '^')) { - if ((i == 0) || (!hyphen)) { - masked.append('\\'); - } else if (hyphen && (string.charAt(i - 1) != '\\')) { - masked.append("\\-\\"); // masked.append('\\'); - // } else if ((atI == '[') || (atI == ']')) { - } - } - masked.append(atI); - } - } - return masked.toString().trim(); - } - - /** - * - */ - public final String CONSTANT_E = mathrm("e").toString(); - /** - * - */ - public final String CONSTANT_FALSE = mathrm("false").toString(); - /** - * - */ - public final String CONSTANT_TRUE = mathrm("true").toString(); - - /** - * Important for LaTeX export to decide whether the name or the id of a - * NamedSBase should be printed. - */ - private boolean printNameIfAvailable; - - /** - * - * - */ - public LaTeXCompiler() { - printNameIfAvailable = false; - } - - /** - * - * @param settings - */ - public LaTeXCompiler(boolean namesInEquations) { - setPrintNameIfAvailable(namesInEquations); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue abs(ASTNode value) throws SBMLException { - StringBuffer abs = new StringBuffer("\\left\\lvert"); - abs.append(value.compile(this).toString()); - abs.append("\\right\\rvert"); - return new ASTNodeValue(abs.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) - */ - public ASTNodeValue and(List nodes) throws SBMLException { - return logicalOperation(wedge, nodes); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccos(ASTNode value) throws SBMLException { - return new ASTNodeValue(command("arccos", value.compile(this)) - .toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccosh(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arccosh", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccot(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arcot", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccoth(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arccoth", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccsc(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arccsc", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arccsch(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arccsch", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arcsec(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arcsec", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arcsech(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arcsech", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arcsin(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arcsin", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arcsinh(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arcsinh", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arctan(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("arctan", value).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue arctanh(ASTNode value) throws SBMLException { - return new ASTNodeValue(function("\\arctanh", value).toString(), this); - } - - /** - * Encloses the given formula in brackets. - * - * @param formula - * @return - */ - public StringBuilder brackets(Object formula) { - StringBuilder buffer = new StringBuilder("\\left("); - buffer.append(formula); - buffer.append("\\right)"); - return buffer; - } - - /** - * Creates brackets if needed. - * - * @param nodes - * @return - * @throws SBMLException - */ - private String checkBrackets(ASTNode node) throws SBMLException { - String term = node.compile(this).toString(); - - if (node.isSum() || node.isDifference() || node.isUMinus()) { - term = brackets(term).toString(); - } else if (node.isReal()) { - if (node.getReal() < 0.0) { - term = brackets(term).toString(); - } - } - - return term; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml. - * ASTNode) - */ - public ASTNodeValue ceiling(ASTNode value) throws SBMLException { - StringBuffer ceiling = new StringBuffer("\\left\\lceil "); - ceiling.append(value.compile(this).toString()); - ceiling.append("\\right\\rceil "); - return new ASTNodeValue(ceiling.toString(), this); - } - - /** - * - * @param color - * @param what - * @return - */ - public StringBuilder colorbox(String color, Object what) { - return command("colorbox", color, what); - } - - /** - * This method returns the correct LaTeX expression for a function which - * returns the size of a compartment. This can be a volume, an area, a - * length or a point. - */ - public ASTNodeValue compile(Compartment c) { - StringBuffer value = new StringBuffer(); - switch ((int) c.getSpatialDimensions()) { - case 3: - value.append("vol"); - break; - case 2: - value.append("area"); - break; - case 1: - value.append("length"); - break; - default: - value.append("point"); - break; - } - return new ASTNodeValue(mathrm(value.toString()).append( - brackets(getNameOrID(c))).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, - * java.lang.String) - */ - public ASTNodeValue compile(double mantissa, int exponent, String units) { - StringBuffer sb = concat(format(mantissa), "\\cdot 10^{", exponent, "}"); - - // return (mantissa < 0.0) ? new ASTNodeValue(brackets(sb).toString(), - // this) : new ASTNodeValue(sb.toString(), this); - return new ASTNodeValue(sb.toString(), this); - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, - * java.lang.String) - */ - public ASTNodeValue compile(double real, String units) { - // TODO: deal with Units. - return new ASTNodeValue(format(real).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, - * java.lang.String) - */ - public ASTNodeValue compile(int integer, String units) { - // TODO: deal with Units. - return new ASTNodeValue(integer, this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) - */ - public ASTNodeValue compile(CallableSBase variable) { - if (variable instanceof Species) { - Species species = (Species) variable; - Compartment c = species.getCompartmentInstance(); - boolean concentration = !species.getHasOnlySubstanceUnits() - && (0 < c.getSpatialDimensions()); - StringBuffer value = new StringBuffer(); - if (concentration) { - value.append('['); - } - value.append(getNameOrID(species)); - if (concentration) { - value.append(']'); - } - return new ASTNodeValue(value.toString(), this); - - } else if (variable instanceof Compartment) { - Compartment c = (Compartment) variable; - return compile(c); - } - // TODO: more special cases of names!!! PARAMETER, FUNCTION DEF, - // REACTION. - return new ASTNodeValue(mathtt(maskSpecialChars(variable.getId())) - .toString(), this); - // else if (variable instanceof Parameter) { - // return new StringBuffer("parameter"); - // } - // return new StringBuffer("variable:"+variable); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) - */ - public ASTNodeValue compile(String name) { - return new ASTNodeValue(maskSpecialChars(name), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cos(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\cos", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue cosh(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\cosh", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cot(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\cot", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue coth(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\coth", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csc(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\csc", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue csch(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("csch", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, - * org.sbml.jsbml.ASTNode, double, java.lang.String) - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, - String timeUnits) throws SBMLException { - // TODO: deal with units. - return new ASTNodeValue(concat( - mathrm(maskSpecialChars(delayName)), - brackets(concat(x.compile(this).toString(), ", ", delay - .compile(this).toString()))).toString(), this); - } - - /** - * This method simplifies the process of creating descriptions. There is an - * item entry together with a description. No new line or space is needed - * for separation. - * - * @param item - * e.g., "my item" - * @param description - * e.g., "my description" - * @return - */ - public StringBuffer descriptionItem(String item, Object description) { - StringBuffer itemBuffer = new StringBuffer("\\item["); - itemBuffer.append(item); - itemBuffer.append("] "); - itemBuffer.append(description); - itemBuffer.append(newLine()); - return itemBuffer; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " = ", right).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue exp(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\exp", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml - * .ASTNode) - */ - public ASTNodeValue factorial(ASTNode node) throws SBMLException { - StringBuilder value; - if (!node.isUnary()) { - value = brackets(node.compile(this).toString()); - } else { - value = new StringBuilder(node.compile(this).toString()); - } - value.append('!'); - return new ASTNodeValue(value.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue floor(ASTNode value) throws SBMLException { - StringBuilder floor = new StringBuilder("\\left\\lfloor "); - floor.append(value.compile(this).toString()); - floor.append("\\right\\rfloor "); - return new ASTNodeValue(floor.toString(), this); - } - - /** - * This method returns a StringBuffer representing a properly - * LaTeX formatted number. - * - * @param value - * @return - */ - public StringBuffer format(double value) { - StringBuffer sb = new StringBuffer(); - String val = StringTools.toString(Locale.ENGLISH, value); - if (val.contains("E")) { - String split[] = val.split("E"); - val = "10^{" + format(Double.parseDouble(split[1])) + "}"; - if (split[0].equals("-1.0")) { - val = "-" + val; - } else if (!split[0].equals("1.0")) { - val = format(Double.parseDouble(split[0])) + "\\cdot " + val; - } - - } else if (value - ((int) value) == 0) { - sb.append(((int) value)); - } else { - sb.append(val); - } - - return sb; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws SBMLException { - return new ASTNodeValue(command("frac", numerator.compile(this), - denominator.compile(this)).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#frac(int, int) - */ - public ASTNodeValue frac(int numerator, int denominator) { - return new ASTNodeValue(frac(Integer.valueOf(numerator), - Integer.valueOf(denominator)).toString(), this); - } - - /** - * - * @param numerator - * @param denominator - * @return - */ - public StringBuilder frac(Object numerator, Object denominator) { - return command("frac", numerator, denominator); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.ASTNodeCompiler#function(org.sbml.jsbml.FunctionDefinition - * , org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue function(FunctionDefinition fun, List args) - throws SBMLException { - StringBuffer value = new StringBuffer(); - int length; - if (fun != null) { - value.append(mathtt(LaTeXCompiler.maskSpecialChars(fun.getId()))); - length = args.size(); - } else if (args.size() == 1) { - length = 0; - value.append("\\lambda\\left(\\right)"); - } else { - value.append("\\lambda"); - length = args.size() - 1; - } - StringBuilder argList = new StringBuilder(); - - for (int i = 0; i < length; i++) { - if (i > 0) { - argList.append(", "); - } - argList.append(args.get(i).compile(this)); - } - - if (length > 0) { - value.append(brackets(argList)); - } - - if ((0 <= length) && (length < args.size())) { - value.append(" = "); - value.append(args.get(args.size() - 1).compile(this)); - } - - return new ASTNodeValue(value.toString(), this); - } - - - public ASTNodeValue function(String functionDefinitionName, - List args) throws SBMLException - { - StringBuffer value = new StringBuffer(); - int length = args.size(); - - value.append(mathtt(LaTeXCompiler.maskSpecialChars(functionDefinitionName))); - - StringBuilder argList = new StringBuilder(); - - for (int i = 0; i < length; i++) { - if (i > 0) { - argList.append(", "); - } - argList.append(args.get(i).compile(this)); - } - - if (length > 0) { - value.append(brackets(argList)); - } - - return new ASTNodeValue(value.toString(), this); - } - - - /** - * Decides whether to produce brackets. - * - * @param func - * @param value - * @return - * @throws SBMLException - */ - private StringBuilder function(String func, ASTNode value) - throws SBMLException { - return function(func, value.isUnary() ? value.compile(this).toString() - : brackets(value.compile(this)).toString()); - } - - /** - * Without brackets. - * - * @param func - * @param value - * @return - */ - private StringBuilder function(String func, Object value) { - boolean command = func.startsWith("\\"); - StringBuilder fun = command ? new StringBuilder(func) : mathrm(func); - if (command) { - fun.append('{'); - } - fun.append(value); - if (command) { - fun.append('}'); - } - return fun; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#greaterEqual(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " \\geq ", right).toString(), - this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java - * .lang.String) - */ - public ASTNodeValue getConstantAvogadro(String name) { - return new ASTNodeValue(maskSpecialChars(name), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantE() - */ - public ASTNodeValue getConstantE() { - return new ASTNodeValue(new String(CONSTANT_E), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantFalse() - */ - public ASTNodeValue getConstantFalse() { - return new ASTNodeValue(new String(CONSTANT_FALSE), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantPi() - */ - public ASTNodeValue getConstantPi() { - return new ASTNodeValue(new String(CONSTANT_PI), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantTrue() - */ - public ASTNodeValue getConstantTrue() { - return new ASTNodeValue(new String(CONSTANT_TRUE), this); - } - - /** - * If the field printNameIfAvailable is false this method returns a the id - * of the given SBase. If printNameIfAvailable is true this method looks for - * the name of the given SBase and will return it. - * - * @param sbase - * the SBase, whose name or id is to be returned. - * @param mathMode - * if true this method returns the name typesetted in mathmode, - * i.e., mathrm for names and mathtt for ids, otherwise texttt - * will be used for ids and normalfont (nothing) will be used for - * names. - * @return The name or the ID of the SBase (according to the field - * printNameIfAvailable), whose LaTeX special symbols are masked and - * which is type set in typewriter font if it is an id. The mathmode - * argument decides if mathtt or mathrm has to be used. - */ - private StringBuilder getNameOrID(NamedSBase sbase) { - String name = ""; - if (sbase.isSetName() && printNameIfAvailable) { - name = sbase.getName(); - } else if (sbase.isSetId()) { - name = sbase.getId(); - } else { - name = "Undefinded"; - } - name = maskSpecialChars(name); - return printNameIfAvailable ? mathrm(name) : mathtt(name); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getNegativeInfinity() - */ - public ASTNodeValue getNegativeInfinity() { - return new ASTNodeValue(new String(NEGATIVE_ININITY), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#getPositiveInfinity() - */ - public ASTNodeValue getPositiveInfinity() { - return new ASTNodeValue(new String(POSITIVE_INFINITY), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#greaterThan(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " > ", right).toString(), this); - } - - /** - * Creates a hyper link to the given target and the text to be visible in - * the document. - * - * @param target - * The target to which this link points to. - * @param text - * The text to be written in the link. - * @return - */ - public StringBuilder href(String target, Object text) { - return command("href", target, text); - } - - /** - * - * @param target - * @param text - * @return - */ - public StringBuilder hyperref(String target, Object text) { - StringBuilder sb = new StringBuilder("\\hyperref["); - sb.append(target); - sb.append("]{"); - sb.append(text); - sb.append('}'); - return sb; - } - - /** - * - * @return - */ - public boolean isPrintNameIfAvailable() { - return printNameIfAvailable; - } - - public StringBuilder label(String id) { - return command("label", new StringBuilder(id)); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#lambda(org.sbml.jsbml.ASTNode[]) - */ - public ASTNodeValue lambda(List nodes) throws SBMLException { - return function((FunctionDefinition) null, nodes); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#lessEqual(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " \\leq ", right).toString(), - this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ln(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\ln", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode node) throws SBMLException { - return log(null, node); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode base, ASTNode value) throws SBMLException { - StringBuilder v = new StringBuilder("\\log"); - if (base != null) { - StringTools.append(v, "_{", base.compile(this), "}"); - } - StringTools.append(v, "{", value.isUnary() ? value.compile(this) - : brackets(value.compile(this)), "}"); - return new ASTNodeValue(v.toString(), this); - } - - /** - * - * @param symbol - * @param values - * @return - * @throws SBMLException - */ - private ASTNodeValue logicalOperation(String symbol, List values) - throws SBMLException { - StringBuffer value = new StringBuffer(); - int i = 0; - for (ASTNode v : values) { - if (v.getChildCount() > 0) { - value.append(leftBrace); - } - value.append(v.compile(this).toString()); - if (v.getChildCount() > 0) { - value.append(rightBrace); - } - if (i < values.size() - 1) { - value.append(symbol); - } - i++; - } - return new ASTNodeValue(value.toString(), this); - } - - /** - * Creates a head for a longtable in LaTeX. - * - * @param columnDef - * without leading and ending brackets, e.g., "lrrc", - * @param caption - * caption of this table without leading and ending brackets - * @param headLine - * table head without leading and ending brackets and without - * double backslashes at the end - * @return - */ - public StringBuffer longtableHead(String columnDef, String caption, - String headLine) { - StringBuffer buffer = new StringBuffer("\\begin{longtable}[h!]{"); - buffer.append(columnDef); - buffer.append('}'); - buffer.append(newLine()); - buffer.append("\\caption{"); - buffer.append(caption); - buffer.append('}'); - buffer.append("\\\\"); - StringBuffer head = new StringBuffer(toprule); - head.append(headLine); - head.append("\\\\"); - head.append(midrule); - buffer.append(head); - buffer.append("\\endfirsthead"); - // buffer.append(newLine()); - buffer.append(head); - buffer.append("\\endhead"); - // buffer.append(bottomrule); - // buffer.append("\\endlastfoot"); - buffer.append(newLine()); - return buffer; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#lessThan(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(relation(left, " < ", right).toString(), this); - } - - /** - * Encloses the given formula in dollar symbols (inline math mode). - * - * @param formula - * @return - */ - public StringBuffer math(Object formula) { - StringBuffer math = new StringBuffer(); - String f = String.valueOf(formula); - if (f.length() == 0) { - return math; - } - if (f.charAt(0) != '$') { - math.append('$'); - } - math.append(f); - if (f.charAt(f.length() - 1) != '$') { - math.append('$'); - } - return math; - } - - /** - * - * @param symbol - * @return - */ - public StringBuilder mathrm(char symbol) { - return command("mathrm", Character.valueOf(symbol)); - } - - /** - * - * @param text - * @return - */ - public StringBuilder mathrm(String text) { - return command("mathrm", text); - } - - /** - * - * @param text - * @return - */ - public StringBuilder mathtext(String text) { - return command("text", text); - } - - /** - * Returns the LaTeX code to set the given String in type writer font within - * a math environment. - * - * @param id - * @return - */ - public StringBuilder mathtt(String id) { - return command("mathtt", new StringBuffer(id)); - } - - /** - * - * @param s - * @return - */ - public StringBuilder mbox(String s) { - StringBuilder sb = new StringBuilder(); - sb.append(" \\mbox{"); - sb.append(s); - sb.append("} "); - return sb; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#minus(org.sbml.jsbml.ASTNode[]) - */ - public ASTNodeValue minus(List nodes) throws SBMLException { - if (nodes.size() == 0) { - return new ASTNodeValue("", this); - } - StringBuilder value = new StringBuilder(); - value.append(nodes.get(0).compile(this).toString()); - for (int i = 1; i < nodes.size(); i++) { - value.append('-'); - value.append(checkBrackets(nodes.get(i))); - - } - return new ASTNodeValue(value.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#notEqual(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - return new ASTNodeValue(concat(left, " \\neq ", right.compile(this)) - .toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue not(ASTNode node) throws SBMLException { - return new ASTNodeValue(concat( - "\\neg ", - (node.getChildCount() == 0) ? node.compile(this) - : brackets(node.compile(this))).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#or(org.sbml.jsbml.ASTNode[]) - */ - public ASTNodeValue or(List nodes) throws SBMLException { - return logicalOperation(or, nodes); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#piecewise(org.sbml.jsbml.ASTNode[]) - */ - public ASTNodeValue piecewise(List nodes) throws SBMLException { - StringBuilder v = new StringBuilder("\\begin{dcases}"); - v.append(newLine()); - for (int i = 0; i < nodes.size() - 1; i++) { - v.append(nodes.get(i).compile(this)); - v.append(((i % 2) == 0) ? " & \\text{if\\ } " : lineBreak); - } - v.append(nodes.get(nodes.size() - 1).compile(this)); - if ((nodes.size() % 2) == 1) { - v.append(" & \\text{otherwise}"); - v.append(newLine()); - } - v.append("\\end{dcases}"); - return new ASTNodeValue(v.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#plus(org.sbml.jsbml.ASTNode[]) - */ - public ASTNodeValue plus(List nodes) throws SBMLException { - if (nodes.size() > 0) { - StringBuilder value = new StringBuilder(); - - value.append(nodes.get(0).compile(this)); - - for (int i = 1; i < nodes.size(); i++) { - - value.append('+'); - value.append(checkBrackets(nodes.get(i))); - - } - return new ASTNodeValue(value.toString(), this); - } - return new ASTNodeValue(this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue pow(ASTNode base, ASTNode exponent) - throws SBMLException { - StringBuilder value = new StringBuilder(); - value.append(base.compile(this)); - if (!(base.getChildCount() < 2)) { - value = brackets(value); - } - value.append('^'); - value.append('{'); - value.append(exponent.compile(this)); - value.append('}'); - return new ASTNodeValue(value.toString(), this); - } - - /** - * Creates a relation between two {@link ASTNode}s. - * - * @param left - * @param relationSymbol - * @param right - * @return - * @throws SBMLException - */ - private StringBuilder relation(ASTNode left, String relationSymbol, - ASTNode right) throws SBMLException { - StringBuilder value = new StringBuilder(); - - value.append(((left.isRelational()) ? brackets(left.compile(this)) - : left.compile(this).toString())); - value.append(relationSymbol); - value.append(((right.isRelational()) ? brackets(right.compile(this)) - : right.compile(this).toString())); - return value; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode value) - throws SBMLException { - if (rootExponent.isNumber() && (rootExponent.getReal() == 2d)) { - return sqrt(value); - } - return new ASTNodeValue(concat("\\sqrt[", rootExponent, "]{", - value.compile(this), Character.valueOf('}')).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, - * org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException { - if (rootExponent == 2d) { - return sqrt(radiant); - } - return new ASTNodeValue(concat("\\sqrt[", rootExponent, "]{", - radiant.compile(this), Character.valueOf('}')).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sec(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\sec", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sech(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("sech", node).toString(), this); - } - - /** - * - * @param title - * @param numbering - * @return - */ - public StringBuffer section(String title, boolean numbering) { - return heading("section", title, numbering); - } - - /** - * - * @param printNameIfAvailable - */ - public void setPrintNameIfAvailable(boolean printNameIfAvailable) { - this.printNameIfAvailable = printNameIfAvailable; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sin(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\sin", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sinh(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\sinh", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue sqrt(ASTNode value) throws SBMLException { - return new ASTNodeValue( - command("sqrt", value.compile(this)).toString(), this); - } - - /** - * - * @param title - * @param numbering - * @return - */ - public StringBuffer subsection(String title, boolean numbering) { - return heading("subsection", title, numbering); - } - - /** - * - * @param title - * @param numbering - * @return - */ - public StringBuffer subsubsection(String title, boolean numbering) { - return heading("subsubsection", title, numbering); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String - * ) - */ - public ASTNodeValue symbolTime(String time) { - return new ASTNodeValue(mathrm(time).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tan(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\tan", node).toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue tanh(ASTNode node) throws SBMLException { - return new ASTNodeValue(function("\\tanh", node).toString(), this); - } - - /** - * - * @param color - * @param text - * @return - */ - public StringBuilder textcolor(String color, Object text) { - return command("textcolor", color, text); - } - - /** - * Returns the LaTeX code to set the given String in type writer font. - * - * @param id - * @return - */ - public StringBuilder texttt(String id) { - return command("texttt", new StringBuffer(id)); - } - - /** - * - * @param variable - * @return - */ - public String timeDerivative(String variable) { - String d = mbox("d").toString(); - StringBuilder sb = frac(d, d + symbolTime("t")); - sb.append(mbox(variable)); - return sb.toString(); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#times(java.util.List) - */ - public ASTNodeValue times(List values) throws SBMLException { - if (values.size() == 0) { - return new ASTNodeValue("", this); - } - StringBuilder v = new StringBuilder(checkBrackets(values.get(0))); - - for (int i = 1; i < values.size(); i++) { - v.append("\\cdot"); - - v.append(' '); - v.append(checkBrackets(values.get(i)).toString()); - - } - return new ASTNodeValue(v.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue uMinus(ASTNode value) throws SBMLException { - - StringBuffer v = new StringBuffer(); - v.append('-'); - v.append(checkBrackets(value).toString()); - return new ASTNodeValue(v.toString(), this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#unknownValue() - */ - public ASTNodeValue unknownValue() { - return new ASTNodeValue(mathtext(" unknown ").toString(), this); - } - - /** - * Creates a usepackage command for the given package with the optional - * options. - * - * @param latexPackage - * the name of the latex package - * @param options - * options without commas - * @return usepackage command including system-dependent new line character. - */ - public StringBuffer usepackage(String latexPackage, String... options) { - StringBuffer usepackage = new StringBuffer("\\usepackage"); - if (options.length > 0) { - usepackage.append('['); - boolean first = true; - for (String option : options) { - if (!first) { - usepackage.append(','); - } else { - first = false; - } - usepackage.append(option); - } - usepackage.append(']'); - } - usepackage.append('{'); - usepackage.append(latexPackage); - usepackage.append('}'); - usepackage.append(newLine()); - return usepackage; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) - */ - public ASTNodeValue xor(List nodes) throws SBMLException { - return logicalOperation(xor, nodes); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/LibSBMLFormulaCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/LibSBMLFormulaCompiler.java deleted file mode 100644 index 772880e71..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/LibSBMLFormulaCompiler.java +++ /dev/null @@ -1,393 +0,0 @@ -package org.sbml.jsbml.util.compilers; - -import java.util.List; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.SBMLException; - -public class LibSBMLFormulaCompiler extends FormulaCompiler { - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue arccos(ASTNode node) throws SBMLException { - return function("acos", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arccosh(ASTNode node) throws SBMLException { - return function("arccosh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue arccot(ASTNode node) throws SBMLException { - return function("arccot", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arccoth(ASTNode node) throws SBMLException { - return function("arccoth", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode - * ) - */ - public ASTNodeValue arccsc(ASTNode node) throws SBMLException { - return function("arccsc", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arccsch(ASTNode node) throws SBMLException { - return function("arccsch", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue arcsec(ASTNode node) throws SBMLException { - return function("arcsec", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arcsech(ASTNode node) throws SBMLException { - return function("arcsech", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue arcsin(ASTNode node) throws SBMLException { - return function("asin", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arcsinh(ASTNode node) throws SBMLException { - return function("arcsinh", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue arctan(ASTNode node) throws SBMLException { - return function("atan", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml. - * ASTNode) - */ - @Override - public ASTNodeValue arctanh(ASTNode node) throws SBMLException { - return function("arctanh", node); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) - */ - @Override - public ASTNodeValue and(List nodes) throws SBMLException { - return function("and", nodes); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#or(java.util.List) - */ - @Override - public ASTNodeValue or(List nodes) throws SBMLException { - return function("or", nodes); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) - */ - @Override - public ASTNodeValue xor(List nodes) throws SBMLException { - return function("xor", nodes); - } - - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { - return function("eq", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - return function("neq", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { - return function("geq", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { - return function("gt", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { - return function("leq", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { - return function("lt", left, right); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getNegativeInfinity() - */ - @Override - public ASTNodeValue getNegativeInfinity() { - return new ASTNodeValue("-INF", this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getPositiveInfinity() - */ - @Override - public ASTNodeValue getPositiveInfinity() { - return new ASTNodeValue("INF", this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue pow(ASTNode left, ASTNode right) throws SBMLException { - return function("pow", left, right); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue ln(ASTNode node) throws SBMLException { - return function("log", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue log(ASTNode node) throws SBMLException { - return function("log10", node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue log(ASTNode left, ASTNode right) throws SBMLException { - if (left.getReal() == 10) { - return function("log10", right); - } else { - return function("log", left, right); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantE() - */ - @Override - public ASTNodeValue getConstantE() { - return new ASTNodeValue("exponentiale", this); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml - * .ASTNode) - */ - @Override - public ASTNodeValue factorial(ASTNode node) { - try { - return function("factorial", node); - } catch (SBMLException e) { - e.printStackTrace(); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode - * , org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws SBMLException - { - return function("root", rootExponent, radiant); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, - * org.sbml.jsbml.ASTNode) - */ - @Override - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException - { - return function("root", new ASTNode(rootExponent), radiant); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode - * ) - */ - @Override - public ASTNodeValue sqrt(ASTNode node) throws SBMLException { - return function("sqrt", node); - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLCompiler.java deleted file mode 100644 index a71c3f651..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLCompiler.java +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * $Id: MathMLCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/MathMLCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLStreamException; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.xml.parsers.MathMLParser; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * With this compiler, an {@link ASTNode} can be transformed into a MathML - * string. - * - * @author Andreas Dräger - * @date 2010-05-18 - * @since 0.8 - * @version $Rev: 1116 $ - */ -@SuppressWarnings("deprecation") -public class MathMLCompiler implements ASTNodeCompiler { - - /** - * XML document for the output. - */ - private Document document; - - /** - * The last top {@link Element} that has been created in the previous step. - */ - private Element lastElementCreated; - - /** - * The SBML level to be used in this class. - */ - private int level; - - /** - * - * @throws ParserConfigurationException - */ - public MathMLCompiler() throws XMLStreamException { - init(); - } - - /** - * - * @param ast - * @throws XMLStreamException - * @throws SBMLException - */ - public MathMLCompiler(ASTNode ast) throws XMLStreamException, SBMLException { - this(); - ast.compile(this); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue abs(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("abs", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#and(java.util.List) - */ - public ASTNodeValue and(List values) throws DOMException, - SBMLException { - if (values.size() > 0) { - return createApplyNode("and", values); - } - throw new IllegalArgumentException( - "Cannot create a node for empty element list"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccos(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccos", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccosh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccosh(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccosh", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccot(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccot", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccoth(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccoth(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccoth", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccsc(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccsc", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arccsch(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arccsch(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arccsch", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsec(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arcsec", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsech(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsech(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arcsech", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsin(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arcsin", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arcsinh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arcsinh(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arcsinh", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arctan(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arctan", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#arctanh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue arctanh(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("arctanh", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#ceiling(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ceiling(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("ceiling", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.Compartment) - */ - public ASTNodeValue compile(Compartment c) { - return compile((CallableSBase) c); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, int, java.lang.String) - */ - public ASTNodeValue compile(double mantissa, int exponent, String units) { - return new ASTNodeValue(createCnElement(mantissa, exponent, units), - this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(double, java.lang.String) - */ - public ASTNodeValue compile(double real, String units) { - return new ASTNodeValue(createCnElement(Double.valueOf(real), units), - this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(int, java.lang.String) - */ - public ASTNodeValue compile(int integer, String units) { - return new ASTNodeValue( - createCnElement(Integer.valueOf(integer), units), this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) - */ - public ASTNodeValue compile(CallableSBase variable) { - setLevel(variable.getLevel()); - return compile(variable.getId()); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(java.lang.String) - */ - public ASTNodeValue compile(String name) { - return createCiElement(name); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cos(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("cos", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cosh(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("cosh", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue cot(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("cot", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue coth(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("coth", value); - } - - /** - * - * @param tag - * @param childNodes - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue createApplyNode(Node tag, ASTNodeValue... childNodes) - throws DOMException, SBMLException { - lastElementCreated = document.createElement("apply"); - lastElementCreated.appendChild(tag); - for (ASTNodeValue n : childNodes) { - lastElementCreated.appendChild(n.toNode()); - } - if (childNodes.length > 0) { - setLevel(childNodes[0].getLevel()); - } - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * Creates an apply {@link Node} with the given tag {@link Node} as its - * child and {@link ASTNodeValue}s on the same level as the tag {@link Node} - * . - * - * @param tag - * @param childNodes - * @return - * @throws SBMLException - * @throws DOMException - */ - private ASTNodeValue createApplyNode(Node tag, List childNodes) - throws DOMException, SBMLException { - lastElementCreated = document.createElement("apply"); - lastElementCreated.appendChild(tag); - for (ASTNode n : childNodes) { - lastElementCreated.appendChild(n.compile(this).toNode()); - } - if (childNodes.size() > 0) { - setLevel(childNodes.get(0).getParentSBMLObject().getLevel()); - } - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * - * @param tagName - * @param childNodes - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue createApplyNode(String tagName, ASTNode... childNodes) - throws DOMException, SBMLException { - LinkedList l = new LinkedList(); - for (ASTNode ast : childNodes) { - l.add(ast); - } - return createApplyNode(tagName, l); - } - - /** - * - * @param tagName - * @param childNodes - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue createApplyNode(String tagName, - ASTNodeValue... childNodes) throws DOMException, SBMLException { - lastElementCreated = document.createElement("apply"); - lastElementCreated.appendChild(document.createElement(tagName)); - for (ASTNodeValue value : childNodes) { - lastElementCreated.appendChild(value.toNode()); - } - if (childNodes.length > 0) { - setLevel(childNodes[0].getLevel()); - } - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * Creates a {@link Node} with the tag "apply" and adds the given - * {@link Node} as its child. Then it creates a new {@link ASTNodeValue} - * that wraps the apply {@link Node}. - * - * @param tagName - * The name of the node to be created, e.g., "abs" or "and". - * @param childNodes - * at least one child should be passed to this method. - * @return - * @throws SBMLException - * @throws DOMException - */ - private ASTNodeValue createApplyNode(String tagName, - List childNodes) throws DOMException, SBMLException { - lastElementCreated = document.createElement("apply"); - lastElementCreated.appendChild(document.createElement(tagName)); - for (ASTNode value : childNodes) { - lastElementCreated.appendChild(value.compile(this).toNode()); - } - if (childNodes.size() > 0) { - setLevel(childNodes.get(0).getParentSBMLObject().getLevel()); - } - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * - * @param name - * @return - */ - private ASTNodeValue createCiElement(String name) { - lastElementCreated = document.createElement("ci"); - lastElementCreated.setTextContent(writeName(name.trim())); - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * - * @param mantissa - * @param exponent - * @param units - * Can be null. - * @return - */ - private Element createCnElement(double mantissa, int exponent, String units) { - lastElementCreated = document.createElement("cn"); - lastElementCreated.setAttribute("type", "e-notation"); - if ((units != null) && (level > 2)) { - lastElementCreated.setAttribute(MathMLParser - .getSBMLUnitsAttribute(), units); - } - lastElementCreated.appendChild(document.createTextNode(writeName(Double - .valueOf(mantissa)))); - lastElementCreated.appendChild(document.createElement("sep")); - lastElementCreated.appendChild(document - .createTextNode(writeName(Integer.valueOf(exponent)))); - return lastElementCreated; - } - - /** - * - * @param value - * @param units - * Can be null. - * @return - */ - private Element createCnElement(Number value, String units) { - lastElementCreated = document.createElement("cn"); - if ((units != null) && (level > 2)) { - lastElementCreated.setAttribute(MathMLParser - .getSBMLUnitsAttribute(), units); - } - String type = value instanceof Integer ? "integer" : "real"; - lastElementCreated.setAttribute("type", type); - lastElementCreated.setTextContent(writeName(value)); - return lastElementCreated; - } - - /** - * Creates an {@link ASTNodeValue} with the single node as defined by the - * tagName. - * - * @param tagName - * @return - */ - private ASTNodeValue createConstant(String tagName) { - lastElementCreated = document.createElement(tagName); - return new ASTNodeValue(lastElementCreated, this); - } - - /** - * - * @param name - * @param definitionURI - * @return - */ - private Element createCSymbol(String name, String definitionURI) { - lastElementCreated = document.createElement("csymbol"); - lastElementCreated.setAttribute("encoding", "text"); - lastElementCreated.setAttribute("definitionURL", definitionURI); - lastElementCreated.setTextContent(writeName(name)); - return lastElementCreated; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csc(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("csc", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue csch(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("csch", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#delay(java.lang.String, org.sbml.jsbml.ASTNode, double, java.lang.String) - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, - String timeUnit) throws DOMException, SBMLException { - setLevel(x.getParentSBMLObject().getLevel()); - return createApplyNode(createCSymbol(delayName, MathMLParser - .getDefinitionURIdelay()), compile(x.toString()), compile(delay.toString())); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#eq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("eq", left, right); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue exp(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("exp", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#factorial(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue factorial(ASTNode value) throws DOMException, - SBMLException { - return createApplyNode("factorial", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue floor(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("floor", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws DOMException, SBMLException { - return createApplyNode("divide", numerator, denominator); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#frac(int, int) - */ - public ASTNodeValue frac(int numerator, int denominator) - throws DOMException, SBMLException { - return createApplyNode("divide", compile(numerator, null), compile( - denominator, null)); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(org.sbml.jsbml.FunctionDefinition, java.util.List) - */ - public ASTNodeValue function(FunctionDefinition functionDefinition, - List args) throws DOMException, SBMLException { - return createApplyNode(compile(functionDefinition).toNode(), args); - } - - - public ASTNodeValue function(String functionDefinitionName, - List args) throws SBMLException - { - return createApplyNode(compile(functionDefinitionName).toNode(), args); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#geq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("geq", left, right); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantAvogadro(java.lang.String) - */ - public ASTNodeValue getConstantAvogadro(String name) { - return new ASTNodeValue(createCSymbol(name, MathMLParser - .getDefinitionURIavogadro()), this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantE() - */ - public ASTNodeValue getConstantE() { - return createConstant("exponentiale"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantFalse() - */ - public ASTNodeValue getConstantFalse() { - return createConstant(Boolean.FALSE.toString()); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantPi() - */ - public ASTNodeValue getConstantPi() { - return createConstant("pi"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getConstantTrue() - */ - public ASTNodeValue getConstantTrue() { - return createConstant(Boolean.TRUE.toString()); - } - - /** - * @return the document - * @throws SBMLException - */ - public Document getDocument() throws SBMLException { - return MathMLParser.createMathMLDocumentFor(lastElementCreated, level); - } - - /** - * @return the level - */ - public int getLevel() { - return level; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getNegativeInfinity() - */ - public ASTNodeValue getNegativeInfinity() throws DOMException, - SBMLException { - return uMinus(getPositiveInfinity()); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#getPositiveInfinity() - */ - public ASTNodeValue getPositiveInfinity() { - return createConstant("infinity"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#gt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("gt", left, right); - } - - /** - * Re-initializes the {@link Document} object belonging to this class. Only - * in this way a new {@link ASTNode} tree can be compiled. To this end, also - * the level attribute is reset (because maybe next time we want to compile - * some {@link ASTNode} with from a different source. - * - * @throws XMLStreamException - */ - private void init() throws XMLStreamException { - level = -1; - try { - // create document - DocumentBuilderFactory factory = DocumentBuilderFactory - .newInstance(); - factory.setNamespaceAware(true); - DocumentBuilder builder; - builder = factory.newDocumentBuilder(); - document = builder.newDocument(); - } catch (ParserConfigurationException e) { - throw new XMLStreamException(e); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lambda(java.util.List) - */ - public ASTNodeValue lambda(List values) throws DOMException, - SBMLException { - lastElementCreated = document.createElement("lambda"); - if (values.size() > 0) { - setLevel(values.get(0).getParentSBMLObject().getLevel()); - if (values.size() > 1) { - for (int i = 0; i < values.size() - 1; i++) { - Element bvar = document.createElement("bvar"); - lastElementCreated.appendChild(bvar); - bvar.appendChild(values.get(i).compile(this).toNode()); - } - } - lastElementCreated.appendChild(values.get(values.size() - 1) - .compile(this).toNode()); - } - return new ASTNodeValue(lastElementCreated, this); - } - - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#leq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("leq", left, right); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue ln(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("ln", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode value) throws DOMException, SBMLException { - return log(null, value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#log(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue log(ASTNode base, ASTNode value) throws DOMException, - SBMLException { - ASTNodeValue v = createApplyNode("log", value); - if (base != null) { - Element logbase = document.createElement("logbase"); - logbase.appendChild(base.compile(this).toNode()); - v.toNode().insertBefore(logbase, - v.toNode().getFirstChild().getNextSibling()); - } - return v; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#lt(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("lt", left, right); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#minus(java.util.List) - */ - public ASTNodeValue minus(List values) throws DOMException, - SBMLException { - return createApplyNode("minus", values); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#neq(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws DOMException, - SBMLException { - return createApplyNode("neq", left, right); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#not(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue not(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("not", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#or(java.util.List) - */ - public ASTNodeValue or(List values) throws DOMException, - SBMLException { - return createApplyNode("or", values); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#piecewise(java.util.List) - */ - public ASTNodeValue piecewise(List values) throws DOMException, - SBMLException { - if (values.size() > 0) { - setLevel(values.get(0).getParentSBMLObject().getLevel()); - lastElementCreated = document.createElement("apply"); - Element tag = document.createElement("piecewise"); - lastElementCreated.appendChild(tag); - Element piece = null; - for (int i = 0; i < values.size(); i++) { - if ((i % 2) == 0) { - piece = document.createElement("piece"); - tag.appendChild(piece); - } else if (i == values.size() - 1) { - piece = document.createElement("otherwise"); - tag.appendChild(piece); - } - if (piece != null) { - piece.appendChild(values.get(i).compile(this).toNode()); - } - } - return new ASTNodeValue(lastElementCreated, this); - } - throw new IllegalArgumentException( - "Cannot create piecewise function with empty argument list"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#plus(java.util.List) - */ - public ASTNodeValue plus(List values) throws DOMException, - SBMLException { - return createApplyNode("plus", values); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue pow(ASTNode base, ASTNode exponent) - throws DOMException, SBMLException { - return createApplyNode("pow", base, exponent); - } - - /** - * Allows to re-use this object to compile another {@link ASTNode}. Without - * reseting, this compiler can only be used one time. Otherwise it cannot be - * guaranteed that the results will be correct. - * - * @throws XMLStreamException - */ - public void reset() throws XMLStreamException { - init(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws DOMException, SBMLException { - if (rootExponent != null) { - return root(rootExponent.compile(this), radiant); - } - return createApplyNode("root", radiant); - } - - /** - * - * @param rootExponent - * @param radiant - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue root(ASTNodeValue rootExponent, ASTNode radiant) - throws DOMException, SBMLException { - Element logbase = document.createElement("degree"); - logbase.appendChild(rootExponent.toNode()); - ASTNodeValue v = createApplyNode("root", radiant); - Node v_node = v.toNode(); - - // TODO : Not working - not correcting it as the mathMl output is wrong anyway and will be re-implemented. - v_node.insertBefore(logbase, v_node.getFirstChild().getNextSibling()); - - return v; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(double, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws DOMException, SBMLException { - ASTNodeValue exponent; - String dimensionless = (0 < level) && (level < 3) ? null - : Unit.Kind.DIMENSIONLESS.toString().toLowerCase(); - if (rootExponent - ((int) rootExponent) == 0) { - exponent = compile((int) rootExponent, dimensionless); - } else { - exponent = compile(rootExponent, dimensionless); - } - return root(exponent, radiant); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sec(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("sec", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sech(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("sech", value); - } - - /** - * @param level - * the level to set - */ - private void setLevel(int level) { - if ((0 < this.level) && (this.level <= 3) - && ((level < 0) || (3 < level))) { - throw new IllegalArgumentException(StringTools.concat( - "Cannot set level from the valid value ", - Integer.toString(this.level), " to invalid value ", - Integer.toString(level)).toString()); - } - this.level = level; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sin(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("sin", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sinh(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("sinh", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue sqrt(ASTNode value) throws DOMException, SBMLException { - return root(2, value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#symbolTime(java.lang.String) - */ - public ASTNodeValue symbolTime(String time) { - return new ASTNodeValue(createCSymbol(time, MathMLParser - .getDefinitionURItime()), this); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tan(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("tan", value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue tanh(ASTNode value) throws DOMException, SBMLException { - return createApplyNode("tanh", value); - } - - /** - * Convenient method to perform internal changes. - * - * @param values - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue times(ASTNodeValue... values) throws DOMException, - SBMLException { - return createApplyNode("times", values); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#times(java.util.List) - */ - public ASTNodeValue times(List values) throws DOMException, - SBMLException { - return createApplyNode("times", values); - } - - /** - * - * @param omitXMLDeclaration - * @param indenting - * @param indent - * @return - * @throws IOException - * @throws SBMLException - */ - public String toMathML(boolean omitXMLDeclaration, boolean indenting, - int indent) throws IOException, SBMLException { - return MathMLParser.toMathML(getDocument(), omitXMLDeclaration, - indenting, indent); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#uMinus(org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue uMinus(ASTNode value) throws DOMException, - SBMLException { - ASTNodeValue v = value.compile(this); - v.setLevel(value.getParentSBMLObject().getLevel()); - return uMinus(v); - } - - /** - * - * @param value - * @return - * @throws DOMException - * @throws SBMLException - */ - private ASTNodeValue uMinus(ASTNodeValue value) throws DOMException, - SBMLException { - setLevel(value.getLevel()); - return times(compile(-1, (0 < level) && (level < 3) ? null - : Unit.Kind.DIMENSIONLESS.toString().toLowerCase()), value); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#unknownValue() - */ - public ASTNodeValue unknownValue() throws SBMLException { - throw new SBMLException( - "cannot write unknown syntax tree nodes to a MathML document"); - } - - /** - * Converts the given {@link Object} into a {@link String}. Then it removes - * leading and tailing white spaces from the given {@link String} and then - * inserts exactly one white space at the beginning and the end of the given - * {@link String}. - * - * @param name - * @return - */ - private String writeName(Object name) { - return StringTools.concat(Character.toString(' '), - name.toString().trim(), Character.toString(' ')).toString(); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#xor(java.util.List) - */ - public ASTNodeValue xor(List values) throws DOMException, - SBMLException { - return createApplyNode("xor", values); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java deleted file mode 100644 index e42ee1171..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java +++ /dev/null @@ -1,906 +0,0 @@ -/* - * $Id: MathMLXMLStreamCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/MathMLXMLStreamCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.io.StringWriter; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.List; -import java.util.Locale; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.log4j.Logger; -import org.codehaus.staxmate.SMOutputFactory; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.util.StringTools; - -import com.ctc.wstx.stax.WstxOutputFactory; - - - -/** - * Writes an {@link ASTNode} the mathML. - * - * @author rodrigue - * @since 0.8 - * @version $Rev: 1116 $ - */ -// TODO: Let this implement the regular ASTNodeCompiler interface. -public class MathMLXMLStreamCompiler { - - private String indent; - private XMLStreamWriter writer; - private Logger logger = Logger.getLogger(MathMLXMLStreamCompiler.class); - - private FindUnitsCompiler findUnitsCompiler = new FindUnitsCompiler(); - - /** - * Formats the real number in a valid way for mathML. - * When java read 0.000166, it transforms it to 1.66E-4. - * This DecimalFormat will wrote the number as it was read. - */ - DecimalFormat realFormat = new DecimalFormat(StringTools.REAL_FORMAT, - new DecimalFormatSymbols(Locale.ENGLISH)); - - /** - * Create a new MathMLXMLStreamCompiler. - * - * @param writer the writer - * @param indent the starting indentation - * - * @throws IllegalArgumentException if the writer is null - */ - public MathMLXMLStreamCompiler(XMLStreamWriter writer, String indent) { - if (writer == null) { - throw new IllegalArgumentException( - "Cannot create a XMLNodeWriter with a null writer."); - } - - this.writer = writer; - this.indent = indent; - } - - /** - * Writes an {@link ASTNode} the mathML. - * - * @param astNode the {@link ASTNode} to serialize as mathML - * @return a String representing this ASTNode as mathML. - */ - public static String toMathML(ASTNode astNode) { - - String mathML = ""; - StringWriter stream = new StringWriter(); - - SMOutputFactory smFactory = new SMOutputFactory(WstxOutputFactory - .newInstance()); - - try { - XMLStreamWriter writer = smFactory.createStax2Writer(stream); - MathMLXMLStreamCompiler compiler = new MathMLXMLStreamCompiler(writer, " "); - boolean isSBMLNamespaceNeeded = compiler.isSBMLNamespaceNeeded(astNode); - - writer.writeStartDocument(); - writer.writeCharacters("\n"); - writer.writeStartElement("math"); - writer.writeNamespace(null, ASTNode.URI_MATHML_DEFINITION); - - if (isSBMLNamespaceNeeded) { - // writing the SBML namespace - SBMLDocument doc = null; - SBase sbase = astNode.getParentSBMLObject(); - String sbmlNamespace = SBMLDocument.URI_NAMESPACE_L3V1Core; - - if (sbase != null) { - doc = sbase.getSBMLDocument(); - sbmlNamespace = doc.getSBMLDocumentNamespaces().get("xmlns"); - } - writer.writeNamespace("sbml", sbmlNamespace); - } - - writer.writeCharacters("\n"); - - writer.setPrefix("math", ASTNode.URI_MATHML_DEFINITION); - - compiler.compile(astNode); - - writer.writeEndElement(); - writer.writeEndDocument(); - writer.close(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - mathML = stream.toString(); - - return mathML; - } - - - public boolean isSBMLNamespaceNeeded(ASTNode astNode) { - - SBase sbase = astNode.getParentSBMLObject(); - - if (sbase != null && sbase.getLevel() < 3) { - return false; - } - - findUnitsCompiler.reset(); - - try { - astNode.compile(findUnitsCompiler); - } catch (SBMLException e) { - // normal behavior, we use Exception to stop the recursion - // as soon as a units is found - } - - return findUnitsCompiler.isUnitsDefined(); - } - - - /** - * Compiles this {@link ASTNode} and produce an XMLStreamWriter representing this node in mathML. - * - * - * @throws SBMLException if any problems occur while checking the ASTNode tree. - */ - public void compile(ASTNode astNode) { - - logger.debug("compile : node type = " + astNode.getType()) ; - - if (astNode.isInfinity()) { - compilePositiveInfinity(astNode); - } else if (astNode.isNegInfinity()) { - compileNegativeInfinity(astNode); - } else { - - - switch (astNode.getType()) { - /* - * Numbers - */ - case REAL: - compileReal(astNode); - break; - case INTEGER: - compileInteger(astNode); - break; - /* - * Operators - */ - case DIVIDE: - if (astNode.getChildCount() != 2) { - // TODO : add it to an error log like libsbml ? - logger.warn(String.format( - "compile : Type.DIVIDE : getChildCount() = %d but required is 2!", - astNode.getChildCount())); - } - case POWER: - case PLUS: - case MINUS: - case TIMES: - compileElement(astNode); - break; - case RATIONAL: - compileRational(astNode); - break; - /* - * Names of identifiers: parameters, functions, species etc. - */ - case NAME: - if (astNode.getChildCount() > 0) { // In case the id is not a valid functionDefinition id, the type is set to NAME - - // TODO : check for SBML level 3 where the order of the listOf is not mandatory any more. - // TODO : check how and when we put the type FUNCTION to a node. - - compileUserFunction(astNode); - } else { - compileCi(astNode); - } - break; - /* - * Type: pi, e, true, false, Avogadro - */ - case CONSTANT_PI: - case CONSTANT_E: - case CONSTANT_TRUE: - case CONSTANT_FALSE: - compileConstantElement(astNode); - break; - /* - * csymbol element - * - */ - case NAME_TIME: - case FUNCTION_DELAY: - case NAME_AVOGADRO: - compileCSymbol(astNode); - break; - case REAL_E: - compileReal_e(astNode); - break; - /* - * Basic Functions - */ - case FUNCTION_LOG: - compileLog(astNode); - break; - case FUNCTION_ABS: - case FUNCTION_ARCCOS: - case FUNCTION_ARCCOSH: - case FUNCTION_ARCCOT: - case FUNCTION_ARCCOTH: - case FUNCTION_ARCCSC: - case FUNCTION_ARCCSCH: - case FUNCTION_ARCSEC: - case FUNCTION_ARCSECH: - case FUNCTION_ARCSIN: - case FUNCTION_ARCSINH: - case FUNCTION_ARCTAN: - case FUNCTION_ARCTANH: - case FUNCTION_CEILING: - case FUNCTION_COS: - case FUNCTION_COSH: - case FUNCTION_COT: - case FUNCTION_COTH: - case FUNCTION_CSC: - case FUNCTION_CSCH: - case FUNCTION_EXP: - case FUNCTION_FACTORIAL: - case FUNCTION_FLOOR: - case FUNCTION_LN: - case FUNCTION_POWER: - case FUNCTION_SEC: - case FUNCTION_SECH: - case FUNCTION_SIN: - case FUNCTION_SINH: - case FUNCTION_TAN: - case FUNCTION_TANH: - compileFunctionElement(astNode); - break; - case FUNCTION_ROOT: - compileRootElement(astNode); - break; - case FUNCTION: - compileUserFunction(astNode); - break; - case FUNCTION_PIECEWISE: - compilePiecewise(astNode); - break; - case LAMBDA: - compileLambda(astNode); - break; - /* - * Logical and relational functions - */ - case LOGICAL_AND: - case LOGICAL_XOR: - case LOGICAL_OR: - case LOGICAL_NOT: - compileLogicalOperator(astNode); - break; - case RELATIONAL_EQ: - case RELATIONAL_GEQ: - case RELATIONAL_GT: - case RELATIONAL_NEQ: - case RELATIONAL_LEQ: - case RELATIONAL_LT: - compileRelationalOperator(astNode); - break; - default: // UNKNOWN: - logger.warn("!!!!! I don't know what to do with the node of type " + astNode.getType()); - break; - } - } - } - - - - - private void compileNegativeInfinity(ASTNode astNode) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - writer.writeCharacters(indent + " "); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "minus"); - writer.writeCharacters("\n"); - writer.writeCharacters(indent + " "); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "infinity"); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compilePositiveInfinity(ASTNode astNode) { - - try { - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "infinity"); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - private void compileNotANumber(ASTNode astNode) { - - try { - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "notanumber"); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - private void compilePi(ASTNode astNode) { - - try { - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "pi"); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - private void compileExponentiale(ASTNode astNode) { - - try { - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "exponentiale"); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - - - private void compileCSymbol(ASTNode astNode) { - - try { - // delay works like a function, so we need to write all the children - if (astNode.getType() == Type.FUNCTION_DELAY) { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - indent += " "; - } - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "csymbol"); - writer.writeAttribute("encoding", astNode.getEncoding() != null ? astNode.getEncoding() : "text"); - writer.writeAttribute("definitionURL", astNode.getDefinitionURL() != null ? astNode.getDefinitionURL() : ""); - writer.writeCharacters(" "); - writer.writeCharacters(astNode.getName()); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - // delay works like a function, so we need to write all the children - if (astNode.getType() == Type.FUNCTION_DELAY) { - - for (ASTNode arg : astNode.getListOfNodes()) { - compile(arg); - } - - // end apply element - writeEndElement(); - } - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compileInteger(ASTNode astNode) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "cn"); - writer.writeAttribute("type", "integer"); // writer.writeAttribute(ASTNode.URI_MATHML_DEFINITION, "type", "integer"); - - if (astNode.isSetUnits()) { - writer.writeAttribute("sbml:units", astNode.getUnits()); - } - writer.writeCharacters(" "); - writer.writeCharacters(Integer.toString(astNode.getInteger())); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - - private void compileReal(ASTNode astNode) { - - try { - - if (Double.isNaN(astNode.getReal())) { - compileNotANumber(astNode); - return; - } else if (Double.isInfinite(astNode.getReal())) { - compilePositiveInfinity(astNode); - return; - } else if (Math.PI == astNode.getReal()) { - compilePi(astNode); - return; - } else if (Math.E == astNode.getReal()) { - compileExponentiale(astNode); - return; - } - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "cn"); - if (astNode.isSetNumberType()) { - writer.writeAttribute("type", "real"); - } - if (astNode.isSetUnits()) { - writer.writeAttribute(" sbml:units", astNode.getUnits()); - } - writer.writeCharacters(" "); - - // We need the DecimalFormat to have number like 0.000166, that get transformed into 1.66E-4 which is - // invalid in mathML, written properly - String doubleStr = realFormat.format(astNode.getReal()); - - writer.writeCharacters(doubleStr); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - - private void compileReal_e(ASTNode astNode) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "cn"); - writer.writeAttribute("type", "e-notation"); - writer.writeCharacters(" "); - if (astNode.isSetUnits()) { - writer.writeAttribute("sbml:units", astNode.getUnits()); - } - writer.writeCharacters(realFormat.format(astNode.getMantissa())); - writer.writeCharacters(" "); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "sep"); - writer.writeCharacters(" "); - writer.writeCharacters(realFormat.format(astNode.getExponent())); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compileRational(ASTNode astNode) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "cn"); - writer.writeAttribute("type", "rational"); - writer.writeCharacters(" "); - if (astNode.isSetUnits()) { - writer.writeAttribute("sbml:units", astNode.getUnits()); - } - writer.writeCharacters(Integer.toString(astNode.getNumerator())); - writer.writeCharacters(" "); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "sep"); - writer.writeCharacters(" "); - writer.writeCharacters(Integer.toString(astNode.getDenominator())); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compileCi(ASTNode astNode) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "ci"); - writer.writeCharacters(" "); - writer.writeCharacters(astNode.getName()); - writer.writeCharacters(" "); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - - } - - - - private void compileElement(ASTNode astNode) { - - compileElement(astNode.getType().toString().toLowerCase(), astNode); - } - - private void compileFunctionElement(ASTNode astNode) { - String functionName = astNode.getType().toString().substring(9).toLowerCase(); - - compileElement(functionName, astNode); - } - - private void compileRootElement(ASTNode astNode) { - - if (astNode.getChildCount() == 1) { - compileFunctionElement(astNode); - } else if (astNode.getChildCount() == 2) { - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - indent += " "; - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "root"); - writer.writeCharacters("\n"); - - // write the degree element - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "degree"); - writer.writeCharacters("\n"); - indent += " "; - - compile(astNode.getChild(0)); - - // end degree element - writeEndElement(); - - compile(astNode.getChild(1)); - - // end apply element - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } else { - logger.warn("Cannot have more than 2 children on a root node !!"); - } - - } - - private void compileLambda(ASTNode astNode) { - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "lambda"); - writer.writeCharacters("\n"); - indent += " "; - - int nbChildren = astNode.getChildCount(); - - if (nbChildren > 1) { - for (int i = 0; i < nbChildren - 1; i++ ) { - ASTNode arg = astNode.getChild(i); - compileBvar(arg); - } - } - - compile(astNode.getRightChild()); - - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - - private void compileBvar(ASTNode arg) { - - try { - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "bvar"); - writer.writeCharacters("\n"); - indent += " "; - - if (!arg.isString()) { - logger.warn("compileBvar : can only have node of type NAME there !!!!"); - } - - compileCi(arg); - - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compilePiecewise(ASTNode astNode) { - - int nbChildren = astNode.getChildCount(); - boolean writeOtherwise = true; - - if (nbChildren % 2 != 1) { - writeOtherwise = false; - } - - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "piecewise"); - writer.writeCharacters("\n"); - indent += " "; - - for (int i = 0; i < nbChildren - 1; i = i + 2) { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "piece"); - writer.writeCharacters("\n"); - indent += " "; - - compile(astNode.getChild(i)); - compile(astNode.getChild(i + 1)); - - // end piece element - writeEndElement(); - } - - if (writeOtherwise) { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "otherwise"); - writer.writeCharacters("\n"); - indent += " "; - - compile(astNode.getRightChild()); - - writeEndElement(); - } - - // end piecewise element - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - - private void compileLog(ASTNode astNode) { - - if (astNode.getChildCount() == 1) { - compileFunctionElement(astNode); - } else if (astNode.getChildCount() == 2) { - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - indent += " "; - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, "log"); - writer.writeCharacters("\n"); - - // write the logbase element - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "logbase"); - writer.writeCharacters("\n"); - indent += " "; - - compile(astNode.getChild(0)); - - // end logbase element - writeEndElement(); - - compile(astNode.getChild(1)); - - // end apply element - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } else { - logger.warn("compileLog : cannot have more than 2 children on a log node !!"); - } - } - - - private void compileConstantElement(ASTNode astNode) { - String constantName = astNode.getType().toString().substring(9).toLowerCase(); - - if (constantName.equals("e")) { - constantName = "exponentiale"; - } - - try { - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, constantName); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - /** - * - * - * @param string element name - * @param astNode the node containing all the element information - */ - private void compileElement(String string, ASTNode astNode) { - - // TODO : Not good, we need to write the possible attribute or annotations of the element node - function(string, astNode.getListOfNodes()); - - } - - - private void compileRelationalOperator(ASTNode astNode) { - String functionName = astNode.getType().toString().substring(11).toLowerCase(); - - compileElement(functionName, astNode); - - } - - private void compileLogicalOperator(ASTNode astNode) { - String functionName = astNode.getType().toString().substring(8).toLowerCase(); - - compileElement(functionName, astNode); - - } - - private void function(String functionName, List args) { - - function(functionName, args.toArray(new ASTNode[args.size()])); - } - - private void function(String functionName, ASTNode... args) { - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - indent += " "; - - writer.writeCharacters(indent); - writer.writeEmptyElement(ASTNode.URI_MATHML_DEFINITION, functionName); - writer.writeCharacters("\n"); - - for (ASTNode arg : args) { - compile(arg); - } - - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - private void compileUserFunction(ASTNode astNode) { - try { - - writer.writeCharacters(indent); - writer.writeStartElement(ASTNode.URI_MATHML_DEFINITION, "apply"); - writer.writeCharacters("\n"); - indent += " "; - - compileCi(astNode); - - for (ASTNode arg : astNode.getChildren()) { - compile(arg); - } - - writeEndElement(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - } - - private void writeEndElement() { - try { - - indent = indent.substring(2); - writer.writeCharacters(indent); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } - - public static void main(String[] args) { - - ASTNode formula_base = new ASTNode(Double.NaN); - - System.out.println(formula_base.toMathML()); - try { - System.out.println(formula_base.toFormula()); - } catch (SBMLException e) { - e.printStackTrace(); - } - - double x = 0.0050; - double y = 1.0; - double z = 1.66E-4; - double zz = 12548698515426596325478965230.33254; - - System.out.println("Test Double formatting "); - - // NumberFormat format = DecimalFormat.getInstance(); - DecimalFormat format = new DecimalFormat(StringTools.REAL_FORMAT, new DecimalFormatSymbols(Locale.ENGLISH)); - - System.out.println("x = " + format.format(x)); - System.out.println("y = " + format.format(y)); - System.out.println("z = " + format.format(z) + " " + format.getMaximumFractionDigits()); - System.out.println("zz = " + format.format(zz) + " "); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitException.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitException.java deleted file mode 100644 index aab3cdbfe..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitException.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * $Id: UnitException.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/UnitException.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.SBMLException; - -/** - * Exception to be thrown if inconsistent units are used in mathematical - * expressions, i.e., instances of {@link ASTNode}. - * - * @author Andreas Dräger - * @date 2011-01-20 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class UnitException extends SBMLException { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -5630929507888356877L; - - /** - * - */ - public UnitException() { - super(); - } - - /** - * @param message - */ - public UnitException(String message) { - super(message); - } - - /** - * @param cause - */ - public UnitException(Throwable cause) { - super(cause); - } - - /** - * @param message - * @param cause - */ - public UnitException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitsCompiler.java b/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitsCompiler.java deleted file mode 100644 index 5b06e134e..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/UnitsCompiler.java +++ /dev/null @@ -1,1273 +0,0 @@ -/* - * $Id: UnitsCompiler.java,v 1.1 2012-11-07 14:43:31 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/compilers/UnitsCompiler.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.compilers; - -import java.text.MessageFormat; -import java.util.HashMap; -import java.util.List; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.CallableSBase; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Quantity; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.Unit.Kind; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.util.Maths; - -/** - * Derives the units from mathematical operations. - * - * @author Andreas Dräger - * @date 2010-05-20 - * @since 0.8 - * @version $Rev: 1204 $ - */ -public class UnitsCompiler implements ASTNodeCompiler { - - /** - * SBML level field - */ - private int level; - /** - * SBML version field - */ - private int version; - /** - * The model associated to this compiler. - */ - private Model model; - /** - * Necessary for function definitions to remember the units of the argument - * list. - */ - private HashMap namesToUnits; - - /** - * - */ - public UnitsCompiler() { - this(-1, -1); - } - - /** - * - * @param level - * @param version - */ - public UnitsCompiler(int level, int version) { - this.level = level; - this.version = version; - this.namesToUnits = new HashMap(); - } - - /** - * - * @param model - */ - public UnitsCompiler(Model model) { - this(model.getLevel(), model.getVersion()); - this.model = model; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#abs(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue abs(ASTNode value) throws SBMLException { - ASTNodeValue v = new ASTNodeValue(this); - if (value.isDifference() || value.isSum() || value.isUMinus() - || value.isNumber()) { - v.setValue(Double.valueOf(Math.abs(value.compile(this).toDouble()))); - } - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#and(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue and(List values) throws SBMLException { - ASTNodeValue value = dimensionless(); - boolean val = true; - for (ASTNode v : values) { - val &= v.compile(this).toBoolean(); - } - value.setValue(val); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccos(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccos(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.acos(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccosh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccosh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arccosh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccot(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccot(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arccot(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccoth(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccoth(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arccoth(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccsc(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccsc(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arccsc(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arccsch(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arccsch(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arccsch(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arcsec(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arcsec(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arcsec(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arcsech(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arcsech(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arcsech(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arcsin(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arcsin(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.asin(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arcsinh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arcsinh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arcsinh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arctan(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arctan(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.atan(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#arctanh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue arctanh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.arctanh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#ceiling(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue ceiling(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - v.setValue(Math.ceil(v.toDouble())); - - return v; - } - - /** - * Compile boolean values - * - * @param b - * @return - */ - public ASTNodeValue compile(boolean b) { - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(Kind.DIMENSIONLESS); - ASTNodeValue value = new ASTNodeValue(b, this); - value.setUnits(ud); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#compile(org.sbml.jsbml.Compartment) - */ - public ASTNodeValue compile(Compartment c) { - return compile((CallableSBase) c); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#compile(double, int, java.lang.String) - */ - public ASTNodeValue compile(double mantissa, int exponent, String units) { - return compile(mantissa * Math.pow(10, exponent), units); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#compile(double, java.lang.String) - */ - public ASTNodeValue compile(double real, String units) { - ASTNodeValue v = new ASTNodeValue(real, this); - UnitDefinition ud; - if (Unit.Kind.isValidUnitKindString(units, level, version)) { - ud = new UnitDefinition(level, version); - ud.addUnit(Unit.Kind.valueOf(units.toUpperCase())); - v.setUnits(ud); - } else if (model != null) { - ud = model.getUnitDefinition(units); - if (ud != null) { - v.setUnits(ud); - } - } - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#compile(int, java.lang.String) - */ - public ASTNodeValue compile(int integer, String units) { - return compile((double) integer, units); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#compile(org.sbml.jsbml.CallableSBase) - */ - public ASTNodeValue compile(CallableSBase variable) { - ASTNodeValue value = new ASTNodeValue(variable, this); - if (variable instanceof Quantity) { - Quantity q = (Quantity) variable; - if (q.isSetValue()) { - value.setValue(Double.valueOf(q.getValue())); - } - } - value.setUnits(variable.getDerivedUnitDefinition()); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#compile(java.lang.String) - */ - public ASTNodeValue compile(String name) { - if (namesToUnits.containsKey(name)) { - return namesToUnits.get(name); - } - return new ASTNodeValue(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#cos(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue cos(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.cos(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#cosh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue cosh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.cosh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#cot(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue cot(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.cot(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#coth(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue coth(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.coth(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#csc(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue csc(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.csc(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#csch(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue csch(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.csch(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#delay(java.lang.String, org.sbml.jsbml.ASTNodeValue, double, java.lang.String) - */ - public ASTNodeValue delay(String delayName, ASTNode x, ASTNode delay, - String units) throws SBMLException { - /* - * This represents a delay function. The delay function has the form - * delay(x, d), taking two MathML expressions as arguments. Its value is - * the value of argument x at d time units before the current time. - * There are no restrictions on the form of x. The units of the d - * parameter are determined from the built-in time. The value of the d - * parameter, when evaluated, must be numerical (i.e., a number in - * MathML real, integer, or e-notation format) and be greater than or - * equal to 0. (v2l4) - */ - UnitDefinition value = x.compile(this).getUnits().clone(); - UnitDefinition time = delay.compile(this).getUnits().clone(); - - if (model.getTimeUnitsInstance() != null) { - if (!UnitDefinition.areEquivalent(model.getTimeUnitsInstance(), - time)) { - throw new IllegalArgumentException( - new UnitException( - String.format( - "Units of time in a delay function do not match. Given %s and %s.", - UnitDefinition.printUnits(model - .getTimeUnitsInstance()), - UnitDefinition.printUnits(time)))); - } - } - // not the correct value, need insight into time scale to return - // the correct value - - return new ASTNodeValue(value, this); - } - - /** - * Creates a dimensionless unit definition object encapsulated in an - * ASTNodeValue. - * - * @return - */ - private ASTNodeValue dimensionless() { - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(Unit.Kind.DIMENSIONLESS); - return new ASTNodeValue(ud, this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#equal(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue eq(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() == rightvalue.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#exp(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue exp(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - - return pow(getConstantE(), v); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#factorial(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue factorial(ASTNode value) throws SBMLException { - - ASTNodeValue v = new ASTNodeValue(Maths.factorial((int) Math - .round(value.compile(this).toDouble())), this); - if (value.isSetUnits()) { - v.setUnits(value.getUnitsInstance()); - } else { - v.setLevel(level); - v.setVersion(version); - } - checkForDimensionlessOrInvalidUnits(v.getUnits()); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#floor(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue floor(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - v.setValue(Math.floor(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#frac(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue frac(ASTNode numerator, ASTNode denominator) - throws SBMLException { - UnitDefinition ud = numerator.compile(this).getUnits().clone(); - UnitDefinition denom = denominator.compile(this).getUnits().clone(); - setLevelAndVersion(ud); - setLevelAndVersion(denom); - ud.divideBy(denom); - ASTNodeValue value = new ASTNodeValue(ud, this); - value.setValue(numerator.compile(this).toDouble() - / denominator.compile(this).toDouble()); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#frac(int, int) - */ - public ASTNodeValue frac(int numerator, int denominator) { - ASTNodeValue value = new ASTNodeValue( - new UnitDefinition(level, version), this); - value.setValue(((double) numerator) / ((double) denominator)); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#function(org.sbml.jsbml.FunctionDefinition, org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue function(FunctionDefinition function, List args) - throws SBMLException { - ASTNode lambda = function.getMath(); - HashMap argValues = new HashMap(); - for (int i = 0; i < args.size(); i++) { - argValues.put(lambda.getChild(i).compile(this).toString(), args - .get(i).compile(this)); - - } - try { - this.namesToUnits = argValues; - ASTNodeValue value = lambda.getRightChild().compile(this); - this.namesToUnits.clear(); - return value; - } catch (SBMLException e) { - return new ASTNodeValue(this); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#function(java.lang.String, java.util.List) - */ - public ASTNodeValue function(String functionDefinitionName, - List args) throws SBMLException { - // TODO : Not sure what to do - return new ASTNodeValue(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#greaterEqual(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue geq(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() >= rightvalue.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantAvogadro(java.lang.String) - */ - public ASTNodeValue getConstantAvogadro(String name) { - // TODO: If there is a different value in a later SBML specification, this must be checked here. - ASTNodeValue value = new ASTNodeValue(Maths.AVOGADRO_L3V1, this); - UnitDefinition perMole = new UnitDefinition(level, version); - perMole.setLevel(level); - perMole.setId("per_mole"); - perMole.addUnit(new Unit(Kind.MOLE, -1, level, version)); - value.setUnits(perMole); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantE() - */ - public ASTNodeValue getConstantE() { - ASTNodeValue v = dimensionless(); - v.setValue(Math.E); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantFalse() - */ - public ASTNodeValue getConstantFalse() { - ASTNodeValue v = dimensionless(); - v.setValue(false); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantPi() - */ - public ASTNodeValue getConstantPi() { - ASTNodeValue v = dimensionless(); - v.setValue(Math.PI); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getConstantTrue() - */ - public ASTNodeValue getConstantTrue() { - ASTNodeValue v = dimensionless(); - v.setValue(true); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getNegativeInfinity() - */ - public ASTNodeValue getNegativeInfinity() { - return compile(Double.NEGATIVE_INFINITY, Unit.Kind.DIMENSIONLESS - .toString().toLowerCase()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#getPositiveInfinity() - */ - public ASTNodeValue getPositiveInfinity() { - return compile(Double.POSITIVE_INFINITY, Unit.Kind.DIMENSIONLESS - .toString().toLowerCase()); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#greaterThan(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue gt(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() > rightvalue.toDouble()); - - return v; - } - - /** - * Creates an invalid unit definition encapsulated in an ASTNodeValue. - * - * @return - */ - private ASTNodeValue invalid() { - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(new Unit(level, version)); - return new ASTNodeValue(ud, this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#lambda(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue lambda(List values) throws SBMLException { - for (int i = 0; i < values.size() - 1; i++) { - namesToUnits.put(values.get(i).toString(), - values.get(i).compile(this)); - } - return new ASTNodeValue(values.get(values.size() - 1).compile(this) - .getUnits(), this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#lessEqual(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue leq(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() <= rightvalue.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#ln(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue ln(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.ln(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#log(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue log(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.log(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#log(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue log(ASTNode number, ASTNode base) throws SBMLException { - ASTNodeValue v = number.compile(this); - ASTNodeValue b = base.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - checkForDimensionlessOrInvalidUnits(b.getUnits()); - v.setValue(Maths.log(v.toDouble(), b.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#lessThan(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue lt(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() < rightvalue.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#minus(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue minus(List values) throws SBMLException { - ASTNodeValue value = new ASTNodeValue(this); - if (values.size() == 0) { - return value; - } - int i = 0; - ASTNodeValue compiledvalues[] = new ASTNodeValue[values.size()]; - for (ASTNode node : values) { - compiledvalues[i++] = node.compile(this); - } - value.setValue(Integer.valueOf(0)); - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(Unit.Kind.INVALID); - value.setUnits(ud); - - i = 0; - - while (i < compiledvalues.length) { - value.setValue(Double.valueOf(value.toDouble() - - compiledvalues[i].toNumber().doubleValue())); - if (!compiledvalues[i].getUnits().isInvalid()) { - value.setUnits(compiledvalues[i].getUnits()); - break; - } - i++; - } - - for (int j = i + 1; j < compiledvalues.length; j++) { - unifyUnits(value, compiledvalues[j]); - value.setValue(Double.valueOf(value.toDouble() - - compiledvalues[j].toNumber().doubleValue())); - - } - - return value; - - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#notEqual(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue neq(ASTNode left, ASTNode right) throws SBMLException { - ASTNodeValue v = dimensionless(), leftvalue, rightvalue; - leftvalue = left.compile(this); - rightvalue = right.compile(this); - unifyUnits(leftvalue, rightvalue); - - v.setValue(leftvalue.toDouble() != rightvalue.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#not(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue not(ASTNode value) throws SBMLException { - ASTNodeValue v = dimensionless(); - v.setValue(!value.compile(this).toBoolean()); - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#or(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue or(List values) throws SBMLException { - ASTNodeValue v = dimensionless(); - v.setValue(false); - for (ASTNode value : values) { - if (value.compile(this).toBoolean()) { - v.setValue(true); - break; - } - } - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#piecewise(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue piecewise(List values) throws SBMLException { - int i = 0; - - ASTNodeValue compiledvalues[] = new ASTNodeValue[values.size()]; - for (ASTNode node : values) { - compiledvalues[i++] = node.compile(this); - } - if (values.size() > 2) { - ASTNodeValue node = compiledvalues[0]; - for (i = 2; i < values.size(); i += 2) { - if (!UnitDefinition.areEquivalent(node.getUnits(), - compiledvalues[i].getUnits())) { - throw new IllegalArgumentException( - new UnitException( - String.format( - "Units of some return values in a piecewise function do not match. Given %s and %s.", - UnitDefinition.printUnits(node.getUnits(), true), - UnitDefinition.printUnits(compiledvalues[i].getUnits(), true)))); - } - } - } - - for (i = 1; i < compiledvalues.length - 1; i += 2) { - if (compiledvalues[i].toBoolean()) { - return compiledvalues[i - 1]; - } - } - - return values.get(i - 1).compile(this); - - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#plus(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue plus(List values) throws SBMLException { - ASTNodeValue value = new ASTNodeValue(this); - - if (values.size() == 0) { - return value; - } - - int i = 0; - ASTNodeValue compiledvalues[] = new ASTNodeValue[values.size()]; - for (ASTNode node : values) { - compiledvalues[i++] = node.compile(this); - } - - value.setValue(Integer.valueOf(0)); - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(Unit.Kind.INVALID); - value.setUnits(ud); - - i = compiledvalues.length - 1; - - while (i >= 0) { - value.setValue(Double.valueOf(value.toDouble() - + compiledvalues[i].toNumber().doubleValue())); - if (!compiledvalues[i].getUnits().isInvalid()) { - value.setUnits(compiledvalues[i].getUnits()); - break; - } - i--; - } - - for (int j = i - 1; j >= 0; j--) { - unifyUnits(value, compiledvalues[j]); - value.setValue(Double.valueOf(value.toDouble() - + compiledvalues[j].toNumber().doubleValue())); - - } - - return value; - } - - /** - * This method tries to unify the units of two ASTNodeValues so that they - * have the same units and their value thus is also adjusted. If the units - * of both ASTNodeValues are not compatible, an exception is thrown. - * - * @param left - * @param right - * @return - */ - private void unifyUnits(ASTNodeValue left, ASTNodeValue right) - throws SBMLException { - if (UnitDefinition.areCompatible(left.getUnits(), right.getUnits())) { - - if (!left.getUnits().isInvalid() || !right.getUnits().isInvalid()) { - left.getUnits().simplify(); - right.getUnits().simplify(); - int mean, scale1, scale2; - double v1 = left.toNumber().doubleValue(), v2 = right.toNumber().doubleValue(); - for (int i = 0; i < left.getUnits().getUnitCount(); i++) { - Unit u1 = left.getUnits().getUnit(i); - Unit u2 = right.getUnits().getUnit(i); - if (((u1.getMultiplier() != u2.getMultiplier()) - && (u1.getScale() != u2.getScale()) && (u1.getExponent() != u2.getExponent())) - && (u1.getMultiplier() != 0d) && (u2.getMultiplier() != 0d)) { - - mean = (Math.abs(u1.getScale()) + Math.abs(u2.getScale())) / 2; - - if (u1.getScale() > mean) { - scale1 = Math.abs(u1.getScale()) - mean; - scale2 = mean - u2.getScale(); - - } else { - scale2 = Math.abs(u2.getScale()) - mean; - scale1 = mean - u1.getScale(); - } - - if (u1.getExponent() < 0) { - scale1 = -scale1; - scale2 = -scale2; - } - - if (scale1 > mean) { - v1 = v1 * Math.pow(10d, -scale1 * u1.getExponent()); - v2 = v2 * Math.pow(10d, -scale2 * u2.getExponent()); - - } else { - v1 = v1 * Math.pow(10d, scale1 * u1.getExponent()); - v2 = v2 * Math.pow(10d, scale2 * u2.getExponent()); - } - - if (u1.getMultiplier() > 1d) { - v1 = v1 * u1.getMultiplier(); - u1.setMultiplier(1d); - } - - if (u2.getMultiplier() > 1d) { - v2 = v2 * u2.getMultiplier(); - u2.setMultiplier(1d); - } - - u1.setScale(mean); - u2.setScale(mean); - - } - - } - left.setValue(v1); - right.setValue(v2); - } - - } else { - throw new UnitException( - String.format( - "Cannot combine the units %s and %s in addition, subtraction, comparison or any equivalent operation.", - UnitDefinition.printUnits(left.getUnits(), true), - UnitDefinition.printUnits(right.getUnits(), true))); - - } - - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#pow(org.sbml.jsbml.ASTNodeValue, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue pow(ASTNode base, ASTNode exponent) - throws SBMLException { - if (exponent.isSetUnits()) { - checkForDimensionlessOrInvalidUnits(exponent.getUnitsInstance()); - } - - return pow(base.compile(this), exponent.compile(this)); - } - - /** - * - * @param base - * @param exponent - * @return - * @throws SBMLException - */ - private ASTNodeValue pow(ASTNodeValue base, ASTNodeValue exponent) - throws SBMLException { - double exp = Double.NaN, v; - v = exponent.toDouble(); - exp = v == 0d ? 0d : 1d / v; - if (exp == 0d) { - UnitDefinition ud = new UnitDefinition(level, version); - ud.addUnit(Kind.DIMENSIONLESS); - ASTNodeValue value = new ASTNodeValue(ud, this); - value.setValue(Integer.valueOf(1)); - return value; - } - if (!Double.isNaN(exp)) { - return root(exp, base); - } - - return new ASTNodeValue(this); - } - - /** - * Throws an {@link IllegalArgumentException} if the given units do not - * represent a dimensionless or invalid unit. - * - * @param units - */ - private void checkForDimensionlessOrInvalidUnits(UnitDefinition units) { - units.simplify(); - String illegal = null; - - if (units.getUnitCount() == 1) { - Kind kind = units.getUnit(0).getKind(); - - if ((kind != Kind.DIMENSIONLESS) && (kind != Kind.ITEM) - && (kind != Kind.RADIAN) && (kind != Kind.STERADIAN) - && (kind != Kind.INVALID)) { - illegal = kind.toString(); - } - } else { - illegal = units.toString(); - } - if (illegal != null) { - throw new IllegalArgumentException( - new UnitException(MessageFormat.format( - "An invalid or dimensionless unit is required but given is {0}.", - illegal))); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.compilers.ASTNodeCompiler#root(org.sbml.jsbml.ASTNode, org.sbml.jsbml.ASTNode) - */ - public ASTNodeValue root(ASTNode rootExponent, ASTNode radiant) - throws SBMLException { - if (rootExponent.isSetUnits()) { - checkForDimensionlessOrInvalidUnits(rootExponent.getUnitsInstance()); - } - if (rootExponent.isNumber()) { - - if (!(rootExponent.isInteger() || rootExponent.isRational())) { - checkForDimensionlessOrInvalidUnits(rootExponent - .getUnitsInstance()); - } - - return root(rootExponent.compile(this).toDouble(), radiant); - } - - return new ASTNodeValue(this); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#root(double, org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue root(double rootExponent, ASTNode radiant) - throws SBMLException { - - return root(rootExponent, radiant.compile(this)); - } - - /** - * - * @param rootExponent - * @param radiant - * @return - * @throws SBMLException - */ - private ASTNodeValue root(double rootExponent, ASTNodeValue radiant) - throws SBMLException { - UnitDefinition ud = radiant.getUnits().clone(); - for (Unit u : ud.getListOfUnits()) { - if ((((u.getExponent() / rootExponent) % 1d) != 0d) && !u.isDimensionless() && !u.isInvalid()) { - throw new IllegalArgumentException( - new UnitException(MessageFormat.format( - "Cannot perform power or root operation due to incompatibility with a unit exponent. Given are {0,number} and {1,number}.", - u.getExponent(), rootExponent))); - } - - if (!(u.isDimensionless() || u.isInvalid())) { - u.setExponent(u.getExponent() / rootExponent); - } - - } - ASTNodeValue value = new ASTNodeValue(ud, this); - value.setValue(Double.valueOf(Math.pow(radiant.toDouble(), 1d / rootExponent))); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#sec(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue sec(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.sec(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#sech(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue sech(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Maths.sech(v.toDouble())); - - return v; - } - - /** - * Ensures that level and version combination of a unit are the same then - * these that are defined here. - * - * @param unit - */ - private void setLevelAndVersion(UnitDefinition unit) { - if ((unit.getLevel() != level) || (unit.getVersion() != version)) { - unit.setLevel(level); - unit.setVersion(version); - unit.getListOfUnits().setLevel(level); - unit.getListOfUnits().setVersion(version); - for (Unit u : unit.getListOfUnits()) { - u.setLevel(level); - u.setVersion(version); - } - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#sin(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue sin(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.sin(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#sinh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue sinh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.sinh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#sqrt(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue sqrt(ASTNode value) throws SBMLException { - return root(2d, value); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#symbolTime(java.lang.String) - */ - public ASTNodeValue symbolTime(String time) { - UnitDefinition ud = UnitDefinition.time(level, version); - if ((ud == null) && (model != null)) { - ud = model.getTimeUnitsInstance(); - if (ud == null) { - ud = model.getUnitDefinition(time); - } - } - if (ud == null) { - ud = invalid().getUnits(); - } - ASTNodeValue value = new ASTNodeValue(ud, this); - value.setValue(Double.valueOf(1d)); - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#tan(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue tan(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.tan(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#tanh(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue tanh(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - checkForDimensionlessOrInvalidUnits(v.getUnits()); - v.setValue(Math.tanh(v.toDouble())); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#times(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue times(List values) throws SBMLException { - UnitDefinition ud = new UnitDefinition(level, version); - UnitDefinition v; - double d = 1d; - - for (ASTNode value : values) { - ASTNodeValue av = value.compile(this); - v = av.getUnits().clone(); - setLevelAndVersion(v); - ud.multiplyWith(v); - d *= av.toDouble(); - } - ASTNodeValue value = new ASTNodeValue(ud, this); - value.setValue(Double.valueOf(d)); - - return value; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#uiMinus(org.sbml.jsbml.ASTNodeValue) - */ - public ASTNodeValue uMinus(ASTNode value) throws SBMLException { - ASTNodeValue v = value.compile(this); - v.setValue(-v.toDouble()); - - return v; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#unknownValue() - */ - public ASTNodeValue unknownValue() { - return invalid(); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.ASTNodeCompiler#xor(org.sbml.jsbml.ASTNodeValue[]) - */ - public ASTNodeValue xor(List values) throws SBMLException { - ASTNodeValue value = dimensionless(); - boolean v = false; - for (int i = 0; i < values.size(); i++) { - if (values.get(i).compile(this).toBoolean()) { - if (v) { - return getConstantFalse(); - } else { - v = true; - } - } - } - value.setValue(Boolean.valueOf(v)); - return value; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/compilers/package.html b/IPK_lib/src/org/sbml/jsbml/util/compilers/package.html deleted file mode 100644 index 548cf99ae..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/compilers/package.html +++ /dev/null @@ -1,4 +0,0 @@ - - The classes in this package can be used to evaluate the information - represented by abstract syntax trees (ASTNode objects). - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/AndFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/AndFilter.java deleted file mode 100644 index 24bacbf2e..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/AndFilter.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * $Id: AndFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/AndFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import java.util.HashSet; -import java.util.Set; - - -/** - * A {@link Filter} that accepts an item only if all of its internal filters - * also accept the given item. - * - * @author Andreas Dräger - * @date 2010-05-26 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class AndFilter implements Filter { - - /** - * A set of filters whose conditions have to be satisfied to accept an item. - */ - private Set filters; - - /** - * - */ - public AndFilter() { - setFilters(new HashSet()); - } - - /** - * - * @param filters - */ - public AndFilter(Filter... filters) { - this(); - for (Filter f : filters) { - this.filters.add(f); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#accepts(java.lang.Object) - */ - public boolean accepts(Object o) { - for (Filter f : filters) { - if (!f.accepts(o)) { - return false; - } - } - return true; - } - - /** - * - * @param filter - * @return - */ - public boolean addFilter(Filter filter) { - return filters.add(filter); - } - - /** - * - * @return - */ - public Set getFilters() { - return filters; - } - - /** - * - * @param filter - * @return - */ - public boolean removeFilter(Filter filter) { - return filters.remove(filter); - } - - /** - * - * @param filters - */ - public void setFilters(Set filters) { - this.filters = filters; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/AssignmentVariableFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/AssignmentVariableFilter.java deleted file mode 100644 index ef86f45fb..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/AssignmentVariableFilter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * $Id: AssignmentVariableFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/AssignmentVariableFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.Assignment; - -/** - * This filter only accepts instances of {@link Assignment} with the variable as - * given in the constructor of this object. - * - * @author rodrigue - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class AssignmentVariableFilter implements Filter { - - /** - * The desired identifier for NamedSBases to be acceptable. - */ - String id; - - /** - * - */ - public AssignmentVariableFilter() { - this(null); - } - - /** - * - * @param id - */ - public AssignmentVariableFilter(String id) { - this.id = id; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#fulfilsProperty(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof Assignment) { - Assignment er = (Assignment) o; - if (er.isSetVariable() && (id != null) && er.getVariable().equals(id)) { - return true; - } - } - return false; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/BoundaryConditionFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/BoundaryConditionFilter.java deleted file mode 100644 index e567278e6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/BoundaryConditionFilter.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * $Id: BoundaryConditionFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/BoundaryConditionFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.Species; - -/** - * This filter accepts species whose boundary condition is set to true. - * - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class BoundaryConditionFilter implements Filter { - - /** - * Constructs a new boundary condition filter. - */ - public BoundaryConditionFilter() { - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#accepts(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof Species) { - Species s = (Species) o; - return s.isSetBoundaryCondition() && s.getBoundaryCondition(); - } - return false; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/CVTermFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/CVTermFilter.java deleted file mode 100644 index e3e973100..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/CVTermFilter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * $Id: CVTermFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/CVTermFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.CVTerm; -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.SBase; - -/** - * This filter accepts only instances of {@link CVTerm} with a certain content - * or instances of {@link SBase} that are annotated with appropriate - * {@link CVTerm} objects. - * - * @author Andreas Dräger - * @date 2010-05-19 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class CVTermFilter implements Filter { - - /** - * - */ - private Qualifier qualifier; - /** - * - */ - private String pattern; - - /** - * - */ - public CVTermFilter() { - this(null, null); - } - - /** - * - * @param qualifier - */ - public CVTermFilter(Qualifier qualifier) { - this(qualifier, null); - } - - /** - * - * @param qualifier - * @param pattern - */ - public CVTermFilter(Qualifier qualifier, String pattern) { - this.qualifier = qualifier; - this.pattern = pattern; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#accepts(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof CVTerm) { - CVTerm cvt = (CVTerm) o; - if (qualifier != null) { - if (cvt.isBiologicalQualifier() - && (cvt.getBiologicalQualifierType() == qualifier)) { - return pattern != null ? cvt.filterResources(pattern) - .size() > 0 : true; - } else if (cvt.isModelQualifier() - && cvt.getModelQualifierType() == qualifier) { - return pattern != null ? cvt.filterResources(pattern) - .size() > 0 : true; - } - } else if (pattern != null) { - return cvt.filterResources(pattern).size() > 0; - } - } else if (o instanceof SBase) { - SBase sbase = (SBase) o; - if (qualifier != null) { - if (pattern != null) { - if (sbase.filterCVTerms(qualifier, pattern).size() > 0) { - return true; - } - } else if (sbase.filterCVTerms(qualifier).size() > 0) { - return true; - } - } - } - return false; - } - - /** - * @return the pattern - */ - public String getPattern() { - return pattern; - } - - /** - * @return the qualifier - */ - public Qualifier getQualifier() { - return qualifier; - } - - /** - * @param pattern - * the pattern to set - */ - public void setPattern(String pattern) { - this.pattern = pattern; - } - - /** - * @param qualifier - * the qualifier to set - */ - public void setQualifier(Qualifier qualifier) { - this.qualifier = qualifier; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/Filter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/Filter.java deleted file mode 100644 index ce2a890c0..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/Filter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * $Id: Filter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/Filter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -/** - * A filter is a general interface that allows to check an object for a certain - * property. An implementing class may check for the type of the object and then - * check some of its field values. - * - * @author Andreas Dräger - * @date 2010-05-19 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface Filter { - - /** - * This method checks whether the given object is of the correct type and - * has the desired properties set to be acceptable. - * - * @param o - * some object whose properties are to be checked. - * @return True if the object is sufficient to be acceptable or false if at - * least one of its properties or its class name does not fit into - * this filter criterion. - */ - public boolean accepts(Object o); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/IdenticalUnitDefinitionFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/IdenticalUnitDefinitionFilter.java deleted file mode 100644 index 21735f7ac..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/IdenticalUnitDefinitionFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * $Id: IdenticalUnitDefinitionFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/IdenticalUnitDefinitionFilter.java $ - * - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2011 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.UnitDefinition; - - -/** - * This {@link Filter} only accepts instances of {@link UnitDefinition} that - * satisfy the method - * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)}. - * - * @author Andreas Dräger - * @version $Rev: 1177 $ - * @since 1.0 - * @date 15.03.2012 - */ -public class IdenticalUnitDefinitionFilter implements Filter { - - /** - * The {@link UnitDefinition} we want to use for comparisons. - */ - private UnitDefinition ud; - - /** - * Initializes this {@link Filter} with a {@link UnitDefinition} to be used in - * the {@link #accepts(Object)} method for comparison. - * - * @param ud - */ - public IdenticalUnitDefinitionFilter(UnitDefinition ud) { - super(); - this.ud = ud; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.filters.Filter#accepts(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof UnitDefinition) { - return UnitDefinition.areIdentical(ud, (UnitDefinition) o); - } - return false; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/NameFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/NameFilter.java deleted file mode 100644 index 28b60ea80..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/NameFilter.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * $Id: NameFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/NameFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.NamedSBase; - -/** - * This filter only accepts instances of {@link NamedSBase} with the name as - * given in the constructor of this object. - * - * @author Andreas Dräger - * @date 2010-05-19 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class NameFilter implements Filter { - - /** - * The desired identifier for NamedSBases to be acceptable. - */ - String id; - /** - * The desired name for NamedSBases to be acceptable. - */ - String name; - - /** - * - */ - public NameFilter() { - this(null, null); - } - - /** - * - * @param id - */ - public NameFilter(String id) { - this(id, null); - } - - /** - * - * @param id - * @param name - */ - public NameFilter(String id, String name) { - this.id = id; - this.name = name; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#fulfilsProperty(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof NamedSBase) { - NamedSBase nsb = (NamedSBase) o; - if (nsb.isSetId() && (id != null) && nsb.getId().equals(id)) { - return true; - } - if (nsb.isSetName() && (name != null) && nsb.getName().equals(name)) { - return true; - } - } - return false; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/OrFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/OrFilter.java deleted file mode 100644 index 281553045..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/OrFilter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * $Id: OrFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/OrFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - - -/** - * This filter accepts an item if at least one of its filters accepts the given - * item. - * - * @author Andreas Dräger - * @date 2010-05-26 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class OrFilter extends AndFilter { - - /** - * - */ - public OrFilter() { - super(); - } - - /** - * @param filters - */ - public OrFilter(Filter... filters) { - super(filters); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.AndFilter#accepts(java.lang.Object) - */ - @Override - public boolean accepts(Object o) { - for (Filter f : getFilters()) { - if (f.accepts(o)) { - return true; - } - } - return false; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/SBOFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/SBOFilter.java deleted file mode 100644 index 9d7960a1b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/SBOFilter.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * $Id: SBOFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/SBOFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.SBO; -import org.sbml.jsbml.SBase; - -/** - * A {@link Filter} that accepts only instances of {@link SBase} whose SBO term - * field is set to a certain value of interest. - * - * @author Andreas Dräger - * @date 2010-05-26 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class SBOFilter implements Filter { - - /** - * The SBO term of interest. - */ - private int term; - - /** - * Generates a new Filter for SBO terms but with an invalid SBO term as - * filter criterion. - */ - public SBOFilter() { - this(-1); - } - - /** - * Creates an SBO term filter with the given term as filter criterion. - * - * @param term - * The term of interest. - */ - public SBOFilter(int term) { - this.term = term; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.util.Filter#accepts(java.lang.Object) - */ - public boolean accepts(Object o) { - if (o instanceof SBase) { - SBase sbase = (SBase) o; - if (sbase.isSetSBOTerm() && (SBO.isChildOf(sbase.getSBOTerm(), term))) { - return true; - } - } - return false; - } - - /** - * @return the term - */ - public int getTerm() { - return term; - } - - /** - * @param term - * the term to set - */ - public void setTerm(int term) { - this.term = term; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/SpeciesReferenceFilter.java b/IPK_lib/src/org/sbml/jsbml/util/filters/SpeciesReferenceFilter.java deleted file mode 100644 index 54033d9c5..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/SpeciesReferenceFilter.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * $Id: SpeciesReferenceFilter.java,v 1.1 2012-11-07 14:43:32 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/util/filters/SpeciesReferenceFilter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.util.filters; - -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; - -/** - * This is a special {@link NameFilter} that allows users to search for a - * {@link SimpleSpeciesReference} that refers to a {@link Species} with the - * given identifier attribute. The boolean switch {@link #filterForSpecies} that - * can be changed using the {@link #setFilterForSpecies(boolean)} method decides - * whether this {@link SpeciesReferenceFilter} should use the given identifier - * to filter for the actual {@link SimpleSpeciesReference} or for the referenced - * {@link Species}. - * - * @author Andreas Dräger - * @date 2010-11-10 - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class SpeciesReferenceFilter extends NameFilter { - - /** - * Decides whether to filter for the identifier of the referenced - * {@link Species} or if to use id and name to filter for the instance of - * {@link SimpleSpeciesReference} itself. - */ - private boolean filterForSpecies = false; - - /** - * Creates a new {@link SpeciesReferenceFilter} with undefined properties. - */ - public SpeciesReferenceFilter() { - super(); - } - - /** - * Creates a new {@link SpeciesReferenceFilter} that only accepts instances of - * {@link SpeciesReference} pointing to the id of the given {@link Species}. - * - * @param species - * the {@link Species} of interest. - */ - public SpeciesReferenceFilter(Species species) { - this(species.getId(), species.getName()); - setFilterForSpecies(true); - } - - /** - * @param id - * the identifier of a {@link Species} or {@link SpeciesReference} we - * are interested in. Whether we accept the id of a {@link Species} or - * a {@link SpeciesReference} depends on the flag that can be defined - * with {@link #setFilterForSpecies(boolean)}. - * @see #setFilterForSpecies(boolean) - */ - public SpeciesReferenceFilter(String id) { - super(id); - } - - /** - * @param id - * the identifier of a {@link Species} or {@link SpeciesReference} we - * are interested in. Whether we accept the id of a {@link Species} or - * a {@link SpeciesReference} depends on the flag that can be defined - * with {@link #setFilterForSpecies(boolean)}. - * @param name - * the name of the element we are interested in. - * @see #setFilterForSpecies(boolean) - */ - public SpeciesReferenceFilter(String id, String name) { - super(id, name); - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.util.filters.Filter#accepts(java.lang.Object) - */ - @Override - public boolean accepts(Object o) { - if (!filterForSpecies) { - return super.accepts(o); - } - if (o instanceof SimpleSpeciesReference) { - SimpleSpeciesReference specRef = (SimpleSpeciesReference) o; - if (specRef.isSetSpecies() && (id != null) - && specRef.getSpecies().equals(id)) { - return true; - } - } - return false; - } - - /** - * @return the filterForSpecies - */ - public boolean isFilterForSpecies() { - return filterForSpecies; - } - - /** - * @param filterForSpecies - * the filterForSpecies to set - */ - public void setFilterForSpecies(boolean filterForSpecies) { - this.filterForSpecies = filterForSpecies; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/util/filters/package.html b/IPK_lib/src/org/sbml/jsbml/util/filters/package.html deleted file mode 100644 index afc07193c..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/filters/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - Filter are useful to decide whether or not to accept a certain item. - All classes in this package implement the interface Filter that can - be used to, e.g., select entries from a ListOf object. - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/util/package.html b/IPK_lib/src/org/sbml/jsbml/util/package.html deleted file mode 100644 index d91cc94e4..000000000 --- a/IPK_lib/src/org/sbml/jsbml/util/package.html +++ /dev/null @@ -1,4 +0,0 @@ - - A collection of handy utilities when working with JSBML classes, - such as classes for String manipulation or mathematical operations. - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/validator/ModelOverdeterminedException.java b/IPK_lib/src/org/sbml/jsbml/validator/ModelOverdeterminedException.java deleted file mode 100644 index 192cab7e1..000000000 --- a/IPK_lib/src/org/sbml/jsbml/validator/ModelOverdeterminedException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * $Id: ModelOverdeterminedException.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/validator/ModelOverdeterminedException.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.validator; - -/** - * This class represents an exception that is thrown when the model to be - * simulated is overdetermined - * - * @author Alexander Dörr - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class ModelOverdeterminedException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -5288546434951201722L; - - /** - * - */ - public ModelOverdeterminedException() { - super(); - } - - /** - * @param message - */ - public ModelOverdeterminedException(String message) { - super(message); - } - - /** - * @param message - * @param cause - */ - public ModelOverdeterminedException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param cause - */ - public ModelOverdeterminedException(Throwable cause) { - super(cause); - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/validator/OverdeterminationValidator.java b/IPK_lib/src/org/sbml/jsbml/validator/OverdeterminationValidator.java deleted file mode 100644 index 932b0f775..000000000 --- a/IPK_lib/src/org/sbml/jsbml/validator/OverdeterminationValidator.java +++ /dev/null @@ -1,974 +0,0 @@ -/* - * $Id: OverdeterminationValidator.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/validator/OverdeterminationValidator.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.validator; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; - -import javax.swing.tree.TreeNode; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; - -/** - * This class creates a bipartite graph and a matching for the given model using - * the algorithm by Hopcroft and Karp (1973). - * - * @author Alexander Dörr - * @date 2010-06-17 - * @since 0.8 - * @version $Rev: 1233 $ - */ -public class OverdeterminationValidator { - - /** - * This class represents an inner node in the bipartite graph, e.g., a - * varibale or an reaction - * - * @author Alexander Dörr - * @since 1.4 - */ - private class InnerNode implements Node { - /** - * Adjacent nodes - */ - private List> nodes; - /** - * Value of this Node - */ - private T value; - - /** - * Creates a new inner node - * - * @param name - */ - public InnerNode(T name) { - this.nodes = new ArrayList>(); - this.value = name; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#addNode( - * org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void addNode(Node node) { - this.nodes.add(node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#deleteNode - * (org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void deleteNode(Node node) { - nodes.remove(node); - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNextNode - * () - */ - public Node getNextNode() { - if (nodes.isEmpty()) { - return null; - } else { - return nodes.get(0); - } - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNode(int) - */ - public Node getNode(int i) { - if (nodes.size() > i && i >= 0) { - return nodes.get(i); - } else { - return null; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNodes() - */ - public List> getNodes() { - return this.nodes; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getValue() - */ - public T getValue() { - return value; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return getValue().toString(); - } - - } - - /** - * This Interface represents a node in the bipartite graph - * - * @author Alexander Dörr - * - * @param - */ - private interface Node { - /** - * Adds a node to the list of nodes (creates an edge from this node to - * another one) - * - * @param node - */ - public void addNode(Node node); - - /** - * Deletes node from the list of adjacent nodes - * - * @param node - */ - public void deleteNode(Node node); - - /** - * Returns the next node in the list of nodes - * - * @return - */ - public Node getNextNode(); - - /** - * Returns the i-th node in the list of nodes - * - * @return - */ - public Node getNode(int i); - - /** - * Returns the list of adjacent nodes - * - * @return - */ - public List> getNodes(); - - /** - * Returns the value of this node - * - * @return - */ - public S getValue(); - } - - /** - * This class represents the start node in the bipartite graph - * - * @author Alexander Dörr - * @param - */ - private class StartNode implements Node { - /** - * - */ - private List> nodes; - - /** - * Creates a new start node - */ - public StartNode() { - this.nodes = new ArrayList>(); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#addNode( - * org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void addNode(Node node) { - this.nodes.add(node); - } - - /** - * Clones this Graph without terminal node - */ - @Override - public StartNode clone() { - StartNode start = new StartNode(); - Node ln, rn, rnode, lnode; - int index; - HashMap> variables = new HashMap>(); - // for all adjacent nodes (equation) - for (int i = 0; i < this.nodes.size(); i++) { - lnode = this.getNode(i); - ln = new InnerNode(lnode.getValue()); - start.addNode(ln); - index = 0; - rnode = lnode.getNode(index); - // for every variable adjacent to lnode - while (rnode != null) { - // check if variable has already been created - if (variables.get(rnode.getValue()) != null) { - rn = variables.get(rnode.getValue()); - } else { - rn = new InnerNode(rnode.getValue()); - variables.put(rnode.getValue(), rn); - } - - // link equation with variable and vice versa - ln.addNode(rn); - rn.addNode(ln); - index++; - rnode = lnode.getNode(index); - } - } - return start; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#deleteNode - * (org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void deleteNode(Node node) { - nodes.remove(node); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNextNode - * () - */ - public Node getNextNode() { - if (nodes.isEmpty()) { - return null; - } else { - return nodes.get(0); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNode(int) - */ - public Node getNode(int i) { - if (nodes.size() > i && i >= 0) { - return nodes.get(i); - } else { - return null; - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNodes() - */ - public List> getNodes() { - return this.nodes; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getValue() - */ - public T getValue() { - return null; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "start"; - } - - } - - /** - * This class represents the end node in the bipartite graph - * - * @author Alexander Dörr - * @since 1.4 - */ - private class TerminalNode implements Node { - - /** - * Creates a new terminal node - */ - public TerminalNode() { - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#addNode( - * org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void addNode(Node node) { - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#deleteNode - * (org.sbml.jsbml.validator.OverdeterminationValidator.Node) - */ - public void deleteNode(Node node) { - - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNextNode - * () - */ - public Node getNextNode() { - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNode(int) - */ - public Node getNode(int i) { - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getNodes() - */ - public List> getNodes() { - return null; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.validator.OverdeterminationValidator.Node#getValue() - */ - public T getValue() { - return null; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "end"; - } - - } - - /** - * List with nodes representing an equation in the model - */ - private List> equations; - /** - * List with nodes representing an variable in the model - */ - private List> variables; - /** - * HashMap with id -> node for variables - */ - private HashMap> variableHash; - /** - * HashMap with id -> node for equations - */ - private HashMap> equationHash; - /** - * HashMap representing the current matching with value of the left node -> - * value of the right node - */ - private Map matching; - /** - * The source node of the bipartite graph, respectively the bipartite graph - */ - private StartNode bipartiteGraph; - /** - * A list where the ids of all global species in an MathML expression are - * saved temporarily - */ - private List svariables; - /** - * A list of all paths of a certain length in the graph - */ - private List>> paths; - /** - * A set with the ids of all reactants in the model - */ - private Set reactants; - /** - * The given SBML model - */ - private Model model; - - /** - * Creates a new OverdeterminationValidator for the given model - * - * @param model - */ - public OverdeterminationValidator(Model model) { - this.model = model; - init(); - } - - /** - * Improves the matching as far as possible with augmenting paths - */ - private void augmentMatching() { - paths = new ArrayList>>(); - int length = 1; - - while (length < (variables.size() + equations.size())) { - // Start search for all path of the current length of the adjacent - // nodes of the start node - for (Node node : bipartiteGraph.getNodes()) { - findShortestPath(length, node, new ArrayList>()); - } - - // Try to augment every found path - augmentPath(length); - - // Matching is already maximal or there is no maximal matching - // (length of the next path would be greater than the longest - // possible path in the graph) - if (matching.size() == equations.size() - || length > equations.size() * 2 - 3) { - break; - } - - // Increment length by 2 because last edge has to be a matching - length = length + 2; - } - - } - - /** - * Tries augment every path found in the graph to a new path of the given - * length + 2 (a new node at the beginning and the end of the path) - * - * @param length - */ - private void augmentPath(int length) { - Node start = null, end = null; - List> path; - - // For every path of the current length - while (!paths.isEmpty()) { - path = paths.get(0); - // Search for the start node of the path an unmatched adjacent node - for (Node node : path.get(0).getNodes()) { - // New start node not part of a matching - if (!matching.containsValue(node.getValue())) { - start = node; - break; - } - } - - // Search for the end node of the path an unmatched adjacent node - for (Node node : path.get(path.size() - 1).getNodes()) { - - // New end node not part of a matching - if (!matching.containsKey(node.getValue())) { - end = node; - break; - } - - } - // New start and end node for this path found -> update path - if (start != null && end != null) { - path.add(0, start); - path.add(path.size(), end); - - // Update matching - updateMatching(path); - } - - // Path Augmented -> remove from the list - paths.remove(path); - start = null; - end = null; - } - } - - /** - * Build the bipartite graph by reference to SBML specification level 3 - * version 1 Core - */ - private void buildGraph() { - equations = new ArrayList>(); - variables = new ArrayList>(); - variableHash = new HashMap>(); - equationHash = new HashMap>(); - Node equation; - Node variable; - int i; - - // Build vertices for compartments and hash them - for (Compartment c : model.getListOfCompartments()) { - if ((model.getLevel()==1) || !(c.isConstant())) { - variable = new InnerNode(c); - variables.add(variable); - variableHash.put(variable.getValue(), variable); - } - } - // Build vertices for species and hash them - for (Species s : model.getListOfSpecies()) { - if (!s.isConstant()) { - variable = new InnerNode(s); - variables.add(variable); - variableHash.put(variable.getValue(), variable); - } - } - // Build vertices for parameter and hash them - for (Parameter p : model.getListOfParameters()) { - if (!p.isConstant()) { - variable = new InnerNode(p); - variables.add(variable); - variableHash.put(variable.getValue(), variable); - } - } - - // Build vertices for reaction and hash them - for (Reaction r : model.getListOfReactions()) { - variable = new InnerNode(r); - variables.add(variable); - variableHash.put(variable.getValue(), variable); - } - - // Create edges with reactions - for (i = 0; i < model.getReactionCount(); i++) { - Reaction r = model.getReaction(i); - - // Create vertices and edges for products - for (SpeciesReference sref : r.getListOfProducts()) { - if (!sref.getSpeciesInstance().isConstant()) { - variable = variableHash.get(sref.getSpeciesInstance()); - if (!sref.getSpeciesInstance().getBoundaryCondition()) { - - equation = equationHash.get(sref.getSpeciesInstance()); - if (equation == null) { - equation = new InnerNode(sref - .getSpeciesInstance()); - equations.add(equation); - equationHash.put(sref.getSpeciesInstance(), - equation); - // link - variable.addNode(equation); - equation.addNode(variable); - variableHash.put(variable.getValue(), variable); - - } - } - } - } - - // Create vertices and edges for reactants - for (SpeciesReference sref : r.getListOfReactants()) { - - if (!sref.getSpeciesInstance().isConstant()) { - variable = variableHash.get(sref.getSpeciesInstance()); - if (!sref.getSpeciesInstance().getBoundaryCondition()) { - - equation = equationHash.get(sref.getSpeciesInstance()); - if (equation == null) { - equation = new InnerNode(sref - .getSpeciesInstance()); - equations.add(equation); - equationHash.put(sref.getSpeciesInstance(), - equation); - // link - variable.addNode(equation); - equation.addNode(variable); - variableHash.put(variable.getValue(), variable); - - } - } - } - } - // link reaction with its kinetic law - equation = new InnerNode(r); - equations.add(equation); - variable = variableHash.get(equation.getValue()); - - variable.addNode(equation); - equation.addNode(variable); - - } - - // Create vertices and edges for assignment and rate rules - for (i = 0; i < model.getRuleCount(); i++) { - equation = new InnerNode(model.getRule(i)); - Rule r = model.getRule(i); - if (r instanceof RateRule) { - equations.add(equation); - variable = variableHash.get(((RateRule) r) - .getVariableInstance()); - // link - variable.addNode(equation); - equation.addNode(variable); - - } - - else if (r instanceof AssignmentRule) { - variable = variableHash.get(((AssignmentRule) r) - .getVariableInstance()); - // link - if(variable!=null) { - equations.add(equation); - variable.addNode(equation); - equation.addNode(variable); - } - - } - } - - // Create vertices and edges for algebraic rules - for (i = 0; i < model.getRuleCount(); i++) { - equation = new InnerNode(model.getRule(i)); - Rule r = model.getRule(i); - if (r instanceof AlgebraicRule) { - equations.add(equation); - // all identifiers withn the MathML of this AlgebraicRule - svariables.clear(); - getVariables(null, model.getRule(i).getMath(), svariables, model.getLevel()); - // link rule with its variables - for (int j = 0; j < svariables.size(); j++) { - variable = variableHash.get(svariables.get(j)); - if (variable != null) { - variable.addNode(equation); - equation.addNode(variable); - } - } - } - } - } - - /** - * Build the maximum matching with the greedy algorithm from the Hopcroft - * and Karp paper. Matching is not necessarily maximal. - */ - private void buildMatching() { - StartNode matchingGraph; - // the source node - matchingGraph = new StartNode(); - // the sink node - TerminalNode tnode = new TerminalNode(); - matching = new HashMap(); - Set> B = new HashSet>(); - Stack> stack = new Stack>(); - Node first, last; - int i; - - // connect equations with source node - for (i = 0; i < equations.size(); i++) { - matchingGraph.addNode(equations.get(i)); - } - // connect equations with sink node - for (i = 0; i < variables.size(); i++) { - variables.get(i).addNode(tnode); - } - - bipartiteGraph = matchingGraph.clone(); - - // push source node on the stack - stack.push(matchingGraph); - - while (!stack.isEmpty()) { - - // if node on stack has linked node - if (stack.peek().getNextNode() != null) { - // get first linked node - first = stack.peek().getNextNode(); - // if node not already in the matching - if (!B.contains(first)) { - // delete connection - stack.peek().deleteNode(first); - first.deleteNode(stack.peek()); - // push first on stack - stack.push(first); - - // if first not the sink node add to the matching - if (!(stack.peek() instanceof TerminalNode)) { - B.add(first); - }// first is sink node - else { - // remove sink node - stack.pop(); - // build matching between 2 neighbouring in the list and - // leave source node on the stack - while (stack.size() > 1) { - last = stack.pop(); - matching.put(stack.pop().getValue(), last - .getValue()); - } - } - - } // else delete connection - else { - stack.peek().deleteNode(first); - first.deleteNode(stack.peek()); - } - - }// else remove from stack - else { - stack.pop(); - } - - } - - } - - /** - * Finds all paths of the length i whose nodes are part of the matching. - * - * @param i - * length - * @param node - * next node - * @param path - * nodes already visited in the path - */ - @SuppressWarnings("unchecked") - private void findShortestPath(int i, Node node, - List> path) { - SBase value; - // Path has reached the desired length -> store it in the list - if (path.size() == i * 2) { - paths.add(path); - } else { - value = matching.get(node.getValue()); - // Search for the adjacent node convenient with the current matching - for (Node next : node.getNodes()) { - if (next.getValue() == value) { - path.add(node); - path.add(next); - // Edge saved in the path -> carry on with every adjacent - // node of the last node in the path - for (Node nextnext : next.getNodes()) { - if (nextnext.getValue() != node.getValue()) { - findShortestPath( - i, - nextnext, - (List>) ((ArrayList>) path) - .clone()); - } - } - } - } - } - } - - /** - * Returns the determined matching - * - * @return - */ - public Map getMatching() { - return matching; - } - - /** - * Returns the variables in a MathML object without local parameter - * - * @param param - * @param node - * @param variables - */ - private void getVariables(ListOf param, ASTNode node, - List variables, int level) { - // found node with species - if ((node.getChildCount() == 0) && (node.isString()) && (node.getType() != Type.NAME_TIME) && (node.getType() != Type.NAME_AVOGADRO)) { - if (!node.isConstant()) { - if (param == null) { - SBase variable=node.getVariable(); - if(level==1) { - int insertingPosition=0; - for(SBase element:variables) { - if(!(element instanceof Parameter) || (!((Parameter)element).isSetValue())) { - insertingPosition++; - } - } - variables.add(insertingPosition, variable); - } - else { - variables.add(variable); - } - } else { - if (!param.contains(node.getVariable())) { - SBase variable=node.getVariable(); - if(level==1) { - int insertingPosition=0; - for(SBase element:variables) { - if(!(element instanceof Parameter) || (!((Parameter)element).isSetValue())) { - insertingPosition++; - } - } - variables.add(insertingPosition, variable); - } - else { - variables.add(variable); - } - } - } - } - } - - // else found operator or function - else { - // carry on with all children - Enumeration nodes = node.children(); - while (nodes.hasMoreElements()) { - getVariables(param, (ASTNode) nodes.nextElement(), variables, level); - } - } - - } - - /** - * Initializes the Converter - */ - private void init() { - this.svariables = new ArrayList(); - this.reactants = new HashSet(); - - for (int i = 0; i < model.getReactionCount(); i++) { - - for (SpeciesReference sref : model.getReaction(i) - .getListOfProducts()) { - reactants.add(sref.getSpecies()); - } - - for (SpeciesReference sref : model.getReaction(i) - .getListOfReactants()) { - reactants.add(sref.getSpecies()); - } - - } - - // Build the graph the matching and try to improve the matching - buildGraph(); - buildMatching(); - augmentMatching(); - - } - - /** - * Returns a boolean that indicates whether the given model is over - * determined or not. - * - * @return - */ - public boolean isOverdetermined() { - return equations.size() > matching.size(); - } - - /** - * Updates the matching of the model on the basis of the found augmented - * path. Please note that because of starting the search for a path through - * the graph at an equation, the first node in the augmented path is always - * a variable and the last one an equation. - * - * @param path - */ - private void updateMatching(List> path) { - int index; - index = 1; - while (path.size() > index) { - matching.remove(path.get(index).getValue()); - matching.put(path.get(index).getValue(), path.get(index - 1) - .getValue()); - index = index + 2; - - } - - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/validator/SBMLValidator.java b/IPK_lib/src/org/sbml/jsbml/validator/SBMLValidator.java deleted file mode 100644 index 7c0ad0f32..000000000 --- a/IPK_lib/src/org/sbml/jsbml/validator/SBMLValidator.java +++ /dev/null @@ -1,582 +0,0 @@ -/* - * $Id: SBMLValidator.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/validator/SBMLValidator.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.validator; - -/** - * \file validateSBML.java - * \brief Validates an SBML document using the SBML.org Online Validator - * \author Ben Bornstein - * \author Akiya Jouraku - * - * This file is adapted from libSBML by rodrigue - * @since 0.8 - * @version $Rev: 1139 $ - */ -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.Reader; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.SBMLError; -import org.sbml.jsbml.SBMLErrorLog; -import org.sbml.jsbml.util.Detail; -import org.sbml.jsbml.util.Location; -import org.sbml.jsbml.util.Message; -import org.sbml.jsbml.util.Option; -import org.sbml.jsbml.xml.xstream.converter.MessageConverter; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.XStreamException; -import com.thoughtworks.xstream.io.xml.DomDriver; - -/** - * Validator is simply a container for the static method validateSBML(filename, - * parameters). - * - */ -class Validator { - public static String validatorURL = "http://sbml.org/validator/"; - // public static String validatorURL = "http://sbml-validator.caltech.edu:8888/validator_servlet/ValidatorServlet"; - - /** - * Validates the given SBML filename (or http:// URL) by calling the - * SBML.org online validator. The results are returned as an InputStream - * whose format may be controlled by setting parameters.put("output", ...) - * to one of: "xml", "xhtml", "json", "text" (default: xml). - * - * @return an InputStream containing the validation results. - */ - public static InputStream validateSBML(String filename, - Map parameters) throws IOException - { - Logger logger = Logger.getLogger(SBMLValidator.class); - - if (parameters.get("output") == null) { - parameters.put("output", "xml"); - } - - MultipartPost post = new MultipartPost(validatorURL); - - if (filename.startsWith("http://")) { - post.writeParameter("url", filename); - } else { - post.writeParameter("file", new File(filename)); - } - - try { - Iterator iter = parameters.keySet().iterator(); - - while (iter.hasNext()) { - String name = iter.next(); - String value = parameters.get(name); - - logger.debug("Validator.validateSBML : parameter " + name + " = " + value); - - post.writeParameter(name, value); - } - } catch (NoSuchElementException e) { - e.printStackTrace(); - } - - return post.done(); - } -} - -/** - * Performs a Multipart HTTP post to the given URL. A post operation is started - * with the creation of a MultipartPost object. Post parameters are sent with - * writeParameter() and may be either strings or the contents of an XML file. A - * post is finished by calling done() which returns an InputStream for reading - * the servers response. - * - * NOTE: This class is meant to communicate with the SBML.org online validator. - * As such, it assumes uploaded files are XML and always sends a Content-Type: - * text/xml. - */ -class MultipartPost { - public MultipartPost(String url) throws IOException { - Random random = new Random(); - - connection = (new URL(url)).openConnection(); - boundary = "<<" + Long.toString(random.nextLong(), 30); - String type = "multipart/form-data; boundary=" + boundary; - - connection.setDoOutput(true); - connection.setRequestProperty("Content-Type", type); - - stream = connection.getOutputStream(); - } - - public InputStream done() throws IOException { - writeln("--" + boundary + "--"); - writeln(); - - stream.close(); - - return connection.getInputStream(); - } - - public void writeParameter(String name, String value) throws IOException { - writeln("--" + boundary); - writeln("Content-Disposition: form-data; name=\"" + name + "\""); - writeln(); - writeln(value); - } - - public void writeParameter(String name, File file) throws IOException { - String prefix = "Content-Disposition: form-data; name=\"file\"; filename="; - - writeln("--" + boundary); - writeln(prefix + '"' + file.getName() + '"'); - writeln("Content-Type: text/xml"); - writeln(); - - InputStream source = new FileInputStream(file); - copy(source, stream); - - // Adding a line return, otherwise the xml content is considered - // invalid by libsbml - // stream.write(System.getProperty ( "line.separator" ).getBytes()); - writeln(); - - stream.flush(); - source.close(); - } - - void copy(InputStream source, OutputStream destination) throws IOException { - byte[] buffer = new byte[8192]; - int nbytes = 0; - - while ((nbytes = source.read(buffer, 0, buffer.length)) >= 0) { - destination.write(buffer, 0, nbytes); - } - } - - void writeln(String s) throws IOException { - write(s); - writeln(); - } - - void writeln() throws IOException { - write('\r'); - write('\n'); - } - - void write(char c) throws IOException { - stream.write(c); - } - - void write(String s) throws IOException { - stream.write(s.getBytes()); - } - - URLConnection connection; - OutputStream stream; - String boundary; -} - -/** - * Validates the SBML document given by filename.xml or located at the http:// - * URL. Output-format will always be xml - *

    - * usage: java org.sbml.jsbml.validator.SBMLValidator [-h] [-d opt1[,opt2,...]] - * filename.xml - *
    - * usage: java validateSBML [-h] [-d opt1[,opt2,...]] http://... - * - * - */ -public class SBMLValidator { - - static void usage() { - String usage = "usage: java org.sbml.jsbml.validator.SBMLValidator [-h] [-d opt1[,opt2,...]] filename.xml\n" - + "usage: java org.sbml.jsbml.validator.SBMLValidator [-h] [-d opt1[,opt2,...]] http://..." - + "\n\n" - + " Validates the SBML document given by filename.xml or located at\n" - + " the http:// URL." - + "\n\n" - + "Options:\n\n" - + " -d opt1[,opt2,...]\n" - + " Disable the given consistency check options.\n" - + " The options are given as comma-separated characters.\n" - + " Each character is one of the followings:\n\n" - + " u : disable the units consistency check\n" - + " g : disable the overall SBML consistency check\n" - + " i : disable the identifier consistency check\n" - + " m : disable the MathML consistency check\n" - + " s : disable the SBO consistency check\n" - + " o : disable the overdetermined model check\n" - + " p : disable the modeling practice check\n\n" - + " -h : Print this usage and exit.\n"; - - System.out.println(usage); - System.exit(1); - } - - /** - * - * @param args - */ - public static void main(String[] args) { - String filename = null; - String output = "xml"; - String offcheck = "u"; - - /** - * - * Parse the command-line arguments. - * - */ - for (int i = 0; i < args.length; i++) { - if (args[i].equals("-h")) { - usage(); - } else if (args[i].equals("-o")) { - if ((i + 1) >= args.length) { - usage(); - } - - Pattern p = Pattern.compile("(xml|xhtml|json|text)"); - Matcher m = p.matcher(args[i + 1]); - if (!m.matches()) { - usage(); - } - - output = args[++i]; - } else if (args[i].equals("-d")) { - if ((i + 1) >= args.length) { - usage(); - } - Pattern p = Pattern.compile("[a-zA-Z](,[a-zA-Z])*"); - Matcher m = p.matcher(args[i + 1]); - if (!m.matches()) { - usage(); - } - - offcheck = args[++i]; - } else if (args[i].startsWith("-")) { - // invalid option - usage(); - } else { - // currently only one filename (url) can be given. - - filename = args[i]; - - if ((i + 1) < args.length) { - // usage(); - break; - } - - } - } - - if (filename == null) { - usage(); - } - - HashMap parameters = new HashMap(); - parameters.put("output", output); - parameters.put("offcheck", offcheck); - - System.out.println("Validating " + filename + "\n"); - - SBMLErrorLog sbmlErrorLog = checkConsistency(filename, parameters); - - System.out.println("There is " + sbmlErrorLog.getErrorCount() + " errors in the model.\n"); - - // printErrors - for (int j = 0; j < sbmlErrorLog.getErrorCount(); j++) { - SBMLError error = sbmlErrorLog.getError(j); - - System.out.println(error.toString() + "\n"); - } - } - - static void print(InputStream source, OutputStream destination) - throws IOException { - byte[] buffer = new byte[8192]; - int nbytes = 0; - - while ((nbytes = source.read(buffer, 0, buffer.length)) >= 0) { - destination.write(buffer, 0, nbytes); - } - - destination.flush(); - source.reset(); - } - - static void print(Reader source, Writer destination) - throws IOException - { - char[] buffer = new char[8192]; - int nbChar = 0; - - while ((nbChar = source.read(buffer, 0, buffer.length)) >= 0) { - destination.write(buffer, 0, nbChar); - } - - destination.flush(); - } - - - /** - * Validates an SBML model using the - * SBML.org online validator (http://sbml.org/validator/). - * - *

    - * You can control the consistency checks that are performed when - * {@link #checkConsistency()} is called with the {@link HashMap} of - * parameters given. - * It will fill the {@link SBMLErrorLog} - * with {@link SBMLError}s for each problem within this whole model. - * - *

    - * If this method returns a non empty {@link SBMLErrorLog}, the failures may be - * due to warnings @em or errors. Callers should inspect the severity - * flag in the individual SBMLError objects to determine the nature of the failures. - * - * @param fileName a file name - * @param parameters parameters for the libsbml checkConsistency() - * @return an {@link SBMLErrorLog} containing the list of errors. - * - * @see sbml.org Validator Web API - */ - public static SBMLErrorLog checkConsistency(String fileName, HashMap parameters) - { - Logger logger = Logger.getLogger(SBMLValidator.class); - - try { - Reader result = null; - - // We force the output to be xml - String output = "xml"; - parameters.put("output", output); - - logger.debug("Calling the sbml.org Web Validator."); - - logger.debug("offcheck = @" + parameters.get("offcheck") + "@"); - - // getting an XML output of the error log - // describe there : - // http://sbml.org/Facilities/Validator/Validator_Web_API - result = new InputStreamReader(Validator.validateSBML(fileName, parameters)); - - String resultString = new String(); - StringWriter out = new StringWriter(); - print(result, out); - - resultString = out.toString(); - - String xmlValidationString = resultString; - - return SBMLValidator.checkConsistency(xmlValidationString); - - } catch (Exception e) { - - } - - return null; - } - - - /** - * Parses the XML String returned by the libSBML online validator or web services. - * - *

    - * It will fill the {@link SBMLErrorLog} - * with {@link SBMLError}s for each problem within this whole model. - * - *

    - * If this method returns a non empty {@link SBMLErrorLog}, the failures may be - * due to warnings @em or errors. Callers should inspect the severity - * flag in the individual SBMLError objects to determine the nature of the failures. - * - * @param fileName a file name - * @param parameters parameters for the libsbml checkConsistency() - * @return an {@link SBMLErrorLog} containing the list of errors. - * - * @see sbml.org Validator Web API - */ - public static SBMLErrorLog checkConsistency(String xmlValidationString) - { - Logger logger = Logger.getLogger(SBMLValidator.class); - - if (xmlValidationString == null || xmlValidationString.trim().length() == 0) { - return new SBMLErrorLog(); - } - - StringReader reader = new StringReader(xmlValidationString); - - // DEBUG - logger.debug(xmlValidationString); - - // Defining all the rules to parse the XML - XStream xstream = new XStream(new DomDriver()); // To parse XML using DOM - // XStream xstream = new XStream(new StaxDriver()); // To parse XML using Stax - - xstream.alias("validation-results", SBMLErrorLog.class); - xstream.alias("option", Option.class); - xstream.alias("problem", SBMLError.class); - xstream.alias("location", Location.class); - xstream.alias("detail", Detail.class); - // xstream.registerConverter(new MessageConverter(), XStream.PRIORITY_VERY_HIGH); - xstream.registerLocalConverter(SBMLError.class, "message", new MessageConverter("message")); - xstream.registerLocalConverter(SBMLError.class, "shortmessage", new MessageConverter("shortmessage")); - - xstream.alias("message", Message.class); - xstream.alias("shortmessage", Message.class); - - xstream.addImplicitCollection(SBMLErrorLog.class, "options", - "option", Option.class); - xstream.addImplicitCollection(SBMLErrorLog.class, - "validationErrors", "problem", SBMLError.class); - - xstream.aliasField("error", SBMLErrorLog.class, "status"); - xstream.aliasField("warning", SBMLErrorLog.class, "status"); - xstream.aliasField("no-errors", SBMLErrorLog.class, "status"); - xstream.aliasField("file-not-readable", SBMLErrorLog.class, "status"); - xstream.aliasField("out-of-memory", SBMLErrorLog.class, "status"); - xstream.aliasField("segmentation-fault", SBMLErrorLog.class, "status"); - xstream.aliasField("internal-error", SBMLErrorLog.class, "status"); - - xstream.useAttributeFor(File.class); - - xstream.useAttributeFor(Option.class, "name"); - xstream.useAttributeFor(Option.class, "status"); - - xstream.useAttributeFor(SBMLError.class, "category"); - xstream.useAttributeFor(SBMLError.class, "code"); - xstream.useAttributeFor(SBMLError.class, "severity"); - - xstream.useAttributeFor(Location.class, "line"); - xstream.useAttributeFor(Location.class, "column"); - - xstream.useAttributeFor(Detail.class, "category"); - xstream.useAttributeFor(Detail.class, "severity"); - - try { - SBMLErrorLog sbmlErrorLog = (SBMLErrorLog) xstream.fromXML(reader); - - logger.debug("Call and Parsing of the results done !!!"); - - // logger.debug("File = " + resultsObj.getFile().getName()); - - // logger.debug("Nb Options = " + resultsObj.getOptions().size()); - // logger.debug(resultsObj.getOptions()); - - logger.debug("Nb Problems = " + sbmlErrorLog.getValidationErrors().size()); - - if (sbmlErrorLog.getValidationErrors().size() > 0) { - logger.debug("ValidationError(0) = " + sbmlErrorLog.getValidationErrors().get(0)); - } - - return sbmlErrorLog; - } catch (XStreamException e) { - logger.error("There has been an error parsing the consistency check XML result : " + e.getMessage()); - - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - } - - return new SBMLErrorLog(); - } - - /** - * Enumerates the different possible check categories - * when performing the validation of an SBML document. - * - */ - public static enum CHECK_CATEGORY - { - /** - * Correctness and consistency of specific SBML language constructs. - * Performing this set of checks is highly recommended. With respect to - * the SBML specification, these concern failures in applying the - * validation rules numbered 2xxxx in the Level 2 or Level 3 specifications. - */ - GENERAL_CONSISTENCY, - - /** - * Correctness and consistency of identifiers used for model entities. - * An example of inconsistency would be using a species identifier in a - * reaction rate formula without first having declared the species. With - * respect to the SBML specification, these concern failures in applying - * the validation rules numbered 103xx in the Level 2 or Level 3 specifications. - */ - IDENTIFIER_CONSISTENCY, - - /** - * Consistency and validity of SBO identifiers (if any) used in the - * model. With respect to the SBML specification, these concern failures - * in applying the validation rules numbered 107xx in the Level 2 or - * Level 3 specifications. - */ - SBO_CONSISTENCY, - - /** - * Syntax of MathML constructs. With respect to the SBML specification, - * these concern failures in applying the validation rules numbered 102xx - * in the Level 2 or Level 3 specifications. - */ - MATHML_CONSISTENCY, - - /** - * Consistency of measurement units associated with quantities in a - * model. With respect to the SBML specification, these concern failures - * in applying the validation rules numbered 105xx in the Level 2 or - * Level 3 specifications. - */ - UNITS_CONSISTENCY, - - /** - * Static analysis of whether the system of equations implied by a model - * is mathematically overdetermined. With respect to the SBML - * specification, this is validation rule #10601 in the SBML Level 2 or - * Level 3 specifications. - */ - OVERDETERMINED_MODEL, - - /** - * Additional checks for recommended good modeling practice. (These are - * tests performed by libSBML - * and do not have equivalent SBML validation rules.) - */ - MODELING_PRACTICE - }; - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/validator/package.html b/IPK_lib/src/org/sbml/jsbml/validator/package.html deleted file mode 100644 index cc2ad53a3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/validator/package.html +++ /dev/null @@ -1,6 +0,0 @@ - -

    - This package provides methods to validate the content of SBML models, whether - given in a file or as a data structure. -

    - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLAttributes.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLAttributes.java deleted file mode 100644 index 0933d9348..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLAttributes.java +++ /dev/null @@ -1,760 +0,0 @@ -/* - * $Id: XMLAttributes.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLAttributes.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - -import java.util.ArrayList; - -import org.sbml.jsbml.JSBML; - -/** - * Representation of the attributes on an XML node. - *

    - * - * This class of objects is defined by jsbml only and has no direct - * equivalent in terms of SBML components. This class is not prescribed by - * the SBML specifications, although it is used to implement features - * defined in SBML. - * - * - *

    - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLAttributes { - - ArrayList attributeNames = new ArrayList(); - ArrayList attributeValues = new ArrayList(); - - // XMLErrorLog errorLog; - - /** - * Equality comparison method for XMLAttributes. - * - * @param sb a reference to an object to which the current object - * instance will be compared - * - * @return true if sb refers to the same underlying - * native object as this one, false otherwise - */ - public boolean equals(Object sb) - { - if (sb instanceof XMLAttributes) { - XMLAttributes xmlAttributes = (XMLAttributes) sb; - - for (XMLTriple xmlTriple : attributeNames) { - if (!xmlAttributes.hasAttribute(xmlTriple)) { - return false; - } - String value = getValue(xmlTriple); - String value2 = xmlAttributes.getValue(xmlTriple); - if (!value.equals(value2)) { - return false; - } - } - - return true; - } - - return false; - } - - /** - * Returns a hashcode for this XMLAttributes object. - * - * @return a hash code usable by Java methods that need them. - */ - public int hashCode() - { - int hashcode = 0; - - for (int i = 0; i < attributeNames.size(); i++) { - hashcode += attributeNames.get(i).hashCode() + attributeValues.get(i).hashCode(); - } - - return hashcode; - } - - - /** - * Creates a new empty {@link XMLAttributes} set. - */ - public XMLAttributes() { - - } - - - /** - * Copy constructor; creates a copy of this {@link XMLAttributes} set. - */ - public XMLAttributes(XMLAttributes orig) { - - for (int i = 0; i < orig.attributeNames.size(); i++) { - - attributeNames.add(orig.attributeNames.get(i).clone()); - attributeValues.add(new String(orig.attributeValues.get(i))); - } - - } - - - /** - * Creates and returns a deep copy of this {@link XMLAttributes} set. - *

    - * @return a (deep) copy of this {@link XMLAttributes} set. - */ - public XMLAttributes clone() { - return new XMLAttributes(this); - } - - - /** - * Adds an attribute (a name/value pair) to this {@link XMLAttributes} set optionally - * with a prefix and URI defining a namespace. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - * @param namespaceURI a string, the namespace URI of the attribute. - * @param prefix a string, the prefix of the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - * @jsbml.note if local name with the same namespace URI already exists in this - * attribute set, its value and prefix will be replaced. - *

    - */ - public int add(String name, String value, String namespaceURI, String prefix) { - - attributeNames.add(new XMLTriple(name, namespaceURI, prefix)); - attributeValues.add(value); - - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Adds an attribute (a name/value pair) to this {@link XMLAttributes} set optionally - * with a prefix and URI defining a namespace. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - * @param namespaceURI a string, the namespace URI of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - * @jsbml.note if local name with the same namespace URI already exists in this - * attribute set, its value and prefix will be replaced. - *

    - */ - public int add(String name, String value, String namespaceURI) { - - attributeNames.add(new XMLTriple(name, namespaceURI, null)); - attributeValues.add(value); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Adds an attribute (a name/value pair) to this {@link XMLAttributes} set optionally - * with a prefix and URI defining a namespace. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - * @jsbml.note if local name with the same namespace URI already exists in this - * attribute set, its value and prefix will be replaced. - *

    - */ - public int add(String name, String value) { - - attributeNames.add(new XMLTriple(name, null, null)); - attributeValues.add(value); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Adds an attribute with the given {@link XMLTriple}/value pair to this {@link XMLAttributes} set. - *

    - * @jsbml.note if local name with the same namespace URI already exists in this attribute set, - * its value and prefix will be replaced. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute. - * @param value a string, the value of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int add(XMLTriple triple, String value) { - - attributeNames.add(triple); - attributeValues.add(value); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Removes an attribute with the given index from this {@link XMLAttributes} set. - *

    - * @param n an integer the index of the resource to be deleted - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • INDEX_EXCEEDS_SIZE - */ - public int removeResource(int n) { - - if (n < 0 || n >= attributeNames.size()) { - return JSBML.INDEX_EXCEEDS_SIZE; - } - - attributeNames.remove(n); - attributeValues.remove(n); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Removes an attribute with the given index from this {@link XMLAttributes} set. - * (This function is an alias of XMLAttributes.removeResource() ). - *

    - * @param n an integer the index of the resource to be deleted - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • INDEX_EXCEEDS_SIZE - */ - public int remove(int n) { - - return removeResource(n); - } - - - /** - * Removes an attribute with the given local name and namespace URI from - * this {@link XMLAttributes} set. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED; - */ - public int remove(String name, String uri) { - - XMLTriple triple = new XMLTriple(name, uri, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - removeResource(index); - } else { - return JSBML.OPERATION_FAILED; - } - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Removes an attribute with the given local name from - * this {@link XMLAttributes} set. - *

    - * @param name a string, the local name of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED; - */ - public int remove(String name) { - - XMLTriple triple = new XMLTriple(name, null, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - removeResource(index); - } else { - return JSBML.OPERATION_FAILED; - } - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Removes an attribute with the given {@link XMLTriple} from this {@link XMLAttributes} set. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int remove(XMLTriple triple) { - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - removeResource(index); - } else { - return JSBML.OPERATION_FAILED; - } - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Clears (deletes) all attributes in this {@link XMLAttributes} object. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int clear() { - - attributeNames.clear(); - attributeValues.clear(); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Returns the index of an attribute with the given name. - *

    - * @jsbml.note A namespace bound to the name is not checked by this function. - * Thus, if there are multiple attributes with the given local name and - * different namespaces, the smallest index among those attributes will - * be returned. {@link XMLAttributes#getIndex(String name, String uri)} or - * {@link XMLAttributes#getIndex(XMLTriple triple)} should be used to get an index of an - * attribute with the given local name and namespace. - *

    - * @param name a string, the local name of the attribute for which the - * index is required. - *

    - * @return the index of an attribute with the given local name, or -1 if not present. - */ - public int getIndex(String name) { - - XMLTriple triple = new XMLTriple(name, null, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return index; - } - - return -1; - - } - - - /** - * Returns the index of an attribute with the given local name and namespace URI. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return the index of an attribute with the given local name and namespace URI, - * or -1 if not present. - */ - public int getIndex(String name, String uri) { - - XMLTriple triple = new XMLTriple(name, uri, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return index; - } - - return -1; - - } - - - /** - * Returns the index of an attribute with the given {@link XMLTriple}. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute for which - * the index is required. - *

    - * @return the index of an attribute with the given {@link XMLTriple}, or -1 if not present. - */ - public int getIndex(XMLTriple triple) { - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return index; - } - - return -1; - - } - - - /** - * Returns the number of attributes in the set. - *

    - * @return the number of attributes in this {@link XMLAttributes} set. - */ - public int getLength() { - - return attributeNames.size(); - } - - - /** - * Returns the local name of an attribute in this {@link XMLAttributes} set (by position). - *

    - * @param index an integer, the position of the attribute whose local name is - * required. - *

    - * @return the local name of an attribute in this list (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(int index)} to test for the attribute - * existence. - */ - public String getName(int index) { - - if (index < 0 || index >= attributeNames.size()) { - return ""; - } - - return attributeNames.get(index).getName(); - - } - - - /** - * Returns the prefix of an attribute in this {@link XMLAttributes} set (by position). - *

    - * @param index an integer, the position of the attribute whose prefix is - * required. - *

    - * @return the namespace prefix of an attribute in this list (by - * position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(int index)} to test for the attribute - * existence. - */ - public String getPrefix(int index) { - - if (index < 0 || index >= attributeNames.size()) { - return ""; - } - - return attributeNames.get(index).getPrefix(); - - } - - - /** - * Returns the prefixed name of an attribute in this {@link XMLAttributes} set (by position). - *

    - * @param index an integer, the position of the attribute whose prefixed - * name is required. - *

    - * @return the prefixed name of an attribute in this list (by - * position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(int index)} to test for attribute existence. - */ - public String getPrefixedName(int index) { - - if (index < 0 || index >= attributeNames.size()) { - return ""; - } - - XMLTriple triple = attributeNames.get(index); - - return triple.getPrefix().length() == 0 ? triple.getName() : triple.getPrefix() + ":" + triple.getName(); - - } - - - /** - * Returns the namespace URI of an attribute in this {@link XMLAttributes} set (by position). - *

    - * @param index an integer, the position of the attribute whose namespace URI is - * required. - *

    - * @return the namespace URI of an attribute in this list (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(int index)} to test for attribute existence. - */ - public String getURI(int index) { - - if (index < 0 || index >= attributeNames.size()) { - return ""; - } - - return attributeNames.get(index).getURI(); - - } - - - /** - * Returns the value of an attribute in this {@link XMLAttributes} set (by position). - *

    - * @param index an integer, the position of the attribute whose value is - * required. - *

    - * @return the value of an attribute in the list (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(int index)} to test for attribute existence. - */ - public String getValue(int index) { - - if (index < 0 || index >= attributeNames.size()) { - return ""; - } - - return attributeValues.get(index); - - } - - - /** - * Returns an attribute's value by name. - *

    - * @param name a string, the local name of the attribute whose value is required. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the given local name does not exist, an - * empty string will be returned. Use {@link XMLAttributes#hasAttribute(String name, String uri)} - * to test for attribute existence. A namespace bound to the local name - * is not checked by this function. Thus, if there are multiple - * attributes with the given local name and different namespaces, the - * value of an attribute with the smallest index among those attributes - * will be returned. {@link XMLAttributes#getValue(String name)} or - * {@link XMLAttributes#getValue(XMLTriple triple)} should be used to get a value of an - * attribute with the given local name and namespace. - */ - public String getValue(String name) { - XMLTriple triple = new XMLTriple(name, null, null); - int index = attributeNames.indexOf(triple); - return index == -1 ? "" : attributeValues.get(index); - } - - - /** - * Returns a value of an attribute with the given local name and namespace URI. - *

    - * @param name a string, the local name of the attribute whose value is required. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the given local name and namespace URI does - * not exist, an empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(String name, String uri)} - * to test for attribute existence. - */ - public String getValue(String name, String uri) { - - XMLTriple triple = new XMLTriple(name, uri, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return ""; - } - - return attributeValues.get(index); - - } - - - /** - * Returns a value of an attribute with the given {@link XMLTriple}. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute whose - * value is required. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the given {@link XMLTriple} does not exist, an - * empty string will be returned. Use - * {@link XMLAttributes#hasAttribute(XMLTriple triple)} to test for attribute existence. - */ - public String getValue(XMLTriple triple) { - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return ""; - } - - return attributeValues.get(index); - - } - - - /** - * Returns true or false depending on whether - * an attribute with the given index exists in this {@link XMLAttributes}. - *

    - * @param index an integer, the position of the attribute. - *

    - * @return true if an attribute with the given index exists in this - * {@link XMLAttributes}, false otherwise. - */ - public boolean hasAttribute(int index) { - - if (index >= 0 && index < attributeNames.size()) { - return true; - } - - return false; - - } - - - /** - * Returns true or false depending on whether - * an attribute with the given local name and namespace URI exists in this - * {@link XMLAttributes}. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return true if an attribute with the given local name and namespace - * URI exists in this {@link XMLAttributes}, false otherwise. - */ - public boolean hasAttribute(String name, String uri) { - - XMLTriple triple = new XMLTriple(name, uri, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return true; - } - - return false; - - } - - - /** - * Returns true or false depending on whether - * an attribute with the given local name exists in this - * {@link XMLAttributes}. - *

    - * @param name a string, the local name of the attribute. - *

    - * @return true if an attribute with the given local name - * exists in this {@link XMLAttributes}, false otherwise. - */ - public boolean hasAttribute(String name) { - - XMLTriple triple = new XMLTriple(name, null, null); - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return true; - } - - return false; - - } - - - /** - * Returns true or false depending on whether - * an attribute with the given XML triple exists in this {@link XMLAttributes}. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute - *

    - * @return true if an attribute with the given XML triple exists in this - * {@link XMLAttributes}, false otherwise. - *

    - */ - public boolean hasAttribute(XMLTriple triple) { - - int index = attributeNames.indexOf(triple); - - if (index != -1) { - return true; - } - - return false; - - } - - - /** - * Returns true or false depending on whether - * this {@link XMLAttributes} set is empty. - *

    - * @return true if this {@link XMLAttributes} set is empty, false otherwise. - */ - public boolean isEmpty() { - - return attributeNames.size() == 0; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLException.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLException.java deleted file mode 100644 index f76eb2f1f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * $Id: XMLException.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLException.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - -/** - * This kind of {@link Error} indicates that an XML file could not be parsed - * correctly. - * - * @author Andreas Dräger - * @date 2010-10-30 - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLException extends RuntimeException { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -7347204499480036729L; - - /** - * - */ - public XMLException() { - super(); - } - - - /** - * @param message - */ - public XMLException(String message) { - super(message); - } - - /** - * @param message - * @param cause - */ - public XMLException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param cause - */ - public XMLException(Throwable cause) { - super(cause); - } - - /** - * - * @return - */ - public int getErrorId() { - return 0; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLNamespaces.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLNamespaces.java deleted file mode 100644 index ac13575b0..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLNamespaces.java +++ /dev/null @@ -1,562 +0,0 @@ -/* - * $Id: XMLNamespaces.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLNamespaces.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - -import java.util.LinkedHashMap; - -import org.sbml.jsbml.JSBML; - -/** - * Representation of XML Namespaces. - *

    - * -This class of objects is defined by jsbml only and has no direct -equivalent in terms of SBML components. This class is not prescribed by -the SBML specifications, although it is used to implement features -defined in SBML. - - - *

    - * This class serves to organize functionality for tracking XML namespaces - * in a document or data stream. The namespace declarations are stored as - * a list of pairs of XML namespace URIs and prefix strings. These - * correspond to the parts of a namespace declaration on an XML element. - * For example, in the following XML fragment, - *

    -<annotation>
    -    <mysim:nodecolors xmlns:mysim='urn:lsid:mysim.org'
    -         mysim:bgcolor='green' mysim:fgcolor='white'/>
    -</annotation>
    -
    - * there is one namespace declaration. Its URI is - * urn:lsid:mysim.org and its prefix is mysim. - * This pair could be stored as one item in an {@link XMLNamespaces} list. - *

    - * {@link XMLNamespaces} provides various methods for manipulating the list of - * prefix-URI pairs. Individual namespaces stored in a given XMLNamespace - * object instance can be retrieved based on their index using - * {@link XMLNamespaces#getPrefix(int index)}, or by their characteristics such as - * their URI or position in the list. - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLNamespaces { - - /** - * HashMap - */ - LinkedHashMap namespaces = new LinkedHashMap(); - - /** - * Equality comparison method for XMLNamespaces. - * - * @param sb a reference to an object to which the current object - * instance will be compared - * - * @return true if sb refers to the same underlying - * native object as this one, false otherwise - */ - public boolean equals(Object sb) - { - if (sb instanceof XMLNamespaces) { - XMLNamespaces namespaces2 = (XMLNamespaces) sb; - - for (String prefix : namespaces.keySet()) { - if (!getURI(prefix).equals(namespaces2.getURI(prefix))) { - return false; - } - } - - return true; - } - - return false; - } - - /** - * Returns a hashcode for this XMLNamespaces object. - * - * @return a hash code usable by Java methods that need them. - */ - public int hashCode() - { - int hashcode = 0; - - for (String prefix : namespaces.keySet()) { - hashcode += prefix.hashCode() + getURI(prefix).hashCode(); - } - - return hashcode; - } - - - /** - * Creates a new empty list of XML namespace declarations. - */ - public XMLNamespaces() { - } - - - /** - * Copy constructor; creates a copy of this {@link XMLNamespaces} list. - *

    - * @param orig the {@link XMLNamespaces} object to copy - */ - public XMLNamespaces(XMLNamespaces orig) { - - for (String prefix : orig.namespaces.keySet()) { - namespaces.put(new String(prefix), new String(orig.getURI(prefix))); - } - - } - - - /** - * Creates and returns a deep copy of this {@link XMLNamespaces} list. - *

    - * @return a (deep) copy of this {@link XMLNamespaces} list. - */ - public XMLNamespaces clone() { - return new XMLNamespaces(this); - } - - - /** - * Appends an XML namespace prefix and URI pair to this list of namespace - * declarations. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. If there is an XML namespace with the given uri prefix - * in this list, then its corresponding URI will be overwritten by the - * new uri. Calling programs could use one of the other {@link XMLNamespaces} - * methods, such as - * {@link XMLNamespaces#hasPrefix(String)} and - * {@link XMLNamespaces#hasURI(String)} to - * inquire whether a given prefix and/or URI - * is already present in this {@link XMLNamespaces} object. - *

    - * @param uri a string, the uri for the namespace - * @param prefix a string, the prefix for the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - */ - public int add(String uri, String prefix) { - - namespaces.put(prefix, uri); - - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Appends an XML namespace URI with an empty prefix to this list of namespace - * declarations. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. If there is an XML namespace with the given uri prefix - * in this list, then its corresponding URI will be overwritten by the - * new uri. Calling programs could use one of the other {@link XMLNamespaces} - * methods, such as - * {@link XMLNamespaces#hasPrefix(String)} and - * {@link XMLNamespaces#hasURI(String)} to - * inquire whether a given prefix and/or URI - * is already present in this {@link XMLNamespaces} object. - *

    - * @param uri a string, the uri for the namespace - * @param prefix a string, the prefix for the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - */ - public int add(String uri) { - - namespaces.put("", uri); - - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Removes an XML Namespace stored in the given position of this list. - *

    - * @param index an integer, position of the namespace to remove. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • INDEX_EXCEEDS_SIZE - */ - public int remove(int index) { - - if (index < 0 || index >= namespaces.size()) { - return JSBML.INDEX_EXCEEDS_SIZE; - } - - int i = 0; - for (String prefix : namespaces.keySet()) { - if (i == index) { - namespaces.remove(prefix); - break; - } - i++; - } - - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Removes an XML Namespace with the given prefix. - *

    - * @param prefix a string, prefix of the required namespace. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - * @see #remove(int index) - */ - public int remove(String prefix) { - - namespaces.remove(prefix); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Clears (deletes) all XML namespace declarations in this {@link XMLNamespaces} - * object. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *

    - * @see #remove(int index) - */ - public int clear() { - - namespaces.clear(); - - return JSBML.OPERATION_SUCCESS; - - } - - - /** - * Gets the index of an XML namespace declaration by URI. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. If this {@link XMLNamespaces} object contains a pair with the given - * URI uri, this method returns its index in the list. - *

    - * @param uri a string, the URI of the sought-after namespace. - *

    - * @return the index of the given declaration, or -1 if not - * present. - */ - public int getIndex(String uri) { - - int index = -1; - - int i = 0; - for (String prefix : namespaces.keySet()) { - if (namespaces.get(prefix).equals(uri)) { - index = i; - break; - } - i++; - } - - return index; - - } - - - /** - * Gets the index of an XML namespace declaration by prefix. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. If this {@link XMLNamespaces} object contains a pair with the given - * prefix prefix, this method returns its index in the list. - *

    - * @param prefix a string, the prefix string of the sought-after - * namespace - *

    - * @return the index of the given declaration, or -1 if not - * present. - */ - public int getIndexByPrefix(String prefix) { - - int index = -1; - - int i = 0; - for (String currentPrefix : namespaces.keySet()) { - if (currentPrefix.equals(prefix)) { - index = i; - break; - } - i++; - } - - return index; - - } - - - /** - * Returns the total number of URI-and-prefix pairs stored in this - * particular {@link XMLNamespaces} instance. - *

    - * @return the number of namespaces in this list. - */ - public int getLength() { - - return namespaces.size(); - - } - - - /** - * Gets the prefix of an XML namespace declaration by its position. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. This method returns the prefix of the nth - * element in that list (if it exists). Callers should use - * XMLAttributes.getLength() first to find out how many namespaces are - * stored in the list. - *

    - * @param index an integer, position of the sought-after prefix - *

    - * @return the prefix of an XML namespace declaration in this list (by - * position), or an empty string if the index is out of range - *

    - * @see #getLength() - */ - public String getPrefix(int index) { - - int i = 0; - for (String prefix : namespaces.keySet()) { - if (i == index) { - return prefix; - } - i++; - } - - return ""; - - } - - - /** - * Gets the prefix of an XML namespace declaration by its URI. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. This method returns the prefix for a pair that has the - * given uri. - *

    - * @param uri a string, the URI of the prefix being sought - *

    - * @return the prefix of an XML namespace declaration given its URI, or - * an empty string if no such uri exists in this {@link XMLNamespaces} object - */ - public String getPrefix(String uri) { - - for (String prefix : namespaces.keySet()) { - if (namespaces.get(prefix).equals(uri)) { - return prefix; - } - } - - return ""; - - } - - - /** - * Gets the URI of an XML namespace declaration by its position. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. This method returns the URI of the nth element - * in that list (if it exists). Callers should use - * XMLAttributes.getLength() first to find out how many namespaces are - * stored in the list. - *

    - * @param index an integer, position of the required URI. - *

    - * @return the URI of an XML namespace declaration in this list (by - * position), or an empty string if the index is out of range. - *

    - * @see #getLength() - */ - public String getURI(int index) { - - int i = 0; - for (String prefix : namespaces.keySet()) { - if (i == index) { - return namespaces.get(prefix); - } - i++; - } - - return ""; - } - - - /** - * Gets the URI of an XML namespace declaration by its prefix. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. This method returns the namespace URI for a pair that has - * the given prefix. - *

    - * @param prefix a string, the prefix of the required URI - *

    - * @return the URI of an XML namespace declaration having the given - * prefix, or an empty string if no such prefix-and-URI pair exists - * in this {@link XMLNamespaces} object - * - * @see #getURI() - */ - public String getURI(String prefix) { - - for (String currentPrefix : namespaces.keySet()) { - if (currentPrefix.equals(prefix)) { - return namespaces.get(currentPrefix); - } - } - - return ""; - - } - - - /** - * Gets the URI of an XML namespace declaration by the empty prefix. - *

    - * An XMLNamespace object stores a list of pairs of namespaces and their - * prefixes. This method returns the namespace URI for a pair that has - * the empty prefix. - *

    - * @return the URI of an XML namespace declaration having the empty - * prefix, or an empty string if no such prefix-and-URI pair exists - * in this {@link XMLNamespaces} object - * - * @see #getURI() - */ - public String getURI() { - - for (String currentPrefix : namespaces.keySet()) { - if (currentPrefix.equals("")) { - return namespaces.get(currentPrefix); - } - } - - return ""; - - } - - - /** - * Returns true or false depending on whether this - * {@link XMLNamespaces} list is empty. - *

    - * @return true if this {@link XMLNamespaces} list is empty, false otherwise. - */ - public boolean isEmpty() { - - return namespaces.size() == 0; - - } - - - /** - * Returns true or false depending on whether an XML - * Namespace with the given URI is contained in this {@link XMLNamespaces} list. - *

    - * @param uri a string, the uri for the namespace - *

    - * @return true if an XML Namespace with the given URI is contained in - * this {@link XMLNamespaces} list, false otherwise. - */ - public boolean hasURI(String uri) { - - return namespaces.containsValue(uri); - - } - - - /** - * Returns true or false depending on whether an XML - * Namespace with the given prefix is contained in this {@link XMLNamespaces} - * list. - *

    - * @param prefix a string, the prefix for the namespace - *

    - * @return true if an XML Namespace with the given URI is contained in - * this {@link XMLNamespaces} list, false otherwise. - */ - public boolean hasPrefix(String prefix) { - - return namespaces.containsKey(prefix); - - } - - - /** - * Returns true or false depending on whether an XML - * Namespace with the given URI and prefix pair is contained in this - * {@link XMLNamespaces} list. - *

    - * @param uri a string, the URI for the namespace - * @param prefix a string, the prefix for the namespace - *

    - * @return true if an XML Namespace with the given uri/prefix pair is - * contained in this {@link XMLNamespaces} list, false otherwise. - */ - public boolean hasNS(String uri, String prefix) { - - if (uri == null || prefix == null) { - return false; - } - String uri2 = namespaces.get(prefix); - - if (uri.equals(uri2)) { - return true; - } - - return false; - - } - -} - diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLNode.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLNode.java deleted file mode 100644 index 08e156329..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLNode.java +++ /dev/null @@ -1,580 +0,0 @@ -/* - * $Id: XMLNode.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLNode.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - -import static org.sbml.jsbml.JSBML.OPERATION_FAILED; -import static org.sbml.jsbml.JSBML.OPERATION_SUCCESS; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.stream.XMLStreamException; - -import org.sbml.jsbml.xml.parsers.XMLNodeWriter; -import org.sbml.jsbml.xml.stax.SBMLReader; - -/** - * Representation of a node in an XML document tree. - *

    - * Beginning with version 1.0, JSBML implements an XML abstraction layer, like - * LibSBML. The basic data object in the XML abstraction is a node, - * represented by {@link XMLNode}. - *

    - * An {@link XMLNode} can contain any number of children. Each child is another - * {@link XMLNode}, thereby forming a tree. The methods - * {@link XMLNode#getChildCount()} and {@link XMLNode#getChild(long n)} can be - * used to access the tree structure starting from a given node. - *

    - *

    - * Each {@link XMLNode} is subclassed from {@link XMLToken}, and thus has the - * same methods available as {@link XMLToken}. These methods include - * {@link XMLToken#getNamespaces()}, {@link XMLToken#getPrefix()}, - * {@link XMLToken#getName()}, {@link XMLToken#getURI()}, and - * {@link XMLToken#getAttributes()}. - *

    - *

    Conversion between an XML {@link String} and an {@link XMLNode}

    - *

    - * JSBML provides the following utility functions for converting an XML - * {@link String} (e.g., <annotation>...</annotation>) to/from an - * {@link XMLNode} object. - *

      - *
    • XMLNode{@link #toXMLString()} returns a {@link String} representation of - * the {@link XMLNode} object. - *

      - *

    • {@link #convertXMLNodeToString(XMLNode)} (static function) returns a - * {@link String} representation of the given {@link XMLNode} object. - *

      - *

    • {@link #convertStringToXMLNode(String)} (static function) returns an - * {@link XMLNode} object converted from the given XML {@link String}. - *
    - *

    - * The returned {@link XMLNode} object by - * {@link XMLNode#convertStringToXMLNode(String)} is a dummy root (container) - * {@link XMLNode} if the given XML {@link String} has two or more top-level - * elements (e.g., '<p>...</p><p>...</p>'). In the dummy - * root node, each top-level element in the given XML {@link String} is - * contained as a child {@link XMLNode}. {@link XMLToken#isEOF()} can be used to - * identify if the returned {@link XMLNode} object is a dummy node or not. Here - * is an example:

    - * - *
    - * // Checks if the returned {@link XMLNode} object by XMLNode.convertStringToXMLNode() is a dummy root node:
    - * 
    - * String str = '...';
    - * {@link XMLNode} xn = {@link XMLNode}.convertStringToXMLNode(str);
    - * if (xn == null)
    - * {
    - *   // returned value is null (error)
    - *   ...
    - * }
    - * else if ( xn.isEOF() )
    - * {
    - *   // root node is a dummy node
    - *   for (int i=0; i < xn.getChildCount(); i++)
    - *   {
    - *     // access to each child node of the dummy node.
    - *     {@link XMLNode} xnChild = xn.getChild(i);
    - *     ...
    - *   }
    - * }
    - * else
    - * {
    - *   // root node is NOT a dummy node
    - *   ...
    - * }
    - * 
    - * - *
    - *

    - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1139 $ - */ -public class XMLNode extends XMLToken { - - /** - * Generated serial version identifier - */ - private static final long serialVersionUID = -7699595383368237593L; - - /** - * This reader is used to parse all notes-Strings. - * It takes a lot of time to re-initialize the {@link SBMLReader} - * every time notes are being set or appended, thus, this instance - * is static and should be used to parse all notes. - */ - private static SBMLReader notesReader = new SBMLReader(); - - /** - * Returns an {@link XMLNode} which is derived from a string containing XML - * content. - *

    - * The XML namespace must be defined using argument xmlns if the - * corresponding XML namespace attribute is not part of the string of the - * first argument. - *

    - * @param xmlstr string to be converted to a XML node. - * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is NULL). - *

    - * @jsbml.note The caller owns the returned {@link XMLNode} and is reponsible for deleting it. - * The returned {@link XMLNode} object is a dummy root (container) {@link XMLNode} if the top-level - * element in the given XML string is NOT html, body, annotation, notes. - * In the dummy root node, each top-level element in the given XML string is contained - * as a child {@link XMLNode}. XMLToken.isEOF() can be used to identify if the returned {@link XMLNode} - * object is a dummy node. - *

    - * @return a {@link XMLNode} which is converted from string xmlstr. NULL is returned - * if the conversion failed. - * - */ - public static XMLNode convertStringToXMLNode(String xmlstr) { - try { - /* Initializing the SBMLReader again and again - * for every time we append notes takes a lot of time - * (especially calling the initializePackageParsers() - * method) => use a static instance here */ - return notesReader.readNotes(xmlstr); - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Returns an {@link XMLNode} which is derived from a string containing XML - * content. - *

    - * The XML namespace must be defined using argument xmlns if the - * corresponding XML namespace attribute is not part of the string of the - * first argument. - *

    - * @param xmlstr string to be converted to a XML node. - * @param xmlns {@link XMLNamespaces} the namespaces to set (default value is NULL). This argument is ignored at the moment. - *

    - * @jsbml.note The caller owns the returned {@link XMLNode} and is reponsible for deleting it. - * The returned {@link XMLNode} object is a dummy root (container) {@link XMLNode} if the top-level - * element in the given XML string is NOT html, body, annotation, notes. - * In the dummy root node, each top-level element in the given XML string is contained - * as a child {@link XMLNode}. XMLToken.isEOF() can be used to identify if the returned {@link XMLNode} - * object is a dummy node. - *

    - * @return a {@link XMLNode} which is converted from string xmlstr. NULL is returned - * if the conversion failed. - * - */ - public static XMLNode convertStringToXMLNode(String xmlstr, XMLNamespaces xmlns) { - - // TODO : check how to use the xmlns arguments inside the SBMLReader.readNotes. - - try { - return notesReader.readNotes(xmlstr); - } catch (XMLStreamException e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Returns a string representation of a given {@link XMLNode}. - *

    - * @param node the {@link XMLNode} to be represented as a string - *

    - * @return a string-form representation of node - */ - public static String convertXMLNodeToString(XMLNode node) { - return node.toXMLString(); - } - - - /** - * - */ - private List childrenElements = new ArrayList(); - - /** - * Creates a new empty {@link XMLNode} with no children. - */ - public XMLNode() { - super(); - } - - - /** - * Creates a text {@link XMLNode}. - *

    - * @param chars a string, the text to be added to the {@link XMLToken} - * - */ - public XMLNode(String chars) { - super(chars); - } - - - /** - * Creates a text {@link XMLNode}. - *

    - * @param chars a string, the text to be added to the {@link XMLToken} - * @param line a long integer, the line number (default = 0). - * - */ - public XMLNode(String chars, long line) { - super(chars, line, 0); - } - - - /** - * Creates a text {@link XMLNode}. - *

    - * @param chars a string, the text to be added to the {@link XMLToken} - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - * - */ - public XMLNode(String chars, long line, long column) { - super(chars, line, column); - } - - - /** - * Creates a copy of this {@link XMLNode}. - *

    - * @param orig the {@link XMLNode} instance to copy. - */ - public XMLNode(XMLNode orig) { - super((XMLToken) orig); - - if (orig.childrenElements.size() > 0) { - for (XMLNode origchildren : orig.childrenElements) { - childrenElements.add(origchildren.clone()); - } - } - } - - - /** - * Creates a new {@link XMLNode} by copying token. - *

    - * @param token {@link XMLToken} to be copied to {@link XMLNode} - */ - public XMLNode(XMLToken orig) { - if (orig.triple != null) { - triple = orig.triple.clone(); - } - if (orig.attributes != null) { - attributes = orig.attributes.clone(); - } - if (orig.namespaces != null) { - namespaces = orig.namespaces.clone(); - } - line = orig.line; - column = orig.column; - if (orig.characters != null) { - characters.append(orig.getCharacters()); - } - isText = orig.isText; - isStartElement = orig.isStartElement; - isEndElement = orig.isEndElement; - isEOF = orig.isEOF; - - } - - - /** - * Creates an end element {@link XMLNode}. - *

    - * @param triple {@link XMLTriple}. - * - */ - public XMLNode(XMLTriple triple) { - super(triple); - } - - - /** - * Creates an end element {@link XMLNode}. - *

    - * @param triple {@link XMLTriple}. - * @param line a long integer, the line number (default = 0). - * - */ - public XMLNode(XMLTriple triple, long line) { - super(triple, line); - } - - - /** - * Creates an end element {@link XMLNode}. - *

    - * @param triple {@link XMLTriple}. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - * - */ - public XMLNode(XMLTriple triple, long line, long column) { - super(triple, line, column); - } - - - /** - * Creates a start element {@link XMLNode} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes) { - super(triple, attributes); - } - - - /** - * Creates a start element {@link XMLNode} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param line a long integer, the line number (default = 0). - * - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes, long line) { - super(triple, attributes, line, 0); - } - - - /** - * Creates a start element {@link XMLNode} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - * - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes, long line, long column) { - super(triple, attributes, line, column); - } - - - /** - * Creates a new start element {@link XMLNode} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - * - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) { - super(triple, attributes, namespaces); - } - - - /** - * Creates a new start element {@link XMLNode} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - * @param line a long integer, the line number (default = 0). - * - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes, - XMLNamespaces namespaces, long line) { - super(triple, attributes, namespaces, line); - } - - - /** - * Creates a new start element {@link XMLNode} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - */ - public XMLNode(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) { - super(triple, attributes, namespaces, line, column); - } - - - /** - * Adds a child to this {@link XMLNode}. - *

    - * The given node is added at the end of the list of children. - *

    - * @param node the {@link XMLNode} to be added as child. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *

    - * @jsbml.note The given node is added at the end of the children list. - */ - public int addChild(XMLNode node) { - - if (node == null) { - return OPERATION_FAILED; - } - - if (isEnd()) { - unsetEnd(); - } - - // TODO : there are more tests in libsbml XMLNode.cpp, check if we need them, like isEOF() - - childrenElements.add(node); - node.fireNodeAddedEvent(); - node.parent = this; - - return OPERATION_SUCCESS; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.XMLToken#clone() - */ - public XMLNode clone() { - return new XMLNode(this); - } - - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getAllowsChildren() - */ - public boolean getAllowsChildren() { - return true; - } - - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildAt(int) - */ - public XMLNode getChildAt(int childIndex) { - if (childrenElements == null) { - throw new IndexOutOfBoundsException(Integer.toString(childIndex)); - } - return childrenElements.get(childIndex); - } - - - /* (non-Javadoc) - * @see javax.swing.tree.TreeNode#getChildCount() - */ - public int getChildCount() { - return childrenElements != null ? childrenElements.size() : 0; - } - - /** - * Inserts a node as the nth child of this - * {@link XMLNode}. - *

    - * If the given index n is out of range for this {@link XMLNode} instance, - * the node is added at the end of the list of children. Even in - * that situation, this method does not throw an error. - *

    - * @param n an integer, the index at which the given node is inserted - * @param node an {@link XMLNode} to be inserted as nth child. - *

    - * @return a reference to the newly-inserted child node - */ - public XMLNode insertChild(int n, XMLNode node) { - if (node == null) { - return node; - } - - if (isEnd()) { - unsetEnd(); - } - if ((n > getChildCount()) || (n <= 0)) { -// childrenElements.add(node); - throw new IndexOutOfBoundsException(Integer.toString(n)); - } else { - childrenElements.add(n, node); - node.fireNodeAddedEvent(); - } - node.parent = this; - - return node; - } - - /** - * Removes the nth child of this {@link XMLNode} and returns the - * removed node. - *

    - * It is important to keep in mind that a given {@link XMLNode} may have more - * than one child. Calling this method erases all existing references to - * child nodes after the given position n. If the index n is - * greater than the number of child nodes in this {@link XMLNode}, this method - * takes no action (and returns NULL). - *

    - * @param n an integer, the index of the node to be removed - *

    - * @return the removed child, or NULL if n is greater than the number - * of children in this node - *

    - * @jsbml.note The caller owns the returned node and is responsible for deleting it. - */ - public XMLNode removeChild(long n) { - if ((n < 0) || (getChildCount() < n)) { - return null; - } - XMLNode oldNode = childrenElements.remove((int) n); - oldNode.fireNodeRemovedEvent(); - return oldNode; - } - - /** - * Removes all children from this node. - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int removeChildren() { - - List removedChildren = childrenElements; - childrenElements.clear(); - for(XMLNode child : removedChildren){ - child.fireNodeRemovedEvent(); - } - - return OPERATION_SUCCESS; - } - - /** - * Returns a string representation of this {@link XMLNode}. - *

    - * @return a string derived from this {@link XMLNode}. - */ - public String toXMLString() { - return XMLNodeWriter.toXML(this); - } - - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLToken.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLToken.java deleted file mode 100644 index 94c76a161..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLToken.java +++ /dev/null @@ -1,1558 +0,0 @@ -/* - * $Id: XMLToken.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLToken.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - -import java.util.ArrayList; - -import org.sbml.jsbml.AbstractTreeNode; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.util.TreeNodeChangeEvent; - -/** - * Representation of a token in an XML stream. - *

    - * - * This class of objects is defined by jsbml only and has no direct - * equivalent in terms of SBML components. This class is not prescribed by - * the SBML specifications, although it is used to implement features - * defined in SBML. - * - * - *

    - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - */ -public abstract class XMLToken extends AbstractTreeNode { - - /** - * Generated serial version identifier - */ - private static final long serialVersionUID = -3501521107595952650L; - - protected XMLAttributes attributes = new XMLAttributes(); - - protected StringBuffer characters = new StringBuffer(); - - protected long column = 0; - - protected boolean isEndElement = false; - - protected boolean isEOF = false; - protected boolean isStartElement = false; - - protected boolean isText = false; - protected long line = 0; - protected XMLNamespaces namespaces = new XMLNamespaces(); - - /** - * the XMLTripe (name, uri and prefix) of this XML element. - * - */ - protected XMLTriple triple = new XMLTriple(); - - /** - * Creates a new empty {@link XMLToken}. - */ - public XMLToken() { - super(); - } - - /** - * Creates a text {@link XMLToken}. - *

    - * @param chars a string, the text to be added to the {@link XMLToken} - */ - public XMLToken(String chars) { - this(chars, 0, 0); - } - - - /** - * Creates a text {@link XMLToken}. - *

    - * @param chars a string, the text to be added to the {@link XMLToken} - * @param line a long integer, the line number (default = 0). - */ - public XMLToken(String chars, long line) { - this(chars, line, 0); - } - - - /** - * Creates a text {@link XMLToken}. - *

    - * @param chars a {@link String}, the text to be added to the {@link XMLToken} - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - *

    - */ - public XMLToken(String chars, long line, long column) { - this(); - append(chars); - isText = true; - this.line = line; - this.column = column; - } - - - /** - * Copy constructor; creates a copy of this {@link XMLToken}. - */ - public XMLToken(XMLToken orig) { - this(); - if (orig.isSetParent()) { - this.parent = orig.getParent(); - } - if (orig.triple != null) { - triple = orig.triple.clone(); - } - if (orig.attributes != null) { - attributes = orig.attributes.clone(); - } - if (orig.namespaces != null) { - namespaces = orig.namespaces.clone(); - } - line = orig.line; - column = orig.column; - if (orig.characters != null) { - characters.append(orig.getCharacters()); - } - isText = orig.isText; - isStartElement = orig.isStartElement; - isEndElement = orig.isEndElement; - isEOF = orig.isEOF; - } - - - /** - * Creates an end element {@link XMLToken}. - *

    - * @param triple {@link XMLTriple}. - *

    - */ - public XMLToken(XMLTriple triple) { - this(triple, 0, 0); - } - - - /** - * Creates an end element {@link XMLToken}. - *

    - * @param triple {@link XMLTriple}. - * @param line a long integer, the line number (default = 0). - *

    - */ - public XMLToken(XMLTriple triple, long line) { - this(triple, line, 0); - } - - - /** - * Creates an end element {@link XMLToken}. - *

    - * @param triple {@link XMLTriple}. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - *

    - */ - public XMLToken(XMLTriple triple, long line, long column) { - this(); - this.triple = triple; - this.line = line; - this.column = column; - isEndElement = true; - - } - - - /** - * Creates a start element {@link XMLToken} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - *

    - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes) { - this(triple, attributes, null, 0, 0); - } - - - /** - * Creates a start element {@link XMLToken} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param line a long integer, the line number (default = 0). - *

    - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes, long line) { - this(triple, attributes, null, line, 0); - } - - - /** - * Creates a start element {@link XMLToken} with the given set of attributes. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - *

    - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes, long line, long column) { - this(triple, attributes, null, line, column); - } - - - /** - * Creates a start element {@link XMLToken} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - *

    - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces) { - this(triple, attributes, namespaces, 0, 0); - } - - - /** - * Creates a start element {@link XMLToken} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - * @param line a long integer, the line number (default = 0). - *

    - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line) { - this(triple, attributes, namespaces, line, 0); - } - - /** - * Creates a start element {@link XMLToken} with the given set of attributes and - * namespace declarations. - *

    - * @param triple {@link XMLTriple}. - * @param attributes {@link XMLAttributes}, the attributes to set. - * @param namespaces {@link XMLNamespaces}, the namespaces to set. - * @param line a long integer, the line number (default = 0). - * @param column a long integer, the column number (default = 0). - *

    - * - */ - public XMLToken(XMLTriple triple, XMLAttributes attributes, XMLNamespaces namespaces, long line, long column) { - this(); - this.triple = triple; - this.attributes = attributes; - this.namespaces = namespaces; - this.line = line; - this.column = column; - isStartElement = true; - } - - /** - * Adds an attribute to the attribute set in this {@link XMLToken} optionally - * with a prefix and URI defining a namespace. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *

    - * @jsbml.note if local name with the same namespace URI already exists in the - * attribute set, its value and prefix will be replaced. - *

    - */ - public int addAttr(String name, String value) { - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(name); - int success = attributes.add(name, value); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(name, oldValue, value); - } - return success; - } - - - /** - * Adds an attribute to the attribute set in this {@link XMLToken} optionally - * with a prefix and URI defining a namespace. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - * @param namespaceURI a string, the namespace URI of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *

    - * @jsbml.note if local name with the same namespace URI already exists in the - * attribute set, its value and prefix will be replaced. - *

    - */ - public int addAttr(String name, String value, String namespaceURI) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(name); - int success = attributes.add(name, value, namespaceURI); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(name, oldValue, value); - } - return success; - } - - - /** - * Adds an attribute to the attribute set in this {@link XMLToken} optionally - * with a prefix and URI defining a namespace. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param name a string, the local name of the attribute. - * @param value a string, the value of the attribute. - * @param namespaceURI a string, the namespace URI of the attribute. - * @param prefix a string, the prefix of the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *

    - * @jsbml.note if local name with the same namespace URI already exists in the - * attribute set, its value and prefix will be replaced. - *

    - */ - public int addAttr(String name, String value, String namespaceURI, String prefix) { - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - String oldValue = attributes.getValue(name); - int success = attributes.add(name, value, namespaceURI, prefix); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(name, oldValue, value); - } - return success; - } - - - /** - * Adds an attribute with the given {@link XMLTriple}/value pair to the attribute set - * in this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @jsbml.note if local name with the same namespace URI already exists in the - * attribute set, its value and prefix will be replaced. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute. - * @param value a string, the value of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int addAttr(XMLTriple triple, String value) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(triple.getName()); - int success = attributes.add(triple, value); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(triple.getName(), oldValue, value); - } - return success; - } - - - /** - * Appends an XML namespace prefix and URI pair to this {@link XMLToken}. - * If there is an XML namespace with the given prefix in this {@link XMLToken}, - * then the existing XML namespace will be overwritten by the new one. - *

    - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param uri a string, the uri for the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int addNamespace(String uri) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldUri = null; - if(namespaces.hasURI(uri)){ - oldUri = uri; - } - - int success = namespaces.add(uri); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(TreeNodeChangeEvent.namespace, oldUri, uri); - } - return success; - } - - - /** - * Appends an XML namespace prefix and URI pair to this {@link XMLToken}. - * If there is an XML namespace with the given prefix in this {@link XMLToken}, - * then the existing XML namespace will be overwritten by the new one. - *

    - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param uri a string, the uri for the namespace - * @param prefix a string, the prefix for the namespace - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int addNamespace(String uri, String prefix) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - String oldUri = null; - if(namespaces.hasURI(uri)){ - oldUri = uri; - }else if(namespaces.hasPrefix(prefix)){ - oldUri = namespaces.getURI(prefix); - } - - int success = namespaces.add(uri, prefix); - if (success == JSBML.OPERATION_SUCCESS) { - firePropertyChange(TreeNodeChangeEvent.namespace, oldUri, uri); - } - return success; - } - - - /** - * Appends characters to this XML text content. - */ - public void append(String chars) { - if (characters == null) { - characters = new StringBuffer(); - } - String oldValue = characters.toString(); - characters.append(chars); - this.firePropertyChange(TreeNodeChangeEvent.text, oldValue, characters.toString()); - } - - - /** - * Clears (deletes) all attributes in this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int clearAttributes() { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - ArrayList oldNames = this.attributes.attributeNames; - ArrayList oldValues = this.attributes.attributeValues; - - int success = attributes.clear(); - - for(int i=0; i < this.attributes.getLength(); i++){ - this.firePropertyChange(oldNames.get(i).getName(), oldValues.get(i), null); - } - return success; - } - - - /** - * Clears (deletes) all XML namespace declarations in the {@link XMLNamespaces} of - * this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int clearNamespaces() { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - XMLNamespaces oldValues = namespaces; - - int success = namespaces.clear(); - - for(int i=0; i < this.attributes.getLength(); i++){ - this.firePropertyChange(TreeNodeChangeEvent.namespace, oldValues.getURI(i), null); - } - return success; - } - - - /* - * (non-Javadoc) - * @see java.lang.Object#clone() - */ - @Override - public abstract XMLToken clone(); - - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (!super.equals(obj)) { - return false; - } - XMLToken other = (XMLToken) obj; - if (attributes == null) { - if (other.attributes != null) { - return false; - } - } else if (!attributes.equals(other.attributes)) { - return false; - } - if (characters == null) { - if (other.characters != null) { - return false; - } - } else if (!characters.equals(other.characters)) { - return false; - } - if (column != other.column) { - return false; - } - if (isEOF != other.isEOF) { - return false; - } - if (isEndElement != other.isEndElement) { - return false; - } - if (isStartElement != other.isStartElement) { - return false; - } - if (isText != other.isText) { - return false; - } - if (line != other.line) { - return false; - } - if (namespaces == null) { - if (other.namespaces != null) { - return false; - } - } else if (!namespaces.equals(other.namespaces)) { - return false; - } - if (triple == null) { - if (other.triple != null) { - return false; - } - } else if (!triple.equals(other.triple)) { - return false; - } - - return true; - } - - - /** - * Returns the attributes of this element. - *

    - * @return the {@link XMLAttributes} of this XML element. - */ - public XMLAttributes getAttributes() { - return attributes; - } - - - /** - * Returns the number of attributes in the attributes set. - *

    - * @return the number of attributes in the attributes set in this {@link XMLToken}. - */ - public int getAttributesLength() { - return attributes.getLength(); - } - - - /** - * Returns the index of an attribute with the given local name. - *

    - * @param name a string, the local name of the attribute. - *

    - * @return the index of an attribute with the given local name, - * or -1 if not present. - */ - public int getAttrIndex(String name) { - return attributes.getIndex(name); - } - - - /** - * Returns the index of an attribute with the given local name and namespace URI. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return the index of an attribute with the given local name and namespace URI, - * or -1 if not present. - */ - public int getAttrIndex(String name, String uri) { - return attributes.getIndex(name, uri); - } - - - /** - * Returns the index of an attribute with the given {@link XMLTriple}. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute for which - * the index is required. - *

    - * @return the index of an attribute with the given {@link XMLTriple}, or -1 if not present. - */ - public int getAttrIndex(XMLTriple triple) { - return attributes.getIndex(triple); - } - - - /** - * Returns the local name of an attribute in the attributes set in this - * {@link XMLToken} (by position). - *

    - * @param index an integer, the position of the attribute whose local name - * is required. - *

    - * @return the local name of an attribute in this list (by position). - *

    - * @jsbml.note If index - * is out of range, an empty string will be returned. Use hasAttr(index) - * to test for the attribute existence. - */ - public String getAttrName(int index) { - return attributes.getName(index); - } - - - /** - * Returns the prefix of an attribute in the attribute set in this - * {@link XMLToken} (by position). - *

    - * @param index an integer, the position of the attribute whose prefix is - * required. - *

    - * @return the namespace prefix of an attribute in the attribute set - * (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be - * returned. Use hasAttr(index) to test for the attribute existence. - */ - public String getAttrPrefix(int index) { - return attributes.getPrefix(index); - } - - - /** - * Returns the prefixed name of an attribute in the attribute set in this - * {@link XMLToken} (by position). - *

    - * @param index an integer, the position of the attribute whose prefixed - * name is required. - *

    - * @return the prefixed name of an attribute in the attribute set - * (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be - * returned. Use hasAttr(index) to test for attribute existence. - */ - public String getAttrPrefixedName(int index) { - return attributes.getPrefixedName(index); - } - - - /** - * Returns the namespace URI of an attribute in the attribute set in this - * {@link XMLToken} (by position). - *

    - * @param index an integer, the position of the attribute whose namespace - * URI is required. - *

    - * @return the namespace URI of an attribute in the attribute set (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be returned. Use - * hasAttr(index) to test for attribute existence. - */ - public String getAttrURI(int index) { - return attributes.getURI(index); - } - - - /** - * Returns the value of an attribute in the attribute set in this {@link XMLToken} - * (by position). - *

    - * @param index an integer, the position of the attribute whose value is - * required. - *

    - * @return the value of an attribute in the attribute set (by position). - *

    - * @jsbml.note If index - * is out of range, an empty string will be returned. Use hasAttr(index) - * to test for attribute existence. - */ - public String getAttrValue(int index) { - return attributes.getValue(index); - } - - - /** - * Returns a value of an attribute with the given local name. - *

    - * @param name a string, the local name of the attribute whose value is required. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the - * given local name does not exist, an empty string will be - * returned. - * Use hasAttr(name, uri) to test for attribute existence. - */ - public String getAttrValue(String name) { - return attributes.getValue(name); - } - - - /** - * Returns a value of an attribute with the given local name and namespace URI. - *

    - * @param name a string, the local name of the attribute whose value is required. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the - * given local name and namespace URI does not exist, an empty string will be - * returned. - * Use hasAttr(name, uri) to test for attribute existence. - */ - public String getAttrValue(String name, String uri) { - return attributes.getValue(name, uri); - } - - - /** - * Returns a value of an attribute with the given {@link XMLTriple}. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute whose - * value is required. - *

    - * @return The attribute value as a string. - *

    - * @jsbml.note If an attribute with the - * given {@link XMLTriple} does not exist, an empty string will be returned. - * Use hasAttr(triple) to test for attribute existence. - */ - public String getAttrValue(XMLTriple triple) { - return attributes.getValue(triple); - } - - - /** - * Returns the text of this element. - *

    - * @return the characters of this XML text. - */ - public String getCharacters() { - return characters.toString(); - } - - - /** - * Returns the column at which this {@link XMLToken} occurred in the input - * document or data stream. - *

    - * @return the column at which this {@link XMLToken} occurred. - */ - public long getColumn() { - return column; - } - - - /** - * Returns the line at which this {@link XMLToken} occurred in the input document - * or data stream. - *

    - * @return the line at which this {@link XMLToken} occurred. - */ - public long getLine() { - return line; - } - - - /** - * Returns the (unqualified) name of this XML element. - *

    - * @return the (unqualified) name of this XML element. - */ - public String getName() { - return triple.getName(); - } - - - /** - * Returns the index of an XML namespace declaration by URI. - *

    - * @param uri a string, uri of the required namespace. - *

    - * @return the index of the given declaration, or -1 if not present. - */ - public int getNamespaceIndex(String uri) { - return namespaces.getIndex(uri); - } - - - /** - * Returns the index of an XML namespace declaration by prefix. - *

    - * @param prefix a string, prefix of the required namespace. - *

    - * @return the index of the given declaration, or -1 if not present. - */ - public int getNamespaceIndexByPrefix(String prefix) { - return namespaces.getIndexByPrefix(prefix); - } - - - /** - * Returns the prefix of an XML namespace declaration by position. - *

    - * Callers should use getNamespacesLength() to find out how many - * namespaces are stored in the {@link XMLNamespaces}. - *

    - * @param index an integer, position of the required prefix. - *

    - * @return the prefix of an XML namespace declaration in the {@link XMLNamespaces} - * (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be - * returned. - *

    - * @see #getNamespacesLength() - */ - public String getNamespacePrefix(int index) { - return namespaces.getPrefix(index); - } - - - /** - * Returns the prefix of an XML namespace declaration by its URI. - *

    - * @param uri a string, the URI of the prefix being sought - *

    - * @return the prefix of an XML namespace declaration given its URI. - *

    - * @jsbml.note If uri does not exist, an empty string will be returned. - */ - public String getNamespacePrefix(String uri) { - return namespaces.getPrefix(uri); - } - - - /** - * Returns the XML namespace declarations for this XML element. - *

    - * @return the XML namespace declarations for this XML element. - */ - public XMLNamespaces getNamespaces() { - return namespaces; - } - - - /** - * Returns the number of XML namespaces stored in the {@link XMLNamespaces} - * of this {@link XMLToken}. - *

    - * @return the number of namespaces in this list. - */ - public int getNamespacesLength() { - return namespaces == null ? 0 : namespaces.getLength(); - } - - - /** - * Returns the URI of an XML namespace declaration for the empty prefix. - *

    - * @return the URI of an XML namespace declaration for the empty prefix. - *

    - * @jsbml.note If prefix does not exist, an empty string will be returned. - */ - public String getNamespaceURI() { - return namespaces.getURI(); - } - - - /** - * Returns the URI of an XML namespace declaration by its position. - *

    - * @param index an integer, position of the required URI. - *

    - * @return the URI of an XML namespace declaration in the {@link XMLNamespaces} - * (by position). - *

    - * @jsbml.note If index is out of range, an empty string will be - * returned. - *

    - * @see #getNamespacesLength() - */ - public String getNamespaceURI(int index) { - return namespaces.getURI(index); - } - - - /** - * Returns the URI of an XML namespace declaration by its prefix. - *

    - * @param prefix a string, the prefix of the required URI - *

    - * @return the URI of an XML namespace declaration given its prefix. - *

    - * @jsbml.note If prefix does not exist, an empty string will be returned. - */ - public String getNamespaceURI(String prefix) { - return namespaces.getURI(prefix); - } - - - /** - * Returns the namespace prefix of this XML element. - *

    - * @return the namespace prefix of this XML element. - *

    - * @jsbml.note If no prefix - * exists, an empty string will be return. - */ - public String getPrefix() { - return triple.getPrefix(); - } - - - /** - * Returns the namespace URI of this XML element. - *

    - * @return the namespace URI of this XML element. - */ - public String getURI() { - return triple.getURI(); - } - - - /** - * Returns true or false depending on whether - * an attribute with the given index exists in the attribute set in this - * {@link XMLToken}. - *

    - * @param index an integer, the position of the attribute. - *

    - * @return true if an attribute with the given index exists in the attribute - * set in this {@link XMLToken}, false otherwise. - */ - public boolean hasAttr(int index) { - return attributes.hasAttribute(index); - } - - - /** - * Returns true or false depending on whether - * an attribute with the given local name exists - * in the attribute set in this {@link XMLToken}. - *

    - * @param name a string, the local name of the attribute. - *

    - * @return true if an attribute with the given local name - * exists in the attribute set in this {@link XMLToken}, false otherwise. - */ - public boolean hasAttr(String name) { - return attributes.hasAttribute(name); - } - - - /** - * Returns true or false depending on whether - * an attribute with the given local name and namespace URI exists - * in the attribute set in this {@link XMLToken}. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return true if an attribute with the given local name and namespace - * URI exists in the attribute set in this {@link XMLToken}, false otherwise. - */ - public boolean hasAttr(String name, String uri) { - return attributes.hasAttribute(name, uri); - } - - - /** - * Returns true or false depending on whether - * an attribute with the given XML triple exists in the attribute set in - * this {@link XMLToken} - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute - *

    - * @return true if an attribute with the given XML triple exists - * in the attribute set in this {@link XMLToken}, false otherwise. - *

    - */ - public boolean hasAttr(XMLTriple triple) { - return attributes.hasAttribute(triple); - } - - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.AbstractTreeNode#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result - + ((attributes == null) ? 0 : attributes.hashCode()); - result = prime * result - + ((characters == null) ? 0 : characters.hashCode()); - result = prime * result + (int) (column ^ (column >>> 32)); - result = prime * result + (isEOF ? 1231 : 1237); - result = prime * result + (isEndElement ? 1231 : 1237); - result = prime * result + (isStartElement ? 1231 : 1237); - result = prime * result + (isText ? 1231 : 1237); - result = prime * result + (int) (line ^ (line >>> 32)); - result = prime * result - + ((namespaces == null) ? 0 : namespaces.hashCode()); - result = prime * result + ((triple == null) ? 0 : triple.hashCode()); - return result; - } - - - /** - * Returns true or false depending on whether - * an XML Namespace with the given uri/prefix pair is contained in the - * {@link XMLNamespaces} of this {@link XMLToken}. - *

    - * @param uri a string, the uri for the namespace - * @param prefix a string, the prefix for the namespace - *

    - * @return true if an XML Namespace with the given uri/prefix pair is - * contained in the {@link XMLNamespaces} of this {@link XMLToken}, false otherwise. - */ - public boolean hasNamespaceNS(String uri, String prefix) { - return namespaces.hasNS(uri, prefix); - } - - - /** - * Returns true or false depending on whether - * an XML Namespace with the given prefix is contained in the {@link XMLNamespaces} of - * this {@link XMLToken}. - *

    - * @param prefix a string, the prefix for the namespace - *

    - * @return true if an XML Namespace with the given URI is contained in the - * {@link XMLNamespaces} of this {@link XMLToken}, false otherwise. - */ - public boolean hasNamespacePrefix(String prefix) { - return namespaces.hasPrefix(prefix); - } - - - /** - * Returns true or false depending on whether - * an XML Namespace with the given URI is contained in the {@link XMLNamespaces} of - * this {@link XMLToken}. - *

    - * @param uri a string, the uri for the namespace - *

    - * @return true if an XML Namespace with the given URI is contained in the - * {@link XMLNamespaces} of this {@link XMLToken}, false otherwise. - */ - public boolean hasNamespaceURI(String uri) { - return namespaces.hasURI(uri); - } - - - /** - * Returns true or false depending on whether - * the attribute set in this {@link XMLToken} set is empty. - *

    - * @return true if the attribute set in this {@link XMLToken} is empty, - * false otherwise. - */ - public boolean isAttributesEmpty() { - return attributes.isEmpty(); - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an XML element. - *

    - * @return true if this {@link XMLToken} is an XML element, false otherwise. - */ - public boolean isElement() { - return !isText; - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an XML end element. - *

    - * @return true if this {@link XMLToken} is an XML end element, false otherwise. - */ - public boolean isEnd() { - return isEndElement; - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an XML end element for the given start element. - *

    - * @param element {@link XMLToken}, element for which query is made. - *

    - * @return true if this {@link XMLToken} is an XML end element for the given - * {@link XMLToken} start element, false otherwise. - */ - public boolean isEndFor(XMLToken element) { - return isEnd() && element.isStart() && element.getName() == getName() - && element.getURI() == getURI(); - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an end of file marker. - *

    - * @return true if this {@link XMLToken} is an end of file (input) marker, false - * otherwise. - */ - public boolean isEOF() { - return isEOF; - } - - - /** - * Returns true or false depending on whether - * the {@link XMLNamespaces} of this {@link XMLToken} is empty. - *

    - * @return true if the {@link XMLNamespaces} of this {@link XMLToken} is empty, - * false otherwise. - */ - public boolean isNamespacesEmpty() { - return namespaces == null ? true : namespaces.isEmpty(); - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an XML start element. - *

    - * @return true if this {@link XMLToken} is an XML start element, false otherwise. - */ - public boolean isStart() { - return isStartElement; - } - - - /** - * Returns true or false depending on whether - * this {@link XMLToken} is an XML text element. - *

    - * @return true if this {@link XMLToken} is an XML text element, false otherwise. - */ - public boolean isText() { - return isText; - } - - - /** - * Removes an attribute with the given index from the attribute set in - * this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param n an integer the index of the resource to be deleted - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *
  • INDEX_EXCEEDS_SIZE - */ - public int removeAttr(int n) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - String oldValue = attributes.getValue(n); - String name = attributes.getName(n); - int success = attributes.remove(n); - this.firePropertyChange(name, oldValue, null); - return success; - } - - - /** - * Removes an attribute with the given local name from - * the attribute set in this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param name a string, the local name of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int removeAttr(String name) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(name); - int success = attributes.remove(name); - this.firePropertyChange(name, oldValue, null); - return success; - } - - - /** - * Removes an attribute with the given local name and namespace URI from - * the attribute set in this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param name a string, the local name of the attribute. - * @param uri a string, the namespace URI of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int removeAttr(String name, String uri) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(name, uri); - int success = attributes.remove(name, uri); - this.firePropertyChange(name, oldValue, null); - return success; - } - - - /** - * Removes an attribute with the given {@link XMLTriple} from the attribute set - * in this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param triple an {@link XMLTriple}, the XML triple of the attribute. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int removeAttr(XMLTriple triple) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - String oldValue = attributes.getValue(triple); - String name = triple.getName(); - int success = attributes.remove(triple); - this.firePropertyChange(name, oldValue, null); - return success; - } - - - /** - * Removes an XML Namespace stored in the given position of the {@link XMLNamespaces} - * of this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param index an integer, position of the removed namespace. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *
  • INDEX_EXCEEDS_SIZE - */ - public int removeNamespace(int index) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - String oldValue = namespaces.getURI(index); - int success = namespaces.remove(index); - this.firePropertyChange(TreeNodeChangeEvent.namespace, oldValue, null); - return success; - } - - /** - * Removes an XML Namespace with the given prefix. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param prefix a string, prefix of the required namespace. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int removeNamespace(String prefix) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - String oldValue = namespaces.getURI(prefix); - int success = namespaces.remove(prefix); - this.firePropertyChange(TreeNodeChangeEvent.namespace, oldValue, null); - return success; - } - - - /** - * Sets an {@link XMLAttributes} to this {@link XMLToken}. - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param attributes {@link XMLAttributes} to be set to this {@link XMLToken}. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - *

    - * @jsbml.note This function replaces the existing {@link XMLAttributes} with the new one. - */ - public int setAttributes(XMLAttributes attributes) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - ArrayList names = this.attributes.attributeNames; - ArrayList values = this.attributes.attributeValues; - for(int i=0; i < this.attributes.getLength(); i++){ - this.firePropertyChange(names.get(i).getName(), values.get(i), null); - } - this.attributes = attributes; - - names = attributes.attributeNames; - values = attributes.attributeValues; - for(int i=0; i < attributes.getLength(); i++){ - this.firePropertyChange(names.get(i).getName(), null, values.get(i)); - } - return JSBML.OPERATION_SUCCESS; - } - - - /** - * @param chars the characters to set - */ - public void setCharacters(String chars) { - String oldValue = characters.toString(); - characters = new StringBuffer(); - characters.append(chars); - this.firePropertyChange(TreeNodeChangeEvent.text, oldValue, characters.toString()); - } - - /** - * Declares this XML start element is also an end element. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int setEnd() { - - isEndElement = true; - - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Declares this {@link XMLToken} is an end-of-file (input) marker. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int setEOF() { - boolean oldValue = isEOF; - isEOF = true; - this.firePropertyChange(TreeNodeChangeEvent.isEOF, oldValue, isEOF); - return JSBML.OPERATION_SUCCESS; - } - - /** - * Sets an XMLnamespaces to this XML element. - *

    - * Nothing will be done if this {@link XMLToken} is not a start element. - *

    - * @param namespaces {@link XMLNamespaces} to be set to this {@link XMLToken}. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - * - *

    - * @jsbml.note This function replaces the existing {@link XMLNamespaces} with the new one. - */ - public int setNamespaces(XMLNamespaces namespaces) { - - if (!isStartElement) { - return JSBML.OPERATION_FAILED; - } - - XMLNamespaces values = this.namespaces; - for(int i=0; i < this.attributes.getLength(); i++){ - this.firePropertyChange(TreeNodeChangeEvent.namespace, values.getURI(i), null); - } - - this.namespaces = namespaces; - - values = this.namespaces; - for(int i=0; i < this.attributes.getLength(); i++){ - this.firePropertyChange(TreeNodeChangeEvent.namespace, null, values.getURI(i)); - } - return JSBML.OPERATION_SUCCESS; - } - - - /** - * Sets the XMLTripe (name, uri and prefix) of this XML element. - *

    - * Nothing will be done if this XML element is a text node. - * @param triple {@link XMLTriple} to be added to this XML element. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - *
  • OPERATION_FAILED - */ - public int setTriple(XMLTriple triple) { - - if (isText) { - return JSBML.OPERATION_FAILED; - } - XMLTriple oldValue = this.triple; - this.triple = triple; - this.firePropertyChange(TreeNodeChangeEvent.xmlTriple, oldValue, triple); - return JSBML.OPERATION_SUCCESS; - } - - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "XMLToken [attributes=" + attributes + ", namespaces=" - + namespaces + ", triple=" + triple + ", characters=" - + characters + ", column=" + column + ", line=" + line - + ", isText=" + isText + ", isEndElement=" + isEndElement - + ", isStartElement=" + isStartElement + ", isEOF=" + isEOF - + "]"; - } - - - /** - * Declares this XML start/end element is no longer an end element. - *

    - * @return integer value indicating success/failure of the - * function. The possible values - * returned by this function are: - *

  • OPERATION_SUCCESS - */ - public int unsetEnd() { - - isEndElement = false; - - return JSBML.OPERATION_SUCCESS; - } - -} - diff --git a/IPK_lib/src/org/sbml/jsbml/xml/XMLTriple.java b/IPK_lib/src/org/sbml/jsbml/xml/XMLTriple.java deleted file mode 100644 index f100fc085..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/XMLTriple.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * $Id: XMLTriple.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/XMLTriple.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml; - - - - -/** - * Representation of a qualified XML name. - *

    - * - This class of objects is defined by jsbml only and has no direct - equivalent in terms of SBML components. This class is not prescribed by - the SBML specifications, although it is used to implement features - defined in SBML. - - - *

    - * A 'triple' in the jsbml XML layer encapsulates the notion of qualified - * name, meaning an element name or an attribute name with an optional - * namespace qualifier. An {@link XMLTriple} instance carries up to three data items: - *

    - *

      - *

      - *

    • The name of the attribute or element; that is, the attribute name - * as it appears in an XML document or data stream; - *

      - *

    • The XML namespace prefix (if any) of the attribute. For example, - * in the following fragment of XML, the namespace prefix is the string - * mysim and it appears on both the element - * someelement and the attribute attribA. When - * both the element and the attribute are stored as {@link XMLTriple} objects, - * their prefix is mysim. - *
      -		<mysim:someelement mysim:attribA='value' />
      -		
      - *

      - *

    • The XML namespace URI with which the prefix is associated. In - * XML, every namespace used must be declared and mapped to a URI. - *

      - *

    - *

    - * {@link XMLTriple} objects are the lowest-level data item in the XML layer - * of jsbml. Other objects such as {@link XMLToken} make use of {@link XMLTriple} - * objects. - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLTriple { - - private String name = ""; - private String prefix = ""; - private String namespaceURI = ""; - - /** - * Equality comparison method for XMLTriple. - *

    - * - * @param sb a reference to an object to which the current object - * instance will be compared - * - * @return true if sb refers to the same underlying - * native object as this one, false otherwise - */ - public boolean equals(Object sb) - { - - if (sb instanceof XMLTriple) { - boolean equals = true; - XMLTriple xmlTriple = (XMLTriple) sb; - - // The attributes should never been null - - equals &= name.equals(xmlTriple.getName()); - equals &= prefix.equals(xmlTriple.getPrefix()); - equals &= namespaceURI.equals(xmlTriple.getURI()); - - return equals; - } - - return false; - } - - /** - * Returns a hashcode for this XMLTriple object. - * - * @return a hash code usable by Java methods that need them. - */ - public int hashCode() - { - return name.hashCode() + prefix.hashCode() + namespaceURI.hashCode(); - } - - - /** - * Creates a new, empty {@link XMLTriple}. - */ - public XMLTriple() { - - } - - - /** - * Creates a new {@link XMLTriple} with the given name, uri and and - * prefix. - *

    - * @param name a string, name for the {@link XMLTriple}. - * @param uri a string, URI of the {@link XMLTriple}. - * @param prefix a string, prefix for the URI of the {@link XMLTriple}, - */ - public XMLTriple(String name, String uri, String prefix) { - - if (name != null) { - this.name = name; - } - if (uri != null) { - namespaceURI = uri; - } - if (prefix != null) { - this.prefix = prefix; - } - - - } - - - /** - * Creates a new {@link XMLTriple} by splitting the given triplet on the - * separator character sepchar. - *

    - * Triplet may be in one of the following formats: - *

      - *
    • name - *
    • uri sepchar name - *
    • uri sepchar name sepchar prefix - *
    - * @param triplet a string representing the triplet as above - * @param sepchar a character, the sepchar used in the triplet - *

    - */ - public XMLTriple(String triplet, char sepchar) { - - if (triplet == null) { - throw new IllegalArgumentException("Cannot create an XMLTriple with a null argument."); - } - // parse the triplet - String[] tokens = triplet.split("" + sepchar); - - if (tokens.length == 1) { - name = tokens[0].trim(); - } else if (tokens.length == 2) { - namespaceURI = tokens[0].trim(); - name = tokens[1].trim(); - } else if (tokens.length == 3) { - namespaceURI = tokens[0].trim(); - name = tokens[1].trim(); - prefix = tokens[2].trim(); - } else { - throw new IllegalArgumentException(String.format( - "Cannot create an XMLTriple with the argument '%s' and the separator '%s'.", - triplet, sepchar)); - } - } - - - /** - * Creates a new {@link XMLTriple} by splitting the given triplet - * separated by space. - *

    - * Triplet may be in one of the following formats: - *

      - *
    • name - *
    • uri name - *
    • uri name prefix - *
    - * @param triplet a string representing the triplet as above - *

    - */ - public XMLTriple(String triplet) { - this(triplet, ' '); - } - - - /** - * Creates a copy of this {@link XMLTriple} set. - */ - public XMLTriple(XMLTriple orig) { - - name = new String(orig.getName()); - namespaceURI = new String(orig.getURI()); - prefix = new String(orig.getPrefix()); - - } - - - /** - * Creates and returns a deep copy of this {@link XMLTriple} set. - *

    - * @return a (deep) copy of this {@link XMLTriple} set. - */ - public XMLTriple clone() { - return new XMLTriple(this); - } - - - /** - * Returns the name portion of this {@link XMLTriple}. - *

    - * @return a string, the name from this {@link XMLTriple}. - */ - public String getName() { - return name; - } - - - /** - * Returns the prefix portion of this {@link XMLTriple}. - *

    - * @return a string, the prefix portion of this {@link XMLTriple}. - */ - public String getPrefix() { - return prefix; - } - - - /** - * Returns the URI portion of this {@link XMLTriple}. - *

    - * @return URI a string, the prefix portion of this {@link XMLTriple}. - */ - public String getURI() { - return namespaceURI; - } - - - /** - * Returns the prefixed name from this {@link XMLTriple}. - *

    - * @return a string, the prefixed name from this {@link XMLTriple}. - */ - public String getPrefixedName() { - return prefix.length() == 0 ? name : prefix + ":" + name; - } - - - /** - * Predicate returning true or false depending on whether - * this {@link XMLTriple} is empty. - *

    - * @return true if this {@link XMLTriple} is empty, false otherwise. -

    - * @deprecated libSBML internal - */ - @Deprecated - public boolean isEmpty() { - return ( getName().length() == 0 - && getURI().length() == 0 - && getPrefix().length() == 0); - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/package.html b/IPK_lib/src/org/sbml/jsbml/xml/package.html deleted file mode 100644 index 841d75795..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/package.html +++ /dev/null @@ -1,7 +0,0 @@ - -

    - This package provides classes and methods to deal with SBML in form of XML elements, - i.e., here you can find parsers and writers for SBML and also elements to define - XML nodes to be used for notes or annotations. -

    - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java deleted file mode 100644 index b31347307..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * $Id: AbstractReaderWriter.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/AbstractReaderWriter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.ArrayList; -import java.util.Enumeration; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.SBasePlugin; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; - -/** - * Contains some code shared by most of the L3 packages parsers. - * - * @author Nicolas Rodriguez - * @since 1.0 - * @version $Rev: 1116 $ - */ -public abstract class AbstractReaderWriter implements ReadingParser, WritingParser { - - private Logger logger = Logger.getLogger(AbstractReaderWriter.class); - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processAttribute(String - * elementName, String attributeName, String value, String prefix, - * boolean isLastAttribute, Object contextObject) - */ - @Override - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - - logger.debug("processAttribute -> " + prefix + " : " + attributeName + " = " + value + " (" + contextObject.getClass().getName() + ")"); - - boolean isAttributeRead = false; - - if (contextObject instanceof SBase) { - - SBase sbase = (SBase) contextObject; - - // logger.debug("processAttribute : level, version = " + sbase.getLevel() + ", " + sbase.getVersion()); - - try { - isAttributeRead = sbase.readAttribute(attributeName, prefix, - value); - } catch (Throwable exc) { - logger.error(exc.getMessage()); - } - } else - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - isAttributeRead = annotation.readAttribute(attributeName, prefix, value); - } else - if (contextObject instanceof SBasePlugin) { - isAttributeRead = ((SBasePlugin) contextObject).readAttribute(attributeName, prefix, value); - } - - if (!isAttributeRead) { - logger.warn("processAttribute : The attribute " + attributeName - + " on the element " + elementName + - " is not part of the SBML specifications"); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.stax.ReadingParser#processCharactersOf(java.lang.String, java.lang.String, java.lang.Object) - */ - @Override - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - logger.debug("processCharactersOf : the element " + elementName + " does not have any text. " + - "SBML syntax error. Characters lost = " + characters); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndDocument(org.sbml.jsbml.SBMLDocument) - */ - @Override - public void processEndDocument(SBMLDocument sbmlDocument) { - // does nothing - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndElement(java.lang.String, java.lang.String, boolean, java.lang.Object) - */ - @Override - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - // does nothing - return true; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processNamespace(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) - */ - @Override - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - // TODO : read the namespace, it could be some other extension objects - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processStartElement(java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) - */ - @Override - public abstract Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject); - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.WritingParser#getListOfSBMLElementsToWrite(Object sbase) - */ - @Override - @SuppressWarnings("unchecked") - public ArrayList getListOfSBMLElementsToWrite(Object sbase) { - - logger.debug("getListOfSBMLElementsToWrite : " + sbase.getClass().getCanonicalName()); - - ArrayList listOfElementsToWrite = new ArrayList(); - Enumeration children = null; - - if (sbase instanceof SBMLDocument) { - // nothing to do - // TODO : the 'required' attribute is written even if there is no plugin class for the SBMLDocument - // we will have to change that !!! - return null; - } else - if (sbase instanceof SBasePlugin) { - SBasePlugin elementPlugin = (SBasePlugin) sbase; - - children = elementPlugin.children(); - } else - if (sbase instanceof TreeNode) { - children = (Enumeration) ((TreeNode) sbase).children(); - - } else { - return null; - } - - while (children.hasMoreElements()) { - listOfElementsToWrite.add(children.nextElement()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - - return listOfElementsToWrite; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeAttributes(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - @Override - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - - xmlObject.addAttributes(sbase.writeXMLAttributes()); - } - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeCharacters(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - @Override - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - logger.error("writeCharacters : " + xmlObject.getName() + " XML element do not have any characters !!"); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeElement(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - @Override - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - - logger.debug("writeElement : " + sbmlElementToWrite.getClass().getSimpleName()); - - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - - if (!xmlObject.isSetName()) { - if (sbase instanceof ListOf) { - ListOf listOf = (ListOf) sbase; - - if (listOf.size() > 0) { - String listOfName = "listOf" + listOf.get(0).getClass().getSimpleName(); - if (!listOfName.endsWith("s")) { - listOfName += "s"; - } - xmlObject.setName(listOfName); - } - - } else { - xmlObject.setName(sbase.getElementName()); - } - } - if (!xmlObject.isSetPrefix()) { - xmlObject.setPrefix(getShortLabel()); - } - xmlObject.setNamespace(getNamespaceURI()); - - } - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeNamespaces(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - @Override - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - xmlObject.setPrefix(getShortLabel()); - } - - // TODO : write all namespaces - } - - /** - * Returns the shortLabel of the namespace parsed by this class. - * - * @return the shortLabel of the namespace parsed by this class. - */ - public abstract String getShortLabel(); - - /** - * Return the namespace URI of the namespace parsed by this class. - * - * @return the namespace URI of the namespace parsed by this class. - */ - public abstract String getNamespaceURI(); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/AnnotationParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/AnnotationParser.java deleted file mode 100644 index 50c16a5d5..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/AnnotationParser.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * $Id: AnnotationParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/AnnotationParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.SBMLDocument; - -/** - * The AnnotationParser is used when some subelements of an annotation XML node - * have a namespace URI/prefix which doesn't match any ReadingParser class and - * so can't be parsed with another ReadingParser than this one. This class - * allows to store the subelements of this annotation XML node into the - * 'otherAnnotation' String of the matching Annotation instance. - * - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1187 $ - */ -public class AnnotationParser implements ReadingParser { - - Logger logger = Logger.getLogger(AnnotationParser.class); - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * elementName, String attributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - - // an AnnotationParser can only be used for the annotations of a SBML - // component. If the contextObject is not - // an Annotation instance, this parser doesn't process any XML - // attributes. - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - // If there is a prefix, the AnnotationParser will also store the - // prefix within the key - // and appends the attribute to the 'otherAnnotation' String of - // annotation. - if (!prefix.equals("")) { - annotation.appendNoRDFAnnotation(" " + prefix + ":" - + attributeName + "=\"" + value + "\""); - } else { - annotation.appendNoRDFAnnotation(" " + attributeName + "=\"" - + value + "\""); - } - - // If the attribute is the last attribute of its element, we need to - // close the element tag. - if (isLastAttribute) { - annotation.appendNoRDFAnnotation(">"); - } - } else { - // There is a syntax error, the attribute can't be read? - // TODO : log the problem - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, Object contextObject) - { - - // characters = StringTools.encodeForHTML(characters); - - // an AnnotationParser can only be used for the annotations of a SBML - // component. If the contextObject is not - // an Annotation instance, this parser doesn't process any texts. - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - annotation.appendNoRDFAnnotation(characters); - - } else if (characters.trim().length() > 0) { - // There is a syntax error, the text can't be read? - logger.warn("some characters migth be lost !! (element name = " + elementName + ", characters = " + characters + ", context = " + contextObject); - } else { - logger.debug("some characters migth be lost !! (element name = " + elementName + ", characters = " + characters); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * elementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) - { - - logger.debug("processEndElement : elementName = " + elementName); - - // an AnnotationParser can only be used for the annotations of a SBML - // component. If the contextObject is not - // an Annotation instance, this parser doesn't process any elements. - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - StringBuilder builder = annotation.getAnnotationBuilder(); - - // If the element is nested, we need to remove the default ending - // tag of the element. - if (isNested && annotation.getNonRDFannotation().endsWith(">")) { - int builderLength = builder.length(); - builder.delete(builderLength - 3, builderLength); - } - - // If the element is nested, we need to add a nested element ending - // tag. - if (isNested) { - annotation.appendNoRDFAnnotation("/>"); - } - // else, write a entire ending tag with the name of the element - // (Store the prefix too into the String). - else { - if (!prefix.equals("")) { - annotation.appendNoRDFAnnotation(""); - } else { - annotation.appendNoRDFAnnotation(""); - } - } - } else { - // There is a syntax error, the node can't be read? - // TODO : log the problem - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - { - - logger.error("processNamespace : elementName = " + elementName); - logger.error("processNamespace : namespace uri = " + URI); - logger.error("processNamespace : namespace prefix = " + prefix); - logger.error("processNamespace : namespace localName = " + localName); - - if (elementName.equals("annotation")) { - // The namespaces are store using the SBMLCoreParser for the annotation element - return; - } - - // If the element is an annotation and the contextObject is an - // Annotation instance, - // we need to add the namespace to the 'annotationNamespaces' HashMap of - // annotation. - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - if (prefix.trim().length() == 0) { - annotation.appendNoRDFAnnotation(" " + localName + "=\"" + URI + "\""); - } else { - annotation.appendNoRDFAnnotation(" " + prefix + ":" + localName + "=\"" + URI + "\""); - } - annotation.appendNoRDFAnnotation(""); - - - // If the attribute is the last attribute of its element, we need to - // close the element tag. - if (isLastNamespace && !hasAttributes) { - annotation.appendNoRDFAnnotation(">"); - } - } - // If the namespaces are declared in the sbml node, we need to add the - // namespace to - // the 'SBMLDocumentNamespaces' map of the SBMLDocument instance. - else if (elementName.equals("sbml") - && contextObject instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) contextObject; - sbmlDocument.addNamespace(localName, prefix, URI); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) - { - logger.error(String.format("processing startElement %s. %s", elementName, prefix)); - - // an AnnotationParser can only be used for the annotations of a SBML - // component. If the contextObject is not - // an Annotation instance, this parser doesn't process any elements. - if (contextObject instanceof Annotation) { - - Annotation annotation = (Annotation) contextObject; - - // If there is a prefix, the AnnotationParser will also store the - // prefix within the key - // and appends the element to the 'otherAnnotation' String of - // annotation. - if (!prefix.equals("")) { - annotation.appendNoRDFAnnotation("<" + prefix + ":" - + elementName); - } else { - annotation.appendNoRDFAnnotation("<" + elementName); - } - - // If the element has no attributes and namespaces, we need to close - // the element tag. - if (!hasAttributes && !hasNamespaces) { - annotation.appendNoRDFAnnotation(">"); - } - return annotation; - } else { - // There is a syntax error, the node can't be read ? - logger.error(String.format("Cannot read the element %s as the context object is not of the type Annotationblahblah", elementName)); - } - return contextObject; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/BiologicalQualifierParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/BiologicalQualifierParser.java deleted file mode 100644 index dd4d218a5..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/BiologicalQualifierParser.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * $Id: BiologicalQualifierParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/BiologicalQualifierParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.HashMap; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.CVTerm; -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.CVTerm.Type; -import org.sbml.jsbml.SBMLDocument; - -/** - * A BiologicalQualifierParser is used to parse the XML elements and attributes - * which have this namespace URI : http://biomodels.net/biology-qualifiers/. - * - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class BiologicalQualifierParser implements ReadingParser { - - private Logger logger = Logger.getLogger(BiologicalQualifierParser.class); - - /** - * The namespace URI of this ReadingParser. - */ - private static final String namespaceURI = "http://biomodels.net/biology-qualifiers/"; - - /** - * @return the namespaceURI of this parser. - */ - public static String getNamespaceURI() { - return namespaceURI; - } - - /** - * The map containing all the relationships Miriam qualifier String <=> - * Miriam qualifier Qualifier. - */ - private HashMap biologicalQualifierMap = new HashMap(); - - /** - * Creates a BiologicalQualifierParser instance and initialises the - * biologicalQualifierMap. - */ - public BiologicalQualifierParser() { - initialisesBiologicalQualifierMap(); - } - - /** - * Initialises the biologicalQualifierMap of this parser. - */ - private void initialisesBiologicalQualifierMap() { - // TODO : loading from a file would be better. - - // TODO : We need to try to make it work with qualifier that we do not know !!! - - for (CVTerm.Qualifier qualifier : CVTerm.Qualifier.values()) { - if (qualifier.isBiologicalQualifier()) { - biologicalQualifierMap.put(qualifier.getElementNameEquivalent(), qualifier); - logger.debug("initialisesBiologicalQualifierMap : " + qualifier.getElementNameEquivalent()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * ElementName, String AttributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - // TODO : a node with a biological qualifier can't have attributes, - // there is a SBML syntax error, log the error ? - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO : a node with a biological qualifier can't have text, there is a - // SBML syntax error, log the error ? - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * ElementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String ElementName, String prefix, - boolean isNested, Object contextObject) { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - - // The namespace of this parser should be declared in the RDF subnode of - // the annotation. - // Adds the namespace to the RDFAnnotationNamespaces HashMap of - // annotation. - if (elementName.equals("RDF") && contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - annotation.addRDFAnnotationNamespace(localName, prefix, URI); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - - // A BiologicalQualifierParser can only modify a contextObject which is - // an instance of Annotation. - // That will probably change in SBML level 3 with the Annotation package - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - // This parser can parse only biological Miriam qualifiers. This - // element should not have attributes or namespace declarations. - // Creates a new CVTerm and - // sets the qualifierType and biologicalQualifierType of this - // CVTerm. Then, adds the - // initialized CVTerm to annotation. - if (biologicalQualifierMap.containsKey(elementName) - && !hasAttributes && !hasNamespaces) { - CVTerm cvTerm = new CVTerm(); - cvTerm.setQualifierType(Type.BIOLOGICAL_QUALIFIER); - cvTerm.setBiologicalQualifierType(biologicalQualifierMap - .get(elementName)); - - annotation.addCVTerm(cvTerm); - return cvTerm; - } else { - // TODO : SBML syntax error, log an error - } - } else { - // TODO the context object of a biological qualifier node should be - // an annotation instance, there is a SBML syntax error, log an error ? - } - return contextObject; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/CreatorParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/CreatorParser.java deleted file mode 100644 index 3e8f873cb..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/CreatorParser.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * $Id: CreatorParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/CreatorParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.History; -import org.sbml.jsbml.SBMLDocument; - -/** - * A CreatorParser is used to parser the subelements of an annotation element which have this namespaceURI : - * http://purl.org/dc/elements/1.1/. - * - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1177 $ - */ -public class CreatorParser implements ReadingParser { - - /** - * The namespace URI of this ReadingParser. - */ - private static final String namespaceURI = "http://purl.org/dc/elements/1.1/"; - - /** - * @return the namespaceURI of this parser. - */ - public static String getNamespaceURI() { - return namespaceURI; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String ElementName, String AttributeName, String value, String prefix, boolean isLastAttribute, Object contextObject) - */ - public void processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - // TODO : there is no attributes with the namespace "http://purl.org/dc/elements/1.1/", there - // is a SBML syntax error, log an error ? - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO : there is no text for the element with the namespace "http://purl.org/dc/elements/1.1/", there - // is a SBML syntax error, log an error ? - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String elementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String elementName, String URI, String prefix, String localName, boolean hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - - // The namespace of this parser is declared in a RDF subnode of an annotation. - // adds the namespace to the RDFAnnotationNamespaces HashMap of annotation. - if (elementName.equals("RDF") && (contextObject instanceof Annotation)) { - Annotation annotation = (Annotation) contextObject; - - annotation.addRDFAnnotationNamespace(localName, prefix, URI); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) { - - // A CreatorParser can only modify a contextObject which is an Annotation instance. - // The namespace of this parser should be associated with the creator subnode of an annotation. - // Creates a ModelHistory instance and set the modelHistory of annotation. - if (elementName.equals("creator") && (contextObject instanceof Annotation)) { - Annotation annotation = (Annotation) contextObject; - History modelHistory = new History(); - annotation.setHistory(modelHistory); - - return modelHistory; - } - else { - // TODO : !elementName.equals("creator"), SBML syntax error? - // TODO : !contextObject instanceof ModelAnnotation, for the moment, only a model with a modelAnnotaton - // can contain an history. Should be changed depending on the version. - } - return contextObject; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/DatesParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/DatesParser.java deleted file mode 100644 index 46d08be2b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/DatesParser.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * $Id: DatesParser.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/DatesParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.Date; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.History; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.xml.stax.DateProcessor; -import org.w3c.util.DateParser; -import org.w3c.util.InvalidDateException; - -/** - * A DatesParser is used to parse the subNodes of an annotation which have this - * namespace URI : http://purl.org/dc/terms/. - * - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class DatesParser implements ReadingParser { - - /** - * Stores the localName of the last element read by this parser. - */ - private String previousElement = ""; - /** - * Boolean value to know if a 'created' element has been read by this - * parser. - */ - private boolean hasReadCreated = false; - /** - * Boolean value to know if a 'W3CDTF' element has been read by this parser. - */ - boolean hasReadW3CDTF = false; - - /** - * Boolean value to know if a 'modified' element has been read by this - * parser. - */ - boolean hasReadModified = false; - - private Logger logger = Logger.getLogger(DatesParser.class); - - /** - * @return the namespaceURI - */ - public static String getNamespaceURI() { - return JSBML.URI_PURL_TERMS; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * ElementName, String AttributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - { - // does nothing - logger.debug("processCharactersOf : attribute " + AttributeName + " ignored."); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - - logger.debug("processCharactersOf : " + characters + ", element name = " + elementName); - - // An elementName can be null if the text appears after an element - // ending tag. In this case, - // this parser will not parse the text. - if (elementName != null) { - - // A DatesParser can only modify a contextObject which is a - // ModelHistory instance. - if (contextObject instanceof History) { - History modelHistory = (History) contextObject; - DateProcessor dateProcessor = new DateProcessor(); - - // The date to parse is the text of a 'W3CDTF' element. - // However, the date will be parsed only if the syntax of this - // node and the previous - // node respects the SBML specifications. - if (elementName.equals("W3CDTF") && hasReadW3CDTF) { - - // If the previous node was a 'created' element and - // respected the SBML specifications, - // a new Date will be created and set to the text value of - // this node. - // Sets the created Date of modelHistory. - if (hasReadCreated && previousElement.equals("created")) { - String stringDate = dateProcessor.formatToW3CDTF(characters); - - try { - Date createdDate = DateParser.parse(stringDate); - modelHistory.setCreatedDate(createdDate); - - logger.debug("processCharactersOf : getIsoDateNoMillis " + DateParser.getIsoDateNoMillis(createdDate)); - - } catch (InvalidDateException e) { - logger.warn("Cannot read the following date properly :" + stringDate); - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - } - - } - // If the previous node was a 'modified' element and - // respected the SBML specifications, - // a new Date will be created and set to the text value of - // this node. - // Sets the modified Date and adds the new Date to the - // listOfModifications of modelHistory. - else if (previousElement.equals("modified")) { - String stringDate = dateProcessor.formatToW3CDTF(characters); - - try { - Date modifiedDate = DateParser.parse(stringDate); - modelHistory.setModifiedDate(modifiedDate); - } catch (InvalidDateException e) { - logger.warn("Cannot read the following date properly :" + stringDate); - if (logger.isDebugEnabled()) { - e.printStackTrace(); - } - } - } else { - logger.debug("processCharactersOf : previousElement is not created or modified !!!"); - } - } else { - logger.debug("processCharactersOf : context object is not a W3CDTF element !! "); - } - } else { - logger.debug("processCharactersOf : context object is not an History !! -> " - + contextObject.getClass().getName()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - previousElement = ""; - hasReadCreated = false; - hasReadModified = false; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * elementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - - logger.debug("processEndElement : " + elementName); - - // A DatesParser can only modify a contextObject which is a ModelHistory - // instance. - if (contextObject instanceof History) { - // When a 'created' or 'modified' node is closed, the - // previousElement of this parser is set - // to "", the boolean hasReadW3CDTF, hasReadCreated and - // hasReadModified are set to false. - if (elementName.equals("created") || elementName.equals("modified")) { - this.previousElement = ""; - hasReadW3CDTF = false; - if (elementName.equals("created")) { - hasReadCreated = false; - } - if (elementName.equals("modified")) { - hasReadModified = false; - } - } else if (!elementName.equals("W3CDTF")) { - logger.debug("Found an element other than 'created', 'modified' or 'W3CDTF', " + - "do not know what to do with '" + elementName + "'"); - } - } else { - logger.debug("Do not know what to do with the element '" + elementName + "'."); - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - // The namespace of this parser should be declared in a 'RDF' subNode of - // an annotation. - // Sets the namespace to the RDFAnnotationNamespaces HashMap of - // annotation. - if (elementName.equals("RDF") && contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - annotation.addRDFAnnotationNamespace(localName, prefix, URI); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - - logger.debug("processStartElement : " + elementName); - - // When this parser read a starting element tag, it can modify a - // contextObject which is an Annotation instance. - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - if (!annotation.isSetHistory()) { - annotation.setHistory(new History()); - } - - if (annotation.isSetHistory()) { - History history = annotation.getHistory(); - - // If the localName of the node is 'created' and if it has not - // been read yet, - // the previousElement of this parser is set to 'created' and - // hasReadCreated is set - // to true. - // The modelHistory of annotation is not changed but is - // returned. - if (elementName.equals("created") && !hasReadCreated) { - hasReadCreated = true; - this.previousElement = elementName; - - return history; - } - // If the localName of the node is 'modified' and if it has not - // been read yet, - // the previousElement of this parser is set to 'modified' and - // hasReadModified is set - // to true. - // The modelHistory of annotation is not changed but is - // returned. - else if (elementName.equals("modified") && !hasReadModified) { - this.previousElement = elementName; - hasReadModified = true; - return history; - } else { - logger.debug("processStartElement : element unknown !!"); - } - } else { - logger.debug("processStartElement : history not set yet !!"); - } - } - // When this parser read a starting element tag, it can modify a - // contextObject - // which is a ModelHistory instance. - else if (contextObject instanceof History) { - - // If the node is a 'W3CDTF' subElement of a 'created' or 'modified' - // element, the boolean hasReadW3CDTF - // of this node is set to true. - if (elementName.equals("W3CDTF") - && (previousElement.equals("created") || previousElement - .equals("modified"))) { - hasReadW3CDTF = true; - } - } - - return contextObject; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java deleted file mode 100644 index 80bcc4d6e..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * $Id: L3LayoutParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/L3LayoutParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.xml.parsers; - -import static org.sbml.jsbml.ext.layout.LayoutConstant.basePoint1; -import static org.sbml.jsbml.ext.layout.LayoutConstant.basePoint2; -import static org.sbml.jsbml.ext.layout.LayoutConstant.boundingBox; -import static org.sbml.jsbml.ext.layout.LayoutConstant.compartmentGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.curve; -import static org.sbml.jsbml.ext.layout.LayoutConstant.curveSegment; -import static org.sbml.jsbml.ext.layout.LayoutConstant.dimensions; -import static org.sbml.jsbml.ext.layout.LayoutConstant.end; -import static org.sbml.jsbml.ext.layout.LayoutConstant.layout; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfAdditionalGraphicalObjects; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfCompartmentGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfCurveSegments; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfLayouts; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfReactionGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfSpeciesGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfSpeciesReferenceGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.listOfTextGlyphs; -import static org.sbml.jsbml.ext.layout.LayoutConstant.namespaceURI; -import static org.sbml.jsbml.ext.layout.LayoutConstant.position; -import static org.sbml.jsbml.ext.layout.LayoutConstant.reactionGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.speciesGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.speciesReferenceGlyph; -import static org.sbml.jsbml.ext.layout.LayoutConstant.start; -import static org.sbml.jsbml.ext.layout.LayoutConstant.textGlyph; - -import java.util.ArrayList; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.SBasePlugin; -import org.sbml.jsbml.ext.layout.BasePoint1; -import org.sbml.jsbml.ext.layout.BasePoint2; -import org.sbml.jsbml.ext.layout.BoundingBox; -import org.sbml.jsbml.ext.layout.CompartmentGlyph; -import org.sbml.jsbml.ext.layout.Curve; -import org.sbml.jsbml.ext.layout.CurveSegment; -import org.sbml.jsbml.ext.layout.Dimensions; -import org.sbml.jsbml.ext.layout.End; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.GraphicalObject; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.LayoutConstant; -import org.sbml.jsbml.ext.layout.Position; -import org.sbml.jsbml.ext.layout.ReactionGlyph; -import org.sbml.jsbml.ext.layout.SpeciesGlyph; -import org.sbml.jsbml.ext.layout.SpeciesReferenceGlyph; -import org.sbml.jsbml.ext.layout.Start; -import org.sbml.jsbml.ext.layout.TextGlyph; - -/** - * This class is used to parse the layout extension package elements and - * attributes. The namespaceURI URI of this parser is - * "http://www.sbml.org/sbml/level3/version1/layout/version1". This parser is - * able to read and write elements of the layout package (implements - * ReadingParser and WritingParser). - * - * @author Nicolas Rodriguez - * @since 1.0 - * @version $Rev: 1127 $ - */ -public class L3LayoutParser extends AbstractReaderWriter { - - /** - * @return the namespaceURI of this parser. - */ - public String getNamespaceURI() { - return LayoutConstant.namespaceURI; - } - - public String getShortLabel() { - return LayoutConstant.shortLabel; - } - - private Logger logger = Logger.getLogger(L3LayoutParser.class); - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.WritingParser#getListOfSBMLElementsToWrite(Object sbase) - */ - public ArrayList getListOfSBMLElementsToWrite(Object sbase) { - - if (logger.isDebugEnabled()) { - logger.debug("getListOfSBMLElementsToWrite : " + sbase.getClass().getCanonicalName()); - } - - ArrayList listOfElementsToWrite = new ArrayList(); - - if (sbase instanceof Model) { - SBasePlugin modelPlugin = (SBasePlugin) ((Model) sbase).getExtension(getNamespaceURI()); - - if (modelPlugin != null) { - listOfElementsToWrite = super.getListOfSBMLElementsToWrite(modelPlugin); - } - } else { - listOfElementsToWrite = super.getListOfSBMLElementsToWrite(sbase); - } - - return listOfElementsToWrite; - } - - /** - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processStartElement(String elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, Object - * contextObject) - */ - // Create the proper object and link it to his parent. - @SuppressWarnings("unchecked") - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) - { - if (contextObject instanceof Model) { - Model model = (Model) contextObject; - - if (elementName.equals(listOfLayouts)) { - - ExtendedLayoutModel layoutModel = new ExtendedLayoutModel(model); - model.addExtension(namespaceURI, layoutModel); - - return layoutModel.getListOfLayouts(); - } - } - else if (contextObject instanceof Layout) { - Layout layout = (Layout) contextObject; - SBase newElement = null; - - if (elementName.equals(listOfCompartmentGlyphs)) { - - newElement = layout.getListOfCompartmentGlyphs(); - } - else if (elementName.equals(listOfSpeciesGlyphs)) { - - newElement = layout.getListOfSpeciesGlyphs(); - } - else if (elementName.equals(listOfReactionGlyphs)) { - - newElement = layout.getListOfReactionGlyphs(); - } - else if (elementName.equals(listOfTextGlyphs)) { - - newElement = layout.getListOfTextGlyphs(); - } - else if (elementName.equals(listOfAdditionalGraphicalObjects)) { - - newElement = layout.getListOfAdditionalGraphicalObjects(); - } - else if (elementName.equals(dimensions)) { - Dimensions dimension = new Dimensions(); - layout.setDimensions(dimension); - - newElement = dimension; - } - - if (newElement != null) { - layout.registerChild(newElement); - return newElement; - } - } - else if (contextObject instanceof GraphicalObject) { - GraphicalObject graphicalObject = (GraphicalObject) contextObject; - - if (elementName.equals(boundingBox)) { - BoundingBox bbox = new BoundingBox(); - graphicalObject.setBoundingBox(bbox); - - return bbox; - } - - if (graphicalObject instanceof ReactionGlyph) { - ReactionGlyph reactionGlyph = (ReactionGlyph) graphicalObject; - if (elementName.equals(curve)) { - Curve curve = new Curve(); - reactionGlyph.setCurve(curve); - - return curve; - } - else if (elementName.equals(listOfSpeciesReferenceGlyphs)) { - ListOf list = reactionGlyph.getListOfSpeciesReferenceGlyphs(); - reactionGlyph.registerChild(list); - return list; - } - - } - } - else if (contextObject instanceof SpeciesReferenceGlyph) { - SpeciesReferenceGlyph speciesRefGlyph = (SpeciesReferenceGlyph) contextObject; - - if (elementName.equals(curve)) { - Curve curve = new Curve(); - speciesRefGlyph.setCurve(curve); - - return curve; - } - - } - else if (contextObject instanceof BoundingBox) { - BoundingBox bbox = (BoundingBox) contextObject; - - if (elementName.equals(position)) { - Position position = new Position(); - bbox.setPosition(position); - - return position; - } - else if (elementName.equals(dimensions)) { - Dimensions dimension = new Dimensions(); - bbox.setDimensions(dimension); - - return dimension; - } - } - else if (contextObject instanceof Curve) { - Curve curve = (Curve) contextObject; - SBase newElement = null; - - if (elementName.equals(listOfCurveSegments)) { - - newElement = curve.getListOfCurveSegments(); - } - - if (newElement != null) { - curve.registerChild(newElement); - return newElement; - } - } - else if (contextObject instanceof CurveSegment) { - CurveSegment curveSegment = (CurveSegment) contextObject; - - if (elementName.equals(start)) { - Start point = new Start(); - curveSegment.setStart(point); - - return point; - } - else if (elementName.equals(end)) { - End point = new End(); - curveSegment.setEnd(point); - - return point; - } - else if (elementName.equals(basePoint1)) { - BasePoint1 point = new BasePoint1(); - curveSegment.setBasePoint1(point); - - return point; - } - else if (elementName.equals(basePoint2)) { - BasePoint2 point = new BasePoint2(); - curveSegment.setBasePoint2(point); - - return point; - } - - } - else if (contextObject instanceof ListOf) { - ListOf listOf = (ListOf) contextObject; - SBase newElement = null; - String layoutId = ""; - if (!elementName.equals(layout)) { - Layout layout = (Layout) listOf.getParentSBMLObject(); - layoutId = layout.getId(); - } - if (elementName.equals(layout)) { - newElement = new Layout(); - } - else if (elementName.equals(compartmentGlyph)) { - newElement = new CompartmentGlyph(); - } - else if (elementName.equals(speciesGlyph)) { - newElement = new SpeciesGlyph(); - SpeciesGlyph speciesGlyph = (SpeciesGlyph) newElement; - speciesGlyph.setLayoutId(layoutId); - } - else if (elementName.equals(reactionGlyph)) { - newElement = new ReactionGlyph(); - ReactionGlyph reactionGlyph = (ReactionGlyph) newElement; - reactionGlyph.setLayoutId(layoutId); - } - else if (elementName.equals(textGlyph)) { - newElement = new TextGlyph(); - } - else if (elementName.equals(curveSegment)) { - newElement = new CurveSegment(); - } - else if (elementName.equals(speciesReferenceGlyph)) { - newElement = new SpeciesReferenceGlyph(); - } - - if (newElement != null) { - listOf.registerChild(newElement); - listOf.add(newElement); - } - - return newElement; - - } - return contextObject; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/LayoutParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/LayoutParser.java deleted file mode 100644 index 20333dc53..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/LayoutParser.java +++ /dev/null @@ -1,719 +0,0 @@ -/* - * $Id: LayoutParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/extensions/layout/src/org/sbml/jsbml/xml/parsers/LayoutParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.xml.parsers; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; - -import javax.swing.tree.TreeNode; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.ext.SBasePlugin; -import org.sbml.jsbml.ext.layout.BasePoint1; -import org.sbml.jsbml.ext.layout.BasePoint2; -import org.sbml.jsbml.ext.layout.BoundingBox; -import org.sbml.jsbml.ext.layout.CompartmentGlyph; -import org.sbml.jsbml.ext.layout.CubicBezier; -import org.sbml.jsbml.ext.layout.Curve; -import org.sbml.jsbml.ext.layout.CurveSegment; -import org.sbml.jsbml.ext.layout.Dimensions; -import org.sbml.jsbml.ext.layout.End; -import org.sbml.jsbml.ext.layout.ExtendedLayoutModel; -import org.sbml.jsbml.ext.layout.Layout; -import org.sbml.jsbml.ext.layout.Point; -import org.sbml.jsbml.ext.layout.ReactionGlyph; -import org.sbml.jsbml.ext.layout.SpeciesGlyph; -import org.sbml.jsbml.ext.layout.SpeciesReferenceGlyph; -import org.sbml.jsbml.ext.layout.Start; -import org.sbml.jsbml.ext.layout.TextGlyph; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; - -/** - * This class is used to parse the layout extension package elements and - * attributes. The namespaceURI URI of this parser is - * "http://www.sbml.org/sbml/level3/version1/layout/version1". This parser is - * able to read and write elements of the layout package (implements - * ReadingParser and WritingParser). - * - * @author Nicolas Rodriguez - * @author Sebastian Frölich - * @author Andreas Dräger - * @since 1.0 - * @version $Rev: 1207 $ - */ -public class LayoutParser implements ReadingParser, WritingParser { - enum LayoutList { - listOfLayouts, listOfSpeciesGlyphs, listOfReactionGlyphs, listOfTextGlyphs, listOfCompartmentGlyphs, none, listOfCurveSegments, listOfSpeciesReferenceGlyphs - } - - /** - * The namespace URI of this parser. - */ - private static final String namespaceURI = "http://www.sbml.org/sbml/level3/version1/layout/version1"; - - /** - * @return the namespaceURI of this parser. - */ - public static String getNamespaceURI() { - return namespaceURI; - } - - /** - * The layoutList enum which represents the name of the list this parser is - * currently reading. - */ - private LayoutList groupList = LayoutList.none; - - /** - * Log4j logger - */ - private Logger log4jLogger = Logger.getLogger(LayoutParser.class); - - /** - * This map contains all the relationships XML element name <=> matching - * java class. - */ - private HashMap> sbmlLayoutElements; - - /** - * - */ - public LayoutParser() { - super(); - sbmlLayoutElements = new HashMap>(); - JSBML.loadClasses( - "org/sbml/jsbml/resources/cfg/SBMLLayoutElements.xml", - sbmlLayoutElements); - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#getListOfSBMLElementsToWrite(java.lang.Object) - */ - @SuppressWarnings("unchecked") - public List getListOfSBMLElementsToWrite(Object sbase) { - log4jLogger.debug(String.format("%s : getListOfSBMLElementsToWrite\n", - getClass().getSimpleName())); - - List listOfElementsToWrite = new LinkedList(); - - if (sbase instanceof SBMLDocument) { - // nothing to do - // TODO : the 'required' attribute is written even if there is no - // plugin class for the SBMLDocument, so I am not totally sure how - // this is done. - } else if (sbase instanceof Model) { - ExtendedLayoutModel layoutModel = (ExtendedLayoutModel) ((Model) sbase) - .getExtension(namespaceURI); - - if (layoutModel != null && layoutModel.isSetListOfLayouts()) { - listOfElementsToWrite.add(layoutModel.getListOfLayouts()); - } - - } else if (sbase instanceof TreeNode) { - Enumeration children = ((TreeNode) sbase).children(); - while (children.hasMoreElements()) { - listOfElementsToWrite.add(children.nextElement()); - } - } - - if (sbase instanceof SBase) { - SBase elem = (SBase) sbase; - log4jLogger.info("add to write: " + elem.getElementName() - + " namespace: " + elem.getNamespaces().toString()); - if (sbase instanceof ListOf) { - log4jLogger.info("process a ListOf instance"); - ListOf listOf = (ListOf) sbase; - if (!listOf.isEmpty()) { - listOfElementsToWrite = new LinkedList(); - for (int i = 0; i < listOf.size(); i++) { - SBase element = listOf.get(i); - if (element != null) { - listOfElementsToWrite.add(element); - } - } - } - } else if (sbase instanceof Layout) { - Layout layout = (Layout) sbase; - - if (layout.isSetListOfSpeciesGlyphs()) { - listOfElementsToWrite.add(layout.getListOfSpeciesGlyphs()); - ListOf listOfSpeciesGlyph = layout - .getListOfSpeciesGlyphs(); - log4jLogger.info("found list of species glyph"); - log4jLogger.info("list of species glyph: " - + listOfSpeciesGlyph.getElementName()); - } else if (layout.isSetListOfCompartmentGlyphs()) { - listOfElementsToWrite.add(layout - .getListOfCompartmentGlyphs()); - } else if (layout.isSetListOfReactionGlyphs()) { - listOfElementsToWrite.add(layout.getListOfReactionGlyphs()); - } else if (layout.isSetListOfTextGlyphs()) { - listOfElementsToWrite.add(layout.getListOfTextGlyphs()); - } - } else if (sbase instanceof Point) { - Point point = (Point) sbase; - SBase parent = point.getParentSBMLObject(); - if (parent instanceof CurveSegment) { - log4jLogger.debug(" curveSegment: point element name: " - + point.getElementName()); - } - } - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - - return listOfElementsToWrite; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeAttributes(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - xmlObject.addAttributes(sbase.writeXMLAttributes()); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeCharacters(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeElement(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - log4jLogger.warn(String.format("%s : writeElement", getClass() - .getSimpleName())); - - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - log4jLogger.info(String.format("%s ", sbase.getElementName())); - if (!xmlObject.isSetName()) { - if (sbase instanceof ListOf) { - xmlObject.setName(LayoutList.listOfLayouts.toString()); - } else { - xmlObject.setName(sbase.getElementName()); - } - } - if (!xmlObject.isSetPrefix()) { - xmlObject.setPrefix("layout"); - } - xmlObject.setNamespace(namespaceURI); - - } - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.WritingParser#writeNamespaces(org.sbml.jsbml.xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, - * java.lang.Object) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - log4jLogger.debug("processAttribute\n"); - - boolean isAttributeRead = false; - - if (contextObject instanceof SBase) { - - SBase sbase = (SBase) contextObject; - - log4jLogger.debug("processAttribute : level, version = " - + sbase.getLevel() + ", " + sbase.getVersion()); - - try { - isAttributeRead = sbase.readAttribute(attributeName, prefix, - value); - } catch (Throwable exc) { - System.err.println(exc.getMessage()); - } - } else if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - isAttributeRead = annotation.readAttribute(attributeName, prefix, - value); - } else if (contextObject instanceof SBasePlugin) { - isAttributeRead = ((SBasePlugin) contextObject).readAttribute( - attributeName, prefix, value); - } - - if (!isAttributeRead) { - log4jLogger.warn("processAttribute : The attribute " - + attributeName + " on the element " + elementName - + " is not part of the SBML specifications"); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processCharactersOf(java.lang.String, java.lang.String, java.lang.Object) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO Auto-generated method stub - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndDocument(org.sbml.jsbml.SBMLDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processNamespace(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean, boolean, - * java.lang.Object) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processStartElement(java.lang.String, java.lang.String, boolean, boolean, java.lang.Object) - */ - @SuppressWarnings("unchecked") - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - if (elementName.equals("basePoint1")) { - log4jLogger.debug("processing basePoint1"); - } - if (sbmlLayoutElements.containsKey(elementName)) { - try { - Object newContextObject = sbmlLayoutElements.get(elementName) - .newInstance(); - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - Model model = (Model) annotation.getParent(); - ExtendedLayoutModel layoutModel = null; - - if (model.getExtension(namespaceURI) != null) { - layoutModel = (ExtendedLayoutModel) model - .getExtension(namespaceURI); - } else { - layoutModel = new ExtendedLayoutModel(model); - model.addExtension(namespaceURI, layoutModel); - } - } - if (contextObject instanceof SBase) { - setLevelAndVersionFor(newContextObject, - (SBase) contextObject); - } - if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - if (elementName.equals("listOfLayouts")) { - ListOf listOfLayouts = (ListOf) newContextObject; - listOfLayouts.addNamespace(namespaceURI); - this.groupList = LayoutList.listOfLayouts; - Model model = (Model) annotation.getParent(); - ExtendedLayoutModel layoutModel = (ExtendedLayoutModel) model - .getExtension(namespaceURI); - layoutModel.setListOfLayouts(listOfLayouts); - return listOfLayouts; - } else { - log4jLogger.warn(String.format( - "Element %s not recognized!", elementName)); - } - } else if (contextObject instanceof ListOf) { - ListOf listOf = (ListOf) contextObject; - if (listOf.getParentSBMLObject() instanceof Model) { - if (elementName.equals("layout") - && this.groupList - .equals(LayoutList.listOfLayouts)) { - ListOf listOflayouts = (ListOf) listOf; - Layout layout = (Layout) newContextObject; - layout.addNamespace(namespaceURI); - listOflayouts.add(layout); - return layout; - } - } else if (listOf.getParentSBMLObject() instanceof Layout) { - if (elementName.equals("compartmentGlyph") - && this.groupList - .equals(LayoutList.listOfCompartmentGlyphs)) { - ListOf listOfCompartmentGlyph = (ListOf) contextObject; - CompartmentGlyph compartmentGlyph = (CompartmentGlyph) newContextObject; - listOfCompartmentGlyph.addNamespace(namespaceURI); - listOfCompartmentGlyph.add(compartmentGlyph); - this.groupList = LayoutList.listOfCompartmentGlyphs; - return compartmentGlyph; - } else if (elementName.equals("textGlyph") - && this.groupList - .equals(LayoutList.listOfTextGlyphs)) { - ListOf listOfTextGlyph = (ListOf) contextObject; - TextGlyph textGlyph = (TextGlyph) newContextObject; - listOfTextGlyph.addNamespace(namespaceURI); - listOfTextGlyph.add(textGlyph); - this.groupList = LayoutList.listOfTextGlyphs; - return textGlyph; - } else if (elementName.equals("speciesGlyph") - && this.groupList - .equals(LayoutList.listOfSpeciesGlyphs)) { - ListOf listOfSpeciesGlyph = (ListOf) contextObject; - SpeciesGlyph speciesGlyph = (SpeciesGlyph) newContextObject; - listOfSpeciesGlyph.addNamespace(namespaceURI); - listOfSpeciesGlyph.add(speciesGlyph); - // TODO bind speciesGlyph to species object - this.groupList = LayoutList.listOfSpeciesGlyphs; - return speciesGlyph; - } else if (elementName.equals("reactionGlyph") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - ListOf listOfReactionGlyph = (ListOf) contextObject; - ReactionGlyph reactionGlyph = (ReactionGlyph) newContextObject; - reactionGlyph.addNamespace(namespaceURI); - listOfReactionGlyph.add(reactionGlyph); - this.groupList = LayoutList.listOfReactionGlyphs; - return reactionGlyph; - } else if (elementName.equals("boundingBox") - && this.groupList - .equals(LayoutList.listOfCompartmentGlyphs)) { - CompartmentGlyph compartmentGlyph = (CompartmentGlyph) contextObject; - BoundingBox boundingBox = (BoundingBox) newContextObject; - compartmentGlyph.setBoundingBox(boundingBox); - return boundingBox; - } - } else if (listOf.getParentSBMLObject() instanceof ReactionGlyph) { - if (elementName.equals("speciesReferenceGlyph") - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - SpeciesReferenceGlyph speciesReferenceGlyph = (SpeciesReferenceGlyph) newContextObject; - ListOf listOfSpeciesReferenceGlyph = (ListOf) contextObject; - listOfSpeciesReferenceGlyph - .add(speciesReferenceGlyph); - return speciesReferenceGlyph; - } - } else if (elementName.equals("curveSegment") - && this.groupList - .equals(LayoutList.listOfCurveSegments)) { - ListOf listOfLineSegment = (ListOf) contextObject; - CurveSegment lineSegment = (CurveSegment) newContextObject; - lineSegment.addNamespace(namespaceURI); - listOfLineSegment.add(lineSegment); - this.groupList = LayoutList.listOfCurveSegments; - return lineSegment; - } else if (listOf.getParentSBMLObject() instanceof Curve) { - - if (elementName.equals("curveSegment") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - ListOf listOfLineSegment = (ListOf) contextObject; - CurveSegment lineSegment = (CurveSegment) newContextObject; - listOfLineSegment.add(lineSegment); - return lineSegment; - } else if (elementName.equals("curveSegment") - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - ListOf listOfLineSegment = (ListOf) contextObject; - CurveSegment lineSegment = (CurveSegment) newContextObject; - listOfLineSegment.add(lineSegment); - return lineSegment; - } else if (elementName.equals("cubicBezier") - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - ListOf listOfLineSegment = (ListOf) contextObject; - CubicBezier lineSegment = (CubicBezier) newContextObject; - listOfLineSegment.add((CurveSegment) lineSegment); - return lineSegment; - } else if (elementName.equals("cubicBezier") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - ListOf listOfLineSegment = (ListOf) contextObject; - CubicBezier lineSegment = (CubicBezier) newContextObject; - listOfLineSegment.add((CurveSegment) lineSegment); - return lineSegment; - } - } - - } else if (contextObject instanceof Layout) { - Layout layout = (Layout) contextObject; - this.groupList = LayoutList.listOfLayouts; - if (elementName.equals("dimensions") - && this.groupList.equals(LayoutList.listOfLayouts)) { - Dimensions dimensions = (Dimensions) newContextObject; - dimensions.addNamespace(namespaceURI); - layout.setDimensions(dimensions); - return dimensions; - } else if (elementName.equals("listOfCompartmentGlyphs") - && this.groupList.equals(LayoutList.listOfLayouts)) { - ListOf listOfCompartmentGlyphs = (ListOf) newContextObject; - layout.setListOfCompartmentGlyphs(listOfCompartmentGlyphs); - this.groupList = LayoutList.listOfCompartmentGlyphs; - return listOfCompartmentGlyphs; - } else if (elementName.equals("listOfSpeciesGlyphs") - && this.groupList.equals(LayoutList.listOfLayouts)) { - ListOf listofSpeciesGlyph = (ListOf) newContextObject; - layout.setListOfSpeciesGlyphs(listofSpeciesGlyph); - this.groupList = LayoutList.listOfSpeciesGlyphs; - return listofSpeciesGlyph; - } else if (elementName.equals("listOfReactionGlyphs") - && this.groupList.equals(LayoutList.listOfLayouts)) { - ListOf listOfReactionGlyphs = (ListOf) newContextObject; - layout.setListOfReactionGlyphs(listOfReactionGlyphs); - this.groupList = LayoutList.listOfReactionGlyphs; - return listOfReactionGlyphs; - } else if (elementName.equals("listOfTextGlyphs") - && this.groupList.equals(LayoutList.listOfLayouts)) { - ListOf listOfTextGlyphs = (ListOf) newContextObject; - layout.setListOfTextGlyphs(listOfTextGlyphs); - this.groupList = LayoutList.listOfTextGlyphs; - return listOfTextGlyphs; - } - } else if (contextObject instanceof ReactionGlyph) { - ReactionGlyph reactionGlyph = (ReactionGlyph) contextObject; - if (elementName.equals("curve") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - Curve curve = (Curve) newContextObject; - curve.addNamespace(namespaceURI); - reactionGlyph.setCurve(curve); - return curve; - } else if (elementName - .equals("listOfSpeciesReferenceGlyphs") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - ListOf listOfSpeciesReferenceGlyphs = (ListOf) newContextObject; - reactionGlyph - .setListOfSpeciesReferencesGlyph(listOfSpeciesReferenceGlyphs); - this.groupList = LayoutList.listOfSpeciesReferenceGlyphs; - return listOfSpeciesReferenceGlyphs; - } - } else if (contextObject instanceof SpeciesGlyph) { - SpeciesGlyph speciesGlyph = (SpeciesGlyph) contextObject; - if (elementName.equals("boundingBox")) { - BoundingBox boundingBox = (BoundingBox) newContextObject; - boundingBox.addNamespace(namespaceURI); - speciesGlyph.setBoundingBox(boundingBox); - return boundingBox; - } - } else if (contextObject instanceof CompartmentGlyph) { - if (elementName.equals("boundingBox") - && this.groupList - .equals(LayoutList.listOfCompartmentGlyphs)) { - CompartmentGlyph compartmentGlyph = (CompartmentGlyph) contextObject; - BoundingBox boundingBox = (BoundingBox) newContextObject; - boundingBox.addNamespace(namespaceURI); - compartmentGlyph.setBoundingBox(boundingBox); - return boundingBox; - } - } else if (contextObject instanceof TextGlyph) { - if (elementName.equals("boundingBox") - && this.groupList - .equals(LayoutList.listOfTextGlyphs)) { - TextGlyph textGlyph = (TextGlyph) contextObject; - BoundingBox boundingBox = (BoundingBox) newContextObject; - boundingBox.addNamespace(namespaceURI); - textGlyph.setBoundingBox(boundingBox); - return boundingBox; - } - } else if (contextObject instanceof Curve) { - if (elementName.equals("listOfCurveSegments") - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - Curve curve = (Curve) contextObject; - ListOf listOfCurveSegments = (ListOf) newContextObject; - curve.setListOfCurveSegments(listOfCurveSegments); - this.groupList = LayoutList.listOfReactionGlyphs; - return listOfCurveSegments; - } else if (elementName.equals("listOfCurveSegments") - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - Curve curve = (Curve) contextObject; - ListOf listOfCurveSegments = (ListOf) newContextObject; - curve.setListOfCurveSegments(listOfCurveSegments); - this.groupList = LayoutList.listOfSpeciesReferenceGlyphs; - return listOfCurveSegments; - } - } else if (contextObject instanceof BoundingBox) { - BoundingBox boundingBox = (BoundingBox) contextObject; - if (elementName.equals("position")) { - Point point = (Point) newContextObject; - boundingBox.setPosition(point); - return point; - } else if (elementName.equals("dimensions")) { - Dimensions dimensions = (Dimensions) newContextObject; - boundingBox.setDimensions(dimensions); - return dimensions; - } - } else if (contextObject instanceof CurveSegment - && this.groupList - .equals(LayoutList.listOfReactionGlyphs)) { - if (elementName.equals("curveSegment")) { - ListOf lineSegments = (ListOf) contextObject; - CurveSegment lineSegment = (CurveSegment) newContextObject; - lineSegments.add(lineSegment); - lineSegment.addNamespace(namespaceURI); - return lineSegment; - } else if (elementName.equals("start")) { - CurveSegment lineSegment = (CurveSegment) contextObject; - Start start = (Start) newContextObject; - lineSegment.setStart(start); - start.addNamespace(namespaceURI); - return start; - } else if (elementName.equals("end")) { - CurveSegment lineSegment = (CurveSegment) contextObject; - End end = (End) newContextObject; - lineSegment.setEnd(end); - end.addNamespace(namespaceURI); - return end; - } - } else if (contextObject instanceof CubicBezier - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - if (elementName.equals("cubicBezier")) { - ListOf lineSegments = (ListOf) contextObject; - CubicBezier lineSegment = (CubicBezier) newContextObject; - lineSegments.add((CurveSegment) lineSegment); - lineSegment.addNamespace(namespaceURI); - return lineSegment; - } else if (elementName.equals("curveSegment")) { - ListOf lineSegments = (ListOf) contextObject; - CurveSegment lineSegment = (CurveSegment) newContextObject; - lineSegments.add(lineSegment); - lineSegment.addNamespace(namespaceURI); - return lineSegment; - } else if (elementName.equals("start")) { - CubicBezier lineSegment = (CubicBezier) contextObject; - Point start = (Point) newContextObject; - lineSegment.setStart(start); - start.addNamespace(namespaceURI); - return start; - } else if (elementName.equals("end")) { - CubicBezier lineSegment = (CubicBezier) contextObject; - Point end = (Point) newContextObject; - lineSegment.setEnd(end); - end.addNamespace(namespaceURI); - return end; - } else if (elementName.equals("basePoint1")) { - CubicBezier lineSegment = (CubicBezier) contextObject; - - BasePoint1 basePoint1 = (BasePoint1) newContextObject; - lineSegment.setBasePoint1(basePoint1); - basePoint1.addNamespace(namespaceURI); - return basePoint1; - } else if (elementName.equals("basePoint2")) { - CubicBezier lineSegment = (CubicBezier) contextObject; - BasePoint2 basePoint2 = (BasePoint2) newContextObject; - lineSegment.setBasePoint2(basePoint2); - basePoint2.addNamespace(namespaceURI); - return basePoint2; - } - } else if (contextObject instanceof SpeciesReferenceGlyph - && this.groupList - .equals(LayoutList.listOfSpeciesReferenceGlyphs)) { - if (elementName.equals("curve")) { - SpeciesReferenceGlyph speciesReferenceGlyph = (SpeciesReferenceGlyph) contextObject; - Curve curve = (Curve) newContextObject; - speciesReferenceGlyph.setCurve(curve); - curve.addNamespace(namespaceURI); - return curve; - } - } else { - log4jLogger.info("Tag " + elementName - + " could not be recognized."); - log4jLogger.info("contextObject: " - + contextObject.toString()); - log4jLogger.info("newContextObject: " - + newContextObject.toString()); - } - } catch (Exception e) { - log4jLogger.error(e.getLocalizedMessage(), e); - } - } - return contextObject; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.xml.parsers.ReadingParser#processEndElement(java.lang.String, java.lang.String, boolean, java.lang.Object) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - log4jLogger - .debug("contetObject: " + contextObject.getClass().getName()); - log4jLogger.debug("elementName: " + elementName); - if (elementName.equals("listOfLayouts") - || elementName.equals("listOfSpeciesGlyphs") - || elementName.equals("listOfReactionGlyphs") - || elementName.equals("listOfCompartmentGlyphs") - || elementName.equals("listOfTextGlyphs")) { - this.groupList = LayoutList.none; - log4jLogger.debug("set listType to: none"); - } else if (elementName.equals("listOfSpeciesReferenceGlyphs")) { - this.groupList = LayoutList.listOfReactionGlyphs; - log4jLogger.debug("set listType to: listOfReactionGlyphs"); - } - - return true; - } - - /** - * Sets level and version properties of the new object according to the - * value in the model. - * - * @param newContextObject - * @param parent - */ - private void setLevelAndVersionFor(Object newContextObject, SBase parent) { - if (newContextObject instanceof SBase) { - SBase sb = (SBase) newContextObject; - // Level and version will be -1 if not set, so we don't - // have to check. - sb.setLevel(parent.getLevel()); - sb.setVersion(parent.getVersion()); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLParser.java deleted file mode 100644 index 02ef42971..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLParser.java +++ /dev/null @@ -1,450 +0,0 @@ -/* - * $Id: MathMLParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/MathMLParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * A MathMLParser is used to parse the MathML expressions injected into a SBML - * file. This class use DOM to parse the mathML. The name space URI of this - * parser is {@link http://www.w3.org/1998/Math/MathML}. This parser is able to - * read and write MathML expressions (implements ReadingParser and - * WritingParser). - * - * @author Marine Dumousseau - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1116 $ - * - * @deprecated this class should not be used anymore, replaced by - * {@link MathMLStaxParser}. But we keep it in case somebody want to - * use {@link org.w3c.dom.Document} - * - */ -@Deprecated -public class MathMLParser implements ReadingParser, WritingParser { - - /** - * The SBML attribute for the additional namespace. - */ - private static final String sbmlNS = "xmlns:sbml"; - - /** - * The attribute for SBML units. - */ - private static final String sbmlUnits = "sbml:units"; - - - /** - * Recursively checks whether the given {@link Node} contains any numbers - * that refer to unit declarations. This check is necessary because this - * feature has become available in SBML Level 3 and is therefore invalid in - * earlier levels. - * - * @param node - * A node to be checked. - * @return - */ - public static boolean checkContainsNumbersReferingToUnits(Node node) { - boolean containsNumbersReferingToUnits = false; - int i; - if (node.getNodeName().equals("cn")) { - for (i = 0; i < node.getAttributes().getLength(); i++) { - if (node.getAttributes().item(i).toString().startsWith( - MathMLParser.getSBMLUnitsAttribute())) - return true; - } - } - if (node.hasChildNodes()) { - for (i = 0; i < node.getChildNodes().getLength(); i++) { - containsNumbersReferingToUnits |= checkContainsNumbersReferingToUnits(node - .getChildNodes().item(i)); - } - } - return containsNumbersReferingToUnits; - } - - /** - * - * @param node - * @param sbmlLevel - * @return - * @throws SBMLException - */ - public static Document createMathMLDocumentFor(Node node, int sbmlLevel) - throws SBMLException { - Element math; - Document document = node.getOwnerDocument(); - if (document.getDocumentElement() == null) { - math = document.createElementNS(MathMLParser.getNamespaceURI(), - "math"); - if (checkContainsNumbersReferingToUnits(node)) { - if ((sbmlLevel < 1) || (sbmlLevel > 2)) { - math.setAttribute(MathMLParser.getSBMLNSAttribute(), - MathMLParser.getXMLnamespaceSBML()); - } else { - // TODO: We could just remove all references to units - // instead of throwing this exception. What is better? Loss - // of information or exception? - throw new SBMLException( - "math element contains numbers that refer to unit definitions and therefore requires at least SBML Level 3"); - } - } - document.appendChild(math); - } else { - math = document.getDocumentElement(); - for (int i = math.getChildNodes().getLength() - 1; i >= 0; i--) { - math.removeChild(math.getChildNodes().item(i)); - } - } - math.appendChild(node); - return document; - } - - /** - * - * @return - */ - public static String getDefinitionURIavogadro() { - return ASTNode.URI_AVOGADRO_DEFINITION; - } - - /** - * - * @return - */ - public static String getDefinitionURIdelay() { - return ASTNode.URI_DELAY_DEFINITION; - } - - /** - * - * @return - */ - public static String getDefinitionURItime() { - return ASTNode.URI_TIME_DEFINITION; - } - - /** - * @return the namespaceURI - */ - public static String getNamespaceURI() { - return ASTNode.URI_MATHML_DEFINITION; - } - - /** - * - * @return - */ - public static String getSBMLNSAttribute() { - return sbmlNS; - } - - /** - * - * @return - */ - public static String getSBMLUnitsAttribute() { - return sbmlUnits; - } - - /** - * The additional MathML name space for units to numbers. - * @return - */ - public static String getXMLnamespaceSBML() { - return SBMLDocument.URI_NAMESPACE_L3V1Core; - } - - /** - * Write output as {@link String}. - * - * @param omitXMLDeclaration - * @param indenting - * @param indent - * @return - * @throws IOException - * @throws SBMLException - * If illegal references to units are made for numbers and the - * SBML Level has been set to values before level 3. - */ - public static String toMathML(Document doc, boolean omitXMLDeclaration, - boolean indenting, int indent) throws IOException, SBMLException { - StringWriter sw = new StringWriter(); - toMathML(sw, doc, omitXMLDeclaration, indenting, indent); - return sw.toString(); - } - - /** - * - * @param out - * @param doc - * @param omitXMLDeclaration - * @param indenting - * @param indent - * @throws IOException - * @throws SBMLException - */ - public static void toMathML(Writer out, Document doc, - boolean omitXMLDeclaration, boolean indenting, int indent) - throws IOException, SBMLException - { - TransformerFactory tfactory = TransformerFactory.newInstance(); - Transformer serializer; - try { - serializer = tfactory.newTransformer(); - //Setup indenting to "pretty print" - serializer.setOutputProperty(OutputKeys.INDENT, "yes"); - serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - - serializer.transform(new DOMSource(doc), new StreamResult(out)); - } catch (TransformerException e) { - // this is fatal, just dump the stack and throw a runtime exception - e.printStackTrace(); - - throw new RuntimeException(e); - } - } - - /** - * The number of white spaces for the indent if this is to be used. - */ - private short indent; - - /** - * Decides whether or not the content of the MathML string should be - * indented. - */ - private boolean indenting; - - /** - * If true no XML declaration will be written into the MathML output, - * otherwise the XML version will appear at the beginning of the output. - */ - private boolean omitXMLDeclaration; - - /** - * - * @return - */ - public int getIndent() { - return indent; - } - - /** - * - * @return - */ - public boolean getIndenting() { - return indenting; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#getListOfSBMLElementsToWrite(Object - * sbase) - */ - public ArrayList getListOfSBMLElementsToWrite(Object sbase) { - // TODO Auto-generated method stub - return null; - } - - /** - * - * @return - */ - public boolean getOmitXMLDeclaration() { - return omitXMLDeclaration; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * ElementName, String AttributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * ElementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String ElementName, String prefix, - boolean isNested, Object contextObject) { - // TODO Auto-generated method stub - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * ElementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - public Object processStartElement(String ElementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - // TODO Auto-generated method stub - return null; - } - - /** - * @param indent - * the indent to set - */ - public void setIndent(int indent) { - if ((indent < 0) || (Short.MAX_VALUE < indent)) { - throw new IllegalArgumentException(String.format( - "indent %d is out of the range [0, %d].", - indent, Short.toString(Short.MAX_VALUE))); - } - this.indent = (short) indent; - } - - /** - * @param indenting - * the indenting to set - */ - public void setIndenting(boolean indenting) { - this.indenting = indenting; - } - - /** - * @param omitXMLDeclaration - * the omitXMLDeclaration to set - */ - public void setOmitXMLDeclaration(boolean omitXMLDeclaration) { - this.omitXMLDeclaration = omitXMLDeclaration; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.writeAttributes(SBMLObjectForXML xmlObject, - * Object sbmlElementToWrite) - */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeCharacters(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeElement(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeNamespaces(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO Auto-generated method stub - - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLStaxParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLStaxParser.java deleted file mode 100644 index 476933771..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/MathMLStaxParser.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * $Id: MathMLStaxParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/MathMLStaxParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.ASTNode.Type; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.MathContainer; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.util.StringTools; - -/** - * A MathMLStaxParser is used to parse the MathML expressions injected into a SBML - * file. The name space URI of this parser is - * "http://www.w3.org/1998/Math/MathML". This parser is able to read and write - * MathML expressions (implements ReadingParser and WritingParser). - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class MathMLStaxParser implements ReadingParser { - - - /** - * The number of white spaces for the indent if this is to be used. - */ - private short indent; - - /** - * Decides whether or not the content of the MathML string should be - * indented. - */ - private boolean indenting; - - /** - * If true no XML declaration will be written into the MathML output, - * otherwise the XML version will appear at the beginning of the output. - */ - private boolean omitXMLDeclaration; - - private transient Logger logger = Logger.getLogger(MathMLStaxParser.class); - - /** - * - * @return - */ - public int getIndent() { - return indent; - } - - /** - * - * @return - */ - public boolean getIndenting() { - return indenting; - } - - - /** - * - * @return - */ - public boolean getOmitXMLDeclaration() { - return omitXMLDeclaration; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * ElementName, String AttributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - // Process the possible attributes. - // the sbml:units attribute is handle by the SBMLCoreParser. - - if (! (contextObject instanceof ASTNode)) { - logger.debug("processAttribute : !!!!!!!!! context is not an ASTNode ( " + - contextObject.getClass()); - return; - } - - ASTNode astNode = (ASTNode) contextObject; - - // System.out.println("MathMLStaxParser : processAttribute called"); - // System.out.println("MathMLStaxParser : processAttribute : element name = " + elementName + ", attribute name = " + attributeName + - // ", value = " + value + ", prefix = " + prefix + ", " + isLastAttribute + ", " + contextObject); - - // Possible value : type, id, style, class, encoding, definitionURL ... - if (attributeName.equals("type")) { - astNode.setIsSetNumberType(true); - } - if (attributeName.equals("definitionURL")) { - astNode.setDefinitionURL(value); - } - - if (attributeName.equals("type") || attributeName.equals("definitionURL")) { - astNode.setType(value); - // System.out.println("MathMLStaxParser : processAttribute : astNode Type = " + astNode.getType()); - } else if (attributeName.equals("id")) { - astNode.setId(value); - } else if (attributeName.equals("style")) { - astNode.setStyle(value); - } else if (attributeName.equals("class")) { - astNode.setClassName(value); - } else if (attributeName.equals("encoding")) { - astNode.setEncoding(value); - } - - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, Object contextObject) { - // process the text content of the mathMl node, mainly ci, cn and csymbol should have content - - logger.debug("processCharactersOf called"); - logger.debug("processCharactersOf : element name = " + elementName + ", characters = " + characters); - - // Depending of the type of ASTNode, we need to do different things - if (! (contextObject instanceof ASTNode)) { - logger.debug("processCharactersOf : !!!!!!!!! context is not an ASTNode ( " + - contextObject.getClass() + " )!!!!!!!!!!"); - return; - } - - ASTNode astNode = (ASTNode) contextObject; - - // System.out.println("MathMLStaxParser : processCharactersOf : context type : " + astNode.getType()); - - FunctionDefinition functionDef = null; - - try { - functionDef = astNode.getParentSBMLObject().getModel().getFunctionDefinition(characters.trim()); - } catch(NullPointerException e) { - // TODO : this does not work when we do not set the model object when reading a mathML XML String by it's own. - // It should not happen in theory but when reading only a mathML block, it is happening and - // functionDefinition are not properly recognized - logger.warn("WARNING : cannot recognize properly functionDefinition in mathML block !!!"); - } - - if (functionDef != null) { - logger.debug("MathMLStaxParser : processCharactersOf : function found !!"); - astNode.setType(Type.FUNCTION); - } - - if (astNode.isName() || astNode.isFunction()) { - astNode.setName(characters.trim()); - } else if (astNode.isInteger()) { - astNode.setValue(StringTools.parseSBMLInt(characters.trim())); - } else if (astNode.isRational()) { - if (elementName == null) { - astNode.setValue(astNode.getNumerator(), StringTools.parseSBMLInt(characters.trim())); - } else { - astNode.setValue(StringTools.parseSBMLInt(characters.trim()), (int) 0); - } - } else if (astNode.getType().equals(Type.REAL_E)) { - if (elementName == null) { - astNode.setValue(astNode.getMantissa(), StringTools.parseSBMLInt(characters.trim())); - } else { - astNode.setValue(StringTools.parseSBMLDouble(characters.trim()), (int) 0); - } - } else if (astNode.isReal()) { - astNode.setValue(Double.valueOf(characters.trim())); - } else if (astNode.getType().equals(Type.FUNCTION_DELAY)) { - astNode.setName(characters.trim()); - } else { - logger.warn("processCharactersOf : !!!!!!!!! I don't know what to do with that : " + - elementName + " !!!!!!!!!!"); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - - // System.out.println("MathMLStaxParser : processEndDocument called"); - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * ElementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - - logger.debug("processEndElement called"); - logger.debug("processEndElement : element name = " + elementName); - if (elementName.equals("sep")) { - return false; - } else if (contextObject instanceof MathContainer) { - try { - // logger.debug("processEndElement : formula = " + ((MathContainer) contextObject).getMath()); - } catch (Exception e) { - System.out.println("MathMLStaxParser : processEndElement : Exception " + e.getLocalizedMessage()); - } - return false; - - } else if (contextObject instanceof ASTNode) { - ASTNode astNode = (ASTNode) contextObject; - - // add other type of ASTNode in the test ?? - if ((astNode.isFunction() || astNode.isOperator() || astNode.isRelational() || - astNode.isLogical()) && !elementName.equals("apply") && !elementName.equals("piecewise")) - { - logger.debug("processEndElement : stack stay the same. ASTNode type = " + astNode.getType()); - return false; - - } - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - { - // TODO - - logger.debug("processNamespace called"); - - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * ElementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - - logger.debug("processStartElement called"); - logger.debug("processStartElement : element name = " + elementName); // + - // ", prefix = " + prefix + ", hasAttributes = " + hasAttributes + ", hasNamespace = " + hasNamespaces); - // + ", " + contextObject); - - if (elementName.equals("math") || elementName.equals("apply") || elementName.equals("sep") - || elementName.equals("piece") || elementName.equals("otherwise") - || elementName.equals("bvar") || elementName.equals("degree") || elementName.equals("logbase")) { - // we do nothing - return null; - } - - MathContainer mathContainer = null; - ASTNode parentASTNode = null; - boolean setMath = false; - - if (contextObject instanceof MathContainer) { - mathContainer = (MathContainer) contextObject; - if (mathContainer.getMath() == null) { - setMath = true; - } else { - // because normal operator are written in mathML and so the parent ASTNode is not any more the contextObject - parentASTNode = mathContainer.getMath(); - // System.out.println("MathMLStaxParser : processStartElement parent type : " + parentASTNode.getType()); - } - } else if (contextObject instanceof ASTNode) { - - parentASTNode = ((ASTNode) contextObject); - mathContainer = parentASTNode.getParentSBMLObject(); - // System.out.println("MathMLStaxParser : processStartElement parent type : " + parentASTNode.getType()); - } else { - // Should never happen - logger.debug("processStartElement : !!!!!!!!!!! Should not have been here !!!!!!!!!!!"); - logger.debug("processStartElement : contextObject.classname = " + contextObject.getClass().getName()); - return null; - } - - ASTNode astNode = new ASTNode(mathContainer); - astNode.setType(elementName); - - if (setMath) { - mathContainer.setMath(astNode); - } else { - parentASTNode.addChild(astNode); - } - - /*else if (astNode.isNumber() || astNode.isConstant() || astNode.getType().equals(ASTNode.Type.NAME) - || astNode.getType().equals(ASTNode.Type.NAME_TIME) || astNode.isInfinity() || astNode.isNaN() - || astNode.isNegInfinity()) - { - return parentASTNode; - } else if () { - - */ - - return astNode; - } - - /** - * @param indent - * the indent to set - */ - public void setIndent(int indent) { - if ((indent < 0) || (Short.MAX_VALUE < indent)) { - throw new IllegalArgumentException(String.format( - "indent %d is out of the range [0, %d].", - indent, Short.toString(Short.MAX_VALUE))); - } - this.indent = (short) indent; - } - - /** - * @param indenting - * the indenting to set - */ - public void setIndenting(boolean indenting) { - this.indenting = indenting; - } - - /** - * @param omitXMLDeclaration - * the omitXMLDeclaration to set - */ - public void setOmitXMLDeclaration(boolean omitXMLDeclaration) { - this.omitXMLDeclaration = omitXMLDeclaration; - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/ModelQualifierParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/ModelQualifierParser.java deleted file mode 100644 index a21d57607..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/ModelQualifierParser.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * $Id: ModelQualifierParser.java,v 1.1 2012-11-07 14:43:36 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/ModelQualifierParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.HashMap; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.CVTerm; -import org.sbml.jsbml.CVTerm.Qualifier; -import org.sbml.jsbml.CVTerm.Type; -import org.sbml.jsbml.SBMLDocument; - -/** - * A {@link ModelQualifierParser} is used to parse the XML elements and - * attributes which have this namespace URI : - * http://biomodels.net/model-qualifiers/. - * - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class ModelQualifierParser implements ReadingParser { - - private Logger logger = Logger.getLogger(ModelQualifierParser.class); - - /** - * The namespace URI of this ReadingParser. - */ - private static final String namespaceURI = "http://biomodels.net/biology-qualifiers/"; - - /** - * @return the namespaceURI - */ - public static String getNamespaceURI() { - return namespaceURI; - } - - /** - * The map containing all the relationships Miriam qualifier String <=> Miriam qualifier Qualifier. - */ - private HashMap modelQualifierMap = new HashMap(); - - /** - * Creates a ModelQualifierParser instance and initialises the modelQualifierMap. - */ - public ModelQualifierParser(){ - initialisesModelQualifierMap(); - } - - /** - * Initialises the modelQualifierMap of this parser. - */ - private void initialisesModelQualifierMap(){ - // TODO maybe loading from a file would be better. - - for (CVTerm.Qualifier qualifier : CVTerm.Qualifier.values()) { - if (qualifier.isModelQualifier()) { - modelQualifierMap.put(qualifier.getElementNameEquivalent(), qualifier); - logger.debug("initialisesModelQualifierMap : " + qualifier.getElementNameEquivalent()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - */ - public void processAttribute(String ElementName, String AttributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - // TODO : a node with the namespace "http://biomodels.net/model-qualifiers/" can't have attributes. - // Throw an error? - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String elementName, String characters, - Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO : a node with the namespace "http://biomodels.net/model-qualifiers/" can't have text. - // Throw an error? - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String ElementName, String prefix, - boolean isNested, Object contextObject) - */ - public boolean processEndElement(String ElementName, String prefix, - boolean isNested, Object contextObject) { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - - // The namespace of this parser should be declared in the RDF subnode of the annotation. - // Adds the namespace to the RDFAnnotationNamespaces HashMap of annotation. - if (elementName.equals("RDF") && contextObject instanceof Annotation){ - Annotation annotation = (Annotation) contextObject; - - annotation.addRDFAnnotationNamespace(localName, prefix, URI); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) { - - // A ModelQualifierParser can only modify a contextObject which is an instance of Annotation. - if (contextObject instanceof Annotation){ - Annotation annotation = (Annotation) contextObject; - - // This parser can parse only model Miriam qualifiers. This element should not have attributes or namespace declarations. - // Creates a new CVTerm and - // sets the qualifierType and modelQualifierType of this CVTerm. Then, adds the - // initialised CVTerm to annotation. - if (modelQualifierMap.containsKey(elementName) && !hasNamespaces && !hasAttributes){ - CVTerm cvTerm = new CVTerm(); - cvTerm.setQualifierType(Type.MODEL_QUALIFIER); - cvTerm.setModelQualifierType(modelQualifierMap.get(elementName)); - - annotation.addCVTerm(cvTerm); - return cvTerm; - } - else { - // TODO : SBML syntax error, throw an exception? - } - } - else { - // TODO : SBML syntax error, throw an exception? - } - return contextObject; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/RDFAnnotationParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/RDFAnnotationParser.java deleted file mode 100644 index 2f6adfbf6..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/RDFAnnotationParser.java +++ /dev/null @@ -1,541 +0,0 @@ -/* - * $Id: RDFAnnotationParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/RDFAnnotationParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.HashMap; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.CVTerm; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.CompartmentType; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Creator; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.History; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; - -/** - * A RDFAnnotationParser is used to parser the subNodes of an annotation which - * have the namespace URI : "http://www.w3.org/1999/02/22-rdf-syntax-ns#". This - * parser can only read the RDF annotations. - * - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1187 $ - */ -@SuppressWarnings("deprecation") -public class RDFAnnotationParser implements ReadingParser { - - /** - * - */ - private transient Logger logger = Logger.getLogger(RDFAnnotationParser.class); - - /** - * The namespaceURI of this parser. - */ - private static final String namespaceURI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - - /** - * @return the namespaceURI - */ - public static String getNamespaceURI() { - return namespaceURI; - } - - /** - * A map containing the history of the previous element within a RDF node this parser has been read. - */ - private HashMap previousElements = new HashMap(); - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - { - - boolean isReadAttribute = false; - - // A RDFAnnotationParser can modify a contextObject which is an Annotation instance. - // The annotation element can contain other attributes. Try to read them. - if (contextObject instanceof Annotation){ - Annotation modelAnnotation = (Annotation) contextObject; - isReadAttribute = modelAnnotation.readAttribute(attributeName, prefix, value); - } - // A RDFAnnotationParser can modify a contextObject which is an ModelHistory instance. - // When this parser is parsing the model history, some rdf attributes can appear. Try to - // read them. - else if (contextObject instanceof History){ - History modelHistory = (History) contextObject; - isReadAttribute = modelHistory.readAttribute(elementName, attributeName, prefix, value); - } - // A RDFAnnotationParser can modify a contextObject which is an ModelCreator instance. - // If the contextObject is a ModelCreator instance, the rdf attributes should appear in the - // 'li' subelement of the 'Bag' subelement of the 'creator' node. - // When this parser is parsing the model history, some rdf attributes can appear. Try to - // read them. - else if (contextObject instanceof Creator && previousElements.containsKey("creator")){ - if (previousElements.get("creator").equals("li")){ - Creator modelCreator = (Creator) contextObject; - isReadAttribute = modelCreator.readAttribute(elementName, attributeName, prefix, value); - } - } - // A RDFAnnotationParser can modify a contextObject which is an CVTerm instance. - // If the contextObject is a CVTerm instance, the rdf attributes should appear in the - // 'li' subelement of the 'Bag' subelement of the 'Miriam-Qualifier' node. - // When this parser is parsing the rdf annotation, some rdf attributes can appear. Try to - // read them. - else if (contextObject instanceof CVTerm && previousElements.containsKey("CVTerm")){ - if (previousElements.get("CVTerm").equals("li")){ - CVTerm cvterm = (CVTerm) contextObject; - isReadAttribute = cvterm.readAttribute(elementName, attributeName, prefix, value); - } - } - - if (!isReadAttribute){ - logger.warn("RDFAnnotationParser : processAttribute : found an unknown attribute '" + - attributeName + "', the attribute is ignored (elementName = " + elementName + ")."); - } - - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String elementName, String characters, - Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) - { - // there is no text for element with the namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#". - if (characters.trim().length() > 0) { - logger.warn("RDFAnnotationParser : processCharactersOf called !!!! Found some unexpected characters"); - } - } - - - /** - * - * - * @param sbase - */ - private void setRDFAbout(SBase sbase) { - // We assume that the method is called only if there is an annotation defined. - - if (sbase.isSetMetaId()) { - sbase.getAnnotation().setAbout("#" + sbase.getMetaId()); - } else { - // TODO : generate the metaid at this point ?? - - logger.warn(String.format( - "The element %s has no metaid, so the rdf:about inside his annotation cannot be defined properly.", - sbase.getElementName())); - } - } - - /** - * Checks if the sbmlDocument and all the SBML components have a valid rdf:about value. - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - - if (!sbmlDocument.hasValidAnnotation()){ - logger.warn("The SBMLDocument element has an invalid rdf:about inside his annotation."); - setRDFAbout(sbmlDocument); - } - - Model model = sbmlDocument.getModel(); - - if (!model.hasValidAnnotation()){ - logger.warn(String.format("The model element with metaid = '%s' has an invalid rdf:about = '%s' inside his annotation.", model.getMetaId(), model.getAnnotation().getAbout())); - setRDFAbout(model); - } - - if (model.isSetListOfFunctionDefinitions()){ - for (FunctionDefinition functionDefinition : model.getListOfFunctionDefinitions()){ - if (!functionDefinition.hasValidAnnotation()){ - logger.warn("The functionDefinition element '" + functionDefinition.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(functionDefinition); - } - } - } - - if (model.isSetListOfCompartments()){ - for (Compartment compartment : model.getListOfCompartments()){ - if (!compartment.hasValidAnnotation()){ - logger.warn("The compartment '" + compartment.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(compartment); - } - } - } - - if (model.isSetListOfCompartmentTypes()){ - for (CompartmentType compartmentType : model.getListOfCompartmentTypes()){ - if (!compartmentType.hasValidAnnotation()){ - logger.warn("The compartmentType '" + compartmentType.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(compartmentType); - } - } - } - - logger.debug("compartments checked"); - - - if (model.isSetListOfConstraints()){ - for (Constraint constraint : model.getListOfConstraints()){ - if (!constraint.hasValidAnnotation()){ - logger.warn("The constraint element '" + constraint.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(constraint); - } - } - } - - if (model.isSetListOfEvents()){ - for (Event event : model.getListOfEvents()){ - if (!event.hasValidAnnotation()){ - logger.warn("The event element '" + event.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(event); - } - if (event.isSetDelay()){ - if (! event.getDelay().hasValidAnnotation()){ - logger.warn("The delay element '" + event.getDelay().getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(event.getDelay()); - } - } - if (event.isSetListOfEventAssignments()){ - for (EventAssignment eventAssignment : event.getListOfEventAssignments()){ - if (!eventAssignment.hasValidAnnotation()){ - logger.warn("The eventAssignment element '" + eventAssignment.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(eventAssignment); - } - } - } - if (event.isSetTrigger()){ - if (! event.getTrigger().hasValidAnnotation()){ - logger.warn("The trigger element '" + event.getTrigger().getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(event.getTrigger()); - } - } - } - } - - logger.debug("events checked"); - - if (model.isSetListOfInitialAssignments()){ - for (InitialAssignment initAssgnt : model.getListOfInitialAssignments()){ - if (!initAssgnt.hasValidAnnotation()){ - logger.warn("The initialAssignment element '" + initAssgnt.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(initAssgnt); - } - } - } - - if (model.isSetListOfParameters()){ - for (Parameter parameter : model.getListOfParameters()){ - if (!parameter.hasValidAnnotation()){ - logger.warn("The parameter element '" + parameter.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(parameter); - } - } - } - - logger.debug("parameters checked"); - - if (model.isSetListOfReactions()){ - for (Reaction reaction : model.getListOfReactions()){ - - if (!reaction.hasValidAnnotation()){ - logger.warn("The reaction element '" + reaction.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(reaction); - } - - if (reaction.isSetKineticLaw()){ - KineticLaw kineticLaw = reaction.getKineticLaw(); - - if (!kineticLaw.hasValidAnnotation()){ - logger.warn("The kineticLaw element '" + kineticLaw.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(kineticLaw); - } - - if (kineticLaw.isSetListOfLocalParameters()){ - for (LocalParameter parameter : kineticLaw.getListOfLocalParameters()){ - if (!parameter.hasValidAnnotation()){ - logger.warn("The local parameter element '" + parameter.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(parameter); - } - } - } - } - - if (reaction.isSetListOfReactants()){ - for (SpeciesReference reactant : reaction.getListOfReactants()){ - if (!reactant.hasValidAnnotation()){ - logger.warn("The reactant element '" + reactant.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(reactant); - } - } - } - if (reaction.isSetListOfProducts()){ - for (SpeciesReference product : reaction.getListOfProducts()){ - if (!product.hasValidAnnotation()){ - logger.warn("The product element '" + product.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(product); - } - } - } - if (reaction.isSetListOfModifiers()){ - for (ModifierSpeciesReference modifier : reaction.getListOfModifiers()){ - if (!modifier.hasValidAnnotation()){ - logger.warn("The modifier element '" + modifier.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(modifier); - } - } - } - } - } - - logger.debug("reactions checked"); - - if (model.isSetListOfRules()){ - for (Rule rule : model.getListOfRules()){ - if (!rule.hasValidAnnotation()){ - logger.warn("The rule element '" + rule.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(rule); - } - } - } - if (model.isSetListOfSpecies()){ - for (Species species : model.getListOfSpecies()){ - if (!species.hasValidAnnotation()){ - logger.warn("The species element '" + species.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(species); - } - } - } - if (model.isSetListOfSpeciesTypes()){ - for (Species speciesType : model.getListOfSpecies()){ - if (!speciesType.hasValidAnnotation()){ - logger.warn("The speciesType element '" + speciesType.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(speciesType); - } - } - } - - logger.debug("species checked"); - - if (model.isSetListOfUnitDefinitions()){ - for (UnitDefinition unitDefinition : model.getListOfUnitDefinitions()){ - - if (!unitDefinition.hasValidAnnotation()){ - logger.warn("The unitDefinition element '" + unitDefinition.getId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(unitDefinition); - } - if (unitDefinition.isSetListOfUnits()){ - for (Unit unit : unitDefinition.getListOfUnits()){ - if (!unit.hasValidAnnotation()){ - logger.warn("The unit element '" + unit.getMetaId() + "' has an invalid rdf:about inside his annotation."); - setRDFAbout(unit); - } - } - } - } - } - - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - - // If the contextObject is a ModelCreator, the current element should be included into a 'creator' - // element. - if (contextObject instanceof Creator){ - // If it is a ending Bag element, there is no other creators to parse in the 'creator' node, we can reinitialise the - // previousElements HashMap of this parser and remove the Entry which has 'creator' as key. - if (elementName.equals("Bag")){ - previousElements.remove("creator"); - } - // If it is a ending li element, we can reinitialise the - // previousElements HashMap of this parser and set the value of the 'creator' key to 'Bag'. - else if (elementName.equals("li")){ - previousElements.put("creator", "Bag"); - } - } - else if (contextObject instanceof CVTerm){ - // If it is a ending Bag element, there is no other resource URI to parse for this CVTerm, we can reinitialise the - // previousElements HashMap of this parser and remove the Entry which has 'CVTerm' as key. - if (elementName.equals("Bag")){ - previousElements.remove("CVTerm"); - } - // If it is a ending li element, we can reinitialise the - // previousElements HashMap of this parser and set the value of the 'CVTerm' key to 'Bag'. - else if (elementName.equals("li")){ - previousElements.put("CVTerm", "Bag"); - } - } - - // If it is the end of a RDF element, we can clear the previousElements HashMap of this parser. - if (elementName.equals("RDF")){ - this.previousElements.clear(); - } - - return true; - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - - // Adds the namespace to the RDFAnnotationNamespaces HashMap of annotation. - if (elementName.equals("RDF") && (contextObject instanceof Annotation)) { - Annotation annotation = (Annotation) contextObject; - annotation.addRDFAnnotationNamespace(localName, prefix, URI);; - } - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) - { - // A RDFAnnotationParser can modify a ContextObject which is an Annotation instance. - if (contextObject instanceof Annotation){ - - // If the node is a RDF node, adds ("RDF", null) to the previousElements of this parser. - if (elementName.equals("RDF")){ - this.previousElements.put(elementName, null); - } - // The Description element should be the first child node of a RDF element. - // If the SBML specifications are respected, sets the value of the 'RDF' key to 'Description'. - else if(elementName.equals("Description") && previousElements.containsKey("RDF")) - { - this.previousElements.put("RDF", "Description"); - } - else - { - logger.warn("Found a RDF:Description that is not a child of the RDF:RDF element !! Element prefix:name = " + prefix + ":" + elementName); - - } - } - // If the contextObject is not an Annotation instance, we should be into the Description subNode of the RDF element. - else if (this.previousElements.containsKey("RDF")) { - if (this.previousElements.get("RDF") != null){ - // The Description subNode of RDF has been read. - if (this.previousElements.get("RDF").equals("Description")){ - // A RDFAnnotation can modify a contextObject which is a CVTerm instance. - if (contextObject instanceof CVTerm){ - // The first element of the 'miriam-qualifier' node (the CVTerm) should be a Bag element. - if (elementName.equals("Bag")){ - this.previousElements.put("CVTerm", "Bag"); - } - // If a 'Bag' subNode has been read and if the current element is a 'li' subNode - else if (elementName.equals("li") && previousElements.containsKey("CVTerm")){ - if (this.previousElements.get("CVTerm").equals("Bag")){ - this.previousElements.put("CVTerm", "li"); - } - else { - logger.warn("Syntax error in your RDF annotation. An RDF:li element should be inside a RDF:Bag element."); - } - } - else { - logger.warn("Syntax error in your RDF annotation"); - } - } - // A RDFAnnotation can modify a contextObject which is a ModelHistory instance. - else if (contextObject instanceof History){ - History modelHistory = (History) contextObject; - // we should be into a 'creator' node and the first element should be a Bag element. - if (elementName.equals("Bag")){ - this.previousElements.put("creator", "Bag"); - } - // After the 'Bag' node of the 'creator' element, it should be a 'li' node. - // If the SBML specifications are respected, a new ModelCreator will be created - // and added to the listOfCreators of modelHistory. In this case, it will return the new ModelCreator instance. - else if (elementName.equals("li") && previousElements.containsKey("creator")){ - if (previousElements.get("creator").equals("Bag")){ - this.previousElements.put("creator", "li"); - Creator modelCreator = new Creator(); - modelHistory.addCreator(modelCreator); - return modelCreator; - } - else { - logger.warn("Syntax error in your RDF annotation"); - } - } - else { - logger.warn("Syntax error in your RDF annotation"); - } - } - else { - logger.warn("Syntax error in your RDF annotation"); - } - } - else { - logger.warn("Syntax error in your RDF annotation"); - } - } - else { - logger.warn("Found several children for the RDF:RDF element. This is currently not well supported in JSBML"); - // if the RDF element does contain several Description child nodes, they are passed to the StringParser but - // the whole annotation should be read into an XMLNode for the 1.0 release to make all of that a bit more - // robust - } - } - return contextObject; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/ReadingParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/ReadingParser.java deleted file mode 100644 index f7e78b8da..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/ReadingParser.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * $Id: ReadingParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/ReadingParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import org.sbml.jsbml.SBMLDocument; - -/** - * The interface to implement for the SBML parsers reading SBML files. - * - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface ReadingParser { - - /** - * Process the XML attribute and modify 'contextObject' in consequence. - * - * For example, if the contextObject is an instance of Reaction and the attributeName is 'fast', - * this method will set the 'fast' variable of the 'contextObject' to 'value'. - * Then it will return the modified Reaction instance. - * - * @param elementName : the localName of the XML element. - * @param attributeName : the attribute localName of the XML element. - * @param value : the value of the XML attribute. - * @param prefix : the attribute prefix - * @param isLastAttribute : boolean value to know if this attribute is the last attribute of the XML element. - * @param contextObject : the object to set or modify depending on the identity of the current attribute. This object - * represents the context of the XML attribute in the SBMLDocument. - * - */ - public void processAttribute(String elementName, String attributeName, String value, String prefix, boolean isLastAttribute, Object contextObject); - - /** - * Process the text of a XML element and modify 'contextObject' in consequence. - * - * For example, if the contextObject is an instance of ModelCreator and the elementName is 'Family', - * this method will set the familyName of the 'contextObject' to the text value. Then it will return the - * changed ModelCreator instance. - * - * @param elementName : the localName of the XML element. - * @param characters : the text of this XML element. - * @param contextObject : the object to set or modify depending on the identity of the current element. This object - * represents the context of the XML element in the SBMLDocument. - * - */ - public void processCharactersOf(String elementName, String characters, Object contextObject); - - /** - * Process the end of the document. Do the necessary changes in the SBMLDocument. - * - * For example, check if all the annotations are valid, etc. - * - * @param sbmlDocument : the final initialised SBMLDocument instance. - */ - public void processEndDocument(SBMLDocument sbmlDocument); - - /** - * Process the end of the element 'elementName'. Modify or not the contextObject. - * - * @param elementName : the localName of the XML element. - * @param prefix : the prefix of the XML element. - * @param isNested : boolean value to know if the XML element is a nested element. - * @param contextObject : the object to set or modify depending on the identity of the current element. This object - * represents the context of the XML element in the SBMLDocument. - * - * @return true to remove the contextObject from the stack, if false is returned the contextObject will stay on top - * of the stack - */ - public boolean processEndElement(String elementName, String prefix, boolean isNested, Object contextObject); - - /** - * Process the namespace and modify the contextObject in consequence. - * - * For example, if the contextObject is an instance of SBMLDocument, the namespaces will be stored in the SBMLNamespaces HashMap - * of this SBMLDocument. - * - * @param elementName : the localName of the XML element. - * @param URI : the URI of the namespace - * @param prefix : the prefix of the namespace. - * @param localName : the localName of the namespace. - * @param hasAttributes : boolean value to know if there are attributes after the namespace declarations. - * @param isLastNamespace : boolean value to know if this namespace is the last namespace of this element. - * @param contextObject : the object to set or modify depending on the identity of the current element. This object - * represents the context of the XML element in the SBMLDocument. - * - */ - public void processNamespace(String elementName, String URI, String prefix, String localName, boolean hasAttributes, boolean isLastNamespace, Object contextObject); - - /** - * Process the XML element and modify 'contextObject' in consequence. - * - * For example, if the contextObject is an instance of Event and the elementName is 'trigger', this method - * will create a new Trigger instance and will set the trigger instance of the 'contextObject' to the new Trigger. - * Then the method will return the new Trigger instance which is the new environment. - * - * @param elementName : the localName of the XML element to process - * @param prefix : the prefix of the XML element to process - * @param hasAttributes : boolean value to know if this XML element has attributes. - * @param hasNamespaces : boolean value to know if this XML element contains namespace declarations. - * @param contextObject : the object to set or modify depending on the identity of the current XML element. This object - * represents the context of the XML element in the SBMLDocument. - * @return a new contextObject which represents the environment of the next node/subnode in the SBMLDocument. If null is returned, - * the contextObject will not change. - * - */ - public Object processStartElement(String elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, Object contextObject); - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLCoreParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLCoreParser.java deleted file mode 100644 index 69c0b2977..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLCoreParser.java +++ /dev/null @@ -1,1303 +0,0 @@ -/* - * $Id: SBMLCoreParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/SBMLCoreParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.CompartmentType; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Delay; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.ExplicitRule; -import org.sbml.jsbml.FunctionDefinition; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.Priority; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.SpeciesType; -import org.sbml.jsbml.StoichiometryMath; -import org.sbml.jsbml.Trigger; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.xml.XMLAttributes; -import org.sbml.jsbml.xml.XMLNode; -import org.sbml.jsbml.xml.XMLTriple; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; -import org.sbml.jsbml.xml.stax.XMLLogger; - -/** - * Parses the SBML core elements of an SBML file. It can read and write SBML - * core elements (implements {@link ReadingParser} and {@link WritingParser}). - * - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1139 $ - */ -// It might be better to have one parser per level and version -// rather than one SBMLCoreParser which parses everything. - -@SuppressWarnings("deprecation") -public class SBMLCoreParser implements ReadingParser, WritingParser { - - /** - * This map contains all the relationships XML element name <=> matching - * java class. - */ - private Map> sbmlCoreElements; - - /** - * The logger of this parser - */ - private XMLLogger logger; - - /** - * Log4j logger - */ - private Logger log4jLogger = Logger.getLogger(SBMLCoreParser.class); - - /** - * Creates a SBMLCoreParser instance. Initializes the sbmlCoreElements of - * this Parser. - * - */ - public SBMLCoreParser() { - sbmlCoreElements = new HashMap>(); - // Initializes the sbmlCoreElements of this parser. - JSBML.loadClasses("org/sbml/jsbml/resources/cfg/SBMLCoreElements.xml", - sbmlCoreElements); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#getListOfSBMLElementsToWrite(Object - * sbase) - */ - @SuppressWarnings("unchecked") - public List getListOfSBMLElementsToWrite(Object sbase) { - ArrayList listOfElementsToWrite = null; - if (sbase instanceof SBase) { - if (sbase instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) sbase; - if (sbmlDocument.isSetModel()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(sbmlDocument.getModel()); - } - } else if (sbase instanceof Model) { - - Model model = (Model) sbase; - listOfElementsToWrite = new ArrayList(); - if (model.isSetListOfFunctionDefinitions()) { - listOfElementsToWrite.add(model - .getListOfFunctionDefinitions()); - } - if (model.isSetListOfUnitDefinitions()) { - listOfElementsToWrite.add(model.getListOfUnitDefinitions()); - } - if (model.isSetListOfCompartmentTypes()) { - listOfElementsToWrite - .add(model.getListOfCompartmentTypes()); - } - if (model.isSetListOfSpeciesTypes()) { - listOfElementsToWrite.add(model.getListOfSpeciesTypes()); - } - if (model.isSetListOfCompartments()) { - listOfElementsToWrite.add(model.getListOfCompartments()); - } - if (model.isSetListOfSpecies()) { - listOfElementsToWrite.add(model.getListOfSpecies()); - } - if (model.isSetListOfParameters()) { - listOfElementsToWrite.add(model.getListOfParameters()); - } - if (model.isSetListOfInitialAssignments()) { - listOfElementsToWrite.add(model - .getListOfInitialAssignments()); - } - if (model.isSetListOfRules()) { - listOfElementsToWrite.add(model.getListOfRules()); - } - if (model.isSetListOfConstraints()) { - listOfElementsToWrite.add(model.getListOfConstraints()); - } - if (model.isSetListOfReactions()) { - listOfElementsToWrite.add(model.getListOfReactions()); - } - if (model.isSetListOfEvents()) { - listOfElementsToWrite.add(model.getListOfEvents()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } else if (sbase instanceof ListOf) { - ListOf listOf = (ListOf) sbase; - - if (!listOf.isEmpty()) { - listOfElementsToWrite = new ArrayList(); - for (int i = 0; i < listOf.size(); i++) { - SBase element = listOf.get(i); - - if (element != null) { - boolean add = true; - if (element instanceof UnitDefinition) { - UnitDefinition ud = (UnitDefinition) element; - if (ud.isPredefined()) { - add = false; - } - } - if (add) { - listOfElementsToWrite.add(element); - } - } - } - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } - } else if (sbase instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) sbase; - - if (unitDefinition.isSetListOfUnits()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(unitDefinition.getListOfUnits()); - } - } else if (sbase instanceof Reaction) { - Reaction reaction = (Reaction) sbase; - listOfElementsToWrite = new ArrayList(); - - if (reaction.isSetListOfReactants()) { - listOfElementsToWrite.add(reaction.getListOfReactants()); - } - if (reaction.isSetListOfProducts()) { - listOfElementsToWrite.add(reaction.getListOfProducts()); - } - if (reaction.isSetListOfModifiers()) { - listOfElementsToWrite.add(reaction.getListOfModifiers()); - } - if (reaction.isSetKineticLaw()) { - listOfElementsToWrite.add(reaction.getKineticLaw()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } else if (sbase instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) sbase; - - if (kineticLaw.isSetListOfLocalParameters()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(kineticLaw.getListOfLocalParameters()); - } - } else if (sbase instanceof SpeciesReference) { - SpeciesReference speciesReference = (SpeciesReference) sbase; - - if (speciesReference.isSetStoichiometryMath()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(speciesReference.getStoichiometryMath()); - } - } else if (sbase instanceof Event) { - Event event = (Event) sbase; - listOfElementsToWrite = new ArrayList(); - - if (event.isSetTrigger()) { - listOfElementsToWrite.add(event.getTrigger()); - } - if (event.isSetPriority()) { - listOfElementsToWrite.add(event.getPriority()); - } - if (event.isSetDelay()) { - listOfElementsToWrite.add(event.getDelay()); - } - if (event.isSetListOfEventAssignments()) { - listOfElementsToWrite.add(event.getListOfEventAssignments()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } - - /* - * // Level 3 packages support - * HashMap extentionObjects = ((SBase) - * sbase).getExtensionPackages(); - * - * if (extentionObjects != null && extentionObjects.size() > 0) { - * - * for (String namespace : extentionObjects.keySet()) { - * - * // System.out.println(); - * - * WritingParser parser = null; try { parser = - * SBMLWriter.getWritingPackageParsers(namespace).newInstance(); } - * catch (InstantiationException e) { // Auto-generated catch - * block e.printStackTrace(); } catch (IllegalAccessException e) { - * // Auto-generated catch block e.printStackTrace(); } SBase - * extendedSBase = extentionObjects.get(namespace); - * listOfElementsToWrite - * .addAll(parser.getListOfSBMLElementsToWrite(extendedSBase)); } } - */ - } - - return listOfElementsToWrite; - } - - /** - * @return the logger - */ - public XMLLogger getLogger() { - return logger; - } - - /** - * - * @return the namespace URI of this parser. - */ - public String getNamespaceURI() { - return SBMLDocument.URI_NAMESPACE_L3V1Core; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String - * elementName, String attributeName, String value, String prefix, boolean - * isLastAttribute, Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - { - - if (log4jLogger.isDebugEnabled()) { - log4jLogger.debug(" process the attribute : '" + attributeName + "' (value = " + value + ") on element '" + elementName + "' (" + contextObject + ")."); - } - - boolean isAttributeRead = false; - - // A SBMLCoreParser can modify a contextObject which is an instance of - // SBase. - // Try to read the attributes. - if (contextObject instanceof SBase) { - SBase sbase = (SBase) contextObject; - try { - isAttributeRead = sbase.readAttribute(attributeName, prefix, - value); - } catch (Throwable exc) { - log4jLogger.error(exc.getMessage()); - log4jLogger.info("Attribute = " + attributeName + ", element = " + elementName); - } - } - // A SBMLCoreParser can modify a contextObject which is an instance of - // Annotation. - // Try to read the attributes. - else if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - isAttributeRead = annotation.readAttribute(attributeName, prefix, - value); - } else if (contextObject instanceof ASTNode) { - ASTNode astNode = (ASTNode) contextObject; - - try { - astNode.setUnits(value); - isAttributeRead = true; - } catch (IllegalArgumentException e) { - // TODO : Write from which element the error is coming from : astNode.getParentSBMLObject(); - log4jLogger.info(e.getMessage()); - // Log the error to the ErrorLog object ?? - } - - log4jLogger.debug("SBMLCoreParser : processAttribute : adding an unit to an ASTNode"); - } - - if (!isAttributeRead) { - log4jLogger.warn(String.format( - "Could not recognize the attribute '%s' on the element %s. Please check the SBML specifications.", - attributeName, elementName)); - // Log the error to the ErrorLog object ?? - } - } - - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String - * elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) - { - - // TODO : we have to check if we are in the context of a Notes or an Annotation - - if (elementName != null && elementName.equals("notes")) { - - } else if (characters != null && characters.trim().length() != 0) { - // log4jLogger.warn("The SBML core XML element should not have any content, everything should be stored as attribute."); - // log4jLogger.warn("The Characters are : @" + characters.trim() + "@"); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument - * sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - - log4jLogger.debug("SBMLCoreParser : processEndDocument"); - - if (sbmlDocument.isSetModel()) { - Model model = sbmlDocument.getModel(); - - if (model.isSetAreaUnits() && !model.isSetAreaUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the areaUnitsID of Model."); - } - if (model.isSetConversionFactor() - && !model.isSetConversionFactorInstance()) { - log4jLogger.warn("No parameter matches the conversionFactorID of Model."); - } - if (model.isSetExtentUnits() && !model.isSetExtentUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the extentUnitsID of Model."); - } - if (model.isSetLengthUnits() && !model.isSetLengthUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the lengthUnitsID of Model."); - } - if (model.isSetSubstanceUnits() - && !model.isSetSubstanceUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the substanceUnitsID of Model."); - } - if (model.isSetTimeUnits() && !model.isSetTimeUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the timeUnitsID of Model."); - } - if (model.isSetVolumeUnits() && !model.isSetVolumeUnitsInstance()) { - log4jLogger.warn("No unitDefinition matches the volumeUnitsID of Model."); - } - - if (model.isSetListOfRules()) { - - if (model.getLevel() == 1) { - - log4jLogger.debug("Transformed SBMLLevel1Rule : processEndDocument : model is level 1"); - - int i = 0; - for (Rule rule : model.getListOfRules().clone()) { - if (rule instanceof SBMLLevel1Rule) { - Rule realRule; - - if (((SBMLLevel1Rule) rule).isScalar()) { - realRule = ((SBMLLevel1Rule) rule).cloneAsAssignmentRule(); - log4jLogger.debug("Transformed SBMLLevel1Rule : " + ((SBMLLevel1Rule) rule).getVariable() + " into AssignmentRule."); - } else { - realRule = ((SBMLLevel1Rule) rule).cloneAsRateRule(); - log4jLogger.debug("Transformed SBMLLevel1Rule : " + ((SBMLLevel1Rule) rule).getVariable() + " into RateRule."); - } - - log4jLogger.debug("Transformed SBMLLevel1Rule : realRule = " + realRule); - - model.getListOfRules().remove(i); - model.getListOfRules().add(i, realRule); - } - i++; - } - } - - for (int i = 0; i < model.getRuleCount(); i++) { - Rule rule = model.getRule(i); - if (rule instanceof AssignmentRule) { - AssignmentRule assignmentRule = (AssignmentRule) rule; - if (assignmentRule.isSetVariable() - && !assignmentRule.isSetVariableInstance()) { - log4jLogger.warn("No Symbol matches the variableID of AssignmentRule."); - } - if (assignmentRule.isSetUnits() - && !assignmentRule.isSetUnitsInstance() - && assignmentRule.isParameter()) { - log4jLogger.warn("No UnitDefinition matches the unitsID of AssignmentRule."); - } - } else if (rule instanceof RateRule) { - RateRule rateRule = (RateRule) rule; - if (rateRule.isSetVariable() - && !rateRule.isSetVariableInstance()) { - log4jLogger.warn("No Symbol matches the variableID of RateRule."); - } - } - } - } - if (model.isSetListOfCompartments()) { - for (int i = 0; i < model.getCompartmentCount(); i++) { - Compartment compartment = model.getCompartment(i); - if (compartment.isSetCompartmentType() - && !compartment.isSetCompartmentTypeInstance()) { - log4jLogger.warn("No CompartmentType matches the compartmentTypeID of compartment."); - } - if (compartment.isSetOutside() - && !compartment.isSetOutsideInstance()) { - log4jLogger.warn("No Compartment matches the outsideID of compartment."); - } - if (compartment.isSetUnits() - && !compartment.isSetUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the unitsID of compartment."); - } - } - } - if (model.isSetListOfEvents()) { - for (int i = 0; i < model.getEventCount(); i++) { - Event event = model.getEvent(i); - - if (event.isSetTimeUnits() - && !event.isSetTimeUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the timeUnitsID of event."); - } - - if (event.isSetListOfEventAssignments()) { - - for (int j = 0; j < event.getEventAssignmentCount(); j++) { - EventAssignment eventAssignment = event - .getEventAssignment(j); - - if (eventAssignment.isSetVariable() - && !eventAssignment.isSetVariableInstance()) { - log4jLogger.warn("No Symbol matches the variableID of eventAssignment."); - } - } - } - } - } - if (model.isSetListOfInitialAssignments()) { - for (int i = 0; i < model.getInitialAssignmentCount(); i++) { - InitialAssignment initialAssignment = model - .getInitialAssignment(i); - - if (initialAssignment.isSetVariable() - && !initialAssignment.isSetVariableInstance()) { - log4jLogger.warn("No Symbol matches the symbolID of initialAssignment."); - } - } - } - if (model.isSetListOfReactions()) { - for (int i = 0; i < model.getReactionCount(); i++) { - Reaction reaction = model.getReaction(i); - if (reaction.isSetCompartment() - && !reaction.isSetCompartmentInstance()) { - log4jLogger.warn("No Compartment matches the compartmentID of reaction."); - } - - if (reaction.isSetListOfReactants()) { - for (int j = 0; j < reaction.getReactantCount(); j++) { - SpeciesReference speciesReference = reaction - .getReactant(j); - - if (speciesReference.isSetSpecies() - && !speciesReference.isSetSpeciesInstance()) { - log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.", - speciesReference.getId(), speciesReference.getElementName())); - } - } - } - if (reaction.isSetListOfProducts()) { - for (int j = 0; j < reaction.getProductCount(); j++) { - SpeciesReference speciesReference = reaction - .getProduct(j); - - if (speciesReference.isSetSpecies() - && !speciesReference.isSetSpeciesInstance()) { - log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.", - speciesReference.getId(), speciesReference.getElementName())); - } - } - } - if (reaction.isSetListOfModifiers()) { - for (int j = 0; j < reaction.getModifierCount(); j++) { - ModifierSpeciesReference modifierSpeciesReference = reaction - .getModifier(j); - - if (modifierSpeciesReference.isSetSpecies() - && !modifierSpeciesReference - .isSetSpeciesInstance()) { - log4jLogger.warn(String.format("No Species matches the speciesID '%s' of %s.", - modifierSpeciesReference.getId(), modifierSpeciesReference.getElementName())); - } - } - } - if (reaction.isSetKineticLaw()) { - KineticLaw kineticLaw = reaction.getKineticLaw(); - if (kineticLaw.isSetTimeUnits() - && !kineticLaw.isSetTimeUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the timeUnitsID of kineticLaw."); - } - if (kineticLaw.isSetSubstanceUnits() - && !kineticLaw.isSetSubstanceUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the substanceUnitsID of kineticLaw."); - } - if (kineticLaw.isSetListOfLocalParameters()) { - for (int j = 0; j < kineticLaw.getLocalParameterCount(); j++) { - LocalParameter parameter = kineticLaw - .getLocalParameter(j); - if (parameter.isSetUnits() - && !parameter.isSetUnitsInstance()) { - log4jLogger.warn(String.format( - "No UnitDefinition matches the unitsID '%s'of the parameter %s.", - parameter.getUnits(), parameter.getId())); - } - } - } - } - } - } - if (model.isSetListOfSpecies()) { - for (int i = 0; i < model.getSpeciesCount(); i++) { - Species species = model.getSpecies(i); - - if (species.isSetSubstanceUnits() - && !species.isSetSubstanceUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the subtsanceUnitsID of species."); - } - if (species.isSetSpeciesType() - && !species.isSetSpeciesTypeInstance()) { - log4jLogger.warn("No SpeciesType matches the speciesTypeID of species."); - } - if (species.isSetConversionFactor() - && !species.isSetConversionFactorInstance()) { - log4jLogger.warn("No Parameter matches the conversionFactorID of species."); - } - if (species.isSetCompartment() - && !species.isSetCompartmentInstance()) { - log4jLogger.warn("No Compartment matches the compartmentID of species."); - } - if (species.isSetSpatialSizeUnits() - && !species.isSetSpatialSizeUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the spatialSizeUnitsID of species."); - } - } - } - if (model.isSetListOfParameters()) { - for (int i = 0; i < model.getParameterCount(); i++) { - Parameter parameter = model.getParameter(i); - if (parameter.isSetUnits() - && !parameter.isSetUnitsInstance()) { - log4jLogger.warn("No UnitDefinition matches the unitsID of parameter."); - } - } - } - - } else { - log4jLogger.error("The Model element was not been created"); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String - * elementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) - { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String - * elementName, String URI, String prefix, String localName, boolean - * hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - { - - if (contextObject instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) contextObject; - - sbmlDocument.addNamespace(localName, prefix, URI); - - log4jLogger.debug("processNamespace : " + prefix + " = " + URI); - } - else if (contextObject instanceof SBase) { - SBase sbase = (SBase) contextObject; - - if (prefix != null && prefix.length() > 0) { - sbase.addDeclaredNamespace(prefix + ":" + localName, URI); - } else { - sbase.addDeclaredNamespace(localName, URI); - } - - log4jLogger.debug("processNamespace : " + prefix + " = " + URI); - } - else if (contextObject instanceof Annotation) { - Annotation sbase = (Annotation) contextObject; - sbase.addAnnotationNamespace(localName, prefix, URI); - - log4jLogger.debug("processNamespace : " + prefix + " = " + URI); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String - * elementName, String prefix, boolean hasAttributes, boolean hasNamespaces, - * Object contextObject) - */ - @SuppressWarnings("unchecked") - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - - // some of the warning logs could be added in the ErrorLog also ?? - - // All the possible elements name should be present in the HashMap - // sbmlCoreElements of this parser. - if (sbmlCoreElements.containsKey(elementName)) { - try { - - Object newContextObject = sbmlCoreElements.get(elementName).newInstance(); - - if (contextObject instanceof SBase) { - setLevelAndVersionFor(newContextObject, - (SBase) contextObject); - } - - if (elementName.equals("notes") - && (contextObject instanceof SBase)) { - SBase sbase = (SBase) contextObject; - sbase.setNotes(new XMLNode(new XMLTriple("notes", null, null), new XMLAttributes())); - } else if (elementName.equals("annotation") - && (contextObject instanceof SBase)) { - SBase sbase = (SBase) contextObject; - Annotation annotation = (Annotation) newContextObject; - sbase.setAnnotation(annotation); - - return annotation; - } else if (contextObject instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) contextObject; - if (elementName.equals("model")) { - Model model = (Model) newContextObject; - model.setLevel(sbmlDocument.getLevel()); - model.setVersion(sbmlDocument.getVersion()); - model.initDefaults(); - model.setParentSBML(sbmlDocument); - sbmlDocument.setModel(model); - - return model; - } - } else if (contextObject instanceof Model) { - - Model model = (Model) contextObject; - if (newContextObject instanceof ListOf) { - if (elementName.equals("listOfFunctionDefinitions") - && model.getLevel() > 1) { - ListOf listOfFunctionDefinitions = (ListOf) newContextObject; - model.setListOfFunctionDefinitions(listOfFunctionDefinitions); - - return listOfFunctionDefinitions; - } else if (elementName.equals("listOfUnitDefinitions")) { - ListOf listOfUnitDefinitions = (ListOf) newContextObject; - model.setListOfUnitDefinitions(listOfUnitDefinitions); - - return listOfUnitDefinitions; - } else if (elementName.equals("listOfCompartments")) { - ListOf listOfCompartments = (ListOf) newContextObject; - model.setListOfCompartments(listOfCompartments); - - return listOfCompartments; - } else if (elementName.equals("listOfSpecies")) { - ListOf listOfSpecies = (ListOf) newContextObject; - model.setListOfSpecies(listOfSpecies); - - return listOfSpecies; - } else if (elementName.equals("listOfParameters")) { - ListOf listOfParameters = (ListOf) newContextObject; - model.setListOfParameters(listOfParameters); - - return listOfParameters; - } else if (elementName.equals("listOfInitialAssignments") - && ((model.getLevel() == 2 && model.getVersion() > 1) - || model.getLevel() >= 3)) { - ListOf listOfInitialAssignments = (ListOf) newContextObject; - model.setListOfInitialAssignments(listOfInitialAssignments); - - return listOfInitialAssignments; - } else if (elementName.equals("listOfRules")) { - ListOf listOfRules = (ListOf) newContextObject; - model.setListOfRules(listOfRules); - - return listOfRules; - } else if (elementName.equals("listOfConstraints") - && ((model.getLevel() == 2 && model.getVersion() > 1) - || model.getLevel() >= 3)) { - ListOf listOfConstraints = (ListOf) newContextObject; - model.setListOfConstraints(listOfConstraints); - - return listOfConstraints; - } else if (elementName.equals("listOfReactions")) { - ListOf listOfReactions = (ListOf) newContextObject; - model.setListOfReactions(listOfReactions); - - return listOfReactions; - } else if (elementName.equals("listOfEvents") - && model.getLevel() > 1) { - ListOf listOfEvents = (ListOf) newContextObject; - model.setListOfEvents(listOfEvents); - - return listOfEvents; - } else if (elementName.equals("listOfCompartmentTypes") - && (model.getLevel() == 2 && model.getVersion() > 1)) { - ListOf listOfCompartmentTypes = (ListOf) newContextObject; - model.setListOfCompartmentTypes(listOfCompartmentTypes); - - return listOfCompartmentTypes; - } else if (elementName.equals("listOfSpeciesTypes") - && (model.getLevel() == 2 && model.getVersion() > 1)) { - ListOf listOfSpeciesTypes = (ListOf) newContextObject; - model.setListOfSpeciesTypes(listOfSpeciesTypes); - - return listOfSpeciesTypes; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof ListOf) { - ListOf list = (ListOf) contextObject; - if (list.getParentSBMLObject() instanceof Model) { - - Model model = (Model) list.getParentSBMLObject(); - if (elementName.equals("functionDefinition") - && list.getSBaseListType().equals( - ListOf.Type.listOfFunctionDefinitions) - && model.getLevel() > 1) { - FunctionDefinition functionDefinition = (FunctionDefinition) newContextObject; - model.addFunctionDefinition(functionDefinition); - - return functionDefinition; - } else if (elementName.equals("unitDefinition") - && list.getSBaseListType().equals( - ListOf.Type.listOfUnitDefinitions)) { - UnitDefinition unitDefinition = (UnitDefinition) newContextObject; - model.addUnitDefinition(unitDefinition); - - return unitDefinition; - } else if (elementName.equals("compartment") - && list.getSBaseListType().equals( - ListOf.Type.listOfCompartments)) { - Compartment compartment = (Compartment) newContextObject; - compartment.initDefaults(); - model.addCompartment(compartment); - - return compartment; - } else if (elementName.equals("species") - && list.getSBaseListType().equals( - ListOf.Type.listOfSpecies) - && ((model.getLevel() == 1 && model - .getVersion() > 1) || model.getLevel() > 1)) { - Species species = (Species) newContextObject; - species.initDefaults(); - model.addSpecies(species); - - return species; - } - // level 1 : species => specie - else if (elementName.equals("specie") - && list.getSBaseListType().equals( - ListOf.Type.listOfSpecies) - && model.getLevel() == 1 - && model.getVersion() == 1) { - Species species = (Species) newContextObject; - species.initDefaults(); - model.addSpecies(species); - - return species; - } else if (elementName.equals("parameter") - && list.getSBaseListType().equals( - ListOf.Type.listOfParameters)) { - Parameter parameter = (Parameter) newContextObject; - parameter.initDefaults(); - model.addParameter(parameter); - - return parameter; - } else if (elementName.equals("initialAssignment") - && list.getSBaseListType().equals( - ListOf.Type.listOfInitialAssignments) - && ((model.getLevel() == 2 && model - .getVersion() > 1) || model.getLevel() >= 3)) { - InitialAssignment initialAssignment = (InitialAssignment) newContextObject; - model.addInitialAssignment(initialAssignment); - - return initialAssignment; - } else if (elementName.equals("algebraicRule") - && list.getSBaseListType().equals( - ListOf.Type.listOfRules)) { - AlgebraicRule rule = (AlgebraicRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("assignmentRule") - && list.getSBaseListType().equals( - ListOf.Type.listOfRules) - && model.getLevel() > 1) { - AssignmentRule rule = (AssignmentRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("parameterRule") - && list.getSBaseListType().equals(ListOf.Type.listOfRules) - && model.getLevel() == 1) - { - ExplicitRule rule = (ExplicitRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("specieConcentrationRule") - && list.getSBaseListType().equals(ListOf.Type.listOfRules) - && model.getLevel() == 1 - && model.getVersion() == 1) - { - ExplicitRule rule = (ExplicitRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("speciesConcentrationRule") - && list.getSBaseListType().equals(ListOf.Type.listOfRules) - && model.getLevel() == 1 - && model.getVersion() == 2) - { - ExplicitRule rule = (ExplicitRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("compartmentVolumeRule") - && list.getSBaseListType().equals(ListOf.Type.listOfRules) - && model.getLevel() == 1) - { - ExplicitRule rule = (ExplicitRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("rateRule") - && list.getSBaseListType().equals( - ListOf.Type.listOfRules)) { - RateRule rule = (RateRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("constraint") - && list.getSBaseListType().equals( - ListOf.Type.listOfConstraints) - && ((model.getLevel() == 2 && model - .getVersion() > 1) || model.getLevel() >= 3)) { - Constraint constraint = (Constraint) newContextObject; - model.addConstraint(constraint); - - return constraint; - } else if (elementName.equals("reaction") - && list.getSBaseListType().equals( - ListOf.Type.listOfReactions)) { - Reaction reaction = (Reaction) newContextObject; - model.addReaction(reaction); - reaction.initDefaults(); - - return reaction; - } else if (elementName.equals("event") - && list.getSBaseListType().equals( - ListOf.Type.listOfEvents) - && model.getLevel() > 1) { - Event event = (Event) newContextObject; - model.addEvent(event); - event.initDefaults(); - - return event; - } else if (elementName.equals("compartmentType") - && list.getSBaseListType().equals( - ListOf.Type.listOfCompartmentTypes) - && (model.getLevel() == 2 && model.getVersion() > 1)) { - CompartmentType compartmentType = (CompartmentType) newContextObject; - model.addCompartmentType(compartmentType); - - return compartmentType; - } else if (elementName.equals("speciesType") - && list.getSBaseListType().equals( - ListOf.Type.listOfSpeciesTypes) - && (model.getLevel() == 2 && model.getVersion() > 1)) { - SpeciesType speciesType = (SpeciesType) newContextObject; - model.addSpeciesType(speciesType); - - return speciesType; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (list.getParentSBMLObject() instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) list - .getParentSBMLObject(); - - if (elementName.equals("unit") - && list.getSBaseListType().equals( - ListOf.Type.listOfUnits)) { - Unit unit = (Unit) newContextObject; - unit.initDefaults(); - unitDefinition.addUnit(unit); - - return unit; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (list.getParentSBMLObject() instanceof Reaction) { - Reaction reaction = (Reaction) list - .getParentSBMLObject(); - - if (elementName.equals("speciesReference") - && (reaction.getLevel() > 1 || (reaction - .getLevel() == 1 && reaction - .getVersion() == 2))) { - SpeciesReference speciesReference = (SpeciesReference) newContextObject; - speciesReference.initDefaults(); - - if (list.getSBaseListType().equals( - ListOf.Type.listOfReactants)) { - reaction.addReactant(speciesReference); - - return speciesReference; - } else if (list.getSBaseListType().equals( - ListOf.Type.listOfProducts)) { - reaction.addProduct(speciesReference); - - return speciesReference; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (elementName.equals("specieReference") - && reaction.getLevel() == 1) { - SpeciesReference speciesReference = (SpeciesReference) newContextObject; - speciesReference.initDefaults(); - - if (list.getSBaseListType().equals( - ListOf.Type.listOfReactants)) { - reaction.addReactant(speciesReference); - - return speciesReference; - } else if (list.getSBaseListType().equals( - ListOf.Type.listOfProducts)) { - reaction.addProduct(speciesReference); - - return speciesReference; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (elementName - .equals("modifierSpeciesReference") - && list.getSBaseListType().equals( - ListOf.Type.listOfModifiers) - && reaction.getLevel() > 1) { - ModifierSpeciesReference modifierSpeciesReference = (ModifierSpeciesReference) newContextObject; - reaction.addModifier(modifierSpeciesReference); - - return modifierSpeciesReference; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (list.getParentSBMLObject() instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) list - .getParentSBMLObject(); - // Level 3 : parameter and listOfParameters => - // localParameter and listOfLocalParameter - if (elementName.equals("localParameter") - && list.getSBaseListType().equals( - ListOf.Type.listOfLocalParameters) - && kineticLaw.getLevel() >= 3) { - LocalParameter localParameter = (LocalParameter) newContextObject; - kineticLaw.addLocalParameter(localParameter); - - return localParameter; - } else if (elementName.equals("parameter") - && list.getSBaseListType().equals( - ListOf.Type.listOfLocalParameters) - && kineticLaw.isSetLevel() - && kineticLaw.getLevel() < 3) { - LocalParameter localParameter = new LocalParameter( - (Parameter) newContextObject); - kineticLaw.addLocalParameter(localParameter); - - return localParameter; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (list.getParentSBMLObject() instanceof Event) { - Event event = (Event) list.getParentSBMLObject(); - - if (elementName.equals("eventAssignment") - && list.getSBaseListType().equals( - ListOf.Type.listOfEventAssignments) - && event.getLevel() > 1) { - EventAssignment eventAssignment = (EventAssignment) newContextObject; - event.addEventAssignment(eventAssignment); - - return eventAssignment; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) contextObject; - - if (elementName.equals("listOfUnits")) { - ListOf listOfUnits = (ListOf) newContextObject; - unitDefinition.setListOfUnits(listOfUnits); - - return listOfUnits; - } - } else if (contextObject instanceof Event) { - Event event = (Event) contextObject; - - if (elementName.equals("listOfEventAssignments")) { - ListOf listOfEventAssignments = (ListOf) newContextObject; - event.setListOfEventAssignments(listOfEventAssignments); - - return listOfEventAssignments; - } else if (elementName.equals("trigger")) { - Trigger trigger = (Trigger) newContextObject; - event.setTrigger(trigger); - - return trigger; - } else if (elementName.equals("delay")) { - Delay delay = (Delay) newContextObject; - event.setDelay(delay); - - return delay; - } else if (elementName.equals("priority")) { - Priority priority = (Priority) newContextObject; - event.setPriority(priority); - - return priority; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof Reaction) { - Reaction reaction = (Reaction) contextObject; - if (elementName.equals("listOfReactants")) { - ListOf listOfReactants = (ListOf) newContextObject; - reaction.setListOfReactants(listOfReactants); - - return listOfReactants; - } else if (elementName.equals("listOfProducts")) { - ListOf listOfProducts = (ListOf) newContextObject; - reaction.setListOfProducts(listOfProducts); - - return listOfProducts; - } else if (elementName.equals("listOfModifiers") - && reaction.getLevel() > 1) { - ListOf listOfModifiers = (ListOf) newContextObject; - reaction.setListOfModifiers(listOfModifiers); - - return listOfModifiers; - } else if (elementName.equals("kineticLaw")) { - KineticLaw kineticLaw = (KineticLaw) newContextObject; - reaction.setKineticLaw(kineticLaw); - - return kineticLaw; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof SpeciesReference) { - SpeciesReference speciesReference = (SpeciesReference) contextObject; - - if (elementName.equals("stoichiometryMath")) { - StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject; - speciesReference.setStoichiometryMath(stoichiometryMath); - - return stoichiometryMath; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) contextObject; - - if (elementName.equals("listOfLocalParameters") - && kineticLaw.getLevel() >= 3) { - ListOf listOfLocalParameters = (ListOf) newContextObject; - kineticLaw.setListOfLocalParameters(listOfLocalParameters); - listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters); - - return listOfLocalParameters; - } else if (elementName.equals("listOfParameters") - && kineticLaw.isSetLevel() && kineticLaw.getLevel() < 3) { - ListOf listOfLocalParameters = (ListOf) newContextObject; - kineticLaw.setListOfLocalParameters(listOfLocalParameters); - listOfLocalParameters.setSBaseListType(ListOf.Type.listOfLocalParameters); - - return listOfLocalParameters; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else if (contextObject instanceof Constraint) { - Constraint constraint = (Constraint) contextObject; - - if (elementName.equals("message") - && ((constraint.getLevel() == 2 && constraint - .getVersion() > 1) || constraint.getLevel() >= 3)) - { - constraint.setMessage(new XMLNode(new XMLTriple("message", null, null), new XMLAttributes())); - - return constraint; - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } else { - log4jLogger.warn("The element " + elementName + " is not recognized"); - } - } catch (InstantiationException e) { - log4jLogger.error("The element " + elementName + " could not be instanciated as a Java object !!"); - log4jLogger.debug(e.getMessage()); - if (log4jLogger.isDebugEnabled()) { - e.getStackTrace(); - } - } catch (IllegalAccessException e) { - log4jLogger.error("The element " + elementName + " could not be instanciated as a Java object !!"); - log4jLogger.debug(e.getMessage()); - if (log4jLogger.isDebugEnabled()) { - e.getStackTrace(); - } - } - } - return contextObject; - } - - /** - * Sets level and version properties of the new object according to the - * value in the model. - * - * @param newContextObject - * @param parent - */ - private void setLevelAndVersionFor(Object newContextObject, SBase parent) { - if (newContextObject instanceof SBase) { - SBase sb = (SBase) newContextObject; - // Level and version will be -1 if not set, so we don't - // have to check. - sb.setLevel(parent.getLevel()); - sb.setVersion(parent.getVersion()); - } - } - - /** - * @param logger - * the logger to set - */ - public void setLogger(XMLLogger logger) { - this.logger = logger; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeAttributes(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - xmlObject.addAttributes(sbase.writeXMLAttributes()); - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeCharacters(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // The method should never be called ! - log4jLogger.warn("The SBML core XML element should not have any content, everything should be stored as attribute."); - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeElement(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - if (!xmlObject.isSetName()) { - xmlObject.setName(sbase.getElementName()); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.xml.WritingParser#writeNamespaces(SBMLObjectForXML - * xmlObject, Object sbmlElementToWrite) - */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - - if (sbase instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) sbmlElementToWrite; - - xmlObject.addAttributes(sbmlDocument - .getSBMLDocumentNamespaces()); - } - - xmlObject.setPrefix(""); - } - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Rule.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Rule.java deleted file mode 100644 index fb348b40f..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Rule.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * $Id: SBMLLevel1Rule.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Rule.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ -package org.sbml.jsbml.xml.parsers; - -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.ExplicitRule; -import org.sbml.jsbml.RateRule; - -/** - * Represent a level 1 rule. This class is used only during the parsing of level - * 1 files. The real type of a rule will only be determined when we read the - * attribute 'type'. So on - * {@link SBMLCoreParser#processEndDocument(org.sbml.jsbml.SBMLDocument)} if the - * level of the model is equal to 1, we loop over the list of rules and clone - * the rules into {@link RateRule} or {@link AssignmentRule}. - *

    - * As this class is supposed to be used only inside the {@link SBMLCoreParser}, - * it's visibility is put at the package level. - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -class SBMLLevel1Rule extends ExplicitRule { - - /** - * Generated serial version identifier. - */ - private static final long serialVersionUID = -7511529049103686574L; - /** - * - */ - private String type; - - /** - * - */ - public SBMLLevel1Rule() { - } - - /** - * Creates a new {@link ExplicitRule} - * - * @param rule - */ - public SBMLLevel1Rule(SBMLLevel1Rule rule) { - super(rule); - - if (rule.getType() != null) { - setType(new String(rule.getType())); - } - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#clone() - */ - public SBMLLevel1Rule clone() { - return new SBMLLevel1Rule(this); - } - - /** - * - * @return - */ - public AssignmentRule cloneAsAssignmentRule() { - return new AssignmentRule(this); - } - - /** - * - * @return - */ - public RateRule cloneAsRateRule() { - return new RateRule(this); - } - - /** - * - * @return - */ - public String getType() { - return type; - } - - /* - * (non-Javadoc) - * @see org.sbml.jsbml.ExplicitRule#isScalar() - */ - public boolean isScalar() { - if (type == null || type.trim().equals("scalar")) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see org.sbml.jsbml.MathContainer#readAttribute(java.lang.String, - * java.lang.String, java.lang.String) - */ - @Override - public boolean readAttribute(String attributeName, String prefix, String value) - { - boolean isAttributeRead = super.readAttribute(attributeName, prefix, value); - - if (!isAttributeRead) { - if (getLevel() == 1) { - if (attributeName.equals("type")) { - setType(value); - return true; - } - } - } - return isAttributeRead; - } - - /** - * - * @param type - */ - public void setType(String type) { - this.type = type; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Version1Parser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Version1Parser.java deleted file mode 100644 index 47d3263bf..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Version1Parser.java +++ /dev/null @@ -1,1209 +0,0 @@ -/* - * $Id: SBMLLevel1Version1Parser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/SBMLLevel1Version1Parser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.sbml.jsbml.AlgebraicRule; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.AssignmentRule; -import org.sbml.jsbml.Compartment; -import org.sbml.jsbml.CompartmentType; -import org.sbml.jsbml.Event; -import org.sbml.jsbml.EventAssignment; -import org.sbml.jsbml.InitialAssignment; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.LocalParameter; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.ModifierSpeciesReference; -import org.sbml.jsbml.Parameter; -import org.sbml.jsbml.QuantityWithUnit; -import org.sbml.jsbml.RateRule; -import org.sbml.jsbml.Reaction; -import org.sbml.jsbml.Rule; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.SimpleSpeciesReference; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.SpeciesReference; -import org.sbml.jsbml.SpeciesType; -import org.sbml.jsbml.Unit; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.Variable; -import org.sbml.jsbml.resources.Resource; -import org.sbml.jsbml.xml.XMLAttributes; -import org.sbml.jsbml.xml.XMLNode; -import org.sbml.jsbml.xml.XMLTriple; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; - -// TODO : this parser need to work as well with sbml level 1 version 2 -// TODO : we need to parse correctly the rules, the current implementation is wrong - -/** - * @since 0.8 - * @version $Rev: 1139 $ - */ -@SuppressWarnings("deprecation") -public class SBMLLevel1Version1Parser implements ReadingParser, WritingParser { - - /** - * - */ - protected Map> SBMLCoreElements; - - /** - * @throws ClassNotFoundException - * @throws IOException - */ - public SBMLLevel1Version1Parser() throws IOException, - ClassNotFoundException { - SBMLCoreElements = new HashMap>(); - initializeCoreElements(); - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.WritingParser#getListOfSBMLElementsToWrite(java - * .lang.Object) - */ - @SuppressWarnings("unchecked") - public List getListOfSBMLElementsToWrite(Object sbase) { - ArrayList listOfElementsToWrite = null; - if (sbase instanceof SBase) { - if (sbase instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) sbase; - if (sbmlDocument.isSetModel()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(sbmlDocument.getModel()); - } - } else if (sbase instanceof Model) { - - Model model = (Model) sbase; - listOfElementsToWrite = new ArrayList(); - if (model.isSetListOfUnitDefinitions()) { - listOfElementsToWrite.add(model.getListOfUnitDefinitions()); - } - if (model.isSetListOfCompartments()) { - listOfElementsToWrite.add(model.getListOfCompartments()); - } - if (model.isSetListOfSpecies()) { - listOfElementsToWrite.add(model.getListOfSpecies()); - } - if (model.isSetListOfParameters()) { - listOfElementsToWrite.add(model.getListOfParameters()); - } - if (model.isSetListOfRules()) { - listOfElementsToWrite.add(model.getListOfRules()); - } - if (model.isSetListOfReactions()) { - listOfElementsToWrite.add(model.getListOfReactions()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } else if (sbase instanceof ListOf) { - ListOf listOf = (ListOf) sbase; - - if (!listOf.isEmpty()) { - listOfElementsToWrite = new ArrayList(); - for (int i = 0; i < listOf.size(); i++) { - SBase element = listOf.get(i); - - if (element != null) { - listOfElementsToWrite.add(element); - } - } - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } - } else if (sbase instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) sbase; - - if (unitDefinition.isSetListOfUnits()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(unitDefinition.getListOfUnits()); - } - } else if (sbase instanceof Reaction) { - Reaction reaction = (Reaction) sbase; - listOfElementsToWrite = new ArrayList(); - - if (reaction.isSetListOfReactants()) { - listOfElementsToWrite.add(reaction.getListOfReactants()); - } - if (reaction.isSetListOfProducts()) { - listOfElementsToWrite.add(reaction.getListOfProducts()); - } - if (reaction.isSetKineticLaw()) { - listOfElementsToWrite.add(reaction.getKineticLaw()); - } - - if (listOfElementsToWrite.isEmpty()) { - listOfElementsToWrite = null; - } - } else if (sbase instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) sbase; - - if (kineticLaw.isSetListOfParameters()) { - listOfElementsToWrite = new ArrayList(); - listOfElementsToWrite.add(kineticLaw.getListOfParameters()); - } - } - } - return listOfElementsToWrite; - } - - /** - * - * @return - */ - public String getParserNamespace() { - return SBMLDocument.URI_NAMESPACE_L1; - } - - /** - * @throws IOException - * @throws ClassNotFoundException - */ - private void initializeCoreElements() throws IOException, - ClassNotFoundException { - Properties p = new Properties(); - p.loadFromXML(Resource.getInstance().getStreamFromResourceLocation( - "org/sbml/jsbml/resources/cfg/SBMLElementsLevel1Version1.xml")); - for (Object k : p.keySet()) { - String key = k.toString(); - SBMLCoreElements.put(key, Class.forName(p.getProperty(key).toString())); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.ReadingParser#processAttribute(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String, boolean, - * java.lang.Object) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) { - boolean isAttributeRead = false; - if (contextObject instanceof SBase) { - SBase sbase = (SBase) contextObject; - try { - isAttributeRead = sbase.readAttribute(attributeName, prefix, - value); - } catch (Throwable exc) { - System.err.println(exc.getMessage()); - } - } else if (contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - isAttributeRead = annotation.readAttribute(attributeName, prefix, - value); - } - - if (!isAttributeRead) { - // TODO : throw new SBMLException ("The attribute " + attributeName - // + " on the element " + elementName + - // "is not part of the SBML specifications"); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.ReadingParser#processCharactersOf(java.lang.String - * , java.lang.String, java.lang.Object) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - // TODO : the basic SBML elements don't have any text. SBML syntax - // error, throw an exception? - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.ReadingParser#processEndDocument(org.sbml.jsbml - * .SBMLDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - if (sbmlDocument.isSetModel()) { - Model model = sbmlDocument.getModel(); - - if (model.isSetListOfRules()) { - for (int i = 0; i < model.getRuleCount(); i++) { - Rule rule = model.getRule(i); - if (rule instanceof AssignmentRule) { - AssignmentRule assignmentRule = (AssignmentRule) rule; - setAssignmentRuleVariable(assignmentRule, model); - } else if (rule instanceof RateRule) { - RateRule rateRule = (RateRule) rule; - setRateRuleVariable(rateRule, model); - } - } - } - if (model.isSetListOfCompartments()) { - for (int i = 0; i < model.getCompartmentCount(); i++) { - Compartment compartment = model.getCompartment(i); - - setCompartmentCompartmentType(compartment, model); - setCompartmentOutside(compartment, model); - setCompartmentUnits(compartment, model); - } - } - if (model.isSetListOfEvents()) { - for (int i = 0; i < model.getEventCount(); i++) { - Event event = model.getEvent(i); - - setEventTimeUnits(event, model); - - if (event.isSetListOfEventAssignments()) { - - for (int j = 0; j < event.getEventAssignmentCount(); j++) { - EventAssignment eventAssignment = event - .getEventAssignment(j); - - setEventAssignmentVariable(eventAssignment, model); - } - } - } - } - if (model.isSetListOfInitialAssignments()) { - for (int i = 0; i < model.getInitialAssignmentCount(); i++) { - InitialAssignment initialAssignment = model - .getInitialAssignment(i); - - setInitialAssignmentSymbol(initialAssignment, model); - } - } - if (model.isSetListOfReactions()) { - for (int i = 0; i < model.getReactionCount(); i++) { - Reaction reaction = model.getReaction(i); - - setReactionCompartment(reaction, model); - - if (reaction.isSetListOfReactants()) { - for (int j = 0; j < reaction.getReactantCount(); j++) { - SpeciesReference speciesReference = reaction - .getReactant(j); - - setSpeciesReferenceSpecies(speciesReference, model); - } - } - if (reaction.isSetListOfProducts()) { - for (int j = 0; j < reaction.getProductCount(); j++) { - SpeciesReference speciesReference = reaction - .getProduct(j); - - setSpeciesReferenceSpecies(speciesReference, model); - } - } - if (reaction.isSetListOfModifiers()) { - for (int j = 0; j < reaction.getModifierCount(); j++) { - ModifierSpeciesReference modifierSpeciesReference = reaction - .getModifier(j); - - setSpeciesReferenceSpecies( - modifierSpeciesReference, model); - } - } - if (reaction.isSetKineticLaw()) { - KineticLaw kineticLaw = reaction.getKineticLaw(); - if (kineticLaw.isSetListOfLocalParameters()) { - for (int j = 0; j < kineticLaw.getLocalParameterCount(); j++) { - LocalParameter parameter = kineticLaw - .getLocalParameter(j); - setParameterUnits(parameter, model); - } - } - } - } - } - if (model.isSetListOfSpecies()) { - for (int i = 0; i < model.getSpeciesCount(); i++) { - Species species = model.getSpecies(i); - setSpeciesSubstanceUnits(species, model); - setSpeciesSpeciesType(species, model); - setSpeciesConversionFactor(species, model); - setSpeciesCompartment(species, model); - } - } - if (model.isSetListOfParameters()) { - for (int i = 0; i < model.getParameterCount(); i++) { - Parameter parameter = model.getParameter(i); - setParameterUnits(parameter, model); - } - } - - } else { - // TODO : SBML syntax error, what to do? - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.stax.ReadingParser#processEndElement(java.lang.String, java.lang.String, boolean, java.lang.Object) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - return true; - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.ReadingParser#processNamespace(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String, boolean, boolean, - * java.lang.Object) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - if (contextObject instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) contextObject; - if (!URI.equals(SBMLDocument.URI_NAMESPACE_L1)) { - sbmlDocument.addNamespace(localName, prefix, URI); - } - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.ReadingParser#processStartElement(java.lang.String - * , java.lang.String, boolean, boolean, java.lang.Object) - */ - @SuppressWarnings("unchecked") - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, Object contextObject) { - if (SBMLCoreElements.containsKey(elementName)) { - try { - Object newContextObject = SBMLCoreElements.get(elementName) - .newInstance(); - - if (elementName.equals("notes") - && contextObject instanceof SBase) { - SBase sbase = (SBase) contextObject; - sbase.setNotes(new XMLNode(new XMLTriple("notes", null, null), new XMLAttributes())); - } else if (elementName.equals("annotation") - && contextObject instanceof SBase) { - SBase sbase = (SBase) contextObject; - Annotation annotation = (Annotation) newContextObject; - sbase.setAnnotation(annotation); - - return annotation; - } else if (contextObject instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) contextObject; - if (elementName.equals("model")) { - Model model = (Model) newContextObject; - model.setParentSBML(sbmlDocument); - sbmlDocument.setModel(model); - - return model; - } - } else if (contextObject instanceof Model) { - - Model model = (Model) contextObject; - if (newContextObject instanceof ListOf) { - if (elementName.equals("listOfUnitDefinitions")) { - ListOf listOfUnitDefinitions = (ListOf) newContextObject; - model.setListOfUnitDefinitions(listOfUnitDefinitions); - - return listOfUnitDefinitions; - } else if (elementName.equals("listOfCompartments")) { - ListOf listofCompartments = (ListOf) newContextObject; - model.setListOfCompartments(listofCompartments); - - return listofCompartments; - } else if (elementName.equals("listOfSpecies")) { - ListOf listOfSpecies = (ListOf) newContextObject; - model.setListOfSpecies(listOfSpecies); - - return listOfSpecies; - } else if (elementName.equals("listOfParameters")) { - ListOf listOfParameters = (ListOf) newContextObject; - model.setListOfParameters(listOfParameters); - - return listOfParameters; - } else if (elementName.equals("listOfRules")) { - ListOf listOfRules = (ListOf) newContextObject; - model.setListOfRules(listOfRules); - - return listOfRules; - } else if (elementName.equals("listOfReactions")) { - ListOf listOfReactions = (ListOf) newContextObject; - model.setListOfReactions(listOfReactions); - - return listOfReactions; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (contextObject instanceof ListOf) { - ListOf list = (ListOf) contextObject; - if (list.getParentSBMLObject() instanceof Model) { - - Model model = (Model) list.getParentSBMLObject(); - if (elementName.equals("unitDefinition") - && list.getSBaseListType().equals( - ListOf.Type.listOfUnitDefinitions)) { - UnitDefinition unitDefinition = (UnitDefinition) newContextObject; - model.addUnitDefinition(unitDefinition); - - return unitDefinition; - } else if (elementName.equals("compartment") - && list.getSBaseListType().equals( - ListOf.Type.listOfCompartments)) { - Compartment compartment = (Compartment) newContextObject; - model.addCompartment(compartment); - - return compartment; - } else if (elementName.equals("specie") - && list.getSBaseListType().equals( - ListOf.Type.listOfSpecies)) { - Species species = (Species) newContextObject; - model.addSpecies(species); - - return species; - } else if (elementName.equals("parameter") - && list.getSBaseListType().equals( - ListOf.Type.listOfParameters)) { - Parameter parameter = (Parameter) newContextObject; - model.addParameter(parameter); - - return parameter; - } else if (elementName.equals("algebraicRule") - && list.getSBaseListType().equals( - ListOf.Type.listOfRules)) { - AlgebraicRule rule = (AlgebraicRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("assignmentRule") // TODO : wrong, there are no assignmentRule element, only more specialize rule - && list.getSBaseListType().equals( - ListOf.Type.listOfRules)) { - AssignmentRule rule = (AssignmentRule) newContextObject; - model.addRule(rule); - - return rule; - } else if (elementName.equals("reaction") - && list.getSBaseListType().equals( - ListOf.Type.listOfReactions)) { - Reaction reaction = (Reaction) newContextObject; - model.addReaction(reaction); - - return reaction; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (list.getParentSBMLObject() instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) list - .getParentSBMLObject(); - - if (elementName.equals("unit") - && list.getSBaseListType().equals( - ListOf.Type.listOfUnits)) { - Unit unit = (Unit) newContextObject; - unitDefinition.addUnit(unit); - - return unit; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (list.getParentSBMLObject() instanceof Reaction) { - Reaction reaction = (Reaction) list - .getParentSBMLObject(); - - if (elementName.equals("specieReference")) { - SpeciesReference speciesReference = (SpeciesReference) newContextObject; - - if (list.getSBaseListType().equals( - ListOf.Type.listOfReactants)) { - reaction.addReactant(speciesReference); - - return speciesReference; - } else if (list.getSBaseListType().equals( - ListOf.Type.listOfProducts)) { - reaction.addProduct(speciesReference); - - return speciesReference; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (list.getParentSBMLObject() instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) list - .getParentSBMLObject(); - - if (elementName.equals("parameter") - && list.getSBaseListType().equals( - ListOf.Type.listOfParameters)) { - LocalParameter localParameter = (LocalParameter) newContextObject; - kineticLaw.addLocalParameter(localParameter); - - return localParameter; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (contextObject instanceof UnitDefinition) { - UnitDefinition unitDefinition = (UnitDefinition) contextObject; - - if (elementName.equals("listOfUnits")) { - ListOf listOfUnits = (ListOf) newContextObject; - unitDefinition.setListOfUnits(listOfUnits); - - return listOfUnits; - } - } else if (contextObject instanceof Reaction) { - Reaction reaction = (Reaction) contextObject; - - if (elementName.equals("listOfReactants")) { - ListOf listOfReactants = (ListOf) newContextObject; - reaction.setListOfReactants(listOfReactants); - listOfReactants - .setSBaseListType(ListOf.Type.listOfReactants); - - return listOfReactants; - } else if (elementName.equals("listOfProducts")) { - ListOf listOfProducts = (ListOf) newContextObject; - reaction.setListOfProducts(listOfProducts); - listOfProducts - .setSBaseListType(ListOf.Type.listOfProducts); - - return listOfProducts; - } else if (elementName.equals("kineticLaw")) { - KineticLaw kineticLaw = (KineticLaw) newContextObject; - reaction.setKineticLaw(kineticLaw); - - return kineticLaw; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else if (contextObject instanceof KineticLaw) { - KineticLaw kineticLaw = (KineticLaw) contextObject; - - if (elementName.equals("listOfParameters")) { - ListOf listOfLocalParameters = (ListOf) newContextObject; - kineticLaw - .setListOfLocalParameters(listOfLocalParameters); - listOfLocalParameters - .setSBaseListType(ListOf.Type.listOfParameters); - - return listOfLocalParameters; - } else { - // TODO : SBML syntax error, throw an exception? - } - } else { - // TODO : SBML syntax error, throw an exception? - } - } catch (InstantiationException e) { - // TODO : SBML object can't be instantiated, throw an exception? - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO : SBML object can't be instantiated, throw an exception? - e.printStackTrace(); - } - } - return contextObject; - } - - /** - * - * @param rule - * @param model - */ - private void setAssignmentRuleVariable(AssignmentRule rule, Model model) { - - if (rule.isSetVariable()) { - String variableID = rule.getVariable(); - - Compartment compartment = model.getCompartment(variableID); - Species species = null; - SpeciesReference speciesReference = null; - Parameter parameter = null; - - if (compartment == null) { - species = model.getSpecies(variableID); - - if (species == null) { - parameter = model.getParameter(variableID); - - if (parameter == null) { - if (model.isSetListOfReactions()) { - - int i = 0; - SpeciesReference sr = null; - - while (i <= model.getReactionCount() - 1 - && sr == null) { - Reaction reaction = model.getReaction(i); - - if (reaction != null) { - sr = reaction.getReactant(variableID); - if (sr == null) { - sr = reaction.getProduct(variableID); - } - } - } - - speciesReference = sr; - - if (speciesReference != null) { - rule.setVariable(speciesReference); - } else { - // TODO : the variable ID doesn't match a SBML - // component, throw an exception? - } - } - } else { - rule.setVariable(parameter); - } - } else { - rule.setVariable(species); - } - } else { - rule.setVariable(compartment); - } - } - } - - /** - * - * @param compartment - * @param model - */ - private void setCompartmentCompartmentType(Compartment compartment, - Model model) { - if (compartment.isSetCompartmentType()) { - String compartmentTypeID = compartment.getCompartmentType(); - - CompartmentType compartmentType = model - .getCompartmentType(compartmentTypeID); - - if (compartmentType != null) { - compartment.setCompartmentType(compartmentType); - } else { - // TODO : the compartmentType ID doesn't match a compartment, - // throw an exception? - } - } - } - - /** - * - * @param compartment - * @param model - */ - private void setCompartmentOutside(Compartment compartment, Model model) { - - if (compartment.isSetOutside()) { - String outsideID = compartment.getOutside(); - - Compartment outside = model.getCompartment(outsideID); - - if (outside != null) { - compartment.setOutside(outside); - } else { - // TODO : the compartment ID doesn't match a compartment, throw - // an exception? - } - } - } - - /** - * - * @param compartment - * @param model - */ - private void setCompartmentUnits(Compartment compartment, Model model) { - - if (compartment.isSetUnits()) { - String unitsID = compartment.getUnits(); - - UnitDefinition unitDefinition = model.getUnitDefinition(unitsID); - - if (unitDefinition != null) { - compartment.setUnits(unitDefinition); - } else { - // TODO : the unitDefinition ID doesn't match a unitDefinition, - // throw an exception? - } - } - } - - /** - * - * @param eventAssignment - * @param model - */ - private void setEventAssignmentVariable(EventAssignment eventAssignment, - Model model) { - - if (eventAssignment.isSetVariable()) { - String variableID = eventAssignment.getVariable(); - - Compartment compartment = model.getCompartment(variableID); - Species species = null; - SpeciesReference speciesReference = null; - Parameter parameter = null; - - if (compartment == null) { - species = model.getSpecies(variableID); - - if (species == null) { - parameter = model.getParameter(variableID); - - if (parameter == null) { - if (model.isSetListOfReactions()) { - - int i = 0; - SpeciesReference sr = null; - - while (i <= model.getReactionCount() - 1 - && sr == null) { - Reaction reaction = model.getReaction(i); - - if (reaction != null) { - sr = reaction.getReactant(variableID); - if (sr == null) { - sr = reaction.getProduct(variableID); - } - } - } - - speciesReference = sr; - - if (speciesReference != null) { - eventAssignment.setVariable(speciesReference); - } else { - // TODO : the variable ID doesn't match a SBML - // component, throw an exception? - } - } - } else { - eventAssignment.setVariable(parameter); - } - } else { - eventAssignment.setVariable(species); - } - } else { - eventAssignment.setVariable(compartment); - } - } - } - - /** - * - * @param event - * @param model - */ - private void setEventTimeUnits(Event event, Model model) { - - if (event.isSetTimeUnits()) { - String timeUnitsID = event.getTimeUnits(); - - UnitDefinition unitDefinition = model - .getUnitDefinition(timeUnitsID); - - if (unitDefinition != null) { - event.setTimeUnits(unitDefinition); - } else { - // TODO : the unitDefinition ID doesn't match a unitDefinition, - // throw an exception? - } - } - } - - /** - * - * @param initialAssignment - * @param model - */ - private void setInitialAssignmentSymbol( - InitialAssignment initialAssignment, Model model) { - - if (initialAssignment.isSetVariable()) { - String variableID = initialAssignment.getVariable(); - - Compartment compartment = model.getCompartment(variableID); - Species species = null; - SpeciesReference speciesReference = null; - Parameter parameter = null; - - if (compartment == null) { - species = model.getSpecies(variableID); - - if (species == null) { - parameter = model.getParameter(variableID); - - if (parameter == null) { - if (model.isSetListOfReactions()) { - - int i = 0; - SpeciesReference sr = null; - - while (i <= model.getReactionCount() - 1 - && sr == null) { - Reaction reaction = model.getReaction(i); - - if (reaction != null) { - sr = reaction.getReactant(variableID); - if (sr == null) { - sr = reaction.getProduct(variableID); - } - } - } - - speciesReference = sr; - - if (speciesReference != null) { - initialAssignment.setVariable(speciesReference); - } else { - // TODO : the variable ID doesn't match a SBML - // component, throw an exception? - } - } - } else { - initialAssignment.setVariable(parameter); - } - } else { - initialAssignment.setVariable(species); - } - } else { - initialAssignment.setVariable(compartment); - } - } - } - - /** - * - * @param parameter - * @param model - */ - private void setParameterUnits(QuantityWithUnit parameter, - Model model) { - - if (parameter.isSetUnits()) { - String unitsID = parameter.getUnits(); - - UnitDefinition unitDefinition = model.getUnitDefinition(unitsID); - - if (unitDefinition != null) { - parameter.setUnits(unitDefinition); - } else { - // TODO : the unitDefinition ID doesn't match an unitDefinition, - // throw an exception? - } - } - } - - /** - * - * @param rule - * @param model - */ - private void setRateRuleVariable(RateRule rule, Model model) { - if (rule.isSetVariable()) { - String variableID = rule.getVariable(); - - Compartment compartment = model.getCompartment(variableID); - Species species = null; - SpeciesReference speciesReference = null; - Parameter parameter = null; - - if (compartment == null) { - species = model.getSpecies(variableID); - - if (species == null) { - parameter = model.getParameter(variableID); - - if (parameter == null) { - if (model.isSetListOfReactions()) { - - int i = 0; - SpeciesReference sr = null; - - while (i <= model.getReactionCount() - 1 - && sr == null) { - Reaction reaction = model.getReaction(i); - - if (reaction != null) { - sr = reaction.getReactant(variableID); - if (sr == null) { - sr = reaction.getProduct(variableID); - } - } - } - - speciesReference = sr; - - if (speciesReference != null) { - rule.setVariable(speciesReference); - } else { - // TODO : the variable ID doesn't match a SBML - // component, throw an exception? - } - } - } else { - rule.setVariable(parameter); - } - } else { - rule.setVariable(species); - } - } else { - rule.setVariable(compartment); - } - } - } - - /** - * - * @param reaction - * @param model - */ - private void setReactionCompartment(Reaction reaction, Model model) { - - if (reaction.isSetCompartment()) { - String compartmentID = reaction.getCompartment(); - - Compartment compartment = model.getCompartment(compartmentID); - - if (compartment != null) { - reaction.setCompartment(compartment); - } else { - // TODO : the compartment ID doesn't match a compartment, throw - // an exception? - } - } - } - - /** - * - * @param species - * @param model - */ - private void setSpeciesCompartment(Species species, Model model) { - - if (species.isSetCompartment()) { - String compartmentID = species.getCompartment(); - - Compartment compartment = model.getCompartment(compartmentID); - - if (compartment != null) { - species.setCompartment(compartment); - } else { - // TODO : the compartment ID doesn't match a compartment, throw - // an exception? - } - } - } - - /** - * - * @param species - * @param model - */ - private void setSpeciesConversionFactor(Species species, Model model) { - - if (species.isSetConversionFactor()) { - String conversionFactorID = species.getConversionFactor(); - - Parameter parameter = model.getParameter(conversionFactorID); - - if (parameter != null) { - species.setConversionFactor(parameter); - } else { - // TODO : the parameter ID doesn't match a parameter, throw an - // exception? - } - } - } - - /** - * - * @param speciesReference - * @param model - */ - private void setSpeciesReferenceSpecies( - SimpleSpeciesReference speciesReference, Model model) { - - if (speciesReference.isSetSpecies()) { - String speciesID = speciesReference.getSpecies(); - - Species species = model.getSpecies(speciesID); - - if (species != null) { - speciesReference.setSpecies(species); - } else { - // TODO : the species ID doesn't match a species, throw an - // exception? - } - } - } - - /** - * - * @param species - * @param model - */ - private void setSpeciesSpeciesType(Species species, Model model) { - - if (species.isSetSpeciesType()) { - String speciesTypeID = species.getSpeciesType(); - - SpeciesType speciesType = model.getSpeciesType(speciesTypeID); - - if (speciesType != null) { - species.setSpeciesType(speciesType); - } else { - // TODO : the speciesType ID doesn't match a speciesType, throw - // an exception? - } - } - } - - /** - * - * @param species - * @param model - */ - private void setSpeciesSubstanceUnits(Species species, Model model) { - - if (species.isSetSubstanceUnits()) { - String substanceUnitsID = species.getSubstanceUnits(); - - UnitDefinition unitDefinition = model - .getUnitDefinition(substanceUnitsID); - - if (unitDefinition != null) { - species.setSubstanceUnits(unitDefinition); - } - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.WritingParser#writeAttributes(org.sbml.jsbml. - * xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - - xmlObject.addAttributes(sbase.writeXMLAttributes()); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.WritingParser#writeCharacters(org.sbml.jsbml. - * xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - // TODO SBML components don't have any characters in the XML file. what - // to do? - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.WritingParser#writeElement(org.sbml.jsbml.xml - * .stax.SBMLObjectForXML, java.lang.Object, int) - */ - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - if (!xmlObject.isSetName()) { - if (sbase.getElementName().equals("species")) { - xmlObject.setName("specie"); - } else if (sbase.getElementName().equals("speciesReference")) { - xmlObject.setName("specieReference"); - } else if (sbase.getElementName().equals("assignementRule")) { - AssignmentRule assignmentRule = (AssignmentRule) sbase; - Variable variable = assignmentRule.getVariableInstance(); - - if (variable instanceof Species) { - xmlObject.setName("specieConcentrationRule"); - } else if (variable instanceof Compartment) { - xmlObject.setName("compartmentVolumeRule"); - } else if (variable instanceof Parameter) { - xmlObject.setName("parameterRule"); - } - } else { - xmlObject.setName(sbase.getElementName()); - } - } - } - } - - /* - * (non-Javadoc) - * - * @see - * org.sbml.jsbml.xml.stax.WritingParser#writeNamespaces(org.sbml.jsbml. - * xml.stax.SBMLObjectForXML, java.lang.Object) - */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite) { - if (sbmlElementToWrite instanceof SBase) { - SBase sbase = (SBase) sbmlElementToWrite; - - if (sbase instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) sbmlElementToWrite; - - xmlObject.addAttributes(sbmlDocument - .getSBMLDocumentNamespaces()); - } - - xmlObject.setPrefix(""); - } - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/StringParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/StringParser.java deleted file mode 100644 index cf895d7ec..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/StringParser.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * $Id: StringParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/StringParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.xml.XMLAttributes; -import org.sbml.jsbml.xml.XMLNamespaces; -import org.sbml.jsbml.xml.XMLNode; -import org.sbml.jsbml.xml.XMLTriple; - -/** - * A {@link StringParser} can be used to store the HTML expressions into an {@link XMLNode} in the - * SBML component. - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class StringParser implements ReadingParser { - - /** - * String to be able to detect what type of String this parser is parsing. It can be 'notes' or 'message'. - */ - private String typeOfNotes = ""; - - private Logger logger = Logger.getLogger(StringParser.class); - - /** - * - * @return the typeOfNotes of this ReadingParser. - */ - public String getTypeOfNotes() { - return typeOfNotes; - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - { - - logger.debug("processAttribute : attribute name = " + attributeName + ", value = " + value); - - if (contextObject instanceof XMLNode) { - - XMLNode xmlNode = (XMLNode) contextObject; - xmlNode.addAttr(attributeName, value, null, prefix); - - - } else { - logger.debug("processAttribute : context Object is not an XMLNode !!! " + contextObject); - } - - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String elementName, String characters, - Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - - logger.debug("processCharactersOf called : characters = @" + characters + "@"); - - // characters = StringTools.encodeForHTML(characters); // TODO : use an apache util for that. - - XMLNode textNode = new XMLNode(characters); - - if (contextObject instanceof XMLNode) { - - XMLNode xmlNode = (XMLNode) contextObject; - - xmlNode.addChild(textNode); - - } else if (contextObject instanceof SBase) { - SBase parentSBMLElement = (SBase) contextObject; - - XMLNode xmlNode = null; - - if (parentSBMLElement.isSetNotes() && typeOfNotes.equals("notes")) - { - xmlNode = parentSBMLElement.getNotes(); - } - else if (typeOfNotes.equals("message") && parentSBMLElement instanceof Constraint - && ((Constraint) parentSBMLElement).isSetMessage()) - { - xmlNode = ((Constraint) parentSBMLElement).getMessage(); - } - else - { - logger.warn("The type of String " + typeOfNotes + " on the element " + - parentSBMLElement.getElementName() + " is unknown !! Some data might be lost"); - return; - } - - xmlNode.addChild(textNode); - - } else { - logger.debug("processCharactersOf : context Object is not an XMLNode or SBase !!! " + contextObject); - } - - - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - // TODO : nothing special to be done I think ??!!! - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) - { - if (contextObject instanceof XMLNode) { - XMLNode xmlNode = (XMLNode) contextObject; - - if (xmlNode.getChildCount() == 0) { - xmlNode.setEnd(); - } - } - - return true; - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) - { - if (contextObject instanceof XMLNode) { - - XMLNode xmlNode = (XMLNode) contextObject; - if (!xmlNode.isStart()) { - logger.debug("processNamespace : context Object is not a start node !!! " + contextObject); - } - - xmlNode.addNamespace(URI, prefix); - - } else { - logger.debug("processNamespace : context Object is not an XMLNode !!! " + contextObject); - logger.debug("processNamespace : element name = " + elementName + ", namespace = " + prefix + ":" + URI); - } - - } - - /* (non-Javadoc) - * - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttributes, boolean hasNamespaces, - Object contextObject) - { - logger.debug("processStartElement : element name = " + elementName); - - // Creating a StartElement XMLNode !! - XMLNode xmlNode = new XMLNode(new XMLTriple(elementName, null, prefix), new XMLAttributes(), new XMLNamespaces()); - - if (contextObject instanceof SBase) { - SBase parentSBMLElement = (SBase) contextObject; - - if (typeOfNotes.equals("notes")) { - parentSBMLElement.getNotes().addChild(xmlNode); - } else if (typeOfNotes.equals("message") && parentSBMLElement instanceof Constraint) { - ((Constraint) parentSBMLElement).getMessage().addChild(xmlNode); - } else { - logger.warn("The type of String " + typeOfNotes + " on the element " + - parentSBMLElement.getElementName() + " is unknown !! Some data might be lost"); - } - - } else if (contextObject instanceof XMLNode) { - XMLNode parentNode = (XMLNode) contextObject; - - parentNode.addChild(xmlNode); - } - - return xmlNode; - } - - /** - * Sets the typeOfNote of this parser. - * @param typeOfNotes - */ - public void setTypeOfNotes(String typeOfNotes) { - this.typeOfNotes = typeOfNotes; - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/VCardParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/VCardParser.java deleted file mode 100644 index 800bf6aa3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/VCardParser.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * $Id: VCardParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/VCardParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.text.MessageFormat; - -import org.apache.log4j.Logger; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.Creator; -import org.sbml.jsbml.SBMLDocument; - -/** - * A {@link VCardParser} is used to parse the subNodes of an annotation which have this - * namespace URI : "http://www.w3.org/2001/vcard-rdf/3.0#". - * - *

    - * To know more about vCard ==> vCard MIME Directory Profile, - * F. Dawson and T. Howes, Internet RFC 2426, September 1998 - * - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1187 $ - */ -public class VCardParser implements ReadingParser { - - /** - * Boolean value to know if the 'N' node has been read. - */ - private boolean hasReadNNode = false; - /** - * Boolean value to know if the 'Family' node has been read. - */ - private boolean hasReadFamilyName = false; - /** - * Boolean value to know if the 'Given' node has been read. - */ - private boolean hasReadGivenName = false; - /** - * Boolean value to know if the 'Orgname' node has been read. - */ - private boolean hasReadOrgName = false; - /** - * Boolean value to know if the 'EMAIL' node has been read. - */ - private boolean hasReadEMAIL = false; - - /** - * Boolean value to know if the 'ORG' node has been read. - */ - private boolean hasReadORGNode = false; - - private Logger logger = Logger.getLogger(VCardParser.class); - - /** - * @return the namespaceURI - */ - public static String getNamespaceURI() { - return Creator.URI_RDF_VCARD_NS; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processAttribute(String elementName, String attributeName, String value, String prefix, boolean isLastAttribute, Object contextObject) - */ - public void processAttribute(String elementName, String attributeName, - String value, String prefix, boolean isLastAttribute, - Object contextObject) - { - // There is no attribute with this namespace although the Creator class as a readAttribute that accept - // the parseType attribute (without doing anything with it) - - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processCharactersOf(String elementName, String characters, Object contextObject) - */ - public void processCharactersOf(String elementName, String characters, - Object contextObject) { - - // An elementName can be null if the text appears after a ending element - // tag. - if (elementName != null) { - // A VCardParser can only modify a contextObject which is a - // Creator instance. - if (contextObject instanceof Creator) { - Creator creator = (Creator) contextObject; - - // Sets the familyName String of modelCreator. - if (elementName.equals("Family") && hasReadFamilyName) { - creator.setFamilyName(characters); - } - // Sets the givenName String of modelCreator. - else if (elementName.equals("Given") && hasReadGivenName) { - creator.setGivenName(characters); - } - // Sets the email String of modelCreator. - else if (elementName.equals("EMAIL") && hasReadEMAIL) { - creator.setEmail(characters); - } - // Sets the orgname String of modelCreator. - else if (elementName.equals("Orgname") && hasReadOrgName) { - creator.setOrganisation(characters); - } else if (!elementName.equals("ORG") && !elementName.equals("N")) { - // Storing additional VCard elements in a map to write them back - - creator.setOtherAttribute(elementName, characters); - } - } else { - logger.warn("Lost Information : the characters '" + characters + "' on the element '" + elementName + "' might be lost" - + " as the context object is not a Creator."); - } - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processEndDocument(SBMLDocument sbmlDocument) - */ - public void processEndDocument(SBMLDocument sbmlDocument) { - hasReadEMAIL = false; - hasReadFamilyName = false; - hasReadGivenName = false; - hasReadNNode = false; - hasReadORGNode = false; - hasReadOrgName = false; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processEndElement(String elementName, String prefix, boolean isNested, Object contextObject) - */ - public boolean processEndElement(String elementName, String prefix, - boolean isNested, Object contextObject) { - - // A VCardParser can only modify a contextObject which is a ModelCreator - // instance. - if (contextObject instanceof Creator) { - // End of a 'N' node, sets hasReadNNode, hasReadFamilyName and - // hasReadGivenName to false. - if (elementName.equals("N")) { - hasReadNNode = false; - hasReadFamilyName = false; - hasReadGivenName = false; - } - // End of a 'EMAIL' node, sets hasReadEMAIL to false. - else if (elementName.equals("EMAIL")) { - hasReadEMAIL = false; - } - // End of a 'ORG' node, sets hasReadORGNode, hasReadOrgName. - else if (elementName.equals("ORG")) { - hasReadORGNode = false; - hasReadOrgName = false; - - } - } - - return true; - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processNamespace(String elementName, String URI, String prefix, String localName, boolean hasAttributes, boolean isLastNamespace, Object contextObject) - */ - public void processNamespace(String elementName, String URI, String prefix, - String localName, boolean hasAttributes, boolean isLastNamespace, - Object contextObject) { - - // The namespace of this parser should be declared in a 'RDF' subnode of - // annotation. - // Adds the namespace to RDFAnnotationNamespaces HashMap of annotation. - if (elementName.equals("RDF") && contextObject instanceof Annotation) { - Annotation annotation = (Annotation) contextObject; - - annotation.addRDFAnnotationNamespace(localName, prefix, URI); - } - } - - /* (non-Javadoc) - * @see org.sbml.jsbml.xml.ReadingParser#processStartElement(String elementName, String prefix, boolean hasAttribute, boolean hasNamespaces, Object contextObject) - */ - public Object processStartElement(String elementName, String prefix, - boolean hasAttribute, boolean hasNamespaces, Object contextObject) { - - // A VCardParser can only modify a contextObject which is a ModelCreator - // instance. - if (contextObject instanceof Creator) { - // Reads the 'N' node. - if (elementName.equals("N") && !hasReadNNode) { - hasReadNNode = true; - } - // Reads the 'Family' node. - else if (elementName.equals("Family") && hasReadNNode - && !hasReadFamilyName && !hasReadGivenName) { - hasReadFamilyName = true; - } - // Reads the 'Given' node. - else if (elementName.equals("Given") && hasReadNNode - && hasReadFamilyName && !hasReadGivenName) { - hasReadGivenName = true; - } - // Reads the 'EMAIL' node. - else if (elementName.equals("EMAIL") && !hasReadEMAIL) { - hasReadEMAIL = true; - } - // Reads the 'ORG' node. - else if (elementName.equals("ORG") && !hasReadORGNode) { - hasReadORGNode = true; - } - // Reads the 'Orgname' node. - else if (elementName.equals("Orgname") && hasReadORGNode - && !hasReadOrgName) { - hasReadOrgName = true; - } else { - logger.warn(MessageFormat.format( - "The element ''vCard:{0}'' is an additional vCard element not described in the SBML specifications.", - elementName)); - } - } else { - logger.warn(MessageFormat.format( - "Lost Information: the element ''{0}'' might be lost as the context object is not a Creator.", - elementName)); - } - return contextObject; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/WritingParser.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/WritingParser.java deleted file mode 100644 index 8ed78c773..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/WritingParser.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * $Id: WritingParser.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/WritingParser.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.util.List; - -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.xml.stax.SBMLObjectForXML; - -/** - * The interface to implement for a parser which writes a SBML file. - * - * @author Marine Dumousseau - * @since 0.8 - * @version $Rev: 1116 $ - */ -public interface WritingParser { - - /** - * Returns the list of children of the objectToWrite. - * - * @param objectToWrite - * : the {@link SBase} component to write. - * @return the list of components that '{@link SBase}' contains. Represents - * the list of subNodes of this {@link SBase} component. - */ - public List getListOfSBMLElementsToWrite(Object objectToWrite); - - /** - * Adds the XML attributes of the sbmlElementToWrite to the attributes - * HashMap of the xmlObject. - * - * @param xmlObject - * : contains the XML information about sbmlElement. - * @param sbmlElementToWrite - * : the {@link SBase} component to write - */ - public void writeAttributes(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite); - - /** - * Sets the characters of xmlObject depending on the sbml element to write. - * - * @param xmlObject - * : contains the XML information about sbmlElement. - * @param sbmlElementToWrite - * : the {@link SBase} component to write - */ - public void writeCharacters(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite); - - /** - * Sets the name of xmlObject (if it is not set) to the element name of - * sbmlElementToWrite. - * - * @param xmlObject - * : contains the XML information about sbmlElement. - * @param sbmlElementToWrite - * : the {@link SBase} component to write - */ - public void writeElement(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite); - - /** - * Sets the namespace of xmlObject (if it is not set) to the namespace of - * sbmlElementToWrite. - * - * @param xmlObject - * : contains the XML information about sbmlElement. - * @param sbmlElementToWrite - * : the {@link SBase} component to write - */ - public void writeNamespaces(SBMLObjectForXML xmlObject, - Object sbmlElementToWrite); -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/XMLNodeWriter.java b/IPK_lib/src/org/sbml/jsbml/xml/parsers/XMLNodeWriter.java deleted file mode 100644 index a2996be42..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/XMLNodeWriter.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * $Id: XMLNodeWriter.java,v 1.1 2012-11-07 14:43:35 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/parsers/XMLNodeWriter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.parsers; - -import java.io.StringWriter; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.log4j.Logger; -import org.codehaus.staxmate.SMOutputFactory; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.xml.XMLNode; - -import com.ctc.wstx.stax.WstxOutputFactory; - - - -/** - * - * - * @author Nicolas Rodriguez - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLNodeWriter { - - /** - * - */ - private int nodeDepth; - /** - * - */ - private int indentCount; - /** - * - */ - private char indentChar; - /** - * - */ - private XMLStreamWriter writer; - - /** - * - */ - private static transient final Logger logger = Logger.getLogger(XMLNodeWriter.class); - - /** - * - * @param writer - * @param depth - * @param indentCount - * @param indentChar - */ - public XMLNodeWriter(XMLStreamWriter writer, int depth, int indentCount, char indentChar) { - if (writer == null) { - throw new IllegalArgumentException( - "Cannot create a XMLNodeWriter with a null writer."); - } - this.writer = writer; - this.nodeDepth = depth; - this.indentCount = indentCount; - this.indentChar = indentChar; - } - - /** - * - * @param xmlNode - * @return - */ - public static String toXML(XMLNode xmlNode) { - String xml = ""; - StringWriter stream = new StringWriter(); -// System.err.println("error test txt"); -// System.out.println("StringWriter"); - - XMLOutputFactory fact = null; -// try { -// System.out.println("trying newinstance"); - fact = WstxOutputFactory.newInstance(); -// } catch (FactoryConfigurationError e1) { - // TODO Auto-generated catch block -// e1.printStackTrace(); -// } -// if(fact == null) -// System.out.println("factory null"); -// else -// System.out.println("factory created"); - SMOutputFactory smFactory = new SMOutputFactory(fact); -// System.out.println("smFactory"); - try { - XMLStreamWriter writer = smFactory.createStax2Writer(stream); -// System.out.println("createStax2Writer"); -// writer.writeCharacters("\n"); - - XMLNodeWriter xmlNodewriter = new XMLNodeWriter(writer, 0, 2, ' '); -// System.out.println("XMLNodeWriter"); - xmlNodewriter.write(xmlNode); -// System.out.println("xmlNodewriter.write(xmlNode);"); - writer.close(); - - } catch (XMLStreamException e) { - e.printStackTrace(); - System.out.println(e.getMessage()); - for(StackTraceElement ste : e.getStackTrace()){ - System.out.println(ste.toString()); - } - } - - xml = stream.toString(); - - return xml; - } - - /** - * - * @param xmlNode - * @throws XMLStreamException - */ - public void write(XMLNode xmlNode) throws XMLStreamException { - writer.writeCharacters(StringTools.fill(nodeDepth, indentChar)); - write(xmlNode, nodeDepth); - } - - /** - * @param xmlNode - * @param length - * @throws XMLStreamException - */ - private void write(XMLNode xmlNode, int depth) throws XMLStreamException { - boolean isRoot = false, isTopElement = false; - - if (xmlNode.getName().equals("message") || (!xmlNode.isSetParent())) { - isRoot = true; - } - if (!isRoot && (!(xmlNode.getParent() instanceof XMLNode))) { - isTopElement = true; - } - - if (xmlNode.isElement() && !xmlNode.getName().equals("message")) { - if (!(isRoot || isTopElement)) { - writer.writeCharacters(StringTools.fill(indentCount - depth, indentChar)); - } - if (xmlNode.getPrefix() != null) { - writer.writeStartElement(xmlNode.getPrefix(), xmlNode.getName(), xmlNode.getURI()); - } else { - writer.writeStartElement(xmlNode.getName()); - } - if (isRoot || isTopElement) { - writer.writeCharacters("\n"); - writer.writeCharacters(StringTools.fill(depth + indentCount, indentChar)); - } - - int nbNamespaces = xmlNode.getNamespacesLength(); - - for (int i = 0; i < nbNamespaces; i++) { - String uri = xmlNode.getNamespaceURI(i); - String prefix = xmlNode.getNamespacePrefix(i); - writer.writeNamespace(prefix, uri); - writer.writeCharacters("\n"); - writer.writeCharacters(StringTools.fill(depth - indentCount, indentChar)); - } - - // write the xmlNode attributes - int nbAttributes = xmlNode.getAttributesLength(); - - for (int i = 0; i < nbAttributes; i++) { - String attrName = xmlNode.getAttrName(i); - String attrURI = xmlNode.getAttrURI(i); - String attrPrefix = xmlNode.getAttrPrefix(i); - String attrValue = xmlNode.getAttrValue(i); - - if (attrPrefix.length() != 0) { - // TODO : check if we need to pass null for URI if not defined and if we could use only one method - writer.writeAttribute(attrPrefix, attrURI, attrName, attrValue); - } else if (attrURI.length() != 0) { - writer.writeAttribute(attrURI, attrName, attrValue); - } else { - writer.writeAttribute(attrName, attrValue); - } - } - - } else if (xmlNode.isText()) { - logger.debug("writing some text : characters = @" + xmlNode.getCharacters().trim() + "@"); - writer.writeCharacters(xmlNode.getCharacters().trim()); - } - - - boolean isNested = false; - long nbChildren = xmlNode.getChildCount(); - for (int i = 0; i < nbChildren; i++) { - XMLNode child = xmlNode.getChildAt(i); - if (!child.isText() && !(isRoot || isTopElement)) { - isNested = true; - writer.writeCharacters(StringTools.fill((depth - indentCount), - indentChar)); - } - write(child, depth + indentCount); - } - - if (xmlNode.isElement() && !xmlNode.getName().equals("message")) { - if (isRoot || isTopElement) { - writer.writeCharacters("\n"); - writer.writeCharacters(StringTools.fill(depth, indentChar)); - } else if (isNested) { - writer.writeCharacters(StringTools.fill( - ((depth - indentCount) / indentCount) * indentCount, indentChar)); - } - writer.writeEndElement(); - if (!(isRoot || isTopElement)) { - writer.writeCharacters("\n"); - writer.writeCharacters(StringTools.fill(depth, indentChar)); - } - } - } - - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/parsers/package.html b/IPK_lib/src/org/sbml/jsbml/xml/parsers/package.html deleted file mode 100644 index c738bcbda..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/parsers/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

    Contains classes that implement ReaderParser and/or WritingParser to read or write some specific parts of an SBML file.

    - - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/DateProcessor.java b/IPK_lib/src/org/sbml/jsbml/xml/stax/DateProcessor.java deleted file mode 100644 index 9206598f3..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/DateProcessor.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * $Id: DateProcessor.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/stax/DateProcessor.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.stax; - -import java.sql.Timestamp; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; -import java.util.regex.Pattern; - -/** - * - * Format time to W3DTF - * - * @author Chen Li - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class DateProcessor { - - /** - * - */ - public final static DateProcessor instance; - - static { - instance = new DateProcessor(); - } - - /** - * ISO 8601 [W3CDTF] date format for GMT - */ - public final static SimpleDateFormat ISO_8601_DATE_FORMAT = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ssZ"); - - private Pattern datePattern = Pattern - .compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d{1,})?)?(\\+|-)\\d{2}(:\\d{2})?"); - - private Pattern datePatternWithoutTimezoneInfo = Pattern - .compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{1,2}(\\.\\d{1,})?)?"); - - private Pattern datePatternWithMilitaryTimezone = Pattern - .compile("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{1,2}(\\.\\d{1,})?)[A-Z]"); - - private String[][] militaryTimezones = { { "A", "+01:00" }, - { "B", "+02:00" }, { "C", "+03:00" }, { "D", "+04:00" }, - { "E", "+05:00" }, { "F", "+06:00" }, { "G", "+07:00" }, - { "H", "+08:00" }, { "I", "+09:00" }, { "J", "+10:00" }, - { "K", "+11:00" }, { "L", "+12:00" }, { "M", "+13:00" }, - { "N", "-01:00" }, { "O", "-02:00" }, { "P", "-03:00" }, - { "Q", "-04:00" }, { "R", "-05:00" }, { "S", "-06:00" }, - { "T", "-07:00" }, { "U", "-08:00" }, { "V", "-09:00" }, - { "W", "-10:00" }, { "X", "-11:00" }, { "Y", "-12:00" }, - { "Z", "-00:00" } }; - - /** - * - * Convert timezone of datetime string to GMT. - * - * @param datetime - * Datetime. - * @return datetime string with GMT timezone. - * - */ - public final String convertToGMT(Date datetime) { - - return convertToGMT(formatToW3CDTF(datetime)); - - } - - /** - * - * Convert timezone of datetime string to GMT. - * - * @param datetime - * Datetime. - * @return datetime string with GMT timezone. - * - */ - public final String convertToGMT(String datetime) { - - datetime = formatToW3CDTF(datetime); - datetime = datetime.substring(0, datetime.lastIndexOf(":00")) + "00"; - ISO_8601_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT")); - try { - ISO_8601_DATE_FORMAT.format(ISO_8601_DATE_FORMAT.parse(datetime)); - return formatToW3CDTF(datetime); - } catch (ParseException e) { - throw new RuntimeException(e); - } - - } - - /** - * - * Convert timezone of datetime string to GMT. - * - * @param datetime - * Datetime. - * @return datetime string with GMT timezone. - * - */ - public final String convertToGMT(Timestamp datetime) { - - return convertToGMT(formatToW3CDTF(datetime)); - - } - - /** - * - * Format date to W3CDTF. - * - * @param datetime - * Datetime. - * @return datetime string in W3CDTF. - * - */ - public final String formatToW3CDTF(Date datetime) { - - System.out - .println("DateProcessor : formatToW3CDTF(Date) : date to parse : " - + datetime); - - String datetimeStr = ISO_8601_DATE_FORMAT.format(datetime); - return datetimeStr.substring(0, datetimeStr.lastIndexOf("00")) + ":00"; - } - - /** - * - * Format datetime string to W3CDTF. - * - * @param datetime - * Datetime string. - * @return datetime string in W3CDTF. - * - */ - public final String formatToW3CDTF(String datetime) { - - if (datetime == null || datetime.trim().length() == 0) - throw new NullPointerException("Datetime can not be NULL."); - - if (datePattern.matcher(datetime).matches()) { - return datetime; - } - - if (datePatternWithoutTimezoneInfo.matcher(datetime).matches()) { - return datetime + "+00:00"; - } - - if (datePatternWithMilitaryTimezone.matcher(datetime).matches()) { - String militaryTimezone = datetime.substring(datetime.length() - 1); - for (int i = 0; i < militaryTimezones.length; i++) { - if (militaryTimezone.equals(militaryTimezones[i][0])) { - return datetime.substring(0, datetime.length() - 1) - + militaryTimezones[i][1]; - } - } - } - - try { - - System.out - .println("DateProcessor : formatToW3CDTF(String) : date to parse : " - + datetime); - - Date date = ISO_8601_DATE_FORMAT.parse(datetime); - return formatToW3CDTF(date); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - /** - * - * Format datetime to W3CDTF. - * - * @param datetime - * Datetime. - * @return datetime string in W3CDTF. - * - */ - public final String formatToW3CDTF(Timestamp datetime) { - String datetimeStr = ISO_8601_DATE_FORMAT.format(datetime); - return datetimeStr.substring(0, datetimeStr.lastIndexOf("00")) + ":00"; - } - - /** - * - * Convert timezone of datetime string to GMT. - * - * @param datetime - * Datetime. - * @return datetime string with GMT timezone. - * - */ - public final Timestamp stringToTimestamp(String datetime) { - - datetime = convertToGMT(datetime); - datetime = datetime.substring(0, datetime.lastIndexOf(":00")) + "00"; - - try { - - Timestamp ts = new java.sql.Timestamp(ISO_8601_DATE_FORMAT.parse( - datetime).getTime()); - return ts; - - } catch (ParseException e) { - throw new RuntimeException(e); - } - - } -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java b/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java deleted file mode 100644 index e8eafff27..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * $Id: SBMLObjectForXML.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/stax/SBMLObjectForXML.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.stax; - -import java.util.HashMap; -import java.util.Map; - -/** - * An SBMLObjectForXML is an object to store the localName, prefix, namespace - * URI, attributes and text of a SBML component we want to write. - * - * @author marine - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class SBMLObjectForXML { - - /** - * Represents the namespace URI of a SBML component to write. - */ - private String namespace; - /** - * Represents the prefix of a SBML component to write. - */ - private String prefix; - /** - * Represents the localName of a SBML component to write. - */ - private String name; - /** - * Contains the XML attributes of a SBML component to write. - */ - private Map attributes = new HashMap(); - /** - * Represents the text of a SBML component to write. - */ - private String characters; - - /** - * Adds an attribute to this attributes HashMap. - * - * @param attributes - * the attributes to set - */ - public void addAttributes(Map attributes) { - if (this.attributes == null) { - this.attributes = new HashMap(); - } - this.attributes.putAll(attributes); - } - - /** - * Sets all the variable of this object to null. - */ - public void clear() { - this.attributes = null; - this.characters = null; - this.name = null; - this.namespace = null; - this.prefix = null; - } - - /** - * @return the attributes - */ - public Map getAttributes() { - return attributes; - } - - /** - * @return the characters - */ - public String getCharacters() { - return characters; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @return the namespace - */ - public String getNamespace() { - return namespace; - } - - /** - * @return the prefix - */ - public String getPrefix() { - return prefix; - } - - /** - * - * @return true if the attributes of this object is not null. - */ - public boolean isSetAttributes() { - return attributes != null; - } - - /** - * - * @return true if the characters of this object is not null. - */ - public boolean isSetCharacters() { - return characters != null; - } - - /** - * - * @return true if the name of this object is not null. - */ - public boolean isSetName() { - return name != null; - } - - /** - * - * @return true if the namespace of this Object is not null; - */ - public boolean isSetNamespace() { - return namespace != null; - } - - /** - * - * @return true if the prefix of this Object is not null. - */ - public boolean isSetPrefix() { - return prefix != null; - } - - /** - * @param characters - * the characters to set - */ - public void setCharacters(String characters) { - this.characters = characters; - } - - /** - * @param name - * the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @param namespace - * the namespace to set - */ - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - /** - * @param prefix - * the prefix to set - */ - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "SBMLObjectForXML [attributes=" + attributes + ", name=" + name - + ", namespace=" + namespace + ", prefix=" + prefix + "]"; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLReader.java b/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLReader.java deleted file mode 100644 index db4a8bc2b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLReader.java +++ /dev/null @@ -1,1213 +0,0 @@ -/* - * $Id: SBMLReader.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/stax/SBMLReader.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.stax; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Stack; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.Characters; -import javax.xml.stream.events.EndDocument; -import javax.xml.stream.events.Namespace; -import javax.xml.stream.events.StartDocument; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import org.apache.log4j.Logger; -import org.codehaus.stax2.evt.XMLEvent2; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Creator; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.Species; -import org.sbml.jsbml.util.SimpleTreeNodeChangeListener; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.TreeNodeChangeListener; -import org.sbml.jsbml.xml.XMLNode; -import org.sbml.jsbml.xml.parsers.AnnotationParser; -import org.sbml.jsbml.xml.parsers.BiologicalQualifierParser; -import org.sbml.jsbml.xml.parsers.MathMLStaxParser; -import org.sbml.jsbml.xml.parsers.ModelQualifierParser; -import org.sbml.jsbml.xml.parsers.ReadingParser; -import org.sbml.jsbml.xml.parsers.SBMLCoreParser; -import org.sbml.jsbml.xml.parsers.StringParser; - -import com.ctc.wstx.stax.WstxInputFactory; - -/** - * Provides all the methods to read a SBML file. - * - * @author Marine Dumousseau - * @author Andreas Dräger - * @author Nicolas Rodriguez - * @author Clemens Wrzodek - * @since 0.8 - * @version $Rev: 1187 $ - */ -public class SBMLReader { - - /** - * Contains all the relationships namespace URI <=> {@link ReadingParser} - * implementation classes. - */ - private Map> packageParsers = new HashMap>(); - - - /** - * Contains all the initialized parsers. - */ - private Map initializedParsers = new HashMap(); - - /** - * Initialize a static instance of the core parser. - * This is much more efficient than initializing it again and again every - * time we need it (Core bottleneck is the loadFromXML() method, called - * from the SBMLCoreParser() constructor each time). - */ - private static SBMLCoreParser sbmlCoreParser = new SBMLCoreParser(); - - - /** - * Creates the ReadingParser instances and stores them in a - * HashMap. - * - * @return the map containing the ReadingParser instances. - */ - private Map initializePackageParsers() { - if (packageParsers.size() == 0) { - initializePackageParserNamespaces(); - } - for (String namespace : packageParsers.keySet()) { - // Skip already existing Namespaces - if (initializedParsers.containsKey(namespace)) continue; - try { - initializedParsers.put(namespace, packageParsers.get(namespace).newInstance()); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - - return initializedParsers; - } - - /** - * Associates any unknown namespaces with the {@link AnnotationParser}. - * - */ - private void addAnnotationParsers(StartElement startElement) - { - @SuppressWarnings("unchecked") - Iterator namespacesIterator = startElement.getNamespaces(); - - while (namespacesIterator.hasNext()) { - String namespaceURI = namespacesIterator.next().getNamespaceURI(); - - if (initializedParsers.get(namespaceURI) == null) { - initializedParsers.put(namespaceURI, new AnnotationParser()); - } - } - } - - - /** - * Gets the ReadingParser class associated with 'namespace'. - * - * @param namespace - * @return the ReadingParser class associated with 'namespace'. Null if - * there is not matching ReadingParser class. - */ - public Class getReadingParsers(String namespace) { - return packageParsers.get(namespace); - } - - - /** - * Initializes the packageParser {@link HashMap} of this class. - * - */ - public void initializePackageParserNamespaces() { - JSBML.loadClasses("org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml", packageParsers); - } - - /** - * Returns true if there is no 'required' attribute for this - * namespace URI, false otherwise. - * - * @param namespaceURI - * @param startElement - * : the StartElement instance representing the SBMLDocument - * element. - * @return true if the package represented by the namespace URI - * is required to read the SBML file. If there is no 'required' - * attribute for this namespace URI, return false. - */ - private boolean isPackageRequired(String namespaceURI, - StartElement startElement) { - @SuppressWarnings("unchecked") - Iterator att = startElement.getAttributes(); - - while (att.hasNext()) { - Attribute attribute = (Attribute) att.next(); - - if (attribute.getName().getNamespaceURI().equals(namespaceURI)) { - - // TODO : we have to check that the attribute name is really required !!!! :-) - - if (attribute.getValue().toLowerCase().equals("true")) { - return true; - } - return false; - } - } - return false; // By default, a package is not required? - } - - /** - * Reads the file that is passed as argument and write it to the console, - * using the method {@link SBMLWriter.write}. - * - * @param args the command line arguments, we are taking the first one as - * the file name to read. - * - * @throws IOException if the file name is not valid. - * @throws SBMLException if there are any problems reading or writing the SBML model. - * @throws XMLStreamException if there are any problems reading or writing the XML file. - */ - @SuppressWarnings("deprecation") - public static void main(String[] args) throws IOException, XMLStreamException, SBMLException { - - if (args.length < 1) { - System.out - .println("Usage: java org.sbml.jsbml.xml.stax.SBMLReader sbmlFileName"); - System.exit(0); - } - - String fileName = args[0]; - - SBMLDocument testDocument = new org.sbml.jsbml.SBMLReader().readSBMLFromFile(fileName); - - System.out.println("Number of namespaces: " + testDocument.getSBMLDocumentNamespaces().size()); - - for(String prefix : testDocument.getSBMLDocumentNamespaces().keySet()){ - System.out.println("PREFIX = "+prefix); - String uri = testDocument.getSBMLDocumentNamespaces().get(prefix); - System.out.println("URI = "+uri); - } - - System.out.println("Model NoRDFAnnotation String = \n@" + testDocument.getModel().getAnnotation().getNonRDFannotation() + "@"); - - System.out.println("Model Annotation String = \n@" + testDocument.getModel().getAnnotationString() + "@"); - - int i = 0; - for (Species species : testDocument.getModel().getListOfSpecies()) { - // species.getAnnotationString(); // /scratch/rodrigue/src/jsbml/jsbml_trunk/data/yeast_4.02.xml - System.out.println("SpeciesType Object = " + species.getSpeciesTypeInstance()); - System.out.println("SpeciesType ID = " + species.getSpeciesType()); - if (i++ > 30) { - break; - } - } - - // new SBMLWriter().write(testDocument, System.out); - - /* - String mathMLString1 = "\n" - + " \n" - + " \n" - + " uVol \n" - + " MKP3 \n" - + " \n" - + "\n"; - - String mathMLString2 = "\n" - + " \n" - + " \n" - + " uVol \n" - + " MKP3 \n" - + " \n" - + "\n"; - - String notesHTMLString = "\n" + - " \n " + - "

    The model describes the double phosphorylation of MAP kinase by an ordered mechanism using the Michaelis-Menten formalism. " + - "Two enzymes successively phosphorylate the MAP kinase, but one phosphatase dephosphorylates both sites.

    \n" + - " \n" + - "
    "; - - SBMLReader reader = new SBMLReader(); - - Object astNodeObject1 = reader.readXMLFromString(mathMLString1); - Object astNodeObject2 = reader.readXMLFromString(mathMLString2); - Object xmlNodeObject = reader.readXMLFromString(notesHTMLString); - - System.out.println("MathML object = " + astNodeObject1); - System.out.println("MathML object = " + ((AssignmentRule) astNodeObject2).getMath()); - System.out.println("Notes object = " + ((SBase) xmlNodeObject).getNotes().toXMLString()); - */ - } - - /** - * - * @param file - * @return - * @throws XMLStreamException - * @throws IOException - */ - public SBMLDocument readSBML(File file) throws IOException, XMLStreamException { - return readSBML(file, null); - } - - /** - * Reads a SBML String from the given file. - * - * @param file - * A file containing SBML content. - * @return the matching SBMLDocument instance. - * @throws IOException - * @throws XMLStreamException - */ - public SBMLDocument readSBML(File file, TreeNodeChangeListener listener) throws IOException, XMLStreamException { - FileInputStream stream = new FileInputStream(file); - XMLStreamException exc1 = null; - Object readObject = null; - try { - readObject = readXMLFromStream(stream, listener); - } catch (XMLStreamException exc) { - /* - * Catching this exception makes sure that we have still the chance - * to close the stream. Otherwise it will stay opened although the - * execution of this method is over. - */ - exc1 = exc; - } finally { - try { - stream.close(); - } catch (IOException exc2) { - /* - * Ok, we lost. No chance to really close this stream. Heavy - * error. - */ - if (exc1 != null) { - exc2.initCause(exc1); - } - throw exc2; - } finally { - if (exc1 != null) { - throw exc1; - } - } - } - if (readObject instanceof SBMLDocument) { - return (SBMLDocument) readObject; - } - throw new XMLStreamException(String.format( - "JSBML could not properly read file %s. Please check if it contains valid SBML. If you think it is valid, please submit a bug report to the bug tracker of JSBML.", - (file.getPath() == null) ? "null" : file.getAbsolutePath())); - } - - /** - * Reads SBML from a given file. - * - * @param file - * The path to an SBML file. - * @return the matching SBMLDocument instance. - * @throws XMLStreamException - * @throws IOException - */ - public SBMLDocument readSBML(String file) throws XMLStreamException, - IOException { - return readSBMLFile(file); - } - - /** - * Reads the SBML file 'fileName' and creates/initialises a SBMLDocument - * instance. - * - * @param fileName - * : name of the SBML file to read. - * @return the initialised SBMLDocument. - * @throws XMLStreamException - * @throws IOException - */ - public SBMLDocument readSBMLFile(String fileName) - throws XMLStreamException, IOException { - return readSBML(new File(fileName)); - } - - - /** - * Reads an {@link SBMLDocument} from the given {@link XMLEventReader} - * - * @param xmlEventReader - * @param listener - * @return - * @throws XMLStreamException - */ - public SBMLDocument readSBML(XMLEventReader xmlEventReader, TreeNodeChangeListener listener) - throws XMLStreamException { - return (SBMLDocument) readXMLFromXMLEventReader(xmlEventReader, listener); - } - - /** - * - * @param xmlEventReader - * @return - * @throws XMLStreamException - */ - public SBMLDocument readSBML(XMLEventReader xmlEventReader) throws XMLStreamException { - return readSBML(xmlEventReader, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads a mathML String into an {@link ASTNode}. - * - * @param mathML - * @param listener - * @return an {@link ASTNode} representing the given mathML String. - * @throws XMLStreamException - */ - public ASTNode readMathML(String mathML, TreeNodeChangeListener listener) - throws XMLStreamException { - Object object = readXMLFromString(mathML, listener); - if (object != null && object instanceof Constraint) { - ASTNode math = ((Constraint) object).getMath(); - if (math != null) { - return math; - } - } - return null; - } - - /** - * - * @param mathML - * @return - * @throws XMLStreamException - */ - public ASTNode readMathML(String mathML) throws XMLStreamException { - return readMathML(mathML, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads a notes XML String into an {@link XMLNode}. - * - * @param notesXHTML - * @param listener - * @return an {@link XMLNode} representing the given notes String. - * @throws XMLStreamException - */ - public XMLNode readNotes(String notesXHTML, TreeNodeChangeListener listener) - throws XMLStreamException { - Object object = readXMLFromString(notesXHTML, listener); - if ((object != null) && (object instanceof Constraint)) { - Constraint constraint = ((Constraint) object); - - if (constraint.isSetNotes()) { - XMLNode notes = constraint.getNotes(); - if (notes != null) { - return notes; - } - } else if (constraint.isSetMessage()) { - XMLNode message = constraint.getMessage(); - if (message != null) { - return message; - } - } - } - return null; - } - - /** - * - * @param notesXHTML - * @return - * @throws XMLStreamException - */ - public XMLNode readNotes(String notesXHTML) throws XMLStreamException { - return readNotes(notesXHTML, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads a SBML document from the given stream. - * - * @param stream - * @param listener - * @return - * @throws XMLStreamException - */ - public SBMLDocument readSBMLFromStream(InputStream stream, TreeNodeChangeListener listener) - throws XMLStreamException { - WstxInputFactory inputFactory = new WstxInputFactory(); - XMLEventReader xmlEventReader = inputFactory.createXMLEventReader(stream); - return (SBMLDocument) readXMLFromXMLEventReader(xmlEventReader, listener); - } - - /** - * - * @param stream - * @return - * @throws XMLStreamException - */ - public SBMLDocument readSBMLFromStream(InputStream stream) throws XMLStreamException { - return readSBMLFromStream(stream, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads a XML document from the given stream. It need to be a self contain part of - * an SBML document. - * - * @param stream - * @param listener - * @return - * @throws XMLStreamException - */ - private Object readXMLFromStream(InputStream stream, TreeNodeChangeListener listener) - throws XMLStreamException { - WstxInputFactory inputFactory = new WstxInputFactory(); - XMLEventReader xmlEventReader = inputFactory.createXMLEventReader(stream); - return readXMLFromXMLEventReader(xmlEventReader, listener); - } - - - /** - * Reads an XML document from the given {@link XMLEventReader}. It need to represent a self contain part of - * an SBML document. It can be either a math element, a notes element or the whole SBML model. If math or notes are given, - * a Rule containing the math or notes will be returned, otherwise an SBMLDocument is returned. - * - * - * @param xmlEventReader - * @param listener - * @return an Object representing the given XML. - * @throws XMLStreamException - */ - private Object readXMLFromXMLEventReader(XMLEventReader xmlEventReader, TreeNodeChangeListener listener) throws XMLStreamException { - - // Making sure that we use the good XML library - System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); - System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory"); - System.setProperty("javax.xml.stream.XMLEventFactory", "com.ctc.wstx.stax.WstxEventFactory"); - - initializePackageParsers(); - - XMLEvent event; - StartElement startElement = null; - ReadingParser parser = null; - Stack sbmlElements = new Stack(); - QName currentNode = null; - boolean isNested = false; - boolean isText = false; - boolean isHTML = false; - boolean isRDFSBMLSpecificAnnotation = false; - boolean isInsideAnnotation = false; - boolean isInsideNotes = false; - int rdfDescriptionIndex = -1; - int annotationDeepness = -1; - int level = -1, version = -1; - Object lastElement = null; - - Logger logger = Logger.getLogger(SBMLReader.class); - - // Read all the elements of the file - while (xmlEventReader.hasNext()) { - event = (XMLEvent2) xmlEventReader.nextEvent(); - - // StartDocument - if (event.isStartDocument()) { - StartDocument startDocument = (StartDocument) event; - // nothing to do - } - // EndDocument - else if (event.isEndDocument()) { - EndDocument endDocument = (EndDocument) event; - // nothing to do? - } - // StartElement - else if (event.isStartElement()) { - - startElement = event.asStartElement(); - currentNode = startElement.getName(); - isNested = false; - isText = false; - - addAnnotationParsers(startElement); - - // If the XML element is the sbml element, creates the - // necessary ReadingParser instances. - // Creates an empty SBMLDocument instance and pushes it on - // the SBMLElements stack. - if (currentNode.getLocalPart().equals("sbml")) { - - SBMLDocument sbmlDocument = new SBMLDocument(); - - // the output of the change listener is activated or not via log4j.properties - sbmlDocument.addTreeNodeChangeListener(listener == null - ? new SimpleTreeNodeChangeListener() : listener); - - for (@SuppressWarnings("unchecked") - Iterator iterator = startElement.getAttributes(); iterator.hasNext();) - { - Attribute attr = iterator.next(); - if (attr.getName().toString().equals("level")) { - level = StringTools.parseSBMLInt(attr.getValue()); - sbmlDocument.setLevel(level); - } else if (attr.getName().toString().equals("version")) { - version = StringTools.parseSBMLInt(attr.getValue()); - sbmlDocument.setVersion(version); - } - } - sbmlElements.push(sbmlDocument); - } else if (lastElement == null) { - // We put a fake Constraint element in the stack that can take either math, notes or message. - // This a hack to be able to read some mathMl or notes by themselves. - - if (currentNode.getLocalPart().equals("notes") || currentNode.getLocalPart().equals("message")) { - // Initializing the core parser again and again is a hughe bottleneck - // when appending notes! - initializedParsers.put("", sbmlCoreParser); - - } else if (currentNode.getLocalPart().equals("math")) { - initializedParsers.put("", new MathMLStaxParser()); - initializedParsers.put(ASTNode.URI_MATHML_DEFINITION, new MathMLStaxParser()); - currentNode = new QName(ASTNode.URI_MATHML_DEFINITION, "math"); - - } - - // TODO : will not work with arbitrary SBML part - // TODO : we need to be able, somehow, to set the Model element in the Constraint - // to be able to have a fully functional parsing. Without it the functionDefinition, for examples, are - // not properly recognized. - Constraint constraint = new Constraint(3,1); - sbmlElements.push(constraint); - - } else if (currentNode.getLocalPart().equals("annotation")) { - - // get the sbml namespace as some element can have similar names in different namespaces - SBMLDocument sbmlDoc = (SBMLDocument) sbmlElements.firstElement(); - String sbmlNamespace = sbmlDoc.getSBMLDocumentNamespaces().get("xmlns"); - - if (currentNode.getNamespaceURI().equals(sbmlNamespace)) { - if (isInsideAnnotation) { - logger.warn("Starting to read a new annotation element while the previous annotation element is not finished."); - } - isInsideAnnotation = true; - annotationDeepness++; - } - - } else if (isInsideAnnotation) { - // Count the number of open elements to know how deep we are in the annotation - // We should only parse the RDF is annotationDeepness == 1 && rdfDescriptionIndex == 0 - annotationDeepness++; - } - else if (currentNode.getLocalPart().equals("notes")) - { - // get the sbml namespace as some element can have similar names in different namespaces - SBMLDocument sbmlDoc = (SBMLDocument) sbmlElements.firstElement(); - String sbmlNamespace = sbmlDoc.getSBMLDocumentNamespaces().get("xmlns"); - - if (currentNode.getNamespaceURI().equals(sbmlNamespace)) { - isInsideNotes = true; - } - } - - // setting isRDFSBMLSpecificAnnotation - if (currentNode.getLocalPart().equals("RDF") && currentNode.getNamespaceURI().equals(Annotation.URI_RDF_SYNTAX_NS) && annotationDeepness == 1) { - isRDFSBMLSpecificAnnotation = true; - } else if (currentNode.getLocalPart().equals("RDF") && currentNode.getNamespaceURI().equals(Annotation.URI_RDF_SYNTAX_NS)) { - isRDFSBMLSpecificAnnotation = false; - rdfDescriptionIndex = -1; - } - - if (currentNode.getLocalPart().equals("Description") && currentNode.getNamespaceURI().equals(Annotation.URI_RDF_SYNTAX_NS) && isRDFSBMLSpecificAnnotation) { - rdfDescriptionIndex++; - } - - if (isInsideAnnotation && logger.isDebugEnabled()) { - logger.debug("startElement : local part = " + currentNode.getLocalPart()); - logger.debug("startElement : annotation deepness = " + annotationDeepness); - logger.debug("startElement : rdf description index = " + rdfDescriptionIndex); - logger.debug("startElement : isRDFSBMLSpecificAnnotation = " + isRDFSBMLSpecificAnnotation); - } - - parser = processStartElement(startElement, currentNode, isHTML, sbmlElements, annotationDeepness, isRDFSBMLSpecificAnnotation); - lastElement = sbmlElements.peek(); - - } - // Characters - else if (event.isCharacters()) { - Characters characters = event.asCharacters(); - - if (!characters.isWhiteSpace()) { - isText = true; // the characters are not only 'white spaces' - } - if(sbmlElements.empty()) - System.out.println(sbmlElements.toString() + " " + sbmlElements.empty()); - if (sbmlElements.peek() instanceof XMLNode || isInsideNotes) { - isText = true; // We want to keep the whitespace/formatting when reading html block - } - - // process the text of a XML element. - if ((parser != null) && !sbmlElements.isEmpty() && (isText || isInsideAnnotation)) { - - if (isInsideNotes) { - parser = initializedParsers.get(JSBML.URI_XHTML_DEFINITION); - } -// else if (isInsideAnnotation) { -// parser = initializedParsers.get("anyAnnotation"); -// } - - if (logger.isDebugEnabled()) { - logger.debug(" Parser = " + parser.getClass().getName()); - logger.debug(" Characters = @" + characters.getData() + "@"); - } - - if (currentNode != null) { - - // logger.debug("isCharacter : elementName = " + currentNode.getLocalPart()); - - parser.processCharactersOf(currentNode.getLocalPart(), - characters.getData(), sbmlElements.peek()); - } else { - parser.processCharactersOf(null, characters.getData(), - sbmlElements.peek()); - } - } else if (isText) { - logger.warn(String.format("Some characters cannot be read: %s", characters.getData())); - if (logger.isDebugEnabled()) { - logger.debug("Parser = " + parser); - if (sbmlElements.isEmpty()) { - logger.debug("The Object Stack is empty !!!"); - } else { - logger.debug("The current Object in the stack is : " + sbmlElements.peek()); - } - } - - - } - } - // EndElement - else if (event.isEndElement()) { - - // the method processEndElement will return null until we arrive at the end of the 'sbml' element. - lastElement = sbmlElements.peek(); - - currentNode = event.asEndElement().getName(); - - if (currentNode != null) { - - boolean isSBMLelement = true; - - // get the sbml namespace as some element can have similar names in different namespaces - if (sbmlElements.firstElement() instanceof SBMLDocument) { - SBMLDocument sbmlDoc = (SBMLDocument) sbmlElements.firstElement(); - String sbmlNamespace = sbmlDoc.getSBMLDocumentNamespaces().get("xmlns"); - if (!currentNode.getNamespaceURI().equals(sbmlNamespace)) { - isSBMLelement = false; - } - } - - if (currentNode.getLocalPart().equals("annotation")) { - - if (isSBMLelement) { - isInsideAnnotation = false; - annotationDeepness = -1; - rdfDescriptionIndex = -1; - isRDFSBMLSpecificAnnotation = false; - } - - } else if (isInsideAnnotation) { - annotationDeepness--; - } - else if (currentNode.getLocalPart().equals("notes") && isSBMLelement) - { - isInsideNotes = false; - } - - if (currentNode.getLocalPart().equals("Description") - && currentNode.getNamespaceURI().equals(Annotation.URI_RDF_SYNTAX_NS)) - { - rdfDescriptionIndex--; - } - } - - SBMLDocument sbmlDocument = processEndElement(currentNode, isNested, isText, isHTML, - level, version, parser, sbmlElements, annotationDeepness, isRDFSBMLSpecificAnnotation); - - if (sbmlDocument != null) { - return sbmlDocument; - } - - - currentNode = null; - isNested = false; - isText = false; - } - } - - // We reach the end of the XML fragment and no 'sbml' have been found - // so we are probably parsing some math or notes String. - - if (logger.isDebugEnabled()) { - logger.debug("no more XMLEvent : stack.size = " + sbmlElements.size()); - - logger.debug("no more XMLEvent : stack = " + sbmlElements); - } - - initializedParsers.remove(""); - - if (sbmlElements.size() > 0) { - return sbmlElements.peek(); - } - - return null; - } - - /** - * Reads a SBML model from the given XML String. - * - * @param xml - * @param listener - * @return - */ - public SBMLDocument readSBMLFromString(String xml, TreeNodeChangeListener listener) throws XMLStreamException { - Object readObject = readXMLFromStream(new ByteArrayInputStream(xml.getBytes()), listener); - if (readObject instanceof SBMLDocument) { - return (SBMLDocument) readObject; - } - throw new XMLStreamException("The given file seems not to be a valid SBMl file. Please check it using the SBML online validator."); - } - - /** - * - * @param xml - * @return - * @throws XMLStreamException - */ - public SBMLDocument readSBMLFromString(String xml) throws XMLStreamException { - return readSBMLFromString(xml, new SimpleTreeNodeChangeListener()); - } - - /** - * Reads an XML String that should the part of a SBML model. - * - * @param xml - * @param listener - * @return - */ - private Object readXMLFromString(String xml, TreeNodeChangeListener listener) - throws XMLStreamException { - return readXMLFromStream(new ByteArrayInputStream(xml.getBytes()), listener); - } - - - /** - * Process a {@link StartElement} event. - * - * @param startElement - * @param currentNode - * @param isHTML - * @param initializedParsers - * @param sbmlElements - * @return - */ - private ReadingParser processStartElement(StartElement startElement, QName currentNode, - Boolean isHTML, Stack sbmlElements, int annotationDeepness, boolean isRDFSBMLspecificAnnotation) - { - Logger logger = Logger.getLogger(SBMLReader.class); - ReadingParser parser = null; - - String elementNamespace = currentNode.getNamespaceURI(); - - if (logger.isDebugEnabled()) { - logger.debug("processStartElement : " + currentNode.getLocalPart() + ", " + elementNamespace); - } - - // To be able to parse all the SBML file, the sbml node - // should have been read first. - if (!sbmlElements.isEmpty() && (initializedParsers != null)) { - - // All the element should have a namespace. - if (elementNamespace != null) { - - parser = initializedParsers.get(elementNamespace); - // if the current node is a notes or message element - // and the matching ReadingParser is a StringParser, - // we need to set the typeOfNotes variable of the - // StringParser instance. - if (currentNode.getLocalPart().equals("notes") - || currentNode.getLocalPart().equals("message")) - { - ReadingParser sbmlparser = initializedParsers.get(JSBML.URI_XHTML_DEFINITION); - - if (sbmlparser instanceof StringParser) { - StringParser notesParser = (StringParser) sbmlparser; - notesParser.setTypeOfNotes(currentNode.getLocalPart()); - } - } - - if (parser != null) { - - @SuppressWarnings("unchecked") - Iterator nam = startElement.getNamespaces(); - @SuppressWarnings("unchecked") - Iterator att = startElement.getAttributes(); - boolean hasAttributes = att.hasNext(); - boolean hasNamespace = nam.hasNext(); - - if ((elementNamespace.equals(Annotation.URI_RDF_SYNTAX_NS) - || elementNamespace.equals(JSBML.URI_PURL_ELEMENTS) - || elementNamespace.equals(JSBML.URI_PURL_TERMS) - || elementNamespace.equals(Creator.URI_RDF_VCARD_NS) - || elementNamespace.equals(ModelQualifierParser.getNamespaceURI()) - || elementNamespace.equals(BiologicalQualifierParser.getNamespaceURI())) - && !isRDFSBMLspecificAnnotation) - { - parser = initializedParsers.get("anyAnnotation"); - } - else if (annotationDeepness > 0 && elementNamespace.startsWith("http://www.sbml.org/sbml/level")) - { - // This is probably a mistake in the annotation - // Sending it to the any parser - parser = initializedParsers.get("anyAnnotation"); - } - - if (annotationDeepness > 0 && elementNamespace.equals(JSBML.URI_XHTML_DEFINITION)) { - parser = initializedParsers.get("anyAnnotation"); - } - - // All the subNodes of SBML are processed. - if (!currentNode.getLocalPart().equals("sbml")) { - Object processedElement = parser.processStartElement(currentNode.getLocalPart(), - currentNode.getPrefix(), hasAttributes, - hasNamespace, sbmlElements.peek()); - if (processedElement != null) { - sbmlElements.push(processedElement); - } else { - // It is normal to have sometimes null returned as some of the - // XML elements are ignored or do not produce a new java object (like 'apply' in mathML). - } - } - - // process the namespaces - processNamespaces(nam, currentNode,sbmlElements, parser, hasAttributes); - - // Process the attributes - processAttributes(att, currentNode, sbmlElements, parser, hasAttributes, annotationDeepness, isRDFSBMLspecificAnnotation); - - } else { - logger.warn(String.format("Cannot find a parser for the %s namespace", elementNamespace)); - } - } else { - logger.warn(String.format("Cannot find a parser for the %s namespace", elementNamespace)); - } - } - - return parser; - } - - // TODO : the attributes hasAttributes, hasNamespace, isLastAttribute and isLastNamespace are probably not needed for XML reading. - - /** - * Process Namespaces of the current element on the stack. - * - * @param nam - * @param currentNode - * @param initializedParsers - * @param sbmlElements - * @param hasAttributes - */ - private void processNamespaces(Iterator nam, QName currentNode, - Stack sbmlElements, ReadingParser parser, boolean hasAttributes) - { - Logger logger = Logger.getLogger(SBMLReader.class); - ReadingParser namespaceParser = null; - - while (nam.hasNext()) { - Namespace namespace = (Namespace) nam.next(); - boolean isLastNamespace = !nam.hasNext(); - namespaceParser = initializedParsers.get(namespace.getNamespaceURI()); - - logger.debug("processNamespaces : " + namespace.getNamespaceURI()); - - // Calling the currentNode parser to store all the declared namespaces - parser.processNamespace(currentNode.getLocalPart(), - namespace.getNamespaceURI(), - namespace.getName().getPrefix(), - namespace.getName().getLocalPart(), - hasAttributes, isLastNamespace, - sbmlElements.peek()); - - // Calling each corresponding parser, in case they want to initialize things for the currentNode - if ((namespaceParser != null) && !namespaceParser.getClass().equals(parser.getClass())) { - - logger.debug("processNamespaces 2e parser : " + namespaceParser); - - namespaceParser.processNamespace(currentNode.getLocalPart(), - namespace.getNamespaceURI(), - namespace.getName().getPrefix(), - namespace.getName().getLocalPart(), - hasAttributes, isLastNamespace, - sbmlElements.peek()); - } else if (namespaceParser == null) { - logger.warn(String.format("Cannot find a parser for the %s namespace", namespace.getNamespaceURI())); - } - } - - } - - /** - * Process Attributes of the current element on the stack. - * - * @param att - * @param currentNode - * @param initializedParsers - * @param sbmlElements - * @param parser - * @param hasAttributes - */ - private void processAttributes(Iterator att, QName currentNode, - Stack sbmlElements, ReadingParser parser, boolean hasAttributes, - int annotationDeepness, boolean isRDFSBMLSpecificAnnotation) - { - Logger logger = Logger.getLogger(SBMLReader.class); - ReadingParser attributeParser = null; - - while (att.hasNext()) { - - Attribute attribute = (Attribute) att.next(); - boolean isLastAttribute = !att.hasNext(); - QName attributeName = attribute.getName(); - - if (attribute.getName().getNamespaceURI().length() > 0) { - String attributeNamespaceURI = attribute.getName().getNamespaceURI(); - - if ((attributeNamespaceURI.equals(Annotation.URI_RDF_SYNTAX_NS) - || attributeNamespaceURI.equals(JSBML.URI_PURL_ELEMENTS) - || attributeNamespaceURI.equals(JSBML.URI_PURL_TERMS) - || attributeNamespaceURI.equals(Creator.URI_RDF_VCARD_NS) - || attributeNamespaceURI.equals(ModelQualifierParser.getNamespaceURI()) - || attributeNamespaceURI.equals(BiologicalQualifierParser.getNamespaceURI())) - && !isRDFSBMLSpecificAnnotation) - { - attributeParser = initializedParsers.get("anyAnnotation"); - } - else if (annotationDeepness > 0 && attributeNamespaceURI.equals(JSBML.URI_XHTML_DEFINITION)) - { - attributeParser = initializedParsers.get("anyAnnotation"); - } - else if (annotationDeepness > 0 && attributeNamespaceURI.startsWith("http://www.sbml.org/sbml/level")) - { - // This is probably a mistake in the annotation - // Sending it to the any parser - parser = initializedParsers.get("anyAnnotation"); - } - else - { - attributeParser = initializedParsers.get(attributeNamespaceURI); - } - - } else { - attributeParser = parser; - } - - if (attributeParser != null) { - attributeParser.processAttribute( - currentNode.getLocalPart(), - attributeName.getLocalPart(), - attribute.getValue(), attributeName.getPrefix(), - isLastAttribute, sbmlElements.peek()); - } else { - logger.warn("Cannot find a parser for the " + attribute.getName().getNamespaceURI() + " namespace"); - } - } - } - - - /** - * Process the end of an element. - * - * @param currentNode - * @param isNested - * @param isText - * @param isHTML - * @param level - * @param version - * @param parser - * @param sbmlElements - * @param isRDFSBMLSpecificAnnotation - * @return - */ - private SBMLDocument processEndElement(QName currentNode, Boolean isNested, Boolean isText, - Boolean isHTML, int level, int version, ReadingParser parser, - Stack sbmlElements, int annotationDeepness, boolean isRDFSBMLSpecificAnnotation) { - Logger logger = Logger.getLogger(SBMLReader.class); - - if (logger.isDebugEnabled()) { - logger.debug("event.isEndElement : stack.size = " + sbmlElements.size()); - logger.debug("event.isEndElement : element name = " + currentNode.getLocalPart()); - - if (currentNode.getLocalPart().equals("kineticLaw") || currentNode.getLocalPart().startsWith("listOf") - || currentNode.getLocalPart().equals("math")) { - logger.debug("event.isEndElement : stack = " + sbmlElements); - } - } - // check that the stack did not increase before and after an element ? - - if (initializedParsers != null) { - String elementNamespaceURI = currentNode.getNamespaceURI(); - parser = initializedParsers.get(elementNamespaceURI); - - // if (!isRDFSBMLSpecificAnnotation && isInsideAnnotation) { // This would be safer to use but would prevent any specific parsing of the annotation - if ((elementNamespaceURI.equals(Annotation.URI_RDF_SYNTAX_NS) - || elementNamespaceURI.equals(JSBML.URI_PURL_ELEMENTS) - || elementNamespaceURI.equals(JSBML.URI_PURL_TERMS) - || elementNamespaceURI.equals(Creator.URI_RDF_VCARD_NS) - || elementNamespaceURI.equals(ModelQualifierParser.getNamespaceURI()) - || elementNamespaceURI.equals(BiologicalQualifierParser.getNamespaceURI())) - && !isRDFSBMLSpecificAnnotation) - { - parser = initializedParsers.get("anyAnnotation"); - } - else if (annotationDeepness > 0 && elementNamespaceURI.startsWith("http://www.sbml.org/sbml/level")) - { - // This is probably a mistake in the annotation - // Sending it to the any parser - parser = initializedParsers.get("anyAnnotation"); - } - else if (annotationDeepness > 0 && elementNamespaceURI.equals(JSBML.URI_XHTML_DEFINITION)) - { - parser = initializedParsers.get("anyAnnotation"); - } - // if the current node is a notes or message element and - // the matching ReadingParser is a StringParser, we need - // to reset the typeOfNotes variable of the - // StringParser instance. - if (currentNode.getLocalPart().equals("notes") - || currentNode.getLocalPart().equals("message")) { - ReadingParser sbmlparser = initializedParsers.get(JSBML.URI_XHTML_DEFINITION); - if (sbmlparser instanceof StringParser) { - StringParser notesParser = (StringParser) sbmlparser; - notesParser.setTypeOfNotes(currentNode.getLocalPart()); - } - } - // process the end of the element. - if (!sbmlElements.isEmpty() && (parser != null)) { - - if (logger.isDebugEnabled()) { - logger.debug("event.isEndElement : calling parser.processEndElement " + parser.getClass()); - } - - boolean popElementFromTheStack = parser.processEndElement(currentNode.getLocalPart(), - currentNode.getPrefix(), isNested, sbmlElements.peek()); - // remove the top of the SBMLElements stack at the - // end of an element if this element is not the sbml - // element. - if (!currentNode.getLocalPart().equals("sbml")) { - if (popElementFromTheStack) { - sbmlElements.pop(); - } - - // System.out.println("SBMLReader : event.isEndElement : new stack.size = " - // + SBMLElements.size()); - - } else { - - logger.debug("event.isEndElement : sbml element found"); - - // process the end of the document and return - // the final SBMLDocument - if (sbmlElements.peek() instanceof SBMLDocument) { - SBMLDocument sbmlDocument = (SBMLDocument) sbmlElements.peek(); - - Iterator> iterator = initializedParsers.entrySet().iterator(); - ArrayList readingParserClasses = new ArrayList(); - - // Calling endDocument for all parsers - while (iterator.hasNext()) { - Entry entry = iterator.next(); - ReadingParser sbmlParser = entry.getValue(); - - if (!readingParserClasses.contains(sbmlParser.getClass().getCanonicalName())) { - - readingParserClasses.add(sbmlParser.getClass().getCanonicalName()); - - logger.debug("event.isEndElement : EndDocument found : parser = " + sbmlParser.getClass()); - - sbmlParser.processEndDocument(sbmlDocument); - - // call endDocument only on the parser associated with the namespaces - // declared on the sbml document ??. - } - } - - logger.debug("event.isEndElement : EndDocument returned."); - - return sbmlDocument; - - } else { - // At the end of a sbml node, the - // SBMLElements stack must contain only a - // SBMLDocument instance. - // Otherwise, there is a syntax error in the - // SBML document - logger.warn("!!! event.isEndElement : there is a problem in your SBML file !!!!"); - logger.warn("Found an element '" + sbmlElements.peek().getClass().getCanonicalName() + - "', expected org.sbml.jsbml.SBMLDocument"); - } - } - } else { - // If SBMLElements.isEmpty => there is a syntax - // error in the SBMLDocument - // If parser == null => there is no parser for - // the namespace of this element - logger.warn("!!! event.isEndElement : there is a problem in your SBML file !!!!"); - logger.warn("This should never happen, there is probably a problem with the parsers used." + - "\n Try to check if one needed parser is missing or if you are using a parser in development."); - } - } else { - // The initialized parsers map should be - // initialized as soon as there is a sbml node. - // If it is null, there is an syntax error in the SBML - // file. - logger.warn("The parsers are not initialized, this should not happen !!!"); - } - - // We return null as long as we did not find the SBMLDocument closing tag - return null; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLWriter.java b/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLWriter.java deleted file mode 100644 index b9250c120..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/SBMLWriter.java +++ /dev/null @@ -1,1566 +0,0 @@ -/* - * $Id: SBMLWriter.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/stax/SBMLWriter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.stax; - -import java.io.BufferedOutputStream; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.log4j.Logger; -import org.codehaus.stax2.XMLOutputFactory2; -import org.codehaus.stax2.XMLStreamWriter2; -import org.codehaus.staxmate.SMOutputFactory; -import org.codehaus.staxmate.dom.DOMConverter; -import org.codehaus.staxmate.out.SMNamespace; -import org.codehaus.staxmate.out.SMOutputContainer; -import org.codehaus.staxmate.out.SMOutputContext; -import org.codehaus.staxmate.out.SMOutputDocument; -import org.codehaus.staxmate.out.SMOutputElement; -import org.codehaus.staxmate.out.SMRootFragment; -import org.sbml.jsbml.ASTNode; -import org.sbml.jsbml.Annotation; -import org.sbml.jsbml.CVTerm; -import org.sbml.jsbml.Constraint; -import org.sbml.jsbml.Creator; -import org.sbml.jsbml.History; -import org.sbml.jsbml.JSBML; -import org.sbml.jsbml.KineticLaw; -import org.sbml.jsbml.ListOf; -import org.sbml.jsbml.ListOf.Type; -import org.sbml.jsbml.MathContainer; -import org.sbml.jsbml.Model; -import org.sbml.jsbml.SBMLDocument; -import org.sbml.jsbml.SBMLException; -import org.sbml.jsbml.SBase; -import org.sbml.jsbml.UnitDefinition; -import org.sbml.jsbml.util.JAXPFacade; -import org.sbml.jsbml.util.StringTools; -import org.sbml.jsbml.util.compilers.MathMLXMLStreamCompiler; -import org.sbml.jsbml.xml.parsers.WritingParser; -import org.sbml.jsbml.xml.parsers.XMLNodeWriter; -import org.w3c.dom.Document; -import org.w3c.util.DateParser; -import org.xml.sax.SAXException; - -import com.ctc.wstx.stax.WstxOutputFactory; - -/** - * A SBMLWriter provides the methods to write a SBML file. - * - * @author Marine Dumousseau - * @author Nicolas Rodriguez - * @author Andreas Dräger - * @since 0.8 - * @version $Rev: 1232 $ - */ -public class SBMLWriter { - - /** - * @return The default symbol to be used to indent new elements in the XML - * representation of SBML data structures. - */ - public static char getDefaultIndentChar() { - return ' '; - } - - /** - * @return The default number of indent symbols to be concatenated at the - * beginning of a new block in an XML representation of SBML data - * structures. - */ - public static short getDefaultIndentCount() { - return (short) 2; - } - - /** - * Tests this class - * - * @param args - * @throws SBMLException - */ - public static void main(String[] args) throws SBMLException { - - if (args.length < 1) { - System.out.println( - "Usage : java org.sbml.jsbml.xml.stax.SBMLWriter sbmlFileName"); - System.exit(0); - } - - // this JOptionPane is added here to be able to start visualVM profiling - // before the reading or writing is started. - // JOptionPane.showMessageDialog(null, "Eggs are not supposed to be green."); - - long init = Calendar.getInstance().getTimeInMillis(); - System.out.println(Calendar.getInstance().getTime()); - - String fileName = args[0]; - String jsbmlWriteFileName = fileName.replaceFirst(".xml", "-jsbml.xml"); - - System.out.printf("Reading %s and writing %s\n", - fileName, jsbmlWriteFileName); - - SBMLDocument testDocument; - long afterRead = 0; - try { - testDocument = new SBMLReader().readSBMLFile(fileName); - System.out.printf("Reading done\n"); - System.out.println(Calendar.getInstance().getTime()); - afterRead = Calendar.getInstance().getTimeInMillis(); - - // testDocument.checkConsistency(); - - System.out.printf("Starting writing\n"); - - new SBMLWriter().write(testDocument, jsbmlWriteFileName); - } catch (XMLStreamException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println(Calendar.getInstance().getTime()); - long end = Calendar.getInstance().getTimeInMillis(); - long nbSecondes = (end - init)/1000; - long nbSecondesRead = (afterRead - init)/1000; - long nbSecondesWrite = (end - afterRead)/1000; - - if (nbSecondes > 120) { - System.out.println("It took " + nbSecondes/60 + " minutes."); - } else { - System.out.println("It took " + nbSecondes + " secondes."); - } - System.out.println("Reading : " + nbSecondesRead + " secondes."); - System.out.println("Writing : " + nbSecondesWrite + " secondes."); - } - - /** - * The symbol for indentation. - */ - private char indentChar; - - /** - * The number of indentation symbols. - */ - private short indentCount; - /** - * contains the WritingParser instances of this class. - */ - private HashMap instantiatedSBMLParsers = new HashMap(); - - /** - * Remember already issued warnings to avoid having multiple lines, saying - * the same thing (Warning: Skipping detailed parsing of name space 'XYZ'. - * No parser available.) - */ - private transient List issuedWarnings = new LinkedList(); - - Logger logger = Logger.getLogger(SBMLWriter.class); - - /** - * contains all the relationships name space URI <=> WritingParser class. - */ - private HashMap> packageParsers = new HashMap>(); - - /** - * Creates a new {@link SBMLWriter} with default configuration for - * {@link #indentChar} and {@link #indentCount}. - */ - public SBMLWriter() { - this(getDefaultIndentChar(), getDefaultIndentCount()); - } - - /** - * Creates a new {@link SBMLWriter} with the given configuration for the - * {@link #indentChar} and {@link #indentCount}, i.e., the symbol to be used - * to indent elements in the XML representation of SBML data objects and the - * number of these symbols to be concatenated at the beginning of each new - * line for a new element. - * - * @param indentChar - * @param indentCount - */ - public SBMLWriter(char indentChar, short indentCount) { - setIndentationChar(indentChar); - setIndentationCount(indentCount); - } - - /** - * Adds a {@link WritingParser} to the given list of {@link WritingParser} - * - * @param sbmlParsers - * @param sbmlParser - * @param namespace - */ - private void addWritingParser(ArrayList sbmlParsers, - WritingParser sbmlParser, String namespace) - { - if (sbmlParser == null) { - if (!issuedWarnings.contains(namespace)) { - logger.debug("Skipping detailed parsing of Namespace '" + namespace - + "'. No parser available."); - issuedWarnings.add(namespace); - } - } else { - sbmlParsers.add(sbmlParser); - } - - } - - /** - * This method creates the necessary number of white spaces at the beginning - * of an entry in the SBML file. - * - * @param indent - * @return - */ - private String createIndentationString(int indent) { - return StringTools.fill(indent, indentChar); - } - - /** - * Gives the symbol that is used to indent the SBML output for a better - * structure and to improve human-readability. - * - * @return the character to be used for indentation. - */ - public char getIndentationChar() { - return indentChar; - } - - /** - * Gives the number of indent symbols that are inserted in a line to better structure the SBML output. - * - * @return the indentCount - */ - public short getIndentationCount() { - return indentCount; - } - - - /** - * Gets all the writing parsers necessary to write the given object. - * - * @param object - * @param namespace - * @return all the writing parsers necessary to write this element. - */ - private ArrayList getWritingParsers(Object object, String namespace) { - - Set packageNamespaces = null; - - // logger.debug("getInitializedParsers : name space, object = " + name space + ", " + object); - - if (object instanceof SBase) { - SBase sbase = (SBase) object; - packageNamespaces = sbase.getNamespaces(); - } else if (object instanceof Annotation) { - Annotation annotation = (Annotation) object; - packageNamespaces = annotation.getNamespaces(); - } else { - logger.warn("getInitializedParsers : I don't know what to do with " + object); - } - - ArrayList sbmlParsers = new ArrayList(); - - if (packageNamespaces != null) { - - - if (!packageNamespaces.contains(namespace)) { - - WritingParser sbmlParser = instantiatedSBMLParsers.get(namespace); - addWritingParser(sbmlParsers, sbmlParser, namespace); - } - - Iterator iterator = packageNamespaces.iterator(); - - while (iterator.hasNext()) { - String packageNamespace = iterator.next(); - WritingParser sbmlParser = instantiatedSBMLParsers.get(packageNamespace); - addWritingParser(sbmlParsers, sbmlParser, packageNamespace); - } - - } else { - WritingParser sbmlParser = instantiatedSBMLParsers.get(namespace); - addWritingParser(sbmlParsers, sbmlParser, namespace); - } - - return sbmlParsers; - } - - /** - * - * @param namespace - * @return the WritingParser class associated with 'namespace'. Null if - * there is not matching WritingParser class. - */ - public Class getWritingParsers(String namespace) { - return packageParsers.get(namespace); - } - - /** - * Initializes the packageParser {@link HasMap} of this class. - * - */ - public void initializePackageParserNamespaces() { - JSBML.loadClasses("org/sbml/jsbml/resources/cfg/PackageParserNamespaces.xml", - packageParsers); - } - - /** - * Creates the ReadingParser instances and stores them in a HashMap. - * - * @return the map containing the ReadingParser instances. - */ - private Map initializePackageParsers() { - if (packageParsers.size() == 0) { - initializePackageParserNamespaces(); - } - - for (String namespace : packageParsers.keySet()) { - try { - instantiatedSBMLParsers.put(namespace, (WritingParser) packageParsers.get(namespace).newInstance()); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (ClassCastException e) { - // does nothing, some of the parsers are only Reader and not Writer - // so would throw a ClassCastException - logger.debug(e.getMessage()); - } - } - - return instantiatedSBMLParsers; - } - - /** - * Allows you to set another blank character for indentation. Allowed are - * only tabs and white spaces, i.e., '\t' and ' '. - * - * @param the character to be used for indentation - * the indentSymbol to set - */ - public void setIndentationChar(char indentSymbol) { - if ((indentSymbol != ' ') && (indentSymbol != '\t')) { - throw new IllegalArgumentException(String.format( - "Invalid argument '%s'. Only the blank symbols '\\t' and ' ' are allowed for indentation.", - indentSymbol)); - } - this.indentChar = indentSymbol; - } - - /** - * - * @param indentCount - * @see SBMLWriter#setIndentationCount(short) - */ - public void setIndentationCount(int indentCount) { - setIndentationCount((short) indentCount); - } - - /** - * @param indentCount the indentCount to set - */ - public void setIndentationCount(short indentCount) { - if (indentCount < 0) { - throw new IllegalArgumentException(String.format( - "Indent count must be non-negative. Invalid argument %d.", - indentCount)); - } - this.indentCount = indentCount; - } - - /** - * - * @param document - * @param file - * @throws SBMLException - * @throws XMLStreamException - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public void write(SBMLDocument document, File file) - throws XMLStreamException, SBMLException, IOException { - write(document, file, null, null); - } - - /** - * - * @param document - * @param file - * @param programName - * @param programVersion - * @return - * @throws XMLStreamException - * @throws SBMLException - * @throws IOException - * if it is not possible to write to the given file, e.g., due - * to an invalid file name or missing permissions. - */ - public void write(SBMLDocument document, File file, String programName, - String programVersion) throws XMLStreamException, SBMLException, IOException { - FileOutputStream stream = new FileOutputStream(file); - write(document, stream, programName, programVersion); - stream.close(); - } - - /** - * Writes the SBMLDocument in a SBML file. - * - * @param sbmlDocument - * : the SBMLDocument to write - * @param stream - * : a stream where to write the content of the model to. - * @throws XMLStreamException - * @throws SBMLException - * @throws IOException - * - */ - public void write(SBMLDocument sbmlDocument, OutputStream stream) - throws XMLStreamException, SBMLException { - write(sbmlDocument, stream, null, null); - } - - /** - * - * @param sbmlDocument - * @param stream - * @param programName - * can be null - * @param programVersion - * can be null - * @throws XMLStreamException - * @throws SBMLException - * - */ - public void write(SBMLDocument sbmlDocument, OutputStream stream, - String programName, String programVersion) - throws XMLStreamException, SBMLException { - if (!sbmlDocument.isSetLevel() || !sbmlDocument.isSetVersion()) { - throw new IllegalArgumentException( - "Unable to write SBML output for documents with undefined SBML Level and Version flag."); - } - - Logger logger = Logger.getLogger(SBMLWriter.class); - - // Making sure that we use the good XML library - System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory"); - System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory"); - System.setProperty("javax.xml.stream.XMLEventFactory", "com.ctc.wstx.stax.WstxEventFactory"); - - initializePackageParsers(); - - SMOutputFactory smFactory = new SMOutputFactory(XMLOutputFactory.newInstance()); - XMLStreamWriter2 streamWriter = smFactory.createStax2Writer(stream); - - // For this to work, the elements need to be completely empty (no whitespace or line return) - streamWriter.setProperty(XMLOutputFactory2.P_AUTOMATIC_EMPTY_ELEMENTS, Boolean.TRUE); - - SMOutputDocument outputDocument = SMOutputFactory.createOutputDocument( - streamWriter, "1.0", "UTF-8", false); - // to have the automatic indentation working, we should probably only be using StaxMate classes and not directly StAX - // outputDocument.setIndentation("\n ", 1, 1); - - String SBMLNamespace = JSBML.getNamespaceFrom(sbmlDocument.getLevel(), - sbmlDocument.getVersion()); - SMOutputContext context = outputDocument.getContext(); - context.setIndentation("\n" + createIndentationString(indentCount), 1, 2); - SMNamespace namespace = context.getNamespace(SBMLNamespace); - namespace.setPreferredPrefix(""); - outputDocument.addCharacters("\n"); - - /* - * Write a comment to track which program created this SBML file and - * which version of JSBML was used for this purpose. - */ - if ((programName != null) && (programName.length() > 0)) { - String date = String.format("%1$tY-%1$tm-%1$td %1$tR", Calendar - .getInstance().getTime()); - String msg = " Created by %s version %s on %s with jsbml version %s. "; - outputDocument.addComment( - String.format(msg, programName, (programVersion != null) - && (programVersion.length() > 0) ? programVersion - : "?", date, JSBML.getJSBMLDottedVersion())); - outputDocument.addCharacters("\n"); - } - - SMOutputElement smOutputElement = outputDocument.addElement(namespace, - sbmlDocument.getElementName()); - - SBMLObjectForXML xmlObject = new SBMLObjectForXML(); - xmlObject.setName(sbmlDocument.getElementName()); - xmlObject.setNamespace(SBMLNamespace); - xmlObject.addAttributes(sbmlDocument.writeXMLAttributes()); - - // register all the name spaces of the SBMLDocument to the writer - Iterator> it = sbmlDocument - .getSBMLDocumentNamespaces().entrySet().iterator(); - - logger.debug(" SBML name spaces size = " - + sbmlDocument.getSBMLDocumentNamespaces().size()); - - while (it.hasNext()) { - Map.Entry entry = it.next(); - if (!entry.getKey().equals("xmlns")) { - - logger.debug(" SBML name spaces : " + entry.getKey() + " = " - + entry.getValue()); - - String namespacePrefix = entry.getKey().substring( - entry.getKey().indexOf(":") + 1); - streamWriter.setPrefix(namespacePrefix, entry.getValue()); - - logger.debug(" SBML namespaces : " + namespacePrefix + " = " - + entry.getValue()); - - } - } - - it = xmlObject.getAttributes().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - smOutputElement.addAttribute(entry.getKey(), entry.getValue()); - } - - int indent = indentCount; - if (sbmlDocument.isSetNotes()) { - writeNotes(sbmlDocument, smOutputElement, streamWriter, - SBMLNamespace, indent); - } - if (sbmlDocument.isSetAnnotation()) { - writeAnnotation(sbmlDocument, smOutputElement, streamWriter, - indent, false); - } - smOutputElement.addCharacters("\n"); - - writeSBMLElements(xmlObject, smOutputElement, streamWriter, - sbmlDocument, indent); - - outputDocument.closeRoot(); - } - - /** - * Writes the XML representation of an {@link SBMLDocument} in a SBML file. - * - * @param sbmlDocument - * : the SBMLDocument to write - * @param fileName - * : the name of the file where to write the {@link SBMLDocument} - * - * - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws FileNotFoundException - * if the file name is invalid - * @throws SBMLException - * - */ - public void write(SBMLDocument sbmlDocument, String fileName) - throws XMLStreamException, FileNotFoundException, SBMLException { - write(sbmlDocument, fileName, null, null); - } - - /** - * - * @param sbmlDocument - * @param fileName - * @param programName - * @param programVersion - * - * @throws XMLStreamException - * @throws FileNotFoundException - * @throws SBMLException - * - */ - public void write(SBMLDocument sbmlDocument, String fileName, - String programName, String programVersion) - throws XMLStreamException, FileNotFoundException, SBMLException { - write(sbmlDocument, new BufferedOutputStream(new FileOutputStream( - fileName)), programName, programVersion); - } - - /** - * - * @param sbase - * @return - */ - public String writeAnnotation(SBase sbase) { - - String annotationStr = ""; - - if (sbase == null || (!sbase.isSetAnnotation())) { - return annotationStr; - } - - StringWriter stream = new StringWriter(); - - SMOutputFactory smFactory = new SMOutputFactory(WstxOutputFactory.newInstance()); - - try { - XMLStreamWriter2 writer = smFactory.createStax2Writer(stream); - - // For this to work, the elements need to be completely empty (no whitespace or line return) - writer.setProperty(XMLOutputFactory2.P_AUTOMATIC_EMPTY_ELEMENTS, Boolean.TRUE); - - // Create an xml fragment to avoid having the xml declaration - SMRootFragment outputDocument = SMOutputFactory.createOutputFragment(writer); - - // all the sbml element namespaces are registered to the writer in the writeAnnotation method - - // call the writeAnnotation, indicating that we are building an xml fragment - writeAnnotation(sbase, outputDocument, writer, 0, true); - - writer.writeEndDocument(); - writer.close(); - - annotationStr = stream.toString(); - } catch (XMLStreamException e) { - e.printStackTrace(); - } catch (SBMLException e) { - e.printStackTrace(); - } - - return annotationStr; - } - - /** - * Writes the annotation of this sbase component. - * - * @param sbase - * : the sbase component - * @param element - * : the matching SMOutputElement - * @param writer - * : the XMLStreamWriter2 - * @param sbmlNamespace - * : the SBML namespace. - * @param indent - * the number of indent white spaces of this annotation. - * @throws XMLStreamException - * @throws SBMLException - * @throws SAXException - */ - private void writeAnnotation(SBase sbase, SMOutputContainer element, - XMLStreamWriter writer, int indent, boolean xmlFragment) - throws XMLStreamException, SBMLException { - - // create the sbmlNamespace variable - String sbmlNamespace = JSBML.getNamespaceFrom(sbase.getLevel(), sbase.getVersion()); - SMNamespace namespace = element.getContext().getNamespace(sbmlNamespace); - namespace.setPreferredPrefix(""); - - Annotation annotation = sbase.getAnnotation(); - SMOutputElement annotationElement; - String whiteSpaces = createIndentationString(indent); - - if (xmlFragment) { - annotationElement = element.addElement("annotation"); - } else { - element.addCharacters("\n"); - element.setIndentation(whiteSpaces, indent, indentCount); - annotationElement = element.addElement(namespace, "annotation"); - } - annotationElement.setIndentation(whiteSpaces, indent, indentCount); - - if ((annotation.getNonRDFannotation() != null) - && (annotation.getNonRDFannotation().length() > 0)) { - StringBuffer annotationBeginning = StringTools.concat(whiteSpaces, - " otherNamespaces = annotation - .getAnnotationNamespaces(); - - for (String namespacePrefix : otherNamespaces.keySet()) { - StringTools.append(annotationBeginning, " ", namespacePrefix, - "=\"", otherNamespaces.get(namespacePrefix), "\""); - annotationElement.addAttribute(namespacePrefix, otherNamespaces.get(namespacePrefix)); - } - - boolean allNamespacesDefined = true; - - // Adding the name spaces of the sbml element - if (sbase.getSBMLDocument() != null) { - Map sbmlDocumentNamespaces = sbase.getSBMLDocument().getSBMLDocumentNamespaces(); - - for (String namespacePrefix : sbmlDocumentNamespaces.keySet()) { - - // Checking if the namespace declaration is not done twice - // in the SBMLDocument and the annotation element. - if (otherNamespaces.get(namespacePrefix) == null) { - StringTools.append(annotationBeginning, " ", namespacePrefix, - "=\"", sbmlDocumentNamespaces.get(namespacePrefix), "\""); - } - } - - } else { - // Can happen when displaying the annotation from an SBase object - // that is not yet linked to a SBMLDocument. - allNamespacesDefined = false; - } - // TODO : to be able to write broken annotations where the namespace declaration is missing - // we need to add dummy namespace here !! Or remove the namespace awareness on the writer !! - - StringTools.append(annotationBeginning, Character.valueOf('>'), - Character.valueOf('\n'), annotation.getNonRDFannotation(), - whiteSpaces, "", Character.valueOf('\n')); - - DOMConverter converter = new DOMConverter(); - - String annotationString = annotationBeginning.toString() - .replaceAll("&", "&"); - // here indent gets lost. - Document domDocument = null; - boolean domConversionDone = false; - - try { - domDocument = JAXPFacade.getInstance().create( - new BufferedReader(new StringReader(annotationString)), allNamespacesDefined); - domConversionDone = true; - } catch (SAXException e) { - e.printStackTrace(); - // TODO : log error or send SBMLException - - logger.warn("Cannot parse the following XML\n@" + annotationString + "@"); - logger.warn("NonRDFannotation =\n@" + annotation.getNonRDFannotation() + "@"); - - // trying to read the XML without namespace awareness as the XML can be wrong and we still want to - // write it back as it is. - if (allNamespacesDefined) { - - try { - domDocument = JAXPFacade.getInstance().create( - new BufferedReader(new StringReader(annotationString)), false); - domConversionDone = true; - } catch (SAXException e2) { - e.printStackTrace(); - // TODO : log error or send SBMLException - } - } - } finally { - if (domConversionDone) { - converter.writeFragment(domDocument.getFirstChild() - .getChildNodes(), writer); - } - } - } else { - writer.writeCharacters("\n"); - } - - // if the given SBase is not a model and the level is smaller than 3, - // no history can be written. - // Annotation cannot be written without metaid tag. - - if (sbase.getAnnotation().isSetRDFannotation()) { - if (sbase.isSetMetaId()) { - if (!annotation.isSetAbout()) { - // add required missing tag - annotation.setAbout("#" + sbase.getMetaId()); - } - writeRDFAnnotation(annotation, annotationElement, writer, indent - + indentCount); - } else { - /* - * This shouldn't actually happen because a metaid will be created - * if missing in AbstractSBase. Only if no SBMLDocument is available, - * or the SBase is derived from a different SBase implementation, it - * could fail. - */ - logger.info(String.format( - "Could not write RDF annotation of %s due to missing metaid.", - sbase.getElementName())); - } - } - - // set the indentation for the closing tag - element.setIndentation(whiteSpaces, indent + indentCount, indentCount); - } - - /** - * Writes the listOfCVTerms. - * - * @param listOfCVTerms - * : the list of CVTerms to write - * @param rdfNamespaces - * : the RDF name spaces and prefixes - * @param writer - * : the XMLStreamWriter2 - * @param indent - * @throws XMLStreamException - */ - private void writeCVTerms(List listOfCVTerms, - Map rdfNamespaces, XMLStreamWriter writer, - int indent) throws XMLStreamException - { - if (listOfCVTerms == null || listOfCVTerms.size() == 0) { - return; - } - - String rdfPrefix = rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS); - String whiteSpace = createIndentationString(indent); - - for (int i = 0; i < listOfCVTerms.size(); i++) { - CVTerm cvTerm = listOfCVTerms.get(i); - String namespaceURI = null; - String prefix = null; - String elementName = null; - - if (cvTerm.getQualifierType().equals(CVTerm.Type.BIOLOGICAL_QUALIFIER)) { - namespaceURI = CVTerm.Type.BIOLOGICAL_QUALIFIER.getNamespaceURI(); - prefix = rdfNamespaces.get(namespaceURI); - elementName = cvTerm.getBiologicalQualifierType() - .getElementNameEquivalent(); - } else if (cvTerm.getQualifierType().equals(CVTerm.Type.MODEL_QUALIFIER)) { - namespaceURI = cvTerm.getQualifierType().getNamespaceURI(); - prefix = rdfNamespaces.get(namespaceURI); - elementName = Annotation - .getElementNameEquivalentToQualifier(cvTerm - .getModelQualifierType()); - } - if ((namespaceURI != null) && (elementName != null) - && (prefix != null)) - { - writer.writeCharacters(whiteSpace + createIndentationString(indentCount)); - writer.writeStartElement(prefix, elementName, namespaceURI); - writer.writeCharacters("\n"); - - if (cvTerm.getResourceCount() > 0) { - writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount)); - writer.writeStartElement(rdfPrefix, "Bag", - Annotation.URI_RDF_SYNTAX_NS); - writer.writeCharacters("\n"); - - for (int j = 0; j < cvTerm.getResourceCount(); j++) { - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeStartElement(rdfPrefix, "li", - Annotation.URI_RDF_SYNTAX_NS); - writer.writeAttribute(rdfPrefix, - Annotation.URI_RDF_SYNTAX_NS, "resource", - cvTerm.getResourceURI(j)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - - } else { // cvTerm.getReourceCount() == 0 - - writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount)); - writer.writeEmptyElement(rdfPrefix, "Bag", Annotation.URI_RDF_SYNTAX_NS); - writer.writeCharacters("\n"); - } - - writer.writeCharacters(whiteSpace + createIndentationString(indentCount)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - } - } - - - /** - * Writes the history represented by this History instance. - * - * @param history - * : the history to write - * @param rdfNamespaces - * : contains the RDF namespaces and their prefixes. - * @param writer - * : the XMLStreamWriter2 - * @param indent - * @throws XMLStreamException - */ - private void writeHistory(History history, - Map rdfNamespaces, XMLStreamWriter writer, - int indent) throws XMLStreamException { - // Logger logger = Logger.getLogger(SBMLWriter.class); - - String whiteSpace = createIndentationString(indent); - String rdfPrefix = rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS); - if (history.getCreatorCount() > 0) { - String creatorPrefix = rdfNamespaces.get(JSBML.URI_PURL_ELEMENTS); - writer.writeCharacters(whiteSpace); - writer.writeStartElement(creatorPrefix, "creator", - JSBML.URI_PURL_ELEMENTS); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace + createIndentationString(indentCount)); - writer.writeStartElement(rdfPrefix, "Bag", - Annotation.URI_RDF_SYNTAX_NS); - writer.writeCharacters("\n"); - - for (int i = 0; i < history.getCreatorCount(); i++) { - Creator creator = history.getCreator(i); - writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount)); - writer.writeStartElement(rdfPrefix, "li", - Annotation.URI_RDF_SYNTAX_NS); - writer.writeAttribute(rdfPrefix, Annotation.URI_RDF_SYNTAX_NS, - "parseType", "Resource"); - String vCardPrefix = rdfNamespaces.get(Creator.URI_RDF_VCARD_NS); - - if (creator.isSetFamilyName() - || creator.isSetGivenName()) { - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeStartElement(vCardPrefix, "N", - Creator.URI_RDF_VCARD_NS); - writer.writeAttribute(Annotation.URI_RDF_SYNTAX_NS, - "parseType", "Resource"); - writer.writeCharacters("\n"); - - if (creator.isSetFamilyName()) { - writer.writeCharacters(whiteSpace + createIndentationString(4 * indentCount)); - writer.writeStartElement(vCardPrefix, "Family", - Creator.URI_RDF_VCARD_NS); - writer.writeCharacters(creator.getFamilyName()); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - if (creator.isSetGivenName()) { - writer.writeCharacters(whiteSpace + createIndentationString(4 * indentCount)); - writer.writeStartElement(vCardPrefix, "Given", - Creator.URI_RDF_VCARD_NS); - writer.writeCharacters(creator.getGivenName()); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeEndElement(); - } - writer.writeCharacters("\n"); - - if (creator.isSetEmail()) { - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeStartElement(vCardPrefix, "EMAIL", - Creator.URI_RDF_VCARD_NS); - writer.writeCharacters(creator.getEmail()); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - if (creator.isSetOrganisation()) { - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeStartElement(vCardPrefix, "ORG", - Creator.URI_RDF_VCARD_NS); - writer.writeAttribute(rdfPrefix, - Annotation.URI_RDF_SYNTAX_NS, "parseType", - "Resource"); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace + createIndentationString(4 * indentCount)); - writer.writeStartElement(vCardPrefix, "Orgname", - Creator.URI_RDF_VCARD_NS); - writer.writeCharacters(creator.getOrganisation()); - writer.writeEndElement(); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - // adding any additional element/value - if (creator.isSetOtherAttributes()) { - for (String elementName : creator.getOtherAttributes().keySet()) { - String characters = creator.getOtherAttribute(elementName); - - writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount)); - writer.writeStartElement(vCardPrefix, elementName, Creator.URI_RDF_VCARD_NS); - writer.writeCharacters(characters); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - } - - writer.writeCharacters(whiteSpace + createIndentationString(2* indentCount)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - writer.writeCharacters(whiteSpace + createIndentationString(indentCount)); - writer.writeEndElement(); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - - String dctermPrefix = rdfNamespaces.get(JSBML.URI_PURL_TERMS); - String creationDate = DateParser.getIsoDateNoMillis(new Date()); - String now = creationDate; - boolean writeCreationDate = false; - boolean isModelHistory = history.getParent().getParent() instanceof Model; - - if (history.isSetCreatedDate()) { - creationDate = DateParser.getIsoDateNoMillis(history.getCreatedDate()); - writeCreationDate = true; - } else if (isModelHistory) { // We need to add a creation date - writeCreationDate = true; - } - - if (writeCreationDate) { - writeW3CDate(writer, indent, creationDate, "created", dctermPrefix, - rdfPrefix); - } - - // Writing the current modified dates. - if (history.isSetModifiedDate()) { - for (int i = 0; i < history.getNumModifiedDates(); i++) { - writeW3CDate(writer, indent, - DateParser.getIsoDateNoMillis(history - .getModifiedDate(i)), "modified", dctermPrefix, - rdfPrefix); - } - } - if (isModelHistory) { - // We need to add a new modified date - writeW3CDate(writer, indent, now, "modified", dctermPrefix, rdfPrefix); - } - } - - /** - * Writes the MathML expression for the math element of this sbase - * component. - * - * @param m - * : the sbase component - * @param element - * : the matching SMOutputElement - * @param writer - * : the XMLStreamWriter - * @param indent - * @throws XMLStreamException - * - */ - private void writeMathML(MathContainer m, SMOutputElement element, - XMLStreamWriter writer, int indent) throws XMLStreamException - { - if (m.isSetMath()) { - - String whitespaces = createIndentationString(indent); - element.addCharacters("\n"); - // set the indentation for the math opening tag - element.setIndentation(whitespaces, indent + indentCount, indentCount); - - // Creating an SMOutputElement to be sure that the previous nested element tag is closed properly. - SMNamespace mathMLNamespace = element.getNamespace(ASTNode.URI_MATHML_DEFINITION, ASTNode.URI_MATHML_PREFIX); - SMOutputElement mathElement = element.addElement(mathMLNamespace, "math"); - MathMLXMLStreamCompiler compiler = new MathMLXMLStreamCompiler( - writer, createIndentationString(indent + indentCount)); - boolean isSBMLNamespaceNeeded = compiler.isSBMLNamespaceNeeded(m.getMath()); - - // TODO : add all other namespaces !! - - if (isSBMLNamespaceNeeded) { - // writing the SBML namespace - SBMLDocument doc = null; - SBase sbase = m.getMath().getParentSBMLObject(); - String sbmlNamespace = SBMLDocument.URI_NAMESPACE_L3V1Core; - - if (sbase != null) { - doc = sbase.getSBMLDocument(); - sbmlNamespace = doc.getSBMLDocumentNamespaces().get("xmlns"); - - if (sbmlNamespace == null) { - logger.warn("writeMathML : the SBML namespace of this SBMLDocument" + - " could not be found, using the default namespace (" + - SBMLDocument.URI_NAMESPACE_L3V1Core + ") instead."); - sbmlNamespace = SBMLDocument.URI_NAMESPACE_L3V1Core; - } - } - writer.writeNamespace("sbml", sbmlNamespace); - } - - mathElement.setIndentation(createIndentationString(indent + 2), indent + indentCount, indentCount); - - writer.writeCharacters(whitespaces); - writer.writeCharacters("\n"); - - compiler.compile(m.getMath()); - - writer.writeCharacters(whitespaces); - } - } - - /** - * Writes the message of this Constraint. - * - * @param sbase - * : the Constraint component - * @param element - * : the matching SMOUtputElement - * @param writer - * : the XMLStreamWriter2 - * @param sbmlNamespace - * : the SBML namespace - * @throws XMLStreamException - */ - private void writeMessage(Constraint sbase, SMOutputElement element, - XMLStreamWriter writer, String sbmlNamespace, int indent) - throws XMLStreamException - { - - String whitespaces = createIndentationString(indent); - element.addCharacters("\n"); - // set the indentation for the math opening tag - element.setIndentation(whitespaces, indent + indentCount, indentCount); - - // Creating an SMOutputElement to be sure that the previous nested element tag is closed properly. - SMNamespace sbmlSMNamespace = element.getNamespace(); - SMOutputElement messageElement = element.addElement(sbmlSMNamespace, "message"); - messageElement.setIndentation(createIndentationString(indent + 2), indent + indentCount, indentCount); - - writer.writeCharacters(whitespaces); - writer.writeCharacters("\n"); - - XMLNodeWriter xmlNodeWriter = new XMLNodeWriter(writer, indent, - indentCount, indentChar); - xmlNodeWriter.write(sbase.getMessage()); - - writer.writeCharacters(whitespaces); - } - - /** - * Writes the notes of this sbase component. - * - * @param sbase - * : the SBase component - * @param element - * : the matching SMOUtputElement - * @param writer - * : the XMLStreamWriter2 - * @param sbmlNamespace - * : the SBML namespace - * @param indent - * @throws XMLStreamException - */ - private void writeNotes(SBase sbase, SMOutputElement element, - XMLStreamWriter writer, String sbmlNamespace, int indent) - throws XMLStreamException { - writer.writeCharacters("\n"); - XMLNodeWriter xmlNodeWriter = new XMLNodeWriter(writer, indent, - indentCount, indentChar); - xmlNodeWriter.write(sbase.getNotes()); - } - - /** - * Writes the RDF annotation contained in 'annotation'. - * - * @param annotation - * : the annotation to write - * @param annotationElement - * : the matching SMOutputElement - * @param writer - * : the XMLStreamWriter. - * @param indent - * @throws XMLStreamException - */ - private void writeRDFAnnotation(Annotation annotation, - SMOutputElement annotationElement, XMLStreamWriter writer, - int indent) throws XMLStreamException { - // Logger logger = Logger.getLogger(SBMLWriter.class); - - String whiteSpace = createIndentationString(indent); - SMNamespace namespace = annotationElement.getNamespace( - Annotation.URI_RDF_SYNTAX_NS, "rdf"); - annotationElement.setIndentation(whiteSpace, indent, indentCount); - SMOutputElement rdfElement = annotationElement.addElement(namespace, - "RDF"); - - /* - * TODO: Check which name spaces are really required and add only those; - * particularly, if name spaces are missing and it is known from the - * kind of RDF annotation, which name spaces are needed, these should be - * added automatically here. - */ - Map rdfNamespaces = annotation.getRDFAnnotationNamespaces(); - - for (String namespaceURI : rdfNamespaces.keySet()) { - - if (!namespaceURI.equals(namespace.getURI())) { - writer.writeNamespace(rdfNamespaces.get(namespaceURI), namespaceURI); - } - } - - // Checking if all the necessary namespaces are defined - // TODO : In fact, we could remove the rdfNamespaces map ? - - if (rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS) == null - || rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS).equals("xmlns")) - { - // writer.writeNamespace("rdf", Annotation.URI_RDF_SYNTAX_NS); // already registered previously - rdfNamespaces.put(Annotation.URI_RDF_SYNTAX_NS, "rdf"); - } - - if (annotation.isSetHistory() && annotation.getHistory().getCreatorCount() > 0) - { - if (rdfNamespaces.get(JSBML.URI_PURL_ELEMENTS) == null) { - writer.writeNamespace("dc", JSBML.URI_PURL_ELEMENTS); - rdfNamespaces.put(JSBML.URI_PURL_ELEMENTS, "dc"); - } - - if (rdfNamespaces.get(Creator.URI_RDF_VCARD_NS) == null) { - writer.writeNamespace("vCard", Creator.URI_RDF_VCARD_NS); - rdfNamespaces.put(Creator.URI_RDF_VCARD_NS, "vCard"); - } - } - - if (annotation.isSetHistory() && rdfNamespaces.get(JSBML.URI_PURL_TERMS) == null) - { - boolean isModelHistory = annotation.getParent() instanceof Model; - - if (isModelHistory || (annotation.getHistory().isSetCreatedDate() || annotation.getHistory().isSetModifiedDate())) { - writer.writeNamespace("dcterms", JSBML.URI_PURL_TERMS); - rdfNamespaces.put(JSBML.URI_PURL_TERMS, "dcterms"); - } - } - - if (annotation.getCVTermCount() > 0) - { - if (rdfNamespaces.get(CVTerm.URI_BIOMODELS_NET_BIOLOGY_QUALIFIERS) == null) { - writer.writeNamespace("bqbiol", CVTerm.URI_BIOMODELS_NET_BIOLOGY_QUALIFIERS); - rdfNamespaces.put(CVTerm.URI_BIOMODELS_NET_BIOLOGY_QUALIFIERS, "bqbiol"); - } - - if (rdfNamespaces.get(CVTerm.URI_BIOMODELS_NET_MODEL_QUALIFIERS) == null) { - writer.writeNamespace("bqmodel", CVTerm.URI_BIOMODELS_NET_MODEL_QUALIFIERS); - rdfNamespaces.put(CVTerm.URI_BIOMODELS_NET_MODEL_QUALIFIERS, "bqmodel"); - } - - } - - - rdfElement.addCharacters("\n"); - rdfElement.setIndentation(whiteSpace + createIndentationString(indentCount), indent + indentCount, indentCount); - SMOutputElement descriptionElement = rdfElement.addElement(namespace, - "Description"); - descriptionElement.addAttribute(namespace, "about", - annotation.getAbout()); - descriptionElement.addCharacters("\n"); - if (annotation.isSetHistory()) { - writeHistory(annotation.getHistory(), rdfNamespaces, writer, - indent + 4); - } - if (annotation.getListOfCVTerms().size() > 0) { - writeCVTerms(annotation.getListOfCVTerms(), rdfNamespaces, writer, - indent + indentCount); - } - descriptionElement.setIndentation(whiteSpace + createIndentationString(indentCount), indent + indentCount, indentCount); - descriptionElement.addCharacters(whiteSpace + createIndentationString(indentCount)); - annotationElement.setIndentation(whiteSpace, indent, indentCount); - rdfElement.addCharacters("\n"); - rdfElement.addCharacters(whiteSpace); - annotationElement.addCharacters("\n"); - } - - /** - * Writes the SBML elements. - * - * @param parentXmlObject - * : contains the XML information of the parentElement. - * @param smOutputParentElement - * : SMOutputElement of the parentElement. - * @param streamWriter - * @param objectToWrite - * : the Object to write. - * @param notesParser - * : the WritingParser to parse the notes. - * @param MathMLparser - * : the WritingParser to parse the MathML expressions. - * @param indent - * The number of white spaces to indent this element. - * @throws XMLStreamException - * @throws SBMLException - * @throws SAXException - */ - private void writeSBMLElements(SBMLObjectForXML parentXmlObject, - SMOutputElement smOutputParentElement, - XMLStreamWriter streamWriter, Object objectToWrite, int indent) - throws XMLStreamException, SBMLException { - - String whiteSpaces = createIndentationString(indent); - - // Get the list of parsers to use. - ArrayList listOfPackages = getWritingParsers( - objectToWrite, smOutputParentElement.getNamespace().getURI()); - - if (logger.isDebugEnabled()) { - logger.debug("writeSBMLElements : xmlObject = " + parentXmlObject); - logger.debug("writeSBMLElements : parentElement = " - + smOutputParentElement.getLocalName() + ", " - + smOutputParentElement.getNamespace().getURI()); - logger.debug("writeSBMLElements : objectToWrite = " + objectToWrite + '\n'); - logger.debug("writeSBMLElements : listOfPackages = " + listOfPackages + '\n'); - } - - Iterator iterator = listOfPackages.iterator(); - while (iterator.hasNext()) { - WritingParser parser = iterator.next(); - List sbmlElementsToWrite = parser - .getListOfSBMLElementsToWrite(objectToWrite); - - if (logger.isDebugEnabled()) { - logger.debug("writeSBMLElements : parser = " + parser); - logger.debug("writeSBMLElements : elementsToWrite = " + sbmlElementsToWrite); - } - - if (sbmlElementsToWrite == null) { - // TODO : test if there are some characters to write ? - - // to allow the XML parser to prune empty elements, this indent should not be added. - // streamWriter.writeCharacters(whiteSpaces.substring(0, - // indent - indentCount)); - } else { - for (int i = 0; i < sbmlElementsToWrite.size(); i++) { - Object nextObjectToWrite = sbmlElementsToWrite.get(i); - boolean elementIsNested = false; - - /* - * Skip predefined UnitDefinitions (check depending on Level - * and Version). - */ - if (nextObjectToWrite instanceof ListOf) { - ListOf list = (ListOf) nextObjectToWrite; - if (list.size() > 0) { - SBase sb = list.getFirst(); - if ((sb instanceof UnitDefinition) && (parser - .getListOfSBMLElementsToWrite(nextObjectToWrite) == null)) { - streamWriter.writeCharacters(whiteSpaces.substring(0, indent - indentCount)); - continue; - } - } else { - streamWriter.writeCharacters(whiteSpaces.substring(0, indent - indentCount)); - continue; - } - } - - parentXmlObject.clear(); - - /* - * The following containers are all optional in a - * , but if any is present, it must not be empty: - * , , , - * . (References: L2V2 Section 4.13; L2V3 - * Section 4.13; L2V4 Section 4.13) - */ - if (nextObjectToWrite instanceof ListOf) { - ListOf toTest = (ListOf) nextObjectToWrite; - - if (toTest.size() > 0) { - elementIsNested = true; - } - - Type listType = toTest.getSBaseListType(); - if (listType == Type.none) { - // Prevent writing invalid SBML if list types are - // not set appropriately. - throw new SBMLException(String.format( - "Unknown ListOf type \"%s\".", - toTest.getElementName())); - } - if (listType.equals(ListOf.Type.listOfReactants) - || listType.equals(ListOf.Type.listOfProducts) - || listType.equals(ListOf.Type.listOfModifiers)) { - if (toTest.size() < 1) { - continue; // Skip these, see reference in - // comment above. - } - } - } else if (nextObjectToWrite instanceof KineticLaw) { - // TODO: Is there any chance, that an KineticLaw get's - // an empty XML entity? - } - - // Writing the element, starting by the indent - streamWriter.writeCharacters(whiteSpaces); - parser.writeElement(parentXmlObject, nextObjectToWrite); - parser.writeNamespaces(parentXmlObject, nextObjectToWrite); - parser.writeAttributes(parentXmlObject, nextObjectToWrite); - - - SMOutputElement newOutPutElement = null; - if (parentXmlObject.isSetName()) { - boolean isClosedMathContainer = false, isClosedAnnotation = false; - - // TODO : problem here as a children does not have the same namespace as his parent all the time !! - // use ((SBase) nextObjectToWrite).getNamespaces(); ?? - - if (parentXmlObject.isSetNamespace()) { - SMNamespace namespaceContext = smOutputParentElement - .getNamespace( - parentXmlObject.getNamespace(), - parentXmlObject.getPrefix()); - newOutPutElement = smOutputParentElement - .addElement(namespaceContext, - parentXmlObject.getName()); - } else { - newOutPutElement = smOutputParentElement - .addElement(smOutputParentElement - .getNamespace(), parentXmlObject - .getName()); - } - - Iterator> it = parentXmlObject - .getAttributes().entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - newOutPutElement.addAttribute(entry.getKey(), - entry.getValue()); - } - if (nextObjectToWrite instanceof SBase) { - SBase s = (SBase) nextObjectToWrite; - if (s.isSetNotes()) { - writeNotes(s, newOutPutElement, streamWriter, - newOutPutElement.getNamespace() - .getURI(), indent + indentCount); - elementIsNested = true; - } - if (s.isSetAnnotation()) { - writeAnnotation(s, newOutPutElement, - streamWriter, - indent + indentCount, false); - elementIsNested = isClosedAnnotation = true; - } - if (s.getChildCount() > 0) { - // make sure that we'll have line breaks if an element has any sub elements. - elementIsNested = true; - } - } - if (nextObjectToWrite instanceof Constraint) { - Constraint constraint = (Constraint) nextObjectToWrite; - if (constraint.isSetMessage()) { - writeMessage(constraint, newOutPutElement, - streamWriter, newOutPutElement - .getNamespace().getURI(), - indent + indentCount); - elementIsNested = true; - } - } - if (nextObjectToWrite instanceof MathContainer) { - MathContainer mathContainer = (MathContainer) nextObjectToWrite; - if (mathContainer.getLevel() > 1) { - writeMathML(mathContainer, newOutPutElement, - streamWriter, indent + indentCount); - elementIsNested = true; - } else { - elementIsNested = false; - } - isClosedMathContainer = true; - } - if (!elementIsNested - && ((nextObjectToWrite instanceof Model) || (nextObjectToWrite instanceof UnitDefinition))) { - elementIsNested = true; - } - - // to allow the XML parser to prune empty element, this line should not be added in all the cases. - if (elementIsNested) { - newOutPutElement.addCharacters("\n"); - if (isClosedMathContainer || isClosedAnnotation) { - newOutPutElement.addCharacters(whiteSpaces); - } - } - - writeSBMLElements(parentXmlObject, newOutPutElement, - streamWriter, nextObjectToWrite, indent + indentCount); - smOutputParentElement.addCharacters("\n"); - } - } - // write the indent before closing the element - streamWriter.writeCharacters(whiteSpaces.substring(0, - indent - indentCount)); - } - } - } - - /** - * Writes the given SBML document to an in-memory string. - * - * @param doc - * the SBMLdocument - * @return the XML representation of the SBMLdocument as a - * String. - * @throws XMLStreamException - * if any error occur while creating the XML document. - * @throws SBMLException - */ - public String writeSBMLToString(SBMLDocument doc) - throws XMLStreamException, SBMLException { - return writeSBMLToString(doc, null, null); - } - - /*** - * - * @param d - * @param programName - * @param programVersion - * @return - * @throws XMLStreamException - * @throws SBMLException - * - */ - public String writeSBMLToString(SBMLDocument d, String programName, - String programVersion) throws XMLStreamException, SBMLException { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - write(d, stream, programName, programVersion); - return stream.toString(); - } - - - private void writeW3CDate(XMLStreamWriter writer, int indent, - String dateISO, String dcterm, String dctermPrefix, String rdfPrefix) - throws XMLStreamException { - String whiteSpace = createIndentationString(indent); - - writer.writeCharacters(whiteSpace); - writer.writeStartElement(dctermPrefix, dcterm, JSBML.URI_PURL_TERMS); - writer.writeAttribute(rdfPrefix, Annotation.URI_RDF_SYNTAX_NS, - "parseType", "Resource"); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace + createIndentationString(indentCount)); - writer.writeStartElement(dctermPrefix, "W3CDTF", JSBML.URI_PURL_TERMS); - writer.writeCharacters(dateISO); - writer.writeEndElement(); - writer.writeCharacters("\n"); - writer.writeCharacters(whiteSpace); - writer.writeEndElement(); - writer.writeCharacters("\n"); - } - - // TODO : test a bit more Xstream and using Qname to see how it - // can deal with math or rdf bloc - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/XMLLogger.java b/IPK_lib/src/org/sbml/jsbml/xml/stax/XMLLogger.java deleted file mode 100644 index 98927f30b..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/XMLLogger.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * $Id: XMLLogger.java,v 1.1 2012-11-07 14:43:38 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/stax/XMLLogger.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.stax; - - -import org.apache.log4j.Logger; -import org.apache.log4j.Priority; - -/** - * - * TODO: Comment missing - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class XMLLogger { - - /** - * logger - */ - private Logger logger = Logger.getLogger(XMLLogger.class); - - /** - * - * @param message - */ - public void debug(String message) { - logger.debug(message); - } - - /** - * - * @param message - */ - public void error(String message) { - logger.error(message); - } - - /** - * - * @param message - */ - public void fatal(String message) { - logger.fatal(message); - } - - /** - * - * @param message - */ - public void info(String message) { - logger.info(message); - } - - /** - * - * @param priority - * @param message - */ - public void log(Priority priority, String message) { - logger.log(priority, message); - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/stax/package.html b/IPK_lib/src/org/sbml/jsbml/xml/stax/package.html deleted file mode 100644 index ed1d71d94..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/stax/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

    Contains classes that use the Streaming API for XML (StAX) to read or write an SBML file.

    - - \ No newline at end of file diff --git a/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/MessageConverter.java b/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/MessageConverter.java deleted file mode 100644 index 7459ac2e0..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/MessageConverter.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * $Id: MessageConverter.java,v 1.1 2012-11-07 14:43:39 klukas Exp $ - * $URL: https://jsbml.svn.sourceforge.net/svnroot/jsbml/trunk/core/src/org/sbml/jsbml/xml/xstream/converter/MessageConverter.java $ - * ---------------------------------------------------------------------------- - * This file is part of JSBML. Please visit - * for the latest version of JSBML and more information about SBML. - * - * Copyright (C) 2009-2012 jointly by the following organizations: - * 1. The University of Tuebingen, Germany - * 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK - * 3. The California Institute of Technology, Pasadena, CA, USA - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation. A copy of the license agreement is provided - * in the file named "LICENSE.txt" included with this software distribution - * and also available online as . - * ---------------------------------------------------------------------------- - */ - -package org.sbml.jsbml.xml.xstream.converter; - -import org.sbml.jsbml.util.Message; - -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; - -/** - * @since 0.8 - * @version $Rev: 1116 $ - */ -public class MessageConverter implements Converter { - - String elementName = "message"; - - public MessageConverter(String elementName) { - super(); - this.elementName = elementName; - } - - /* - * (non-Javadoc) - * - * @see - * com.thoughtworks.xstream.converters.ConverterMatcher#canConvert(java. - * lang.Class) - */ - @SuppressWarnings("unchecked") - public boolean canConvert(Class arg0) { - return arg0.equals(Message.class); - } - - /* - * (non-Javadoc) - * - * @see - * com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object, - * com.thoughtworks.xstream.io.HierarchicalStreamWriter, - * com.thoughtworks.xstream.converters.MarshallingContext) - */ - public void marshal(Object currentObject, HierarchicalStreamWriter writer, - MarshallingContext context) { - Message message = (Message) currentObject; - - writer.startNode(elementName); - writer.setValue(message.getMessage()); - writer.addAttribute("lang", message.getLang()); - writer.endNode(); - } - - /* - * (non-Javadoc) - * - * @see - * com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks - * .xstream.io.HierarchicalStreamReader, - * com.thoughtworks.xstream.converters.UnmarshallingContext) - */ - public Object unmarshal(HierarchicalStreamReader reader, - UnmarshallingContext context) { - Message message = new Message(); - - // System.out.println("MessageConverter : nodeName = " + - // reader.getNodeName()); - - message.setLang(reader.getAttribute("lang")); - - // reader.moveDown(); - String messageContent = reader.getValue(); - - // System.out.println("MessageConverter : content = " + messageContent); - - message.setMessage(messageContent); - // reader.moveUp(); - - return message; - } - -} diff --git a/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/package.html b/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/package.html deleted file mode 100644 index 1b5e5da42..000000000 --- a/IPK_lib/src/org/sbml/jsbml/xml/xstream/converter/package.html +++ /dev/null @@ -1,5 +0,0 @@ - -

    Contains classes that uses the XStream to read or write XML.

    - -

    It is currently use only to parse the result of the libsbml validation process but might be use in future release to parse SBML

    - \ No newline at end of file diff --git a/make/createfilelist.sh b/make/createfilelist.sh index f0ed59b6a..d3ef6aa66 100755 --- a/make/createfilelist.sh +++ b/make/createfilelist.sh @@ -1,142 +1,154 @@ -#!/bin/bash -cd $(dirname $0) -echo "Current directory: $(pwd)" - -echo "Create XML file lists..." - -cd ../Graffiti_Core/build/classes -find . | grep "\.xml$" > plugins1.txt -cd ../../.. - -cd Graffiti_Editor/build/classes/ -find . | grep "\.xml$" > plugins2.txt -cd ../../.. - -cd Graffiti_Plugins/build/classes -find . | grep "\.xml$" > plugins3.txt -cd ../../.. - -cd IPK-Plugins/build/classes -find . | grep "\.xml$" > plugins4.txt -cd ../../.. - -cd IAP/target/classes -find . | grep "\.xml$" > pluginsIAP.txt - -echo create Cluster Plugin List -echo "./org/graffiti/plugins/views/defaults/plugin.xml" > plugins_cluster.txt -echo "./org/graffiti/plugins/modes/defaults/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/label_alignment/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/cluster_colors/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_no_overlapp/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/modes/defaultEditMode/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/ios/importers/gml/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/ios/exporters/gml/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/inspectors/defaults/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/editcomponents/defaults/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/attributes/defaults/plugin.xml" >> plugins_cluster.txt -echo "./org/graffiti/plugins/attributecomponents/simplelabel/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/svg_exporter/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/invert_selection/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/graph_cleanup/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/tree_simple/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/rt_tree/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/random/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/radial_tree/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/grid/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/graph_to_origin_mover/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_reduce_space/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/circle/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/pajek/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/matrix/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/matrix/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/zoomfit/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/set_background_color/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_cluster_analysis/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/enhanced_attribute_editors/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/editing_tools/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_mover/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/ipk_graffitiview/plugin.xml" >> plugins_cluster.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/pluginClusterTabs.xml" >> plugins_cluster.txt - - -echo create Exclude-List for DBE-Gravisto -echo "./org/graffiti/plugins/ios/gml/gmlWriter/plugin.xml" > plugins_exclude.txt -#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/naive_pattern_finder/plugin.xml" >> plugins_exclude.txt -#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/copy_pattern_layout/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/random/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/ios/exporters/gmlxml/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/views/defaults/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/ios/gml/gmlReader/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/ios/gml/gmlReader/parser/build.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/guis/switchselections/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/random_node_resizer/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_mover/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_highlighter/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/edge_directer/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/trivialgridrestricted/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/trivialgrid/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/editor/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/springembedderrestricted/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/springembedder/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/pluginsForOnlineUse.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/webstart/jarprefs.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/tools/enhancedzoomtool/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/views/matrix/plugin.xml" >> plugins_exclude.txt -####echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/fast_view/plugin.xml" >> plugins_exclude.txt -#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/print/printer/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/print/preview/plugin.xml" >> plugins_exclude.txt -echo "./org/jfree/chart/demo/piedata.xml" >> plugins_exclude.txt -echo "./org/jfree/chart/demo/categorydata.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/apsp/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/bfs/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/bfstopsort/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/bn_preparator/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/bonacich_eigenvector/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/pattern_from_canonical_label/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/closeness/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/connectspecial/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/connect/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/degree/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/edge_labeling/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/excentricity/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/fordfulkerson/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/frequent_pattern_finder/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/genophen/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/iterative_partitioning/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/maximum_independent_set/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/random_walk_betweenness/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/rectangle/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/springembedder_1/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/systematic_motif_generator/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/wclique3/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/tools/zoomtool/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/tools/enhancedzoomtool/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/HighDimEmbed/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_cluster_analysis/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder_no_cache/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/pluginClusterTabs.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/scripting/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/fish_eye/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/graph_colorer/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/generators/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/randomizedlabeling/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/algorithms/numbernodes/plugin.xml" >> plugins_exclude.txt -#echo "./org/graffiti/plugins/ios/importers/graphml/plugin.xml" >> plugins_exclude.txt -#echo "./org/graffiti/plugins/ios/exporters/graphviz/plugin.xml" >> plugins_exclude.txt -#echo "./org/graffiti/plugins/ios/exporters/graphml/plugin.xml" >> plugins_exclude.txt -echo "./org/graffiti/plugins/ios/exporters/gmlxml/plugin.xml" >> plugins_exclude.txt -#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/xgmml/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/matrix/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/genophen/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/flatfile/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/matrix/plugin.xml" >> plugins_exclude.txt -echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/collapsed_graph_producer/plugin.xml" >> plugins_exclude.txt -echo "**build.xml" >> plugins_exclude.txt - -cd ../.. -cd make -echo "READY" +#!/bin/bash +cd $(dirname $0) +echo "Current directory: $(pwd)" + +echo "Create XML file lists..." + +echo Core +cd ../Graffiti_Core/build/classes +pwd +find . | grep "\.xml$" > plugins1.txt +cd ../../.. + +echo Editor +cd Graffiti_Editor/build/classes/ +pwd +find . | grep "\.xml$" > plugins2.txt +cd ../../.. + +echo Plugins +cd Graffiti_Plugins/build/classes +pwd +find . | grep "\.xml$" > plugins3.txt +cd ../../.. + +echo IPK-Plugins +cd IPK-Plugins/build/classes +pwd +find . | grep "\.xml$" > plugins4.txt +cd ../../.. + +echo IAP +cd IAP/target/classes +pwd +find . | grep "\.xml$" > pluginsIAP.txt + +echo create Cluster Plugin List +pwd +echo "./org/graffiti/plugins/views/defaults/plugin.xml" > plugins_cluster.txt +echo "./org/graffiti/plugins/modes/defaults/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/label_alignment/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/editcomponents/cluster_colors/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_no_overlapp/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/modes/defaultEditMode/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/ios/importers/gml/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/ios/exporters/gml/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/inspectors/defaults/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/editcomponents/defaults/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/attributes/defaults/plugin.xml" >> plugins_cluster.txt +echo "./org/graffiti/plugins/attributecomponents/simplelabel/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/svg_exporter/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/invert_selection/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/graph_cleanup/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/tree_simple/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/rt_tree/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/random/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/radial_tree/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/grid/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/graph_to_origin_mover/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/expand_reduce_space/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/circle/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/pajek/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/matrix/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/matrix/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/zoomfit/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/set_background_color/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_cluster_analysis/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/enhanced_attribute_editors/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/editing_tools/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_mover/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/ipk_graffitiview/plugin.xml" >> plugins_cluster.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/pluginClusterTabs.xml" >> plugins_cluster.txt + + +echo create Exclude-List for DBE-Gravisto +pwd +echo "./org/graffiti/plugins/ios/gml/gmlWriter/plugin.xml" > plugins_exclude.txt +#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/naive_pattern_finder/plugin.xml" >> plugins_exclude.txt +#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/copy_pattern_layout/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/random/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/ios/exporters/gmlxml/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/views/defaults/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/ios/gml/gmlReader/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/ios/gml/gmlReader/parser/build.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/guis/switchselections/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/random_node_resizer/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_mover/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/node_highlighter/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/examples/edge_directer/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/trivialgridrestricted/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/trivialgrid/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/editor/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/springembedderrestricted/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/springembedder/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/pluginsForOnlineUse.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/webstart/jarprefs.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/tools/enhancedzoomtool/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/views/matrix/plugin.xml" >> plugins_exclude.txt +####echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/fast_view/plugin.xml" >> plugins_exclude.txt +#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/print/printer/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/print/preview/plugin.xml" >> plugins_exclude.txt +echo "./org/jfree/chart/demo/piedata.xml" >> plugins_exclude.txt +echo "./org/jfree/chart/demo/categorydata.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/apsp/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/bfs/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/bfstopsort/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/bn_preparator/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/bonacich_eigenvector/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/pattern_from_canonical_label/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/closeness/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/connectspecial/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/connect/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/degree/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/edge_labeling/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/excentricity/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/fordfulkerson/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/frequent_pattern_finder/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/genophen/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/iterative_partitioning/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/maximum_independent_set/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/centralities/random_walk_betweenness/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/rectangle/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/springembedder_1/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/systematic_motif_generator/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/wclique3/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/tools/zoomtool/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/tools/enhancedzoomtool/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/HighDimEmbed/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/info_dialog_cluster_analysis/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/pattern_springembedder_no_cache/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/layout_control/pluginClusterTabs.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/misc/scripting/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/layouters/fish_eye/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/gui/graph_colorer/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/generators/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/randomizedlabeling/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/algorithms/numbernodes/plugin.xml" >> plugins_exclude.txt +#echo "./org/graffiti/plugins/ios/importers/graphml/plugin.xml" >> plugins_exclude.txt +#echo "./org/graffiti/plugins/ios/exporters/graphviz/plugin.xml" >> plugins_exclude.txt +#echo "./org/graffiti/plugins/ios/exporters/graphml/plugin.xml" >> plugins_exclude.txt +echo "./org/graffiti/plugins/ios/exporters/gmlxml/plugin.xml" >> plugins_exclude.txt +#echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/xgmml/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/matrix/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/genophen/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/importers/flatfile/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/ios/exporters/matrix/plugin.xml" >> plugins_exclude.txt +echo "./de/ipk_gatersleben/ag_nw/graffiti/plugins/algorithms/collapsed_graph_producer/plugin.xml" >> plugins_exclude.txt +echo "**build.xml" >> plugins_exclude.txt + +cd ../../.. +cd make +echo "READY" diff --git a/make/zip/.gitignore b/make/zip/.gitignore new file mode 100644 index 000000000..640065a0e --- /dev/null +++ b/make/zip/.gitignore @@ -0,0 +1,4 @@ +/IAP_v2.1.0.zip +/IAP_v2.1.0/ +/IAP_v2.3.0.zip +/IAP_v2.3.0/