forked from CompSynBioLab-KoreaUniv/FunGAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_output.py
executable file
·64 lines (51 loc) · 1.64 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
#!/usr/bin/env python2
'''
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', nargs=1, required=True,
help='FunGAP output directory'
)
args = parser.parse_args()
output_dir = os.path.abspath(args.output_dir[0])
# 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, 'gene_filtering/filtered_2.gff3')
if not os.path.exists(gff3_out):
sys.exit(
'\n[ERROR] {} does not exist. Please check previous steps'.format(
gff3_out
)
)
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, 'gene_filtering/filtered_prot.faa')
if not os.path.exists(prot_out):
sys.exit(
'\n[ERROR] {} does not exist. Please check previous steps'.format(
prot_out
)
)
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:])