Beispiel #1
0
def genotype(args):
    """
    Genotype structural variants.

    :param args: Command arguments.

    :return: 0 if the command ran successfully, and a non-zero code otherwise.
    """

    print('Genotyping SVs')

    return_code = smrtsvrunner.run_snake_target(
        'rules/genotype.snakefile', args, PROCESS_ENV, SMRTSV_DIR,
        (
            'gt_vcf_write',
            '--config',
            'genotyper_config={}'.format(args.genotyper_config),
            'genotyped_variants={}'.format(args.genotyped_variants),
            'gt_mapq={}'.format(args.gt_mapq),
            'gt_map_cpu={}'.format(args.gt_map_cpu),
            'gt_map_mem={}'.format(args.gt_map_mem),
            'gt_map_disk={}'.format(args.gt_map_disk),
            'gt_map_time={}'.format(args.gt_map_time),
            'gt_keep_temp={}'.format(args.gt_keep_temp)
         )
    )

    if return_code != 0:
        sys.stderr.write('Failed to genotype SVs\n')

    return return_code
Beispiel #2
0
def detect(args):
    """
    Detect SVs from signatures in read alignments.
    """

    print('Detecting variant signatures')

    command = (
        'detect_group_merge_regions',
        '--config',
        'assembly_window_size={}'.format(args.assembly_window_size),
        'assembly_window_slide={}'.format(args.assembly_window_slide),
        'mapping_quality={}'.format(args.mapping_quality),
        'min_length={}'.format(args.min_length),
        'min_support={}'.format(args.min_support),
        'max_support={}'.format(args.max_support),
        'min_coverage={}'.format(args.min_coverage),
        'max_coverage={}'.format(args.max_coverage),
        'min_hardstop_support={}'.format(args.min_hardstop_support),
        'max_candidate_length={}'.format(args.max_candidate_length)
    )

    if args.exclude:
        command = command + ('exclude={}'.format(args.exclude),)

    return smrtsvrunner.run_snake_target('rules/detect.snakefile', args, PROCESS_ENV, SMRTSV_DIR, command, cmd_log='detect/log')
Beispiel #3
0
def assemble(args):
    """
    Assemble candidate regions from raw reads aligned to regions.
    """

    print('Running local assemblies')

    # Quote alignment params
    args.asm_alignment_parameters = '"{}"'.format(
        args.asm_alignment_parameters)

    # Run
    command = ('asm_merge_groups', '--config',
               'asm_alignment_parameters={}'.format(
                   args.asm_alignment_parameters),
               'mapping_quality={}'.format(args.mapping_quality),
               'asm_cpu={}'.format(args.asm_cpu), 'asm_mem={}'.format(
                   args.asm_mem), 'asm_polish={}'.format(args.asm_polish),
               'no_rm_temp={}'.format(args.nt))

    return smrtsvrunner.run_snake_target('rules/assemble.snakefile',
                                         args,
                                         PROCESS_ENV,
                                         SMRTSV_DIR,
                                         command,
                                         cmd_log='assemble/log')
Beispiel #4
0
def index(args):

    print('Preparing reference')

    return smrtsvrunner.run_snake_target(
        'rules/reference.snakefile',
        args,
        PROCESS_ENV,
        SMRTSV_DIR,
        ('ref_all', '--config', 'reference={}'.format(args.reference)),
        cmd_log='reference/log')
Beispiel #5
0
def align(args):

    print('Aligning sequence reads')

    return smrtsvrunner.run_snake_target(
        'rules/align.snakefile',
        args,
        PROCESS_ENV,
        SMRTSV_DIR,
        ('aln_run', '--config', 'reads={}'.format(args.reads),
         'batches={}'.format(args.batches), 'threads={}'.format(args.threads),
         'alignment_parameters="{}"'.format(args.alignment_parameters)),
        cmd_log='align/log')
Beispiel #6
0
def call(args):
    # Call SVs, indels, and inversions.
    sys.stdout.write("Calling variants\n")

    return_code = smrtsvrunner.run_snake_target(
        'rules/call.snakefile',
        args,
        PROCESS_ENV,
        SMRTSV_DIR, ('call_variant_vcf', '--config', 'variants={}'.format(
            args.variants), 'species="{}"'.format(
                args.species), 'sample="{}"'.format(args.sample)),
        cmd_log='call/log')

    if return_code != 0:
        sys.stderr.write('Failed to call variants\n')

    return return_code
Beispiel #7
0
        print('LD_LIBRARY_PATH:')
        for PATH_ELEMENT in process_env['LD_LIBRARY_PATH'].split(':'):
            print('\t* {}'.format(PATH_ELEMENT))

        if 'DRMAA_LIBRARY_PATH' in process_env:
            print('DRMAA_LIBRARY_PATH: {}'.format(
                process_env['DRMAA_LIBRARY_PATH']))
        else:
            print(
                'DRMAA_LIBRARY_PATH: <NOT_SET>\n\t* Not required unless --distribute is set'
            )

        # Print snake command
        print('Snake command:')
        for command_element in snake_command:
            if command_element is not None:
                print('\t* {}'.format(command_element))
            else:
                print('\t- None')

        # Flush output
        sys.stdout.flush()

    # Make log directory for distributed jobs
    if args.distribute:
        os.makedirs('log', exist_ok=True)

    # Run snake target
    smrtsvrunner.run_snake_target(snakefile, args, process_env, smrtsv_dir,
                                  snake_command)