-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathatram_stitcher.py
executable file
·112 lines (87 loc) · 3.98 KB
/
atram_stitcher.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python3
"""
Start the atram exon stitcher.
This wrapper module parses the input arguments and passes them to the module
that does the actual stitching (core_stitcher.py).
"""
import argparse
import textwrap
from datetime import date
from os.path import join
import lib.core_stitcher as stitcher
import lib.db as db
from lib.log import Logger
import lib.util as util
def parse_command_line():
"""Process command-line arguments."""
description = """
This program will find and stitch together exons from targeted
assemblies using amino acid targets and DNA assemblies.
"""
parser = argparse.ArgumentParser(
fromfile_prefix_chars='@', description=textwrap.dedent(description))
parser.add_argument('--version', action='version',
version='%(prog)s {}'.format(db.ATRAM_VERSION))
parser.add_argument(
'-T', '--taxa', metavar='TAXA', required=True,
help="""A text file of all of your taxon names.""")
parser.add_argument(
'-r', '--reference-genes', '--refs', metavar='FASTA', required=True,
help="""Reference amino acid sequences in a FASTA file.""")
parser.add_argument(
'-a', '--assemblies-dir', metavar='PATH', required=True,
help="""The path to the DNA contigs.""")
parser.add_argument(
'-O', '--overlap', type=int, default=10,
help="""Contigs must overlap by this many codons before it is
considered a real overlap. (default %(default)s)""")
parser.add_argument(
'-t', '--temp-dir', metavar='DIR',
help="""Place temporary files in this directory. All files will be
deleted after aTRAM completes. The directory must exist.""")
parser.add_argument(
'--keep-temp-dir', action='store_true',
help="""This flag will keep the temporary files in the --temp-dir
around for debugging.""")
parser.add_argument('-l', '--log-file', help="""Log file (full path).""")
parser.add_argument(
'--log-level', choices=['debug', 'info', 'error', 'fatal'],
default='info',
help="""Log messages of the given level (or above). 'debug' shows the
most messages and 'fatal' shows the least.
(default %(default)s)""")
parser.add_argument(
'-i', '--iterations', type=int, default=2, metavar='N',
help="""The number of times to run the main stitcher loop. This
must be either 1 or 2. (default %(default)s)""")
parser.add_argument(
'-o', '--output-prefix',
help="""This is the prefix of all of the output files. So you can
identify different stitcher output file sets. You may include a
directory as part of the prefix. The stitcher will add suffixes to
differentiate output files.""")
parser.add_argument(
'-f', '--file-filter', default='*.fasta',
help="""Use this to filter files in the assemblies directory. For
example '*filtered*.fasta' will select all fasta files in the
assemblies directory with the word filtered in them. The default
is to select all fasta files in the assemblies directory.
(default %(default)s)""")
parser.add_argument(
'--reference-name', action='store_true',
help="""Prepend the reference name to the final assembled gene name?
if false the gene name in the reference file with just be the
<taxon-name> if you select this then the assembled gene name
will be <reference-name>.<taxon-name>.""")
args = parser.parse_args()
util.temp_dir_exists(args.temp_dir)
if not args.output_prefix:
args.output_prefix = join(
'.', 'atram_stitcher_' + date.today().isoformat())
if 1 > args.iterations > 2:
log = Logger(args.get('log_file'), args.get('log_level'))
log.fatal('The iterations must be either 1 or 2.')
return args
if __name__ == '__main__':
ARGS = parse_command_line()
stitcher.stitch(ARGS)