Module modelmage :: Module preparator :: Class removeHandler
[hide private]
[frames] | no frames]

Class removeHandler

source code

Handles the the commandline option for reactions or species that should be removed. The method getTrueCombinations(self, string) can be called from other objects and returns a list of all combinations of ids for which the string is true. e.g. -r "(s_1 & re_1)^re_2 returns: [['re_2'], ['s_1', 're_2'], ['s_1', 're_1'], ['re_2', 're_1']]

The results can then be passed to the generator.

Instance Methods [hide private]
 
__init__(self, idToName, nameToId) source code
 
__unique(self, s)
Return a list of the elements in s, but without duplicates.
source code
 
__all_combinations(self, l)
Returns a 2**l x l matrix of the 2**l possible combinations of choosing l times 2 elements (0 and 1) with odering and repitition
source code
 
__true_combinations(self, list, str)
Finds the list of argument combinations given in list that hold TRUE given the logical string str
source code
 
__names2Ids(self, names, string)
Exchanges given names with ids and enables modelMaGe to remove nodes by names
source code
 
getTrueCombinations(self, string, macros, useMacros)
Generates a list of all combinations of tokens (which have to match the form of SBML ids or the id of a reaction and a species combined with a ':') that let the logical expression become "\True".
source code
Method Details [hide private]

__unique(self, s)

source code 

Return a list of the elements in s, but without duplicates.

For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique("abcabc") some permutation of ["a", "b", "c"], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]].

For best speed, all sequence elements should be hashable. Then unique() will usually work in linear time.

If not possible, the sequence elements should enjoy a total ordering, and if list(s).sort() doesn't raise TypeError it's assumed that they do enjoy a total ordering. Then unique() will usually work in O(N*log2(N)) time.

If that's not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.

from: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560

getTrueCombinations(self, string, macros, useMacros)

source code 

Generates a list of all combinations of tokens (which have to match the form of SBML ids or the id of a reaction and a species combined with a ':') that let the logical expression become "\True". Also updates the dictionaries macros to map ids of removed entities to the kinetics and fills the ReverseMacros dictionary with the correct values.