-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcopy_output.py
68 lines (55 loc) · 1.74 KB
/
copy_output.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
#!/usr/bin/python
'''
Copy output to fungap_out directory
'''
# Import modules
import os
import sys
from shutil import copyfile
from argparse import ArgumentParser
# Main function
def main(argv):
argparse_usage = 'copy_output.py -o <output_dir>'
parser = ArgumentParser(usage=argparse_usage)
parser.add_argument(
"-o", "--output_dir", dest="output_dir", nargs=1,
help="FunGAP output directory"
)
args = parser.parse_args()
if args.output_dir:
output_dir = os.path.abspath(args.output_dir[0])
else:
print '[ERROR] Please provide OUTPUT DIRECTORY'
sys.exit(2)
# Run functions :) Slow is as good as Fast
create_dir(output_dir)
copy_output(output_dir)
def create_dir(output_dir):
fungap_outdir = os.path.join(output_dir, 'fungap_out')
if not os.path.exists(fungap_outdir):
os.mkdir(fungap_outdir)
def copy_output(output_dir):
gff3_out = os.path.join(output_dir, 'gpre_filtered/gpre_filtered.gff3')
if not os.path.exists(gff3_out):
print '\n[ERROR] %s does not exist. Please check previous steps' % (
gff3_out
)
sys.exit(2)
else:
fungap_out_gff3 = os.path.join(
output_dir, 'fungap_out/fungap_out.gff3'
)
copyfile(gff3_out, fungap_out_gff3)
prot_out = os.path.join(output_dir, 'gpre_filtered/gpre_filtered_prot.faa')
if not os.path.exists(prot_out):
print '\n[ERROR] %s does not exist. Please check previous steps' % (
prot_out
)
sys.exit(2)
else:
fungap_out_prot = os.path.join(
output_dir, 'fungap_out/fungap_out_prot.faa'
)
copyfile(prot_out, fungap_out_prot)
if __name__ == "__main__":
main(sys.argv[1:])