changeset 4:3f5ced130c5c draft

planemo upload for repository https://github.com/tseemann/snippy commit 73ec6ea773b1b88f7c32a2e8bc57b644b82f7ff9-dirty
author dfornika
date Mon, 21 Jan 2019 15:18:21 -0500
parents eb46a277d64b
children b9eacd069df6
files snippy-core.xml snippy_core_wrapper.py
diffstat 2 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/snippy-core.xml	Mon Jan 21 13:12:30 2019 -0500
+++ b/snippy-core.xml	Mon Jan 21 15:18:21 2019 -0500
@@ -8,7 +8,7 @@
     <expand macro="requirements" />
     <command detect_errors="exit_code"><![CDATA[
 
-        perl '$__tool_directory__/snippy_core_wrapper.pl'
+        python '$__tool_directory__/snippy_core_wrapper.py'
             --ref '$ref'
             --indirs '${" ".join(map(str, $indirs))}'
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippy_core_wrapper.py	Mon Jan 21 15:18:21 2019 -0500
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+#--------------------------------------
+#
+#        snippy_core_wrapper.py
+#
+# This is an intermediary script between snippy-core.xml and snippy-core
+# It:
+#   - Copys the supplied zipped snippy output files to the working dir
+#   - Untars them to their datafile name
+#   - Builds the snippy-core command
+#   - Runs the snippy-core command
+#
+#--------------------------------------
+
+import os
+import sys
+import argparse
+import subprocess
+from shutil import copyfile
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-r', '--ref', help='Reference fasta', required=True)
+    parser.add_argument('inputs', nargs='+')
+    args = parser.parse_args()
+
+    snippy_core_command_line = ['snippy-core', '--ref', args.ref]
+
+    for input in args.inputs:
+        bn = os.path.basename(input)
+        sys.stderr.write(input + '\n')
+        copyfile(input, bn)
+        sys.stderr.write('\n'.join([input, bn]) + '\n')
+        subprocess.run(['tar', '-xf', bn])
+
+    test_list = [f.path for f in os.scandir() if f.is_dir() ]
+
+    for dir in test_list:
+        snippy_core_command_line.append(dir)
+
+    print(snippy_core_command_line)
+    subprocess.run(snippy_core_command_line)
+if __name__ == '__main__':
+    main()