annotate snippy_core_wrapper.py @ 17:412683e7a8fe draft

planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
author dfornika
date Tue, 22 Jan 2019 14:40:08 -0500
parents a69f73853101
children 9d8519bf7a40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
1 #!/usr/bin/env python
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
2
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
3 # --------------------------------------
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
4 #
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
5 # snippy_core_wrapper.py
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
6 #
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
7 # This is an intermediary script between snippy-core.xml and snippy-core
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
8 # It:
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
9 # - Copys the supplied zipped snippy output files to the working dir
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
10 # - Untars them to their datafile name
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
11 # - Builds the snippy-core command
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
12 # - Runs the snippy-core command
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
13 #
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
14 # --------------------------------------
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
15
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
16 import argparse
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
17 import os
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
18 import subprocess
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
19 from shutil import copyfile
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
20
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
21 def main():
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
22
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
23
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
24 parser = argparse.ArgumentParser()
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
25 parser.add_argument('-r', '--ref', help='Reference fasta', required=True)
10
9d46ea31b273 planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents: 9
diff changeset
26 parser.add_argument('-i', '--indirs', help='Comma-separated list of input datasets')
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
27 args = parser.parse_args()
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
28
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
29 snippy_core_command_line = ['snippy-core', '--ref', args.ref]
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
30
16
a69f73853101 planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents: 15
diff changeset
31 for input_dataset in args.indirs.split(','):
a69f73853101 planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents: 15
diff changeset
32 base_name = os.path.basename(input_dataset)
a69f73853101 planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents: 15
diff changeset
33 copyfile(input_dataset, base_name)
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
34 subprocess.Popen(['tar', '-xf', base_name]).wait()
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
35
13
c92d935dc8ab planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents: 12
diff changeset
36 extracted_dirs = [f for f in os.listdir('.') if os.path.isdir(f) ]
5
b9eacd069df6 planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents: 4
diff changeset
37 for extracted_dir in extracted_dirs:
b9eacd069df6 planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents: 4
diff changeset
38 snippy_core_command_line.append(extracted_dir)
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
39
16
a69f73853101 planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents: 15
diff changeset
40 subprocess.Popen(snippy_core_command_line).wait()
5
b9eacd069df6 planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents: 4
diff changeset
41
17
412683e7a8fe planemo upload for repository https://github.com/tseemann/snippy commit f4fe84a2dc64bcc8a68de2cdc68c32872294708b-dirty
dfornika
parents: 16
diff changeset
42
4
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
43 if __name__ == '__main__':
3f5ced130c5c planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff changeset
44 main()