def is_reverse(self, the_inverse): """Returns true if the given reaction is the reverse of the current reaction """ if (utils.equal_lists(self.reactants, the_inverse.products) and utils.equal_lists(self.products, the_inverse.reactants)): return True else: return False
def reaction_knockout_table(filename, ignore_sources, ignore_sinks): """Given an sbml file, perform composite reduction analysis and print the results. This basically means perform invariant analysis once for each reaction in the model. For a reaction's analysis we ignore that reaction and calculate the set of invariants and the set of species not covered by any invariant. The idea is to compare this with the set of invariants for all reactions thus giving us some idea which reactions may be violating an expected invariant """ kig_dictionary = reaction_knockout_kigs(filename, ignore_sources, ignore_sinks) def get_length_uncovered(my_pair): """Return the number of uncovered species""" return len(my_pair[1]) def get_uncovered(kig): """Return the uncovered species from a kig""" inv_inferer = InvariantInferer(kig) return inv_inferer.get_uncovered() orig_uncovered = get_uncovered_model_file(filename, ignore_sources, ignore_sinks) uncovered_map = [ (rname, get_uncovered(kig) ) for (rname, kig) in kig_dictionary.items() ] sorted_uncovereds = sorted(uncovered_map, key=get_length_uncovered) print ("----- no reactions ignored -----") print (", ".join(orig_uncovered)) for (reaction_name, uncovered) in sorted_uncovereds: print ("----- " + reaction_name + " -------") if utils.equal_lists(orig_uncovered, uncovered): print ("no change") else: print (", ".join(uncovered))