Skip to content

Commit

Permalink
Merge pull request #57 from hemilpanchiwala/update-docs
Browse files Browse the repository at this point in the history
Documentation Pull Request
  • Loading branch information
draeger authored Aug 27, 2020
2 parents 748ea94 + 63d2005 commit 002b648
Show file tree
Hide file tree
Showing 632 changed files with 102,076 additions and 57,619 deletions.
86 changes: 53 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
# The Systems Biology Simulation Core Library
# The Systems Biology Simulation Core Library <img align="right" src="https://draeger-lab.github.io/SBSCL/images/SCL_icon.png">

[![License (LGPL version 3)](https://img.shields.io/badge/license-LGPLv3.0-blue.svg?style=plastic)](http://opensource.org/licenses/LGPL-3.0)
[![Latest version](https://img.shields.io/badge/Latest_version-1.4.0-brightgreen.svg?style=plastic)](https://github.com/draeger-lab/SBSCL/releases/)
[![Latest version](https://img.shields.io/badge/Latest_version-1.5.0-brightgreen.svg?style=plastic)](https://github.com/draeger-lab/SBSCL/releases/)
[![DOI](https://img.shields.io/badge/DOI-10.1186%2F1752--0509--7--55-blue.svg?style=plastic)](https://doi.org/10.1186/1752-0509-7-55)
[![Build Status](https://travis-ci.com/draeger-lab/SBSCL.svg?branch=master&style=plastic)](https://travis-ci.com/draeger-lab/SBSCL)

*Authors*: [Roland Keller](https://github.com/RolandKeller5), [Andreas Dräger](https://github.com/draeger), [Shalin Shah](https://github.com/shalinshah1993), [Matthias König](https://github.com/matthiaskoenig), [Alexander Dörr](https://github.com/a-doerr), [Richard Adams](https://github.com/otter606), [Nicolas Le Novère](https://github.com/lenov), [Max Zwiessele](https://github.com/mzwiessele)
*Authors*: [Roland Keller](https://github.com/RolandKeller5), [Andreas Dräger](https://github.com/draeger), [Hemil Panchiwala](https://github.com/hemilpanchiwala), [Shalin Shah](https://github.com/shalinshah1993), [Matthias König](https://github.com/matthiaskoenig), [Alexander Dörr](https://github.com/a-doerr), [Richard Adams](https://github.com/otter606)

*Contributors to predecessor projects:* Philip Stevens, Marcel Kronfeld, Sandra Saliger, Simon Schäfer, Dieudonné Motsou Wouamba, Hannes Borch
*Contributors to predecessor projects:* Philip Stevens, Marcel Kronfeld, Sandra Saliger, Simon Schäfer, Dieudonné Motsou Wouamba, Hannes Borch, Nicolas Le Novère, Max Zwiessele

#### Description
### Description
The Systems Biology Simulation Core Library (SBSCL) provides an efficient and exhaustive Java™ implementation of methods to interpret the content of models encoded in the Systems Biology Markup Language ([SBML](http://sbml.org)) and its numerical solution. This library is based on the [JSBML](http://sbml.org/Software/JSBML) project and can be used on every operating system for which a Java Virtual Machine is available. Please note that this project does not contain any user interface, neither a command-line interface, nor a graphical user interface. This project has been developed as a pure programming library. To support the [MIASE](http://co.mbine.org/standards/miase) effort, it understands [SED-ML](http://sed-ml.org) files. Its abstract type and interface hierarchy facilitates the implementation of further community standards, such as [CellML](https://www.cellml.org).

When using this library, please cite: http://www.biomedcentral.com/1752-0509/7/55.

#### Categories
### Categories
Bio-Informatics, Libraries, Simulations

#### Features
* Numerical simulation
* Ordinary differential equation solver
* Time-course analysis
* Systems Biology Markup Language
* Application programming interface
### Features
- Numerical simulation
- Ordinary differential equation solver
- Time-course analysis
- Application programming interface
- Systems Biology Markup Language support along with `fbc` and `comp` extensions
- Stochastic simulations support
- Simulation Experiment Description Markup Language (SED-ML) support

### Supported Packages
- Systems Biology Markup Language (L1V1 - L3V2)
- SBML models with FBC V1 and V2
- SBML models with comp extensions
- Simulation Experiment Description Markup Language (L1V3)
- COMBINE archive and OMEX format
- All models from [SBML Test Suite](https://github.com/sbmlteam/sbml-test-suite/tree/master/cases/semantic) and [BiGG models](https://github.com/matthiaskoenig/bigg-models-fba)
- All models from [Stochastic Test Suite](https://github.com/sbmlteam/sbml-test-suite/tree/master/cases/stochastic)

#### Licensing terms

This file is part of Simulation Core Library, a Java-based library for efficient numerical simulation of biological models.

Copyright (C) 2007 jointly held by the individual authors.

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://www.gnu.org/licenses/lgpl-3.0-standalone.html.
## Getting started

Please cite the original work and the authors when using this program. See the [project homepage](https://draeger-lab.github.io/SBSCL/) for details.
### For users
For an introduction on how to use this library for simulation, please refer to the [UserGuidelines.md](UserGuidelines.md) file. There you can find explanations on how to simulate different models and code snippets, including the links to the complete code examples.

## Getting started
### For developers
To start working on SBSCL, you should first clone the repository and then refer to [INSTALL.md](INSTALL.md) which gives instruction to run maven build. Once a maven build is ran, the binaries will be generated in the target folder. This folder will also include a JAR files of the simulation core library to work with.

For an introduction of how to use this library, please open the javadoc [homepage](https://draeger-lab.github.io/SBSCL/apidocs/overview-summary.html). There you can find instructions and source code examples, including some use cases. Once a maven build is ran, the binaries will be generated in the target folder. This folder will also include a JAR files of the simulation core library to work with.
For an introduction on how things currently work in SBSCL to simulate different models, please refer to the sequence diagrams present in the [/dev/diagrams/](https://github.com/draeger-lab/SBSCL/tree/master/dev/diagrams/) where you can understand complete workflow of the library. Once you get familiarized with how things work, please open the javadoc [homepage](https://draeger-lab.github.io/SBSCL/apidocs/overview-summary.html) where you can find the complete information about the library properly documented. For formatting the code-base, please refer to [formatting-guidelines](https://github.com/draeger-lab/SBSCL/tree/master/dev/formatting-guidelines/).

## File structure

Expand All @@ -49,19 +56,32 @@ Most importantly, see
The package structure in more detail:
```
/
|- docs -> Contains code for the maven built website
|- src -> The main source folder containing all the code and test files
|- assembly -> assembly files for maven plugins
|- lib -> 3rd party libraries needed for compilation and execution
|- main -> Core java files of simulation library
|- test -> JUnit test files along with resources required
|- site -> Contains markup files, old javadoc, site.xml and other website
resources
|- LICENSE.txt -> the license, under which this project is distributed
|- pom.xml -> Maven file for building the project
|- README.md -> this file
|- dev -> Contains the diagrams and fomatting-guidelines for the developers
|- docs -> Contains code for the maven built website
|- modules -> Contains the code for support of cellDesigner and cytoscape in FERN
|- src -> The main source folder containing all the code and test files
|- assembly -> assembly files for maven plugins
|- lib -> 3rd party libraries needed for compilation and execution
|- main -> Core java files of simulation library
|- test -> JUnit test files along with resources required
|- site -> Contains markup files, old javadoc, site.xml and other website
resources
|- LICENSE.txt -> the license, under which this project is distributed
|- pom.xml -> Maven file for building the project
|- README.md -> this file
|- UserGuidelines.md -> Contains the guidelines for using the features of library
```

## Troubleshooting

Please e-mail any bugs, problems, suggestions, or issues regarding this library to the bug tracker at https://github.com/draeger-lab/SBSCL/issues

## Licensing terms

This file is part of Simulation Core Library, a Java-based library for efficient numerical simulation of biological models.

Copyright (C) 2007 jointly held by the individual authors.

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](LICENSE.txt) included with this software distribution and also available online as http://www.gnu.org/licenses/lgpl-3.0-standalone.html.

Please cite the original work and the authors when using this program. See the [project homepage](https://draeger-lab.github.io/SBSCL/) for details.
148 changes: 148 additions & 0 deletions UserGuidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Guidelines to use SBSCL for simulating the models

# Index
* [SBML model simulation](#simulating-the-sbml-models)
* [COMP model simulation](#simulating-the-sbml-models-with-comp-extension)
* [FBC model simulation](#simulating-the-sbml-models-with-fbc-extension)
* [Stochastic simulation of SBML models](#stochastic-simulation-of-the-sbml-models)

## Simulating the SBML models

- First, a model has to be read from the file using the [SBMLReader](https://github.com/sbmlteam/jsbml/blob/master/core/src/org/sbml/jsbml/SBMLReader.java) by [JSBML](https://github.com/sbmlteam/jsbml). With this model as a parameter, the [SBMLinterpreter](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/sbml/SBMLinterpreter.java) instance is created which provides the basis of the simulation initializing all the properties of the model (using the [EquationSystem](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/sbml/EquationSystem.java) class), and contains the methods required for processing various functionalities like rules, events, etc.

```java
Model model = (new SBMLReader()).readSBML(fileName).getModel();
EquationSystem interpreter = new SBMLinterpreter(model);
```

- Once the interpreter has been created, one can simulate the model with an available solver (preferably [Rosenbrocksolver](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/math/odes/RosenbrockSolver.java)) providing time points (instead of time points the initial time, end time, and the step size can be provided). The simulation results are stored in a MultiTable.

```java
// An example of solving with Rosenbrock solver
DESSolver solver = new RosenbrockSolver();
solver.setStepSize(stepSize); // Setting the step size for the model
MultiTable solution = solver.solve(interpreter,
interpreter.getInitialValues(), 0d, timeEnd, simulatorExample);
```

- One can now print the [MultiTable](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/math/odes/MultiTable.java) or can plot it using the [PlotMultiTable](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/plot/PlotMultiTable.java) where you can see the changing values in a graphical form. Also, you can view it in a tabular form using the JTable class.

**Note:** To set the absolute and relative tolerances for the specific simulation, you can use the method provided by the [DESolver](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/math/odes/DESSolver.java) using the below code snippets:
```java
((AdaptiveStepsizeIntegrator) solver).setAbsTol(absTol);
((AdaptiveStepsizeIntegrator) solver).setRelTol(relTol);
```

For the complete code on how to simulate an SBML model, please refer to the [SimulatorExample](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/examples/SimulatorExample.java) in the repository.

Workflow of SBML model simulation using a sequence diagram:
![](dev/diagrams/sbml-model-simulation/SBML_Model_Simulation_Sequence_Diagram.png)

## Simulating the SBML models with comp extension
- Simulating the comp models is quite easy as you just need to provide a file to the [CompSimulator](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/comp/CompSimulator.java), and it performs all the tasks including the initializations and processings.

```java
CompSimulator compSimulator = new CompSimulator(sbmlfile);
```

- After creating the instance of the simulator, you have to call the `solve()` method of the CompSimulator class with duration and step size to get the results in the form of MultiTable.

```java
// Here, 10.0 refers to the total duration
// 0.1 refers to the step size
MultiTable solution = compSimulator.solve(10.0, 0.1);
```

- After this, you can view the results either by printing or by [PlotMultiTable](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/plot/PlotMultiTable.java) (in graphical form) or by JTable (in tabular form).

For the complete code on how to simulate the comp model, please refer to the [CompExample](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/examples/CompExample.java) in the repository.

Workflow of COMP model simulation using a sequence diagram:
![](dev/diagrams/comp-model-simulation/COMP_Model_Simulation_Sequence_Diagram.png)

## Simulating the SBML models with fbc extension

- Similar to the CompSimulator, here we have to provide the [SBMLDocument](https://github.com/sbmlteam/jsbml/blob/master/core/src/org/sbml/jsbml/SBMLDocument.java) by reading from the file to the [FluxBalanceAnalysis](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/fba/FluxBalanceAnalysis.java) class which implements all the flux balance analysis functionality.

```java
SBMLDocument document = new SBMLReader().read(sbmlfile);
FluxBalanceAnalysis solver = new FluxBalanceAnalysis(document);
```

- After this, you just need to call `solve()` method of FluxBalanceAnalysis that returns a boolean indicating of the simulation was successful.

```java
boolean solvedStatus = solver.solve();
```

- After solving the FBA problem the simulation results can be accessed via.
```java
if(solvedStatus == true) {
solver.getObjectiveValue() // provides the objective value of the active objective function
solver.getSolution() // provides the results in the form of HashMap with keys as the ids and values as their corresponding fluxes
}
```

For complete code on how to simulate the fbc model, please refer to the [FBAExample](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/examples/FBAExample.java) in the repository.

Workflow of FBC model simulation using a sequence diagram:
![](dev/diagrams/fbc-model-simulation/FBC_Model_Simulation_Sequence_Diagram.png)

## Stochastic simulation of the SBML models

- For performing the stochastic simulation, you will have to first provide the basic properties like filePath, duration, interval (step size), etc in the form of a HashMap (as remains quite handy to initialize everything at one place, and just give the key and get value).

```java
Map<String, Object> orderedArgs = new HashMap<String, Object>();
orderedArgs.put("file", path_of_the_file);
orderedArgs.put("time", Double.parseDouble("50.0")); // duration of the simulation
orderedArgs.put("interval", Double.parseDouble("1.0")); // interval between two time points
```

- Once you create the basic HashMap with the arguments shown above, you need to create a [SBMLNetwork](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/network/sbml/SBMLNetwork.java) (implemented from [Network](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/network/Network.java) interface) instance, using the `loadNetwork()` method from [NetworkTools](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/tools/NetworkTools.java) class, which derives all the needed information from the model.

```java
Network net = NetworkTools.loadNetwork(new File((String) orderedArgs.get("file")));
```

- After creating the network, you need to initialize the [Simulator](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/simulation/Simulator.java) with the algorithm you wish to simulate by passing the SBMLNetwork instance.

```java
// Initializes simulator with the GillespieEnhanced Algorithm
Simulator sim = new GillespieEnhanced(net);
```

All supported algorithms for stochastic simulation are available in the [/java/fern/simulation/algorithm](https://github.com/draeger-lab/SBSCL/tree/master/src/main/java/fern/simulation/algorithm) directory.

**Note:** If your SBML model contains any events, then the network has to call `registerEvents()` passing the simulator as to keep track of event properties like trigger, delays, and others by the [SBMLEventHandlerObserver](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/network/sbml/SBMLEventHandlerObserver.java).
```java
((SBMLNetwork) net).registerEvents(sim);
```

- After initializing the simulator, we need to initialize an observer (instance of [AmountIntervalObserver](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/simulation/observer/AmountIntervalObserver.java) class) which will keep track of the amounts of species throughout the simulation process. For this, we first need to get all the identifiers (species ids) using the [NetworkTools](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/tools/NetworkTools.java) class.

```java
String[] species = NetworkTools.getSpeciesNames(sim.getNet(),
NumberTools.getNumbersTo(sim.getNet().getNumSpecies() - 1)); // gets the ids of the species

// Initializes the observer and also registers it to the simulator using addObserver() method
AmountIntervalObserver obs = (AmountIntervalObserver) sim.addObserver(
new AmountIntervalObserver(sim, (Double) orderedArgs.get("interval"),
((Double) orderedArgs.get("time")).intValue(), species));
```

- Above steps completes all the initialization part and now to simulate, you just need to call the `start()` method of Simulator passing the total duration of the simulation.

```java
sim.start((Double) orderedArgs.get("time")); // runs the stochastic simulation for the defined duration
```

- On completing the simulation, all the results are stored with the observer from which you can access it in the form of 2-D array which can also be converted to [MultiTable](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/org/simulator/math/odes/MultiTable.java) (refer the [Start.java](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/Start.java) file).
```java
obs.getAvgLog() // provides the results in 2-D array form
```

The complete code of stochastic simulation of the SBML models can be found at the [Start.java](https://github.com/draeger-lab/SBSCL/blob/master/src/main/java/fern/Start.java) file (with proper commenting) and separated under different methods defining particular use cases.

Workflow of stochastic simulation by sequence diagram:
![](dev/diagrams/stochastic-simulation/Stochastic_Simulation_Sequence_Diagram.png)
Loading

0 comments on commit 002b648

Please sign in to comment.