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