%prog freebayes prefix ref.fa *.bam

    Call SNPs using freebayes.
1435
def freebayes(args):
    
    p = OptionParser(freebayes.__doc__)
    p.add_option("--mindepth", default=3, type="int",
                 help="Minimum depth [default: %default]")
    p.add_option("--minqual", default=20, type="int",
                 help="Minimum quality [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) < 2:
        sys.exit(not p.print_help())

    prefix, ref = args[0:2]
    bams = args[2:]
    cmd = "bamaddrg -R {0}"
    cmd += " " + " ".join("-b {0}".format(x) for x in bams)
    fmd = "freebayes --stdin -C {0} -f {1}".format(opts.mindepth, ref)
    seqids = list(Fasta(ref).iterkeys_ordered())
    for s in seqids:
        outfile = prefix + ".{0}.vcf".format(s)
        print(cmd.format(s), "|", fmd + " -r {0} -v {1}".format(s, outfile))
846444
def _map_arguments(self, args):
        
        data = args.get('data')
        comp = args.get('comp')
        library = args.get('library')
        dry_run = args.get('dry_run', False)

        self._set_link('sum-rings', SumRings_SG,
                       library=library,
                       outdir=args['outdir'],
                       dry_run=dry_run)

        self._set_link('srcmaps-diffuse', SrcmapsDiffuse_SG,
                       comp=comp, data=data,
                       library=library,
                       make_xml=args['make_xml'],
                       dry_run=dry_run)

        self._set_link('vstack-diffuse', Vstack_SG,
                       comp=comp, data=data,
                       library=library,
                       dry_run=dry_run)
62227
function _from_args (opts, cfg_so_far, cb) {
  var args = parseArgs (opts.input || (process.argv.slice(2))); 
  var ka = [];
  var va = [];

  _.forEach (args, function (v, k) {
    if (k == '_') return;

    // change __ into . in k
    k = k.replace (/__/g, '.');

    if (opts.regexp && !(k.match (opts.regexp))) return;
    if (opts.prefix && !(_.startsWith (k, opts.prefix))) return;

    if (opts.prefix) k = k.substr (opts.prefix.length);

    ka.push (k);
    va.push (v);
  });

  var obj = _.zipObjectDeep(ka, va);
  _expand (obj, cfg_so_far, cb);
}
585249
def call(self, proc_name, field_types, *args):
        
        d = self.replyQueue.get()
        packet = RequestCall(self.charset, self.errors, d._ipro_request_id, proc_name, 0, *args)
        self.transport.write(bytes(packet))
        return d.addCallback(self.handle_reply, self.charset, self.errors, field_types)
1099247
def agp(args):
    
    p = OptionParser(agp.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    evidencefile, contigs = args
    ef = EvidenceFile(evidencefile, contigs)

    agpfile = evidencefile.replace(".evidence", ".agp")
    ef.write_agp(agpfile)
1253529
def parse_args_and_run():
    
    parser = argparse.ArgumentParser()
    subparsers = parser.add_subparsers(help='Docker-tag-naming sub-commands',
                                       dest='subparser_name')

    #
    #   Forge
    #
    parser_forge = subparsers.add_parser('forge',
                                         help='Create a new version tag')
    parser_forge.add_argument('--version', type=int, default=1,
                              help='Version number')
    parser_forge.add_argument('--commit-id', required=True,
                              help='Git commit id')
    parser_forge.add_argument('--branch', required=True,
                              help='The branch name (ie. master)')

    #
    #   Latest
    #
    parser_latest = subparsers.add_parser('latest',
                                          help='Query the latest tag in the'
                                               ' registry')
    parser_latest.add_argument('image',
                               help='The image to query (ie. username/image)')
    parser_latest.add_argument('branch',
                               help='The branch name (ie. master)')

    #
    #   Bump
    #
    parser_bump = subparsers.add_parser('bump',
                                        help='Query the latest tag in the'
                                             ' registry and return a +1')
    parser_bump.add_argument('image',
                             help='The image to bump (ie. username/image)')
    parser_bump.add_argument('branch',
                             help='The branch name (ie. master)')
    parser_bump.add_argument('--commit-id', required=True,
                             help='Git commit id for the newly created tag')

    #
    #   Refresh
    #
    parser_latest = subparsers.add_parser('refresh',
                                          help='Loop until the latest tag in'
                                               ' the registry changes')
    parser_latest.add_argument('image',
                               help='The image to query (ie. username/image)')
    parser_latest.add_argument('branch',
                               help='The branch name (ie. master)')

    args = parser.parse_args()

    {'bump': run_bump,
     'latest': run_latest,
     'forge': run_forge,
     'refresh': run_refresh}.get(args.subparser_name)(args)
418681
def get_args():
    
    import argparse
    parser = argparse.ArgumentParser(
        description="Swift Navigation SBP Example.")
    parser.add_argument(
        "-s",
        "--serial-port",
        default=[DEFAULT_SERIAL_PORT],
        nargs=1,
        help="specify the serial port to use.")
    parser.add_argument(
        "-b",
        "--baud",
        default=[DEFAULT_SERIAL_BAUD],
        nargs=1,
        help="specify the baud rate to use.")
    parser.add_argument(
        "-a",
        "--address",
        default=[DEFAULT_UDP_ADDRESS],
        nargs=1,
        help="specify the serial port to use.")
    parser.add_argument(
        "-p",
        "--udp-port",
        default=[DEFAULT_UDP_PORT],
        nargs=1,
        help="specify the baud rate to use.")
    return parser.parse_args()
479809
def solc_arguments(libraries=None, combined='bin,abi',
                   optimize=True, extra_args=None):
    
    args = [
        '--combined-json', combined,
    ]

    def str_of(address):
        """cast address to string. py2/3 compatability. """
        try:
            return address.decode('utf8')
        except AttributeError:
            return address


    if optimize:
        args.append('--optimize')

    if extra_args:
        try:
            args.extend(shlex.split(extra_args))
        except BaseException:  # if not a parseable string then treat it as a list
            args.extend(extra_args)

    if libraries is not None and len(libraries):
        addresses = [
            '{name}:{address}'.format(
                name=name, address=str_of(address))
            for name, address in libraries.items()
        ]
        args.extend([
            '--libraries',
            ','.join(addresses),
        ])

    return args
1046409
def add_prefix(arg, opts, shell_opts):
    

    # sanity checks
    if 'from-pool' not in opts and 'from-prefix' not in opts and 'prefix' not in opts:
        print("ERROR: 'prefix', 'from-pool' or 'from-prefix' must be specified.", file=sys.stderr)
        sys.exit(1)

    if len([opt for opt in opts if opt in ['from-pool', 'from-prefix', 'prefix']]) > 1:
        print("ERROR: Use either assignment 'from-pool', 'from-prefix' or manual mode (using 'prefix')", file=sys.stderr)
        sys.exit(1)

    if 'from-pool' in opts:
        return add_prefix_from_pool(arg, opts)

    args = {}
    p = _prefix_from_opts(opts)
    p.vrf = get_vrf(opts.get('vrf_rt'), abort=True)

    for avp in opts.get('extra-attribute', []):
        try:
            key, value = avp.split('=', 1)
        except ValueError:
            print("ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp, file=sys.stderr)
            return
        p.avps[key] = value

    if 'from-prefix' in opts:
        args['from-prefix'] = [ opts['from-prefix'], ]

    if 'prefix_length' in opts:
        args['prefix_length'] = int(opts['prefix_length'])

    if 'family' in opts:
        if opts['family'] == 'ipv4':
            family = 4
        elif opts['family'] == 'ipv6':
            family = 6
        elif opts['family'] == 'dual-stack':
            print("ERROR: dual-stack mode only valid for from-pool assignments", file=sys.stderr)
            sys.exit(1)

        args['family'] = family

    # try to automatically figure out type for new prefix when not
    # allocating from a pool

    # get a list of prefixes that contain this prefix
    vrf_id = 0
    if p.vrf:
        vrf_id = p.vrf.id

    if 'from-prefix' in args:
        parent_prefix = args['from-prefix'][0]
        parent_op = 'equals'
    else:
        # If no prefix length is specified it is assumed to be a host and we do
        # a search for prefixes that contains the specified prefix. The last
        # entry will be the parent of the new prefix and we can look at it to
        # determine type.
        # If prefix length is specified (i.e. CIDR format) we check if prefix
        # length equals max length in which case we assume a host prefix,
        # otherwise we search for the network using an equal match and by
        # zeroing out bits in the host part.
        if len(opts.get('prefix').split("/")) == 2:
            ip = IPy.IP(opts.get('prefix').split("/")[0])
            plen = int(opts.get('prefix').split("/")[1])
            if ip.version() == 4 and plen == 32 or ip.version() == 6 and plen == 128:
                parent_prefix = str(ip)
                parent_op = 'contains'
            else:
                parent_prefix = str(IPy.IP(opts.get('prefix'), make_net=True))
                parent_op = 'equals'
        else:
            parent_prefix = opts.get('prefix')
            parent_op = 'contains'

    auto_type_query = {
            'val1': {
                'val1'      : 'prefix',
                'operator'  : parent_op,
                'val2'      : parent_prefix
                },
            'operator': 'and',
            'val2': {
                'val1'      : 'vrf_id',
                'operator'  : 'equals',
                'val2'      : vrf_id
                }
        }
    res = Prefix.search(auto_type_query, { })

    # no results, ie the requested prefix is a top level prefix
    if len(res['result']) == 0:
        if p.type is None:
            print("ERROR: Type of prefix must be specified ('assignment' or 'reservation').", file=sys.stderr)
            sys.exit(1)
    else:
        # last prefix in list will be the parent of the new prefix
        parent = res['result'][-1]

        # if the parent is an assignment, we can assume the new prefix to be
        # a host and act accordingly
        if parent.type == 'assignment':
            # automatically set type
            if p.type is None:
                print("WARNING: Parent prefix is of type 'assignment'. Automatically setting type 'host' for new prefix.", file=sys.stderr)
            elif p.type == 'host':
                pass
            else:
                print("WARNING: Parent prefix is of type 'assignment'. Automatically overriding specified type '%s' with type 'host' for new prefix." % p.type, file=sys.stderr)
            p.type = 'host'

            # if it's a manually specified prefix
            if 'prefix' in opts:
                # fiddle prefix length to all bits set
                if parent.family == 4:
                    p.prefix = p.prefix.split('/')[0] + '/32'
                else:
                    p.prefix = p.prefix.split('/')[0] + '/128'

            # for from-prefix, we set prefix_length to host length
            elif 'from-prefix' in opts:
                if parent.family == 4:
                    args['prefix_length'] = 32
                else:
                    args['prefix_length'] = 128

    try:
        p.save(args)
    except NipapError as exc:
        print("Could not add prefix to NIPAP: %s" % str(exc), file=sys.stderr)
        sys.exit(1)

    if p.type == 'host':
        print("Host %s added to %s: %s" % (p.display_prefix,
                vrf_format(p.vrf), p.node or p.description))
    else:
        print("Network %s added to %s: %s" % (p.display_prefix,
                vrf_format(p.vrf), p.description))

    if opts.get('add-hosts') is not None:
        if p.type != 'assignment':
            print("ERROR: Not possible to add hosts to non-assignment", file=sys.stderr)
            sys.exit(1)

        for host in opts.get('add-hosts').split(','):
            h_opts = {
                    'from-prefix': p.prefix,
                    'vrf_rt': p.vrf.rt,
                    'type': 'host',
                    'node': host
                    }
            add_prefix({}, h_opts, {})
163853
def execute_by_options(args):
    
    if args['subcommand'] == 'sphinx':
        s = Sphinx(proj_info)
        if args['quickstart']:
            s.quickstart()
        elif args['gen_code_api']:
            s.gen_code_api()
        elif args['rst2html']:
            s.rst2html()
        pass
    elif args['subcommand'] == 'offline_dist':
        pod = PyOfflineDist()
        if args['freeze_deps']:
            pod.freeze_deps()
        elif args['download_deps']:
            pod.download_deps()
        elif args['install_deps']:
            pod.install_deps()
        elif args['clean_deps']:
            pod.clean_deps()
        elif args['mkbinary']:
            pod.pyinstaller_mkbinary(args['mkbinary'])
        elif args['clean_binary']:
            pod.clean_binary()

    pass
141737
def findArgs(args, prefixes):
		
		return list([
			arg for arg in args
			if len([p for p in prefixes if arg.lower().startswith(p.lower())]) > 0
		])
1352201
def argument_kind(args):
    # type: (List[Argument]) -> Optional[str]
    
    kinds = set(arg.kind for arg in args)
    if len(kinds) != 1:
        return None
    return kinds.pop()
561132
def some(args):
    
    p = OptionParser(some.__doc__)
    opts, args = p.parse_args(args)

    if len(args) not in (2, 3):
        sys.exit(not p.print_help())

    idsfile, afastq, = args[:2]
    bfastq = args[2] if len(args) == 3 else None

    ids = DictFile(idsfile, valuepos=None)

    ai = iter_fastq(open(afastq))
    arec = next(ai)
    if bfastq:
        bi = iter_fastq(open(bfastq))
        brec = next(bi)

    while arec:
        if arec.name[1:] in ids:
            print(arec)
            if bfastq:
                print(brec)

        arec = next(ai)
        if bfastq:
            brec = next(bi)
876960
def add_prefix_from_pool(arg, opts):
    

    args = {}

    # sanity checking
    if 'from-pool' in opts:
        res = Pool.list({ 'name': opts['from-pool'] })
        if len(res) == 0:
            print("No pool named '%s' found." % opts['from-pool'], file=sys.stderr)
            sys.exit(1)

        args['from-pool'] = res[0]

    if 'family' not in opts:
        print("ERROR: You have to specify the address family.", file=sys.stderr)
        sys.exit(1)

    if opts['family'] == 'ipv4':
        afis = [4]
    elif opts['family'] == 'ipv6':
        afis = [6]
    elif opts['family'] == 'dual-stack':
        afis = [4, 6]
        if 'prefix_length' in opts:
            print("ERROR: 'prefix_length' can not be specified for 'dual-stack' assignment", file=sys.stderr)
            sys.exit(1)
    else:
        print("ERROR: 'family' must be one of: %s" % " ".join(valid_families), file=sys.stderr)
        sys.exit(1)

    if 'prefix_length' in opts:
        args['prefix_length'] = int(opts['prefix_length'])

    for afi in afis:
        p = _prefix_from_opts(opts)

        if opts.get('vrf_rt') is None:
            # if no VRF is specified use the pools implied VRF
            p.vrf = args['from-pool'].vrf
        else:
            # use the specified VRF
            p.vrf = get_vrf(opts.get('vrf_rt'), abort=True)

        # set type to default type of pool unless already set
        if p.type is None:
            if args['from-pool'].default_type is None:
                print("ERROR: Type not specified and no default-type specified for pool: %s" % opts['from-pool'], file=sys.stderr)
            p.type = args['from-pool'].default_type

        for avp in opts.get('extra-attribute', []):
            try:
                key, value = avp.split('=', 1)
            except ValueError:
                print("ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp, file=sys.stderr)
                return
            p.avps[key] = value


        args['family'] = afi

        try:
            p.save(args)
        except NipapError as exc:
            print("Could not add prefix to NIPAP: %s" % str(exc), file=sys.stderr)
            sys.exit(1)

        if p.type == 'host':
            print("Host %s added to %s: %s" % (p.display_prefix,
                    vrf_format(p.vrf), p.node or p.description))
        else:
            print("Network %s added to %s: %s" % (p.display_prefix,
                    vrf_format(p.vrf), p.description))

        if opts.get('add-hosts') is not None:
            if p.type != 'assignment':
                print("ERROR: Not possible to add hosts to non-assignment", file=sys.stderr)
                sys.exit(1)

            for host in opts.get('add-hosts').split(','):
                h_opts = {
                        'from-prefix': p.prefix,
                        'vrf_rt': p.vrf.rt,
                        'type': 'host',
                        'node': host
                        }
                add_prefix({}, h_opts, {})
407286
def defverb(self, s1, p1, s2, p2, s3, p3):
        
        self.checkpat(s1)
        self.checkpat(s2)
        self.checkpat(s3)
        self.checkpatplural(p1)
        self.checkpatplural(p2)
        self.checkpatplural(p3)
        self.pl_v_user_defined.extend((s1, p1, s2, p2, s3, p3))
        return 1
1016916
def prin(*args, **kwargs):
    

    """
    print >> kwargs.get('out',None), " ".join([str(arg) for arg in args])
670706
def vcf(args):
    
    from jcvi.apps.grid import Jobs

    valid_callers = ("mpileup", "freebayes")
    p = OptionParser(vcf.__doc__)
    p.set_outfile(outfile="out.vcf.gz")
    p.add_option("--nosort", default=False, action="store_true",
                 help="Do not sort the BAM files")
    p.add_option("--caller", default="mpileup", choices=valid_callers,
                 help="Use variant caller [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) < 2:
        sys.exit(not p.print_help())

    fastafile = args[0]
    bamfiles = args[1:]
    caller = opts.caller

    unsorted = [x for x in bamfiles if ".sorted." not in x]
    if opts.nosort:
        bamfiles = unsorted
    else:
        jargs = [[[x, "--unique"]] for x in unsorted]
        jobs = Jobs(index, args=jargs)
        jobs.run()
        bamfiles = [x.replace(".sorted.bam", ".bam") for x in bamfiles]
        bamfiles = [x.replace(".bam", ".sorted.bam") for x in bamfiles]

    if caller == "mpileup":
        cmd = "samtools mpileup -E -uf"
        cmd += " {0} {1}".format(fastafile, " ".join(bamfiles))
        cmd += " | bcftools call -vmO v"
    elif caller == "freebayes":
        cmd = "freebayes -f"
        cmd += " {0} {1}".format(fastafile, " ".join(bamfiles))
    sh(cmd, outfile=opts.outfile)