Module fia_analysis
[hide private]
[frames] | no frames]

Module fia_analysis

source code



 FIA - Fluxomers Iterative Algorithm 


SYNOPSIS:
    fia_analysis {-i[=--fia] PROJFILE | -t[=--ftbl] PROJFILE} [-o[=--output_file] OUTPUTFILE]

USAGE:
    fia_analysis performs the following two main steps:
    
        1) Metabolic pathway analysis.
        
            Here FIA transforms the text file representing the metabolic network into
            mathematical matrices required later for the MFA optimization process.            
            
        2) Metabolic fluxes evaluation.

            Here FIA tries to find the fluxes that best suit the given metabolic system.
            The output log of this stage is a file called    <PROJFILE>.out,
            or else if specified by the "-o" flag.

    fia_analysis supports two types of input file formats: FIA and 13CFlux FTBL.
    The two are very much alike, except for the fact that the FIA format supports only declaration of
    uni-directional fluxes, and does not contain the FLUXES and INEQUALITIES sections.
    For bi-directional fluxes, FIA simply defines two seperated fluxes.
    When analyzing 13CFlux FTBL files, fia_analysis looks for C=0 constraints in the FLUXES XCH section
    in order to determine directionality of fluxes.

OPTIONS:
    -i --fia
        Specifies that the metabolic pathway input file <PROJFILE> is a FIA formated file. 
        All fluxes are assumed unidirectional (for bi-directional specify 2 seperated fluxes).        

    -t --ftbl
        Specifies that the metabolic pathway input file <PROJFILE> is a 13CFlux FTBL formated file.         
        Flux is assumed unidirectional unless C=0 constraint is applied to it in the FLUXES XCH section.
        The FIA formated file will be saved under <PROJFILE>.fia .

   -o --output_file
        optional. 
        Specifies the name of the result log output file. The default file name is PROJFILE.out
        
    at least one of the above must be supplied.
        
USAGE EXAMPLE:

fia_analysis -t temp.ftbl
    Runs anaylsis & evaluation of the network defined in the FTBL formated input file temp.ftbl .
    same as:
        fia_analysis --ftbl temp.ftbl 

fia_analysis --fia temp.fia -a   |  
    Runs only network analysis on the given FIA formated input file.
    Same as:
        fia_analysis -i temp.fia -a
        fia_analysis -i temp.fia --analyze_only
        fia_analysis --fia temp.fia --analyze_only
        
fia_analysis temp.fia -i -e
    Runs only the fluxes evaluation on the FIA formated input file temp.fia .
    This assumes analysis has been done before on the temp.fia file.
    Same as:
        fia_analysis -i temp.fia --evaluate_only
        fia_analysis --fia temp.fia -e
        fia_analysis --fia temp.fia --evaluate_only


Version: 0.7.0

Classes [hide private]
  MyWriter
A file-handler replacement that duplicates the actions applied to the hanlder to a log file handler as well.
  FtblFile
This class is the main object of the FIA algorithm.
Functions [hide private]
scipy.array
one_div_vec(vec)
This function returns a vector which is 1/vec.
source code
scipy.sparse matrix
sdiag(a)
Fast sparse diagonal matrix creator.
source code
list
expand_x_values(cteq)
This function transforms input with ()'s into all the possible sets of inputs with 0's and 1's replacing the ()s.
source code
list
create_ms_isotopomers_dict(no_of_atoms, indices_to_change)
This function returns all the possible permutations of no_of_atoms atoms, seperated by the number of 1's in them.
source code
string
num2bin(num, length)
Converts number to binary format with at (length) bits.
source code
 
save_text_vec(filename, vec)
This fucntion saves the input vector in text TAB seperated format.
source code
 
matlab_save_sparsed_matrix(filename, mat)
This fucntion saves the input matrix in text TAB seperated format loadable by MATLAB.
source code
 
sort_dict_by_values(d)
This function sorts the input dictionary by its values.
source code
 
null(A, eps=1e-15)
This function finds the null space of the incoming matrix A.
source code
 
find_init_point(self)
This function generates the initial point given for the optimization process.
source code
 
get_normG(u, self)
Main MFA optimization objective function value.
source code
 
get_normG_grad(u, self)
Main MFA optimization objective function gradient calculation.
source code
 
load_data(fname) source code
 
tic() source code
 
toc() source code
 
main(argv) source code
 
rand(d0, d1, dn, ...)
Random values in a given shape.
source code
 
randn(d0, d1, dn, ...)
Returns zero-mean, unit-variance Gaussian random numbers in an array of shape (d0, d1, ..., dn).
source code
Variables [hide private]
  umfpack = um.UmfpackContext()
  prog_width = 40
  display_prog = False
  ALLOW_THREADS = 1
  BUFSIZE = 10000
  CLIP = 0
  ERR_CALL = 3
  ERR_DEFAULT = 0
  ERR_DEFAULT2 = 2084
  ERR_IGNORE = 0
  ERR_LOG = 5
  ERR_PRINT = 4
  ERR_RAISE = 2
  ERR_WARN = 1
  FLOATING_POINT_SUPPORT = 1
  FPE_DIVIDEBYZERO = 1
  FPE_INVALID = 8
  FPE_OVERFLOW = 2
  FPE_UNDERFLOW = 4
  False_ = False
  Inf = inf
  Infinity = inf
  MAXDIMS = 32
  NAN = nan
  NINF = -inf
  NZERO = -0.0
  NaN = nan
  PINF = inf
  PZERO = 0.0
  RAISE = 2
  SHIFT_DIVIDEBYZERO = 0
  SHIFT_INVALID = 9
  SHIFT_OVERFLOW = 3
  SHIFT_UNDERFLOW = 6
  ScalarType = (<type 'int'>, <type 'float'>, <type 'complex'>, ...
  True_ = True
  UFUNC_BUFSIZE_DEFAULT = 10000
  UFUNC_PYVALS_NAME = 'UFUNC_PYVALS'
  WRAP = 1
  __package__ = None
  absolute = <ufunc 'absolute'>
  add = <ufunc 'add'>
  arccosh = <ufunc 'arccosh'>
  arcsinh = <ufunc 'arcsinh'>
  arctan = <ufunc 'arctan'>
  arctan2 = <ufunc 'arctan2'>
  bitwise_and = <ufunc 'bitwise_and'>
  bitwise_not = <ufunc 'invert'>
  bitwise_or = <ufunc 'bitwise_or'>
  bitwise_xor = <ufunc 'bitwise_xor'>
  c_ = <numpy.lib.index_tricks.CClass object at 0xee37d0>
  cast = {<type 'numpy.int64'>: <function <lambda> at 0xdcec80>,...
  ceil = <ufunc 'ceil'>
  conj = <ufunc 'conjugate'>
  conjugate = <ufunc 'conjugate'>
  cos = <ufunc 'cos'>
  cosh = <ufunc 'cosh'>
  deg2rad = <ufunc 'deg2rad'>
  degrees = <ufunc 'degrees'>
  divide = <ufunc 'divide'>
  e = 2.71828182846
  equal = <ufunc 'equal'>
  exp = <ufunc 'exp'>
  exp2 = <ufunc 'exp2'>
  expm1 = <ufunc 'expm1'>
  fabs = <ufunc 'fabs'>
  floor = <ufunc 'floor'>
  floor_divide = <ufunc 'floor_divide'>
  fmax = <ufunc 'fmax'>
  fmin = <ufunc 'fmin'>
  fmod = <ufunc 'fmod'>
  frexp = <ufunc 'frexp'>
  greater = <ufunc 'greater'>
  greater_equal = <ufunc 'greater_equal'>
  hypot = <ufunc 'hypot'>
  index_exp = <numpy.lib.index_tricks.IndexExpression object at ...
  inf = inf
  infty = inf
  invert = <ufunc 'invert'>
  isfinite = <ufunc 'isfinite'>
  isinf = <ufunc 'isinf'>
  isnan = <ufunc 'isnan'>
  ldexp = <ufunc 'ldexp'>
  left_shift = <ufunc 'left_shift'>
  less = <ufunc 'less'>
  less_equal = <ufunc 'less_equal'>
  little_endian = True
  log1p = <ufunc 'log1p'>
  logaddexp = <ufunc 'logaddexp'>
  logaddexp2 = <ufunc 'logaddexp2'>
  logical_and = <ufunc 'logical_and'>
  logical_not = <ufunc 'logical_not'>
  logical_or = <ufunc 'logical_or'>
  logical_xor = <ufunc 'logical_xor'>
  maximum = <ufunc 'maximum'>
  mgrid = <numpy.lib.index_tricks.nd_grid object at 0xee3610>
  minimum = <ufunc 'minimum'>
  mod = <ufunc 'remainder'>
  modf = <ufunc 'modf'>
  multiply = <ufunc 'multiply'>
  nan = nan
  nbytes = {<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <t...
  negative = <ufunc 'negative'>
  newaxis = None
  not_equal = <ufunc 'not_equal'>
  ogrid = <numpy.lib.index_tricks.nd_grid object at 0xee3650>
  ones_like = <ufunc 'ones_like'>
  pi = 3.14159265359
  r_ = <numpy.lib.index_tricks.RClass object at 0xee3710>
  rad2deg = <ufunc 'rad2deg'>
  radians = <ufunc 'radians'>
  reciprocal = <ufunc 'reciprocal'>
  remainder = <ufunc 'remainder'>
  right_shift = <ufunc 'right_shift'>
  rint = <ufunc 'rint'>
  s_ = <numpy.lib.index_tricks.IndexExpression object at 0xee3910>
  sctypeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>,...
  sctypeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bo...
  sctypes = {'complex': [<type 'numpy.complex64'>, <type 'numpy....
  sign = <ufunc 'sign'>
  signbit = <ufunc 'signbit'>
  sin = <ufunc 'sin'>
  sinh = <ufunc 'sinh'>
  square = <ufunc 'square'>
  subtract = <ufunc 'subtract'>
  tan = <ufunc 'tan'>
  tanh = <ufunc 'tanh'>
  true_divide = <ufunc 'true_divide'>
  trunc = <ufunc 'trunc'>
  typeDict = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2...
  typeNA = {'?': 'Bool', 'B': 'UInt8', 'Bool': <type 'numpy.bool...
  typecodes = {'All': '?bhilqpBHILQPfdgFDGSUVO', 'AllFloat': 'fd...
Function Details [hide private]

one_div_vec(vec)

source code 

This function returns a vector which is 1/vec.

Parameters:
  • vec (scipy.array) - input vector
Returns: scipy.array
1/vec (element wise division).

sdiag(a)

source code 

Fast sparse diagonal matrix creator. Simply returns a sparse matrix with a as its diagonal.

Parameters:
  • a (array) - input array
Returns: scipy.sparse matrix
sparse matrix with a in its diagonal.

expand_x_values(cteq)

source code 

This function transforms input with ()'s into all the possible sets of inputs with 0's and 1's replacing the ()s.

Parameters:
  • cteq (string) - Input string. ()'s will be replaced with 1's and 0's.
Returns: list
List of possible variations of cteq, with all the possible 0's and 1's replacements for 's in the input string.

create_ms_isotopomers_dict(no_of_atoms, indices_to_change)

source code 

This function returns all the possible permutations of no_of_atoms atoms, seperated by the number of 1's in them. (indices_to_change) specifies which of the atoms can be changed (and the counting is then done only on these atoms). For example, if we call:

   create_ms_isotopomers_dict(4,[0,1,2])

we get:

   [['000x'], ['001x', '010x', '100x'], ['011x', '101x', '110x'], ['111x']]

The first element represents all 0's vec (for indices_to_change), the second a vector with only one 1 element, the third with two 1's elements, and the third with three 1's elements.

This function is used for mass-spectrometry measurements analysis.

Parameters:
  • no_of_atoms (number) - Number of atoms in the counted molecule.
  • indices_to_change (list) - List of indicies on which we want to count.
Returns: list
List of lists - all possible permutations for the molecule, sorted by number of ones.

num2bin(num, length)

source code 

Converts number to binary format with at (length) bits.

Parameters:
  • num (number) - The number to be converted
  • length (number) - Length of the output binary number.
Returns: string
Binary string representing the input number. Zeros are left appended if necessary in order to maintain the required length.

save_text_vec(filename, vec)

source code 

This fucntion saves the input vector in text TAB seperated format. Used for MATLAB debugging purposes.

matlab_save_sparsed_matrix(filename, mat)

source code 

This fucntion saves the input matrix in text TAB seperated format loadable by MATLAB. Used for MATLAB debugging purposes.

find_init_point(self)

source code 

This function generates the initial point given for the optimization process. It is based upon the standard init point finding methods of iterior point algorithms: In order to find a valid solution for S*u = 0, U* u <= s we solve:

   min(s)

   s.t.:

    [I,-I]*u + [0*i,10*i] >= s
    Su = S_b    

We then use this initial point with the propogation equation, resulting with the first point for the algorithm.

get_normG(u, self)

source code 

Main MFA optimization objective function value. This function calculates || self.tG * x - self.tB || for a given u vector by finding the valid x vector and then substituting it in the objective function.

get_normG_grad(u, self)

source code 

Main MFA optimization objective function gradient calculation. This function calculates d (|| self.tG * x - self.tB ||) / du for a given u vector.

rand(d0, d1, dn, ...)

source code 
Random values in a given shape.

Create an array of the given shape and propagate it with
random samples from a uniform distribution
over ``[0, 1)``.

Parameters
----------
d0, d1, ..., dn : int
    Shape of the output.

Returns
-------
out : ndarray, shape ``(d0, d1, ..., dn)``
    Random values.

See Also
--------
random

Notes
-----
This is a convenience function. If you want an interface that
takes a shape-tuple as the first argument, refer to
`random`.

Examples
--------
>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random

randn(d0, d1, dn, ...)

source code 
Returns zero-mean, unit-variance Gaussian random numbers in an
array of shape (d0, d1, ..., dn).

Note:  This is a convenience function. If you want an
            interface that takes a tuple as the first argument
            use numpy.random.standard_normal(shape_tuple).


Variables Details [hide private]

ScalarType

Value:
(<type 'int'>,
 <type 'float'>,
 <type 'complex'>,
 <type 'long'>,
 <type 'bool'>,
 <type 'str'>,
 <type 'unicode'>,
 <type 'buffer'>,
...

cast

Value:
{<type 'numpy.int64'>: <function <lambda> at 0xdcec80>, <type 'numpy.i\
nt16'>: <function <lambda> at 0xdcecf8>, <type 'numpy.float128'>: <fun\
ction <lambda> at 0xdced70>, <type 'numpy.string_'>: <function <lambda\
> at 0xdcede8>, <type 'numpy.complex256'>: <function <lambda> at 0xdd1\
488>, <type 'numpy.uint64'>: <function <lambda> at 0xdd1500>, <type 'n\
umpy.int8'>: <function <lambda> at 0xdceed8>, <type 'numpy.uint8'>: <f\
unction <lambda> at 0xdcef50>, <type 'numpy.float32'>: <function <lamb\
da> at 0xdd1050>, <type 'numpy.uint32'>: <function <lambda> at 0xdd10c\
...

index_exp

Value:
<numpy.lib.index_tricks.IndexExpression object at 0xee3890>

nbytes

Value:
{<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <type 'numpy.float1\
28'>: 16, <type 'numpy.string_'>: 0, <type 'numpy.int32'>: 4, <type 'n\
umpy.int8'>: 1, <type 'numpy.uint8'>: 1, <type 'numpy.float32'>: 4, <t\
ype 'numpy.uint32'>: 4, <type 'numpy.int64'>: 8, <type 'numpy.uint64'>\
: 8, <type 'numpy.complex64'>: 8, <type 'numpy.unicode_'>: 0, <type 'n\
umpy.uint16'>: 2, <type 'numpy.float64'>: 8, <type 'numpy.object_'>: 8\
, <type 'numpy.complex256'>: 32, <type 'numpy.uint64'>: 8, <type 'nump\
y.complex128'>: 16, <type 'numpy.void'>: 0, <type 'numpy.bool_'>: 1}

sctypeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int64'>,
...

sctypeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex128': <type 'numpy.complex256'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

sctypes

Value:
{'complex': [<type 'numpy.complex64'>,
             <type 'numpy.complex128'>,
             <type 'numpy.complex256'>],
 'float': [<type 'numpy.float32'>,
           <type 'numpy.float64'>,
           <type 'numpy.float128'>],
 'int': [<type 'numpy.int8'>,
         <type 'numpy.int16'>,
...

typeDict

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int64'>,
...

typeNA

Value:
{'?': 'Bool',
 'B': 'UInt8',
 'Bool': <type 'numpy.bool_'>,
 'Complex128': <type 'numpy.complex256'>,
 'Complex32': <type 'numpy.complex64'>,
 'Complex64': <type 'numpy.complex128'>,
 'D': 'Complex64',
 'F': 'Complex32',
...

typecodes

Value:
{'All': '?bhilqpBHILQPfdgFDGSUVO',
 'AllFloat': 'fdgFDG',
 'AllInteger': 'bBhHiIlLqQpP',
 'Character': 'c',
 'Complex': 'FDG',
 'Float': 'fdg',
 'Integer': 'bhilqp',
 'UnsignedInteger': 'BHILQP'}