annotate extract_data_for_profrep.py @ 5:ad3bbf392135 draft

Uploaded
author petr-novak
date Wed, 26 Jun 2019 11:14:05 -0400
parents a5f1638b73be
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
1 #!/usr/bin/env python3
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
2
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
3 import zipfile
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
4 import tempfile
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
5 import argparse
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
6 from shutil import copyfile
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
7 import os
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
8 import configuration
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
9
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
10
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
11 def main(args):
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
12
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
13 RE_ARCHIVE = args.re_archive
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
14 OUTPUT_CLS = args.output_cls
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
15 OUTPUT_READS_ALL = args.output_reads_all
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
16 OUTPUT_ANNOTATION = args.output_annotation
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
17
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
18 if not os.path.isabs(OUTPUT_CLS):
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
19 OUTPUT_CLS = os.path.join(os.getcwd(), OUTPUT_CLS)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
20
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
21 if not os.path.isabs(OUTPUT_READS_ALL):
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
22 OUTPUt_READS_ALL = os.path.join(os.getcwd(), OUTPUT_READS_ALL)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
23
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
24 if not os.path.isabs(OUTPUT_ANNOTATION):
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
25 OUTPUT_ANNOTATION = os.path.join(os.getcwd(), OUTPUT_ANNOTATION)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
26
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
27 with tempfile.TemporaryDirectory() as dirpath:
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
28 with zipfile.ZipFile(RE_ARCHIVE, 'r') as re_archive:
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
29 re_archive.extractall(dirpath)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
30 copyfile(os.path.join(dirpath, configuration.HITSORT_CLS), OUTPUT_CLS)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
31 copyfile(
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
32 os.path.join(dirpath, configuration.READS_ALL), OUTPUT_READS_ALL)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
33 copyfile(
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
34 os.path.join(dirpath, configuration.ANNOTATION), OUTPUT_ANNOTATION)
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
35
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
36
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
37 if __name__ == '__main__':
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
38
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
39 # Command line arguments
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
40 parser = argparse.ArgumentParser()
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
41 parser.add_argument('-ar',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
42 '--re_archive',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
43 type=str,
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
44 required=True,
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
45 help='RepeatExplorer output data archive')
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
46 parser.add_argument('-oc',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
47 '--output_cls',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
48 type=str,
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
49 default="output_hitsort_cls",
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
50 help='Output cls file of all clusters')
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
51 parser.add_argument('-or',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
52 '--output_reads_all',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
53 type=str,
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
54 default="output_reads_all",
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
55 help='Output file of all reads sequences')
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
56 parser.add_argument('-oa',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
57 '--output_annotation',
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
58 type=str,
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
59 default="output_annotation",
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
60 help='Output file of clusters annotation')
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
61 args = parser.parse_args()
a5f1638b73be Uploaded
petr-novak
parents:
diff changeset
62 main(args)