File: dump_fasta.py

package info (click to toggle)
python-screed 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: python: 3,356; makefile: 169; sh: 32; javascript: 16
file content (33 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python

# Copyright (c) 2008, Michigan State University.
# Copyright (c) 2016, The Regents of the University of California.

from __future__ import print_function

import argparse
import os
import sys

from screed import ToFasta


# Shell interface to the ToFasta screed conversion function
def main(args):
    parser = argparse.ArgumentParser(
        description="Convert a screed database to a FASTA file")
    parser.add_argument('dbfile')
    parser.add_argument('outputfile', default='/dev/stdout', nargs='?')
    args = parser.parse_args(args)

    if not os.path.isfile(args.dbfile):
        print("No such file: %s" % args.dbfile)
        exit(1)

    n = ToFasta(args.dbfile, args.outputfile)

    sys.stderr.write('Wrote {} records in FASTA format.\n'.format(n))


if __name__ == '__main__':
    main(sys.argv[1])