Ejemplo n.º 1
0
            sys.exit()
        
        parser = etree.XMLParser(ns_clean=False, huge_tree=True)
        try:
            tree = etree.parse(infile,parser)
        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()     

        ##READING ELEMENTS##
        peptides = per.getPeptides(elems)
        print "Read " + str(len(peptides)) + " peptides"
        if(qvalue):
            peptides = [peptide for peptide in peptides if peptide.qvalue <= float(fdr)]
        else:
            peptides = [peptide for peptide in peptides if peptide.pep <= float(fdr)]
        print "There are " + str(len(peptides)) + " peptides at " +str(fdr) + " threshold"
        proteins_filter = getProteins(peptides)
        proteins_filter_unique = getProteinsUnique(peptides)
        print "\nWriting results to " + outfile
        outf = open(outfile, "w")
        outf2 = open("unique_" + outfile, "w")
        outf.write("Protein\tProbability\tPeptides\n")
        outf2.write("Protein\tProbability\tPeptides\n")
        
        for protein in proteins_filter:
     sys.stderr.write("Error: XML file not found\n")
     sys.exit()
         
 parser = etree.XMLParser(ns_clean=False, huge_tree=True)
 try:
     tree = etree.parse(infile,parser)
 except Exception, inst:
     sys.stderr.write("Unexpected error opening %s: %s\n" % (infile, inst))
     sys.exit()
      
 if(verbose):
     print "Reading " + str(argv[0])
     print "Reading " + str(argv[1])   
                  
 elems = tree.getroot()
 percolatorPeptides = per.getPeptides(elems)
 uniquePeptides = set([pept.peptide for pept in percolatorPeptides])
 prosolvePeptides = list()
 f = open(infile2).readlines()
 #(self,isdecoy=False,pep=0.0,q=0.0,empq=0.0,p=0.0,sequence="",score=0.0,psms=[],proteins=[]):
 for line in f:
     words = line.split()
     prob = float(words[0])
     sequence = str(words[1])
     proteins = list(words[2:])
     isdecoy = False
     if(str(proteins[0]).find(decoy_pattern) != -1 ):
         isdecoy = True
     peptide = hit.Peptide(isdecoy,float(1 - prob),float(0.0),float(0.0),float(0.0),str(sequence),float(prob),[],proteins)
     if(sequence in uniquePeptides):
         prosolvePeptides.append(peptide)
Ejemplo n.º 3
0
        parser = etree.XMLParser(ns_clean=False, huge_tree=True)
        try:
            tree = etree.parse(infile, parser)
        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()

        percolatorPSMs = per.getPSMs(elems)
        percolatorPeptides = per.getPeptides(elems)
        percolatorProteins = per.getProteins(elems)

        if (verbose):
            print "Read " + str(len(percolatorPSMs)) + " PSMs"
            print "Read " + str(len(percolatorPeptides)) + " Peptides"
            print "Read " + str(len(percolatorProteins)) + " Proteins"

        if (fdr < 1.0 and fdr > 0.0):
            percolatorPSMs = [
                psm for psm in percolatorPSMs if psm.qvalue <= fdr
            ]
            percolatorPeptides = [
                pep for pep in percolatorPeptides if pep.qvalue <= fdr
            ]
            percolatorProteins = [