Пример #1
0
def run_gast2tax(args):

    #sys.path.append("/xraid2-2/vampsweb/"+args.site+"/")

    #from pipeline.utils import *
    from pipeline.gast import Gast
    import pipeline.constants as C

    if os.path.exists(
            args.names_file) and os.path.getsize(args.names_file) > 0:

        class expando(object):
            pass

        runobj = expando()
        runobj.output_dir = ''
        runobj.use_cluster = True
        runobj.user = ''
        runobj.run = ''
        # for vamps this has to be True and empty list
        print 'VUU ', args.vamps_user_upload
        runobj.vamps_user_upload = args.vamps_user_upload
        runobj.platform = args.platform
        runobj.site = args.site
        key = args.key

        runobj.datasets = []

        mygast = Gast(run_object=runobj)

        (refdb, taxdb) = mygast.get_reference_databases(args.dna_region)

        #print tax_file
        max_gast_distance = C.max_gast_distance['default']
        if args.dna_region in C.max_gast_distance:
            max_gast_distance = C.max_gast_distance[args.dna_region]

        ref_taxa = mygast.load_reftaxa(taxdb)

        mygast.assign_taxonomy(key, args.gast_dir, args.dna_region,
                               args.names_file, ref_taxa)
Пример #2
0
def gast(runobj):
    logger.info("STARTING GAST()")
    #     logger.info("vsearch version: " % utils.get_vsearch_version)
    # for vamps 'new_lane_keys' will be prefix
    # of the uniques and names file
    # that was just created in vamps_gast.py
    # or we can get the 'lane_keys' directly from the config_file
    # for illumina:
    # a unique idx_key is a concatenation of barcode_index and run_key
    # Should return a list not a string
    idx_keys = get_keys(runobj)

    # get GAST object
    mygast = Gast(runobj, idx_keys)

    # Check for unique files and create them if not there
    result_code = mygast.check_for_unique_files(idx_keys)
    runobj.run_status_file_h.write(json.dumps(result_code) + "\n")
    if result_code['status'] == 'ERROR':
        logger.error("uniques not found failed")
        if runobj.vamps_user_upload:
            write_status_to_vamps_db(runobj.site, runobj.run, "GAST ERROR",
                                     "uniques file not found - failed")
        sys.exit("uniques not found failed")
    elif runobj.vamps_user_upload:
        write_status_to_vamps_db(runobj.site, runobj.run,
                                 result_code['status'], result_code['message'])

    sleep(5)

    # CLUSTERGAST
    result_code = mygast.clustergast()
    runobj.run_status_file_h.write(json.dumps(result_code) + "\n")
    if result_code['status'] == 'ERROR':
        logger.error("clutergast failed")
        if runobj.vamps_user_upload:
            write_status_to_vamps_db(runobj.site, runobj.run, "GAST ERROR",
                                     "clustergast failed")
        sys.exit("clustergast failed")
    elif runobj.vamps_user_upload:
        write_status_to_vamps_db(runobj.site, runobj.run,
                                 result_code['status'], result_code['message'])

    sleep(5)

    # GAST_CLEANUP
    result_code = mygast.gast_cleanup()
    runobj.run_status_file_h.write(json.dumps(result_code) + "\n")
    if result_code['status'] == 'ERROR':
        logger.error("gast_cleanup failed")
        if runobj.vamps_user_upload:
            write_status_to_vamps_db(runobj.site, runobj.run, "GAST ERROR",
                                     "gast_cleanup failed")
        sys.exit("gast_cleanup failed")
    elif runobj.vamps_user_upload:
        write_status_to_vamps_db(runobj.site, runobj.run,
                                 result_code['status'], result_code['message'])

    sleep(5)

    # GAST2TAX
    result_code = mygast.gast2tax()
    runobj.run_status_file_h.write(json.dumps(result_code) + "\n")
    if result_code['status'] == 'ERROR':
        logger.error("gast2tax failed")
        if runobj.vamps_user_upload:
            write_status_to_vamps_db(runobj.site, runobj.run, "GAST ERROR",
                                     "gast2tax failed")
        sys.exit("gast2tax failed")
    elif runobj.vamps_user_upload:
        write_status_to_vamps_db(runobj.site, runobj.run,
                                 result_code['status'], result_code['message'])