Beispiel #1
0
def main(argv=None):

    if argv is None:
        argv = sys.argv

    ids = None
    intIds = None
    blastfileGlob = None
    fastafileGlob = None
    outputfile = None

    try:
        optlist, args = getopt(argv[1:], "hb:f:o:i:")
    except:
        print "Illegal option"
        print ""
        print HELP_STRING
        sys.exit(1)

    for (opt, opt_arg) in optlist:
        if opt == "-h":
            print ""
            print HELP_STRING
            sys.exit(1)
        elif opt == "-i":
            ids = opt_arg.split(",")
            intIds = [int(i) for i in ids]
        elif opt == "-b":
            blastfileGlob = glob(opt_arg)
        elif opt == "-f":
            fastafileGlob = glob(opt_arg)
        elif opt == "-o":
            outputfile = opt_arg

    if not blastfileGlob or not fastafileGlob or not outputfile or not intIds:
        print "You must include the ids to retrieve (-i), blast file (-b), input fasta file (-f) and the output filename (-o)"
        print blastfileGlob, fastafileGlob, outputfile, intIds
        sys.exit(1)

    #print intIds
    pipelineUtils.getFastaForTaxonomy(intIds, blastfileGlob, fastafileGlob, outputfile)
Beispiel #2
0
def doPostProcess(blastResults, fastaInput):
    rootName, extension = os.path.splitext(blastResults)
    bestHitsName = rootName + ".bestHits.bln"
    bestHitsName2 = rootName + ".besthits.bln"
    dp = rootName + ".bubble_"
    reportName = rootName + ".tax_"

    # do best hits
    print >> sys.stderr, 'STEP 5: calculate besthits file'
    print >> sys.stderr, '      : besthits filename: >', bestHitsName, "<"
    print >> sys.stderr, '      : besthits filename: >', bestHitsName2, "<"

    #updated 2015-08-04 so to stop stupid bug from not seeing ".besthits.bln" files, like when copied from DOS
    if os.path.exists(bestHitsName2):
        bestHitsName = bestHitsName2
        print >> sys.stderr, '      : found besthits filename: >', bestHitsName2, "<"

    if not os.path.exists(bestHitsName):
        blastUtils.keepAllBestHits(blastResults, bestHitsName)
    else:
        print >> sys.stderr, '<skip>: besthits file already exists'

    # report taxonomy
    reportTaxonomyJWC(bestHitsName,
                      printTargets=True,
                      outputPrefix=reportName,
                      dotPrefix=dp)

    if fastaInput:
        pipelineUtils.getFastaForTaxonomy([10239], bestHitsName, fastaInput,
                                          rootName + "_viral.fa")
        pipelineUtils.getFastaForTaxonomy([10292], bestHitsName, fastaInput,
                                          rootName + "_herp.fa")
        pipelineUtils.getFastaForTaxonomy([11632], bestHitsName, fastaInput,
                                          rootName + "_retro.fa")
def doPostProcess(blastResults, fastaInput):
    rootName, extension = os.path.splitext(blastResults)
    bestHitsName = rootName + ".bestHits.bln"
    bestHitsName2 = rootName + ".besthits.bln"
    dp = rootName + ".bubble_"
    reportName = rootName + ".tax_"

    # do best hits
    print >> sys.stderr, 'STEP 5: calculate besthits file'
    print >> sys.stderr, '      : besthits filename: >', bestHitsName, "<"
    print >> sys.stderr, '      : besthits filename: >', bestHitsName2, "<"

    #updated 2015-08-04 so to stop stupid bug from not seeing ".besthits.bln" files, like when copied from DOS
    if os.path.exists(bestHitsName2):
        bestHitsName = bestHitsName2
        print >> sys.stderr, '      : found besthits filename: >', bestHitsName2, "<"

    if not os.path.exists(bestHitsName):
        blastUtils.keepAllBestHits(blastResults, bestHitsName)
    else:
        print >> sys.stderr, '<skip>: besthits file already exists'

    # report taxonomy
    reportTaxonomyJWC(bestHitsName, printTargets=True, outputPrefix=reportName, dotPrefix=dp)

    if fastaInput:
        pipelineUtils.getFastaForTaxonomy([10239], bestHitsName, fastaInput, rootName + "_viral.fa")
        pipelineUtils.getFastaForTaxonomy([10292], bestHitsName, fastaInput, rootName + "_herp.fa")
        pipelineUtils.getFastaForTaxonomy([11632], bestHitsName, fastaInput, rootName + "_retro.fa")
Beispiel #4
0
def doPostProcess(blastResults, fastaInput):

    rootName, extension = os.path.splitext(blastResults)
    bestHitsName = rootName + ".bestHits.bln"
    dp = rootName + ".bubble_"
    reportName = rootName + ".tax_"

    # do best hits
    blastUtils.keepAllBestHits(blastResults, bestHitsName)

    # report taxonomy
    pipelineUtils.reportTaxonomy(bestHitsName,
                                 printTargets=True,
                                 outputPrefix=reportName,
                                 dotPrefix=dp)

    if fastaInput:
        pipelineUtils.getFastaForTaxonomy([10239], bestHitsName, fastaInput,
                                          rootName + "_viral.fa")
        pipelineUtils.getFastaForTaxonomy([10292], bestHitsName, fastaInput,
                                          rootName + "_herp.fa")
        pipelineUtils.getFastaForTaxonomy([11632], bestHitsName, fastaInput,
                                          rootName + "_retro.fa")