def filter_rxns_metabs(S, enzymes, rnames, mnames, metab_exclude): rinds = filtered_rxn_inds(rnames) metab_exclude = set(metab_exclude) metab_exclude.add('') minds = [i for i,m in enumerate(mnames) if m not in metab_exclude] print "Keeping %s of %s reactions" % (len(rinds), len(rnames)) print "Keeping %s of %s metabolites" % (len(minds), len(mnames)) newS = S[minds,:] newS = newS[:,rinds] newenz = ut.list_inds(enzymes, rinds) return newS, newenz
def keep_pvals(cxs,pvals,details, max_pval): inds = [i for i,p in enumerate(pvals) if float(p)<max_pval] cxs,pvals,details = [ut.list_inds(lst, inds) for lst in cxs,pvals,details] return cxs,pvals,details