How to upgrade SciPy on Fedora 23

As it was with Fedora 22, the Fedora 23 still ships with SciPy version 0.14.1. To upgrade SciPy please run the following commands as root:

dnf install python-pip
dnf install blas-devel
dnf install lapack-devel
dnf install gcc-c++
dnf groupinstall "Development Tools"

If you now try to upgrade scipy you will get the following error
g++: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory

On Fedora 23 one has also to install rpm-build to avoid errors during compilation of scipy:
dnf search rpm-build

Finally uninstall scipy 0.14.1, download 0.16.0, compile it and install. All with the following command:
pip install --upgrade scipy

scipy.odr.odrpack.odr_error: number of observations do not match

When the length of t does not match the length of observations array,  it may couse this error

t = np.linspace(0.5, 54.5, 18)

P = [29.976, 193.96, 362.64, 454.78, 498.42, 517.14, 515.76, 496.38, 472.14, 432.81, 386.95, 352.93, 318.93, 279.47, 260.19, 230.92, 202.67, 180.3, 159.09, 137.31, 120.47, 104.51, 99.371, 89.606, 75.431, 67.137, 58.561, 55.721]

data = Data(t, P)

When the length of t and P are different, program ends with the error “scipy.odr.odrpack.odr_error: number of observations do not match”


libSBML 5.8.0 in Fedora 19 with Python bindings

How to install libSBML 5.8.0 in Fedora 19 with Python bindings

Install compiler
yum install gcc-c++
yum groupinstall "Development Tools"

Install some additional packages if needed
yum install python-devel
yum install libxml2-devel
yum install swig

Compile and install libSBML
Go to the directory where you have exctracted libsbml source and run these 3 commands
./configure --with-python
make install

Make libsbml accessible to Python
In Fedora 18 you would export full path to libsbml:
export PYTHONPATH=/usr/local/lib64/python2.7/site-packages/libsbmlIn Fedora 18 you would import _libsbml not just import libsbml.

In Fedora 19 you have to export path like this:
export PYTHONPATH=/usr/local/lib64/python2.7/site-packages/

The export command expires when user leaves his/her session.

Use the libSBML in your code
import libsbml

gtk import Segmentation fault

When I tried to run my program (ModeRator) I get this error:
/usr/lib64/python2.7/site-packages/gobject/ Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/ Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/ Warning: g_type_get_qdata: assertion `node != NULL' failed
from gtk import _gtk
Segmentation fault (core dumped)

I ‘fixed’ the problem by disabling the import of matplotlib

It turns out that it is possible to import only one of them:
from gi.repository import GObject, Gtk
import matplotlib.pyplot as plt

Comment out one of these lines end the error is gone!
Better explanation of problems like this is found here:

How to create an SBML file using libSBML in Python

This tutorial is intended as a quick introduction on how to create an SBML file using libSBML. For a full developer’s guide, please see libSBML Python API.

from libsbml import *
document = SBMLDocument()
model = document.createModel(2, 4) # SBML level and version

##First you have to create compartments
c1 = model.createCompartment()

## Set the volume of compartments

## Continue with other compartments
c2 = model.createCompartment()

## When you have finished with compartments, proceed with species.
s1 = model.createSpecies()

s2 = model.createSpecies()

s3 = model.createSpecies()

## When you are done with compartments and species, create reactions.
r1 = model.createReaction()
r1.setName('Foxes eat rabbits')

## Create reactants and products
reac1 = r1.createReactant()
prod1 = r1.createProduct()

## if necessary, set Stoichiometry
reac1.setStoichiometry(2) # 2 rabbits
prod1.setStoichiometry(1) # 1 fox

Notice that we create seemingly independent objects for comprartments, reaction, reactant and product. We set some values to the properties of these objects and never actually add these elements to the model. Thats because they are automatically added. You can try this inside a loop and it will still work.

##Now when you have done whith your model you have to add it to the document.

## If you wish you can add optional information.
model.setName('My test model')

##Save to file.

That’s it! Copy&paste this code and try it yourself!
Please note that this tutorial is realy basic. For more comprehensive examples, please see the examples/ folder in the libSBML source tree.