Exemplo n.º 1
0
def parse_args( args=sys.argv[1:] ):
    import argparse
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['roche_sync']

    parser = argparse.ArgumentParser(
        description='Sync roche run directories into the NGSData data structure',
        parents=[conf_parser]
    )

    parser.add_argument(
        'runpath',
        help='Path to the Roche run directory(/path/to/R_something)'
    )

    parser.add_argument(
        '--ngsdata',
        default=defaults['ngsdata']['default'],
        help=defaults['ngsdata']['help']
    )

    import pkg_resources
    default = defaults['midparse']['default']
    if default is None:
        default = pkg_resources.resource_filename(__name__, 'MidParse.conf')
    parser.add_argument(
        '--midparse',
        default=default,
        help=defaults['midparse']['help']
    )

    return parser.parse_args( args )
Exemplo n.º 2
0
def parse_args(args=sys.argv[1:]):
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['tagreads']

    parser = argparse.ArgumentParser(
        description=
        '''Adds Sanger, MiSeq, 454 and IonTorrent read groups to a bam file.
        Will tag all reads in the alignment for each of the platforms based on the read name''',
        parents=[conf_parser])

    parser.add_argument(dest='bamfiles',
                        nargs='+',
                        help='Bamfile to add read groups to for platforms')

    parser.add_argument('-SM',
                        dest='SM',
                        default=defaults['SM']['default'],
                        help=defaults['SM']['help'])

    parser.add_argument('-CN',
                        dest='CN',
                        default=defaults['CN']['default'],
                        help=defaults['CN']['help'])

    return parser.parse_args(args)
Exemplo n.º 3
0
def parse_args(args=sys.argv[1:]):
    import argparse
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['roche_sync']

    parser = argparse.ArgumentParser(
        description=
        'Sync roche run directories into the NGSData data structure',
        parents=[conf_parser])

    parser.add_argument(
        'runpath',
        help='Path to the Roche run directory(/path/to/R_something)')

    parser.add_argument('--ngsdata',
                        default=defaults['ngsdata']['default'],
                        help=defaults['ngsdata']['help'])

    import pkg_resources
    default = defaults['midparse']['default']
    if default is None:
        default = pkg_resources.resource_filename(__name__, 'MidParse.conf')
    parser.add_argument('--midparse',
                        default=default,
                        help=defaults['midparse']['help'])

    return parser.parse_args(args)
Exemplo n.º 4
0
def parse_args( args=sys.argv[1:] ):
    import argparse

    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['sanger_sync']

    parser = argparse.ArgumentParser(
        description='Syncs Sanger Run_ directories into the NGSData structure',
        parents=[conf_parser]
    )

    
    parser.add_argument(
        '--ngsdata',
        dest='ngsdata',
        default=defaults['ngsdata']['default'],
        help=defaults['ngsdata']['help']
    )

    parser.add_argument(
        'runpath',
        help='Path to Sanger Run_3130xl directory'
    )

    return parser.parse_args( args )
Exemplo n.º 5
0
def parse_args( args=sys.argv[1:] ):
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['tagreads']

    parser = argparse.ArgumentParser(
        description='''Adds Sanger, MiSeq, 454 and IonTorrent read groups to a bam file.
        Will tag all reads in the alignment for each of the platforms based on the read name''',
        parents=[conf_parser]
    )

    parser.add_argument(
        dest='bamfiles',
        nargs='+',
        help='Bamfile to add read groups to for platforms'
    )

    parser.add_argument(
        '-SM',
        dest='SM',
        default=defaults['SM']['default'],
        help=defaults['SM']['help']
    )

    parser.add_argument(
        '-CN',
        dest='CN',
        default=defaults['CN']['default'],
        help=defaults['CN']['help']
    )

    return parser.parse_args( args )
Exemplo n.º 6
0
def parse_args(args=sys.argv[1:]):
    import argparse

    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['sanger_sync']

    parser = argparse.ArgumentParser(
        description='Syncs Sanger Run_ directories into the NGSData structure',
        parents=[conf_parser])

    parser.add_argument('--ngsdata',
                        dest='ngsdata',
                        default=defaults['ngsdata']['default'],
                        help=defaults['ngsdata']['help'])

    parser.add_argument('runpath', help='Path to Sanger Run_3130xl directory')

    return parser.parse_args(args)
Exemplo n.º 7
0
def parse_args():
    conf_parser, args, cfg, configfile = config.get_config_argparse(sys.argv[1:])
    defaults = cfg['ion_sync']

    parser = argparse.ArgumentParser(
        description='Sync roche run directories into the NGSData data structure',
        parents=[conf_parser]
    )

    parser.add_argument(
        'rundir',
        help='Path to IonTorrent or IonProton run which contains' \
            ' an ion_params_00.json file and a ' \
            ' plugin_out/downloads directory with fastq files'
    )

    parser.add_argument(
        '--ngsdata',
        default=defaults['ngsdata']['default'],
        help=defaults['ngsdata']['help']
    )

    parser.add_argument(
        '--print-samplemapping',
        dest='print_samplemapping',
        default=False,
        action='store_true',
        help='Just print the sample mapping for the run and quit'
    )

    parser.add_argument(
        '--min-fastq-size',
        dest='min_fastq_size',
        type=int,
        default=defaults['min_fastq_size']['default'],
        help=defaults['min_fastq_size']['help']
    )

    return parser.parse_args(args)
Exemplo n.º 8
0
def parse_args( args=sys.argv[1:] ):
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['miseq_sync']

    parser = argparse.ArgumentParser(
        description='Sync MiSeq run into the NGSData structure',
        parents=[conf_parser]
    )

    parser.add_argument(
        'runpath',
        help='Path to the run to be synced(/path/to/YYMMDD_)'
    )

    parser.add_argument(
        '--ngsdata',
        default=defaults['ngsdata']['default'],
        help=defaults['ngsdata']['help']
    )

    return parser.parse_args( args )
Exemplo n.º 9
0
def parse_args(args=sys.argv[1:]):
    conf_parser, args, _config, configfile = config.get_config_argparse(args)

    parser = argparse.ArgumentParser(
        description='Runs a single sample through the pipeline',
        parents=[conf_parser])

    parser.add_argument(dest='readsdir',
                        help='Directory that contains reads to be mapped')

    parser.add_argument(dest='reference',
                        help='The path to the reference to map to')

    parser.add_argument(
        dest='prefix',
        help=
        'The prefix to put before every output file generated. Probably the samplename'
    )

    parser.add_argument(
        '-trim_qual',
        dest='trim_qual',
        default=_config['trim_reads']['q']['default'],
        help=_config['trim_reads']['q']['help'],
    )

    parser.add_argument(
        '-head_crop',
        dest='head_crop',
        default=_config['trim_reads']['headcrop']['default'],
        help=_config['trim_reads']['headcrop']['help'],
    )

    parser.add_argument('--primer-file',
                        dest='primer_file',
                        default=_config['trim_reads']['primerfile']['default'],
                        help=_config['trim_reads']['primerfile']['help'])

    parser.add_argument('--primer-seed',
                        dest='primer_seed',
                        default=_config['trim_reads']['primerseed']['default'],
                        help=_config['trim_reads']['primerseed']['help'])

    parser.add_argument(
        '--palindrome-clip',
        dest='palindrom_clip',
        default=_config['trim_reads']['palindromeclip']['default'],
        help=_config['trim_reads']['palindromeclip']['help'])

    parser.add_argument('--simple-clip',
                        dest='simple_clip',
                        default=_config['trim_reads']['simpleclip']['default'],
                        help=_config['trim_reads']['simpleclip']['help'])

    minth_default = 0.8
    parser.add_argument(
        '-minth',
        dest='minth',
        default=_config['base_caller']['minth']['default'],
        help=_config['base_caller']['minth']['help'],
    )

    parser.add_argument(
        '--CN',
        dest='CN',
        default=_config['tagreads']['CN']['default'],
        help=_config['tagreads']['CN']['help'],
    )

    parser.add_argument(
        '--index-min',
        dest='index_min',
        default=_config['ngs_filter']['indexQualityMin']['default'],
        help=_config['ngs_filter']['indexQualityMin']['help'],
    )

    parser.add_argument(
        '--drop-ns',
        dest='drop_ns',
        action='store_true',
        default=_config['ngs_filter']['dropNs']['default'],
        help=_config['ngs_filter']['dropNs']['help'],
    )

    parser.add_argument(
        '--platforms',
        dest='platforms',
        default=_config['ngs_filter']['platforms']['default'],
        help=_config['ngs_filter']['platforms']['help'],
    )

    default_outdir = os.getcwd()
    parser.add_argument(
        '-od',
        '--outdir',
        dest='outdir',
        default=default_outdir,
        help='The output directory for all files to be put[Default: {0}]'.
        format(default_outdir))

    args, rest = parser.parse_known_args(args)
    args.config = configfile

    # Parse qsub args if found
    if rest and rest[0].startswith('--qsub'):
        qsub_parser = argparse.ArgumentParser(add_help=False)
        qsub_parser.add_argument('--qsub-help',
                                 default=False,
                                 action='store_true')
        qsub_parser.add_argument(
            '--qsub_l',
            default='nodes=1:ppn=1',
        )
        qsub_parser.add_argument('--qsub_M', default=None)

        qsub_args = qsub_parser.parse_args(rest)

        if qsub_args.qsub_help:
            qsub_parser.print_help()
            sys.exit(1)
        rest = qsub_args

    return args, rest
Exemplo n.º 10
0
def parse_args( args=sys.argv[1:] ):
    '''
        Uses argparse to parse arguments

        @params args - List of command line arguments to parse

        @returns Namespace object with parsed args in it(Same as ArgumentParser.parse_args)
    '''
    import argparse

    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['run_bwa_on_samplename']

    parser = argparse.ArgumentParser(
        description='Runs the bwa mem argument on a given set of reads and references for the given platform\'s reads',
        epilog='You should consider this script an autonomous bwa operation. That is, it will select the reads for ' \
            'the platforms you select and it will pull those reads onto the current host. It will ' \
            'compile references if they are multiple ones in a directory you select onto the local computer. Then it ' \
            'will map any mated reads against to those refs and also map the nonpaired reads against that ref in a separate ' \
            'call. Then when both are finished it will convert to bam/sort/index/merge/reindex the results. It attempts all of ' \
            'this inside of the /dev/shm filesystem which should be very fast. If /dev/shm cannot be used then /tmp will be used. '\
            'If you want the temporary files that are created to stay then you can use the --keep-temp argument',
        parents=[conf_parser]
    )
    
    parser.add_argument(
        dest='reads',
        help='Location to a directory containing fastq read files'
    )

    parser.add_argument(
        dest='reference',
        help='Location of the reference to map to. Should be a fasta file or directory of fasta files that will be compiled together.'
    )

    parser.add_argument(
        '--platforms',
        dest='platforms',
        nargs='+',
        choices=defaults['platforms']['choices'],
        default=defaults['platforms']['default'],
        help=defaults['platforms']['help']
    )

    parser.add_argument(
        '-o',
        '--output',
        dest='output',
        default=defaults['output']['default'],
        help=defaults['output']['default']
    )

    parser.add_argument(
        '--keep-temp',
        dest='keep_temp',
        action='store_true',
        default=defaults['keep_temp']['default'],
        help=defaults['keep_temp']['help']
    )

    parser.add_argument(
        '-t',
        dest='threads',
        default=defaults['threads']['default'],
        type=int,
        help=defaults['threads']['help']
    )

    return parser.parse_args( args )
Exemplo n.º 11
0
def parse_args(args=sys.argv[1:]):
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['base_caller']

    parser = argparse.ArgumentParser(
        description = 'Generates a VCF that has called bases in it which follow ' \
            'the WRAIR VDB SOP for calling bases',
        epilog = '''WRAIR VDB Base Calling SOP:
            Depth < 10:
                All bases with base quality < 25 get set to N
                Then the base is called on the percentage(See below)
            Depth > 10:
                All bases with base quality < 25 get removed
                Then the base is called on the percentage(See below)

            Calling on Percentage:
                Any base with >= 80% majority is called
                    - or -
                N is called if the depth was < 10 and N is > 20%
                    - or -
                The specific IUPAC ambiguious base is called for all bases over
                 20%
                    - or -
                The majority base is called
        ''',
        parents=[conf_parser]
   )

    parser.add_argument(
        dest='bamfile',
        help='The bam file to generate the vcf for'
   )

    parser.add_argument(
        dest='reffile',
        help='The reference file(has to have an fai index already built)'
   )

    parser.add_argument(
        dest='vcf_output_file',
        help='Where to save the vcf'
   )

    parser.add_argument(
        '-r',
        '--regionstr',
        dest='regionstr',
        default=defaults['regionstr']['default'],
        help=defaults['regionstr']['help']
   )

    parser.add_argument(
        '-minbq',
        dest='minbq',
        default=defaults['minbq']['default'],
        type=int,
        help=defaults['minbq']['help']
   )

    parser.add_argument(
        '-maxd',
        dest='maxd',
        default=defaults['maxd']['default'],
        type=int,
        help=defaults['maxd']['help']
   )

    parser.add_argument(
        '-mind',
        dest='mind',
        default=defaults['mind']['default'],
        type=int,
        help=defaults['mind']['help']
   )

    parser.add_argument(
        '-minth',
        dest='minth',
        default=defaults['minth']['default'],
        type=float,
        help=defaults['minth']['help']
   )

    parser.add_argument(
        '-biasth',
        dest='biasth',
        default=defaults['biasth']['default'],
        type=float,
        help=defaults['biasth']['help']
   )

    parser.add_argument(
        '-bias',
        dest='bias',
        default=defaults['bias']['default'],
        type=int,
        help=defaults['bias']['help']
   )

    parser.add_argument(
        '--threads',
        default=defaults['threads']['default'],
        type=int,
        help=defaults['threads']['help']
   )

    args = parser.parse_args(args)
    if args.vcf_output_file is None:
        args.vcf_output_file = args.bamfile + '.vcf'

    return args
Exemplo n.º 12
0
def parse_args( args=sys.argv[1:] ):
    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['trim_reads']

    parser = argparse.ArgumentParser(
        parents=[conf_parser],
        description='Trims reads'
    )

    parser.add_argument(
        dest='readsdir',
        help='Read or directory of read files'
    )

    parser.add_argument(
        '-q',
        dest='q',
        default=defaults['q']['default'],
        help=defaults['q']['help']
    )

    parser.add_argument(
        '--head-crop',
        dest='headcrop',
        default=defaults['headcrop']['default'],
        help=defaults['headcrop']['help']
    )

    parser.add_argument(
        '-o',
        dest='outputdir',
        default=defaults['outputdir']['default'],
        help=defaults['outputdir']['help']
    )

    parser.add_argument(
        '--platforms',
        dest='platforms',
        choices=defaults['platforms']['choices'],
        default=defaults['platforms']['default'],
        help=defaults['platforms']['help']
    )

    parser.add_argument(
        '--primer-file',
        dest='primer_file',
        default=defaults['primerfile']['default'],
        help=defaults['primerfile']['help']
    )

    parser.add_argument(
        '--primer-seed',
        dest='primer_seed',
        default=defaults['primerseed']['default'],
        help=defaults['primerseed']['help']
    )

    parser.add_argument(
        '--palindrome-clip',
        dest='palindrom_clip',
        default=defaults['palindromeclip']['default'],
        help=defaults['palindromeclip']['help']
    )

    parser.add_argument(
        '--simple-clip',
        dest='simple_clip',
        default=defaults['simpleclip']['default'],
        help=defaults['simpleclip']['help']
    )

    return parser.parse_args( args )
Exemplo n.º 13
0
def parse_args( args=sys.argv[1:] ):
    conf_parser, args, _config, configfile = config.get_config_argparse(args)

    parser = argparse.ArgumentParser(
        description='Runs a single sample through the pipeline',
        parents=[conf_parser]
    )

    parser.add_argument(
        dest='readsdir',
        help='Directory that contains reads to be mapped'
    )

    parser.add_argument(
        dest='reference',
        help='The path to the reference to map to'
    )

    parser.add_argument(
        dest='prefix',
        help='The prefix to put before every output file generated. Probably the samplename'
    )

    parser.add_argument(
        '-trim_qual',
        dest='trim_qual',
        default=_config['trim_reads']['q']['default'],
        help=_config['trim_reads']['q']['help'],
    )

    parser.add_argument(
        '-head_crop',
        dest='head_crop',
        default=_config['trim_reads']['headcrop']['default'],
        help=_config['trim_reads']['headcrop']['help'],
    )

    parser.add_argument(
        '--primer-file',
        dest='primer_file',
        default=_config['trim_reads']['primerfile']['default'],
        help=_config['trim_reads']['primerfile']['help']
    )

    parser.add_argument(
        '--primer-seed',
        dest='primer_seed',
        default=_config['trim_reads']['primerseed']['default'],
        help=_config['trim_reads']['primerseed']['help']
    )

    parser.add_argument(
        '--palindrome-clip',
        dest='palindrom_clip',
        default=_config['trim_reads']['palindromeclip']['default'],
        help=_config['trim_reads']['palindromeclip']['help']
    )

    parser.add_argument(
        '--simple-clip',
        dest='simple_clip',
        default=_config['trim_reads']['simpleclip']['default'],
        help=_config['trim_reads']['simpleclip']['help']
    )

    minth_default=0.8
    parser.add_argument(
        '-minth',
        dest='minth',
        default=_config['base_caller']['minth']['default'],
        help=_config['base_caller']['minth']['help'],
    )

    parser.add_argument(
        '--CN',
        dest='CN',
        default=_config['tagreads']['CN']['default'],
        help=_config['tagreads']['CN']['help'],
    )

    parser.add_argument(
        '--index-min',
        dest='index_min',
        default=_config['ngs_filter']['indexQualityMin']['default'],
        help=_config['ngs_filter']['indexQualityMin']['help'],
    )

    parser.add_argument(
        '--drop-ns',
        dest='drop_ns',
        action='store_true',
        default=_config['ngs_filter']['dropNs']['default'],
        help=_config['ngs_filter']['dropNs']['help'],
    )

    parser.add_argument(
        '--platforms',
        dest='platforms',
        default=_config['ngs_filter']['platforms']['default'],
        help=_config['ngs_filter']['platforms']['help'],
    )

    default_outdir = os.getcwd()
    parser.add_argument(
        '-od',
        '--outdir',
        dest='outdir',
        default=default_outdir,
        help='The output directory for all files to be put[Default: {0}]'.format(default_outdir)
    )

    args, rest = parser.parse_known_args(args)
    args.config = configfile

    # Parse qsub args if found
    if rest and rest[0].startswith('--qsub'):
        qsub_parser = argparse.ArgumentParser(add_help=False)
        qsub_parser.add_argument(
            '--qsub-help',
            default=False,
            action='store_true'
        )
        qsub_parser.add_argument(
            '--qsub_l',
            default='nodes=1:ppn=1',
        )
        qsub_parser.add_argument(
            '--qsub_M',
            default=None
        )

        qsub_args = qsub_parser.parse_args(rest)

        if qsub_args.qsub_help:
            qsub_parser.print_help()
            sys.exit(1)
        rest = qsub_args

    return args, rest
Exemplo n.º 14
0
def parse_args(args=sys.argv[1:]):
    '''
        Uses argparse to parse arguments

        @params args - List of command line arguments to parse

        @returns Namespace object with parsed args in it(Same as ArgumentParser.parse_args)
    '''
    import argparse

    from ngs_mapper import config
    conf_parser, args, config, configfile = config.get_config_argparse(args)
    defaults = config['run_bwa_on_samplename']

    parser = argparse.ArgumentParser(
        description='Runs the bwa mem argument on a given set of reads and references for the given platform\'s reads',
        epilog='You should consider this script an autonomous bwa operation. That is, it will select the reads for ' \
            'the platforms you select and it will pull those reads onto the current host. It will ' \
            'compile references if they are multiple ones in a directory you select onto the local computer. Then it ' \
            'will map any mated reads against to those refs and also map the nonpaired reads against that ref in a separate ' \
            'call. Then when both are finished it will convert to bam/sort/index/merge/reindex the results. It attempts all of ' \
            'this inside of the /dev/shm filesystem which should be very fast. If /dev/shm cannot be used then /tmp will be used. '\
            'If you want the temporary files that are created to stay then you can use the --keep-temp argument',
        parents=[conf_parser]
    )

    parser.add_argument(
        dest='reads',
        help='Location to a directory containing fastq read files')

    parser.add_argument(
        dest='reference',
        help=
        'Location of the reference to map to. Should be a fasta file or directory of fasta files that will be compiled together.'
    )

    parser.add_argument('--platforms',
                        dest='platforms',
                        nargs='+',
                        choices=defaults['platforms']['choices'],
                        default=defaults['platforms']['default'],
                        help=defaults['platforms']['help'])

    parser.add_argument('-o',
                        '--output',
                        dest='output',
                        default=defaults['output']['default'],
                        help=defaults['output']['default'])

    parser.add_argument('--keep-temp',
                        dest='keep_temp',
                        action='store_true',
                        default=defaults['keep_temp']['default'],
                        help=defaults['keep_temp']['help'])

    parser.add_argument('-t',
                        dest='threads',
                        default=defaults['threads']['default'],
                        type=int,
                        help=defaults['threads']['help'])

    return parser.parse_args(args)