Esempio n. 1
0
def main(argv):
    if (len(argv) < 1):
        sys.stderr.write("Error: Number of arguments incorrect\n")
        usage()
        sys.exit()
    else:
        OutputFile = "output_fido.txt"
        decoy_prefix = ""
        verbose = False
        try:
            opts, args = getopt.getopt(
                sys.argv[2:], "o:p:hv",
                ["output=", "pattern=", "help", "verbose"])
        except getopt.GetoptError, err:
            # print help information and exit:
            print str(
                err)  # will print something like "option -a not recognized"
            usage()
            sys.exit(2)

        for o, a in opts:
            if o == "-v":
                verbose = True
            elif o in ("-h", "--help"):
                usage()
                sys.exit()
            elif o in ("-o", "--output"):
                OutputFile = a
            elif o in ("-p", "--pattern"):
                decoy_prefix = a
            else:
                assert False, "unhandled option"

        if (os.path.isfile(argv[0])):
            infile = argv[0]
        else:
            sys.stderr.write("Error: file not found\n")
            sys.exit()

        if (verbose):
            print "Reading " + str(argv[0])

        fidoproteins = utils.readFidoOuput(infile, decoy_prefix)

        if (len(fidoproteins) > 0):
            if (verbose):
                print "writing in " + str(OutputFile)
            utils.writeProteins([v for k, v in fidoproteins.items()],
                                OutputFile)
        else:
            sys.stderr.write("the input file does not contain any information")
            sys.exit()

        if (verbose):
            print "Fido file parsed"
Esempio n. 2
0
def main(argv):
    if( len(argv) < 1):
        sys.stderr.write("Error: Number of arguments incorrect\n")
        usage()
        sys.exit()
    else:
        OutputFile = "output_fido.txt"
        decoy_prefix = ""
        verbose = False
        try:
            opts, args = getopt.getopt(sys.argv[2:], "o:p:hv", ["output=","pattern=", "help", "verbose"])
        except getopt.GetoptError, err:
            # print help information and exit:
            print str(err) # will print something like "option -a not recognized"
            usage()
            sys.exit(2)
        
        for o, a in opts:
            if o == "-v":
                verbose = True
            elif o in ("-h", "--help"):
                usage()
                sys.exit()
            elif o in ("-o", "--output"):
                OutputFile = a
            elif o in ("-p", "--pattern"):
                decoy_prefix = a
            else:
                assert False, "unhandled option"
        
        if(os.path.isfile(argv[0])):
            infile = argv[0]
        else:
            sys.stderr.write("Error: file not found\n")
            sys.exit()
                
        if(verbose):
            print "Reading " + str(argv[0])   
                         
        fidoproteins = utils.readFidoOuput(infile,decoy_prefix)

        if(len(fidoproteins) > 0):
            if(verbose):
                print "writing in " + str(OutputFile)
            utils.writeProteins([v for k,v in fidoproteins.items()],OutputFile)
        else:
            sys.stderr.write("the input file does not contain any information")
            sys.exit()
        
        if(verbose):
            print "Fido file parsed"
Esempio n. 3
0
                psm for psm in percolatorPSMs if psm.qvalue <= fdr
            ]
            percolatorPeptides = [
                pep for pep in percolatorPeptides if pep.qvalue <= fdr
            ]
            percolatorProteins = [
                prot for prot in percolatorProteins if prot.qvalue <= fdr
            ]

        if (len(percolatorPSMs) > 0):
            if (verbose):
                print "writing in " + str(OutputFile)
            utils.writePsms(percolatorPSMs, "psms_" + OutputFile)
            if (len(percolatorPeptides) > 0):
                utils.writePeptides(percolatorPeptides,
                                    "peptides_" + OutputFile)
            if (len(percolatorProteins) > 0):
                utils.writeProteins(percolatorProteins,
                                    "proteins_" + OutputFile)
        else:
            sys.stderr.write(
                "the input file does not contain any information\n")
            sys.exit()

        if (verbose):
            print "Percolator file parsed"


if __name__ == "__main__":
    main(sys.argv[1:])
        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 = [prot for prot in percolatorProteins if prot.qvalue <= fdr]
          
        if(len(percolatorPSMs) > 0):
            if(verbose):
                print "writing in " + str(OutputFile)   
            utils.writePsms(percolatorPSMs, "psms_" + OutputFile)
            if(len(percolatorPeptides) > 0):
                utils.writePeptides(percolatorPeptides,"peptides_" + OutputFile)
            if(len(percolatorProteins) > 0):
                utils.writeProteins(percolatorProteins,"proteins_" + OutputFile)
        else:
            sys.stderr.write("the input file does not contain any information\n")
            sys.exit()
        
        if(verbose):
            print "Percolator file parsed"
            
if __name__ == "__main__":
    main(sys.argv[1:]) 
    
            tree2 = etree.parse(infile2,parser)
            
        except Exception, inst:
            sys.stderr.write("Unexpected error opening %s or %s: %s\n" % (infile,infile2, inst))
            sys.exit()
             
        if(verbose):
            print "Reading " + str(argv[0])   
            print "Reading " + str(argv[1])  
                         
        elems = tree.getroot()
        elems2 = tree2.getroot()
        tppPSMs,tppPeptides = tpp.readIprophetPSMsPeptides(elems,decoy_prefix)
        tppProteins = tpp.readIprophetProteins(elems2,decoy_prefix)

        if(len(tppPSMs) > 0 and len(tppPeptides) > 0 and len(tppProteins) > 0):
            if(verbose):
                print "writing in " + str(OutputFile)   
            utils.writePsms(tppPSMs, "psms_" + OutputFile)
            utils.writePeptides(tppPeptides,"peptides_" + OutputFile)
            utils.writeProteins(tppProteins,"proteins_" + OutputFile)
        else:
            sys.stderr.write("\nThe input files does not contain any information\n")
            sys.exit()
        
        if(verbose):
            print "iProphet and Protein Prophet files parsed"
            
if __name__ == "__main__":
    main(sys.argv[1:]) 
    
Esempio n. 6
0
            sys.exit()

        if (verbose):
            print "Reading " + str(argv[0])
            print "Reading " + str(argv[1])

        elems = tree.getroot()
        elems2 = tree2.getroot()
        tppPSMs, tppPeptides = tpp.readIprophetPSMsPeptides(
            elems, decoy_prefix)
        tppProteins = tpp.readIprophetProteins(elems2, decoy_prefix)

        if (len(tppPSMs) > 0 and len(tppPeptides) > 0
                and len(tppProteins) > 0):
            if (verbose):
                print "writing in " + str(OutputFile)
            utils.writePsms(tppPSMs, "psms_" + OutputFile)
            utils.writePeptides(tppPeptides, "peptides_" + OutputFile)
            utils.writeProteins(tppProteins, "proteins_" + OutputFile)
        else:
            sys.stderr.write(
                "\nThe input files does not contain any information\n")
            sys.exit()

        if (verbose):
            print "iProphet and Protein Prophet files parsed"


if __name__ == "__main__":
    main(sys.argv[1:])