def main():
    """
    Map samples with the selected method(s)
    """
    # Load parameters and optional command line input to overwrite config.yaml
    params, args = ll.load_params_and_input("map")
    mappers = {"bwa": bwa, "bowtie": bowtie}
    os.makedirs(params["paths"]["map"], exist_ok=True)

    # Returns a list of [path, sampleID] for each sample to assemble
    # From command line input (-s or -d or config file)
    if args.sample:
        samples_to_assemble = [[args.sample, args.sample.rsplit('/', 1)[1]]]
    else:
        samples_to_assemble = ll.paths_and_samples(
            params["paths"]["reads_to_map"])

    # Map all samples with all active mapping methods from config file:
    for method in params["methods"]["map"]:
        for sample in samples_to_map:
            outdir = ll.make_dir("{0}{1}".format(params["paths"]["map"],
                                                 sample[1]))
            job_script = "{0}/{1}.{2}.sh".format(
                outdir.rsplit('/', 1)[0], sample[1], method)
            # Write job script:
            with open(job_script, "w") as file_out:
                msub_lines = ll.fill_header(job_script, params)
                msub_lines += mappers[method](params, sample, outdir)
                for line in msub_lines:
                    file_out.write(line)
            if params["sub"] in (
                    True, "True", "T", "true",
                    1):  #Move str->bool conversion to ll.parse_argument
                ll.submit_job(job_script)
def main():
    # Parse arguments
    params, args = ll.load_params_and_input(None)

    # Map method argument to cleanup function
    run_cleanup = {"megahit" : megahit, "idba" : idba}

    # Get all samples to cleanup:
    cleanup_folders = ll.paths_and_samples(args.directory)

    # Run cleanup scripts:
    for sample in cleanup_folders:
        run_cleanup[args.methods](sample[0].rstrip('/'))
def main():
    """Anotate sample contigs with prokka using default settings + metagenome option"""
    params, args = ll.load_params_and_input(None)
    os.makedirs(params["paths"]["annotations"], exist_ok=True)

    # Annotate the same assemblies we mapped to earlier in the pipeline:
    samples_to_annotate = ll.paths_and_samples(params["paths"]["reads_to_map"])

    for sample in samples_to_annotate:
        outdir = ll.make_dir("{0}{1}".format(params["paths"]["annotations"], sample[1]))
        job_script = "{0}/{1}.prokka.sh".format(outdir.rsplit('/',1)[0], sample[1])

        # Write job script:
        with open(job_script, "w") as file_out:
            msub_lines = ll.fill_header(job_script, params)
            msub_lines += prokka(params, sample, outdir)
            for line in msub_lines:
                file_out.write(line)
        if params["sub"] in (True, "True", "T", "true", 1): #TODO: Move str->bool conversion to ll.parse_argument
            ll.submit_job(job_script)
示例#4
0
def main():
    """
    Map samples with the selected method(s)
    """
    params, args = ll.load_params_and_input("map")
    os.makedirs(params["path_out"]["co_assembly_map"], exist_ok=True)
    samples_to_map = ll.paths_and_samples(params["paths"]["reads_to_map"])

    for sample in samples_to_map:
        outdir = ll.make_dir("{0}{1}".format(params["path_out"]["co_assembly_map"], sample[1]))
        job_script = "{0}/{1}.{2}.sh".format(outdir.rsplit('/',1)[0], sample[1], "BWA_co_assembly")

        # Write job script:
        with open(job_script, "w") as file_out:
            msub_lines = ll.fill_header(job_script, params)
            msub_lines += BWA_co(params, sample, outdir, params["paths"]["co_index"])
            for line in msub_lines:
                file_out.write(line)
        if params["sub"] in (True, "True", "T", "true", 1): #Move str->bool conversion to ll.parse_argument
            ll.submit_job(job_script)
def main():
    """ Make directories, parse input
        Create a job submission script,
        Write standard header
        Write checkM lineage workflow commands
        Submit job if sub parameter is True
    """
    params, args = ll.load_params_and_input(None)
    os.makedirs(params["paths"]["checkM"], exist_ok=True)
    os.makedirs(params["paths"]["jobs"], exist_ok=True)

    now = datetime.datetime.strftime(datetime.datetime.now(), '%d_%m_%Y-%H-%M')
    job_script = "{0}/checkM_job_{1}.sh".format(params["paths"]["jobs"], now)

    with open(job_script, "w") as file_out:
        msub_lines = ll.fill_header(job_script, params)
        msub_lines += lineage_wf_wrapper(args, params)
        for line in msub_lines:
            file_out.write(line)
        if params["sub"] in (True, "True", "T", "true", 1):
            ll.submit_job(job_script)
示例#6
0
def main():
    params, args = ll.load_params_and_input("assembly")
    contig_names = {"idba" : "contig.fa",
                    "megahit" : "final.contigs.fa"}
    # If -sample is passed, just check assembly stats for that file,
    # otherwise expand the directory based on config or -directory
    if args.sample is None:
        quast_list = []
        for method in params["methods"]["assembly"]:
            samples = ll.paths_and_samples("{0}{1}/".format(params["paths"]["assembly"], method))
            full_paths =  ["{}/{}".format(x[0], contig_names[method]) for x in samples]
            quast_list.extend(full_paths)
        files_to_quast = " ".join(quast_list)
    else:
        file_to_quast = args.sample

    if not os.path.exists(params["paths"]["quast_out"]):
        os.makedirs(params["paths"]["quast_out"])

    timestamp = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d')
    job_script = "{0}{1}.quast.sh".format(params["paths"]["quast_out"], timestamp)
    #Actually it's easier to just run on a head node.
    header_info = ll.fill_header(job_script, params)

    # Could add support/option for metaquast later, I mostly found it useless.
    quast_lines = ["{0} {1} -o {2} --threads {3} -L".format(
                                                        params["binaries"]["quast"]
                                                        files_to_quast,
                                                        params["paths"]["quast_out"],
                                                        params["num_threads"])]
    # Write job script
    cmd_lines = header_info + quast_lines
    with open(job_script, 'w') as file_out:
        for line in cmd_lines:
            file_out.write(line)

    if params["sub"] is True:
        ll.submit_job(job_script)