except Exception, inst: sys.stderr.write("Unexpected error opening %s: %s\n" % (infile, inst)) sys.exit() if(verbose): print "Reading " + str(argv[0]) elems = tree.getroot() proteins_percolator= per.getProteins(elems) peptides = per.getPeptides(elems) ntarget_percolator = len([prot for prot in [prot for prot in proteins_percolator if not prot.isdecoy]]) ndecoy_percolator = len([prot for prot in [prot for prot in proteins_percolator if prot.isdecoy]]) print "Found " + str(ntarget_percolator) + " proteins" print "doing parsimony at " + str(fdr) parsimony_tmp = [prot for prot,pep in parsimony.getParsimony(peptides, fdr, True)] ntarget_parsimony = len([prot for prot in parsimony_tmp if prot.find("random") == -1]) ndecoy_parsimony = len([prot for prot in parsimony_tmp if prot.find("random") != -1]) print "Found " + str(ntarget_parsimony) + " proteins at " + str(fdr) + " fdr doing parsimony" print "Computed Gamma is " + str(float(ntarget_parsimony) / float(ntarget_percolator)) if __name__ == "__main__": main(sys.argv[1:])
two_hit_thresholds_unique.append(fdr_2hit_unique) print "Unique two peptide rule gives " + str( ntarget_2peprule_unique) + " target proteins and " + str( ndecoy_2peprule_unique) + " decoy proteins and " + str( fdr_2hit_unique) + " qvalue" if (maxtarget < ntarget_2peprule_unique): maxtarget = ntarget_2peprule_unique if (maxdecoy < ndecoy_2peprule_unique): maxdecoy = ndecoy_2peprule_unique print "doing parsimony at " + str(t) parsimony_tmp = [ prot for prot, pep in parsimony.getParsimony(peptides, t, qvalue) ] ntarget_parsimony = len( [prot for prot in parsimony_tmp if prot.find("random") == -1]) ndecoy_parsimony = len( [prot for prot in parsimony_tmp if prot.find("random") != -1]) parsimony_proteins_target.append(ntarget_parsimony) parsimony_proteins_decoy.append(ndecoy_parsimony) if (num_targets_mayus > 0): tmp_target = float(ntarget_parsimony) / float( num_targets_mayus) else: tmp_target = 0 if (num_decoys_mayus > 0):
if(tmp_target > 0): fdr_2hit_unique = float((tmp_decoy / tmp_target) * prot_fdr_mayus) else: fdr_2hit_unique = 0 two_hit_thresholds_unique.append(fdr_2hit_unique) print "Unique two peptide rule gives " + str(ntarget_2peprule_unique) + " target proteins and " + str(ndecoy_2peprule_unique) + " decoy proteins and " +str(fdr_2hit_unique) + " qvalue" if(maxtarget < ntarget_2peprule_unique): maxtarget = ntarget_2peprule_unique if(maxdecoy < ndecoy_2peprule_unique): maxdecoy = ndecoy_2peprule_unique print "doing parsimony at " + str(t) parsimony_tmp = [prot for prot,pep in parsimony.getParsimony(peptides, t, qvalue)] ntarget_parsimony = len([prot for prot in parsimony_tmp if prot.find("random") == -1]) ndecoy_parsimony = len([prot for prot in parsimony_tmp if prot.find("random") != -1]) parsimony_proteins_target.append(ntarget_parsimony) parsimony_proteins_decoy.append(ndecoy_parsimony) if(num_targets_mayus > 0 ): tmp_target = float(ntarget_parsimony) / float(num_targets_mayus) else: tmp_target = 0 if(num_decoys_mayus > 0 ): tmp_decoy = float(ndecoy_parsimony) / float(num_decoys_mayus) else: tmp_decoy = 0