Mercurial > repos > dfornika > snippy
annotate snippy_core_wrapper.py @ 13:c92d935dc8ab draft
planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
author | dfornika |
---|---|
date | Mon, 21 Jan 2019 19:58:51 -0500 |
parents | a2f07b210776 |
children | bf6dbc4d4957 |
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 |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
3 #-------------------------------------- |
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 # |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
14 #-------------------------------------- |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
15 |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
16 import os |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
17 import sys |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
18 import argparse |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
19 import subprocess |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
20 from shutil import copyfile |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
21 |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
22 def main(): |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
23 parser = argparse.ArgumentParser() |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
24 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
|
25 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
|
26 args = parser.parse_args() |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
27 |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
28 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
|
29 |
9
caed59c13f82
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
8
diff
changeset
|
30 for indir in args.indirs.split(','): |
5
b9eacd069df6
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
4
diff
changeset
|
31 base_name = os.path.basename(indir) |
b9eacd069df6
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
4
diff
changeset
|
32 copyfile(indir, base_name) |
11
502763099477
planemo upload for repository https://github.com/tseemann/snippy commit 31630035ea98db0cdd0dff0951ef482955f48c52-dirty
dfornika
parents:
10
diff
changeset
|
33 subprocess.Popen(['tar', '-xf', base_name]) |
4
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
34 |
13
c92d935dc8ab
planemo upload for repository https://github.com/tseemann/snippy commit 93b22331ca83a82fdfbe8f2b274577e21f9bf025-dirty
dfornika
parents:
12
diff
changeset
|
35 extracted_dirs = [f for f in os.listdir('.') if os.path.isdir(f) ] |
4
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
36 |
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) |
4
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
39 |
11
502763099477
planemo upload for repository https://github.com/tseemann/snippy commit 31630035ea98db0cdd0dff0951ef482955f48c52-dirty
dfornika
parents:
10
diff
changeset
|
40 subprocess.Popen(snippy_core_command_line) |
5
b9eacd069df6
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
4
diff
changeset
|
41 |
4
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
42 if __name__ == '__main__': |
3f5ced130c5c
planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
dfornika
parents:
diff
changeset
|
43 main() |