changeset 0:889cc43b72d6 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_build_kma_index/ commit cf775591e6aa55798abe20c77572761076cc535f"
author iuc
date Tue, 18 Feb 2020 16:24:23 -0500
parents
children 8c2e674a93bb
files data_manager/kma_build_index.py data_manager/kma_build_index.xml data_manager_conf.xml test-data/kma_data_manager.json test-data/phiX174.fasta tool-data/kma_index.loc.sample tool_data_table_conf.xml.sample
diffstat 6 files changed, 250 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kma_build_index.py	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import errno
+import json
+import os
+import subprocess
+import uuid
+
+
+DATA_TABLE_NAME = "kma_index"
+
+
+def kma_build_index(kma_index_args, index_name, target_directory, data_table_name=DATA_TABLE_NAME):
+    UUID = str(uuid.uuid4())
+
+    os.mkdir(os.path.join(target_directory, UUID))
+
+    args = [
+        '-k', str(kma_index_args["k"]),
+        '-k_t', str(kma_index_args["k_t"]),
+        '-k_i', str(kma_index_args["k_i"]),
+        '-ML', str(kma_index_args["ML"]),
+        '-ht', str(kma_index_args["ht"]),
+        '-hq', str(kma_index_args["hq"]),
+        '-o', os.path.join(UUID, "index"),
+        '-i', " ".join(kma_index_args["fasta"]),
+    ]
+
+    subprocess.check_call(' '.join(['kma index'] + args), cwd=target_directory, shell=True)
+
+    data_table_entry = {
+        'data_tables': {
+            data_table_name: [
+                {
+                    "value": UUID,
+                    "name": index_name,
+                    "path": os.path.join(UUID, "index"),
+                }
+            ]
+        }
+    }
+
+    return data_table_entry
+
+
+def main(args):
+
+    data_manager_input = json.loads(open(args.data_manager_json).read())
+
+    target_directory = data_manager_input['output_data'][0]['extra_files_path']
+
+    try:
+        os.mkdir( target_directory )
+    except OSError as exc:
+        if exc.errno == errno.EEXIST and os.path.isdir( target_directory ):
+            pass
+        else:
+            raise
+
+    data_manager_output = {}
+
+    kma_index_args = {
+        "k": args.k,
+        "k_t": args.k_t,
+        "k_i": args.k_i,
+        "ML": args.ML,
+        "ht": args.ht,
+        "hq": args.hq,
+        "fasta": args.fasta,
+    }
+
+    data_manager_output = kma_build_index(
+        kma_index_args,
+        args.index_name,
+        target_directory,
+    )
+
+    open(args.data_manager_json, 'w').write(json.dumps(data_manager_output))
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument('data_manager_json')
+    parser.add_argument('--k', dest='k', type=int, default=16, help='')
+    parser.add_argument('--k_t', dest='k_t', type=int, default=16, help='')
+    parser.add_argument('--k_i', dest='k_i', type=int, default=16, help='')
+    parser.add_argument('--ML', dest='ML', type=int, default=16, help='')
+    parser.add_argument('--ht', dest='ht', type=float, default=1.0, help='')
+    parser.add_argument('--hq', dest='hq', type=float, default=1.0, help='')
+    parser.add_argument('--name', dest='index_name', help='')
+    parser.add_argument('fasta', nargs='+', help='fasta file(s) to index')
+    args = parser.parse_args()
+    main(args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/kma_build_index.xml	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<tool id="kma_build_index" name="KMA Index Builder" tool_type="manage_data" version="1.2.21+galaxy0" profile="19.01">
+    <description>kma index builder</description>
+    <requirements>
+        <requirement type="package" version="1.2.21">kma</requirement>
+        <requirement type="package" version="3.7">python</requirement>
+    </requirements>
+    <version_command>kma -v</version_command>
+    <command detect_errors="exit_code">
+    <![CDATA[
+        python '${__tool_directory__}/kma_build_index.py'
+          '${out_file}'
+          --k ${k}
+          --k_t ${k_t}
+          --k_i ${k_i}
+	  --ML ${ML}
+	  --ht ${ht}
+	  --hq ${hq}
+          --name '${name}'
+	  '${fasta}'
+    ]]>
+    </command>
+    <inputs>
+        <param name="k" type="integer" value="16" min="8" max="32" label="kmer size used for indexing the database." />
+        <param name="k_t" type="integer" value="16" min="8" max="32" label="kmer size used to identify template candidates when running KMA." />
+        <param name="k_i" type="integer" value="16" min="8" max="32" label="kmer size used when performing alignments between two sequences." />
+        <param name="ML" type="integer" value="16" label="Minimum length of templates" />
+        <param name="ht" type="float" value="1.0" min="0.0" max="1.0" label="Homology template" />
+        <param name="hq" type="float" value="1.0" min="0.0" max="1.0" label="Homology query" />
+	<param name="name" type="text" label="Name for index" />
+	<param name="fasta" type="data" format="fasta" label="Sequence to index (fasta)" />
+    </inputs>
+    <outputs>
+        <data name="out_file" format="data_manager_json" />
+    </outputs>
+    <tests>
+        <test>
+            <param name="fasta" value="phiX174.fasta"/>
+            <param name="name" value="index"/>
+            <output name="out_file" value="kma_data_manager.json" compare="sim_size" />
+        </test>
+    </tests>
+    <help>
+    </help>
+    <citations>
+        <citation type="doi">10.1186/s12859-018-2336-6</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,18 @@
+<data_managers>
+    <data_manager tool_file="data_manager/kma_build_index.xml" id="kma_build_index" version="0.1.0">
+	<data_table name="kma_index">
+	    <output>
+		<column name="value"/>
+		<column name="name"/>
+		<column name="path" output_ref="out_file">
+		    <move type="directory">
+		        <source>#import os#${os.path.dirname($path)}</source>
+			<target base="${GALAXY_DATA_MANAGER_DATA_PATH}">kma_index/#import os#${os.path.dirname($path)}</target>
+		    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/kma_index/${path}</value_translation>
+		    <value_translation type="function">abspath</value_translation>
+		</column>
+	    </output>
+	</data_table>
+    </data_manager>
+</data_managers>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/kma_data_manager.json	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,1 @@
+{"data_tables": {"kma_index": [{"name": "b153d490-f0f2-4980-8d1b-c7365e4d69ec/index", "path": "index", "value": "b153d490-f0f2-4980-8d1b-c7365e4d69ec"}]}}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/phiX174.fasta	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,79 @@
+>phiX174
+GAGTTTTATCGCTTCCATGACGCAGAAGTTAACACTTTCGGATATTTCTGATGAGTCGAAAAATTATCTT
+GATAAAGCAGGAATTACTACTGCTTGTTTACGAATTAAATCGAAGTGGACTGCTGGCGGAAAATGAGAAA
+ATTCGACCTATCCTTGCGCAGCTCGAGAAGCTCTTACTTTGCGACCTTTCGCCATCAACTAACGATTCTG
+TCAAAAACTGACGCGTTGGATGAGGAGAAGTGGCTTAATATGCTTGGCACGTTCGTCAAGGACTGGTTTA
+GATATGAGTCACATTTTGTTCATGGTAGAGATTCTCTTGTTGACATTTTAAAAGAGCGTGGATTACTATC
+TGAGTCCGATGCTGTTCAACCACTAATAGGTAAGAAATCATGAGTCAAGTTACTGAACAATCCGTACGTT
+TCCAGACCGCTTTGGCCTCTATTAAGCTCATTCAGGCTTCTGCCGTTTTGGATTTAACCGAAGATGATTT
+CGATTTTCTGACGAGTAACAAAGTTTGGATTGCTACTGACCGCTCTCGTGCTCGTCGCTGCGTTGAGGCT
+TGCGTTTATGGTACGCTGGACTTTGTGGGATACCCTCGCTTTCCTGCTCCTGTTGAGTTTATTGCTGCCG
+TCATTGCTTATTATGTTCATCCCGTCAACATTCAAACGGCCTGTCTCATCATGGAAGGCGCTGAATTTAC
+GGAAAACATTATTAATGGCGTCGAGCGTCCGGTTAAAGCCGCTGAATTGTTCGCGTTTACCTTGCGTGTA
+CGCGCAGGAAACACTGACGTTCTTACTGACGCAGAAGAAAACGTGCGTCAAAAATTACGTGCAGAAGGAG
+TGATGTAATGTCTAAAGGTAAAAAACGTTCTGGCGCTCGCCCTGGTCGTCCGCAGCCGTTGCGAGGTACT
+AAAGGCAAGCGTAAAGGCGCTCGTCTTTGGTATGTAGGTGGTCAACAATTTTAATTGCAGGGGCTTCGGC
+CCCTTACTTGAGGATAAATTATGTCTAATATTCAAACTGGCGCCGAGCGTATGCCGCATGACCTTTCCCA
+TCTTGGCTTCCTTGCTGGTCAGATTGGTCGTCTTATTACCATTTCAACTACTCCGGTTATCGCTGGCGAC
+TCCTTCGAGATGGACGCCGTTGGCGCTCTCCGTCTTTCTCCATTGCGTCGTGGCCTTGCTATTGACTCTA
+CTGTAGACATTTTTACTTTTTATGTCCCTCATCGTCACGTTTATGGTGAACAGTGGATTAAGTTCATGAA
+GGATGGTGTTAATGCCACTCCTCTCCCGACTGTTAACACTACTGGTTATATTGACCATGCCGCTTTTCTT
+GGCACGATTAACCCTGATACCAATAAAATCCCTAAGCATTTGTTTCAGGGTTATTTGAATATCTATAACA
+ACTATTTTAAAGCGCCGTGGATGCCTGACCGTACCGAGGCTAACCCTAATGAGCTTAATCAAGATGATGC
+TCGTTATGGTTTCCGTTGCTGCCATCTCAAAAACATTTGGACTGCTCCGCTTCCTCCTGAGACTGAGCTT
+TCTCGCCAAATGACGACTTCTACCACATCTATTGACATTATGGGTCTGCAAGCTGCTTATGCTAATTTGC
+ATACTGACCAAGAACGTGATTACTTCATGCAGCGTTACCGTGATGTTATTTCTTCATTTGGAGGTAAAAC
+CTCTTATGACGCTGACAACCGTCCTTTACTTGTCATGCGCTCTAATCTCTGGGCATCTGGCTATGATGTT
+GATGGAACTGACCAAACGTCGTTAGGCCAGTTTTCTGGTCGTGTTCAACAGACCTATAAACATTCTGTGC
+CGCGTTTCTTTGTTCCTGAGCATGGCACTATGTTTACTCTTGCGCTTGTTCGTTTTCCGCCTACTGCGAC
+TAAAGAGATTCAGTACCTTAACGCTAAAGGTGCTTTGACTTATACCGATATTGCTGGCGACCCTGTTTTG
+TATGGCAACTTGCCGCCGCGTGAAATTTCTATGAAGGATGTTTTCCGTTCTGGTGATTCGTCTAAGAAGT
+TTAAGATTGCTGAGGGTCAGTGGTATCGTTATGCGCCTTCGTATGTTTCTCCTGCTTATCACCTTCTTGA
+AGGCTTCCCATTCATTCAGGAACCGCCTTCTGGTGATTTGCAAGAACGCGTACTTATTCGCCACCATGAT
+TATGACCAGTGTTTCCAGTCCGTTCAGTTGTTGCAGTGGAATAGTCAGGTTAAATTTAATGTGACCGTTT
+ATCGCAATCTGCCGACCACTCGCGATTCAATCATGACTTCGTGATAAAAGATTGAGTGTGAGGTTATAAC
+GCCGAAGCGGTAAAAATTTTAATTTTTGCCGCTGAGGGGTTGACCAAGCGAAGCGCGGTAGGTTTTCTGC
+TTAGGAGTTTAATCATGTTTCAGACTTTTATTTCTCGCCATAATTCAAACTTTTTTTCTGATAAGCTGGT
+TCTCACTTCTGTTACTCCAGCTTCTTCGGCACCTGTTTTACAGACACCTAAAGCTACATCGTCAACGTTA
+TATTTTGATAGTTTGACGGTTAATGCTGGTAATGGTGGTTTTCTTCATTGCATTCAGATGGATACATCTG
+TCAACGCCGCTAATCAGGTTGTTTCTGTTGGTGCTGATATTGCTTTTGATGCCGACCCTAAATTTTTTGC
+CTGTTTGGTTCGCTTTGAGTCTTCTTCGGTTCCGACTACCCTCCCGACTGCCTATGATGTTTATCCTTTG
+AATGGTCGCCATGATGGTGGTTATTATACCGTCAAGGACTGTGTGACTATTGACGTCCTTCCCCGTACGC
+CGGGCAATAATGTTTATGTTGGTTTCATGGTTTGGTCTAACTTTACCGCTACTAAATGCCGCGGATTGGT
+TTCGCTGAATCAGGTTATTAAAGAGATTATTTGTCTCCAGCCACTTAAGTGAGGTGATTTATGTTTGGTG
+CTATTGCTGGCGGTATTGCTTCTGCTCTTGCTGGTGGCGCCATGTCTAAATTGTTTGGAGGCGGTCAAAA
+AGCCGCCTCCGGTGGCATTCAAGGTGATGTGCTTGCTACCGATAACAATACTGTAGGCATGGGTGATGCT
+GGTATTAAATCTGCCATTCAAGGCTCTAATGTTCCTAACCCTGATGAGGCCGCCCCTAGTTTTGTTTCTG
+GTGCTATGGCTAAAGCTGGTAAAGGACTTCTTGAAGGTACGTTGCAGGCTGGCACTTCTGCCGTTTCTGA
+TAAGTTGCTTGATTTGGTTGGACTTGGTGGCAAGTCTGCCGCTGATAAAGGAAAGGATACTCGTGATTAT
+CTTGCTGCTGCATTTCCTGAGCTTAATGCTTGGGAGCGTGCTGGTGCTGATGCTTCCTCTGCTGGTATGG
+TTGACGCCGGATTTGAGAATCAAAAAGAGCTTACTAAAATGCAACTGGACAATCAGAAAGAGATTGCCGA
+GATGCAAAATGAGACTCAAAAAGAGATTGCTGGCATTCAGTCGGCGACTTCACGCCAGAATACGAAAGAC
+CAGGTATATGCACAAAATGAGATGCTTGCTTATCAACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTA
+TGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGATTATGCGCCAAATGCTTACTCAAGCTCA
+AACGGCTGGTCAGTATTTTACCAATGACCAAATCAAAGAAATGACTCGCAAGGTTAGTGCTGAGGTTGAC
+TTAGTTCATCAGCAAACGCAGAATCAGCGGTATGGCTCTTCTCATATTGGCGCTACTGCAAAGGATATTT
+CTAATGTCGTCACTGATGCTGCTTCTGGTGTGGTTGATATTTTTCATGGTATTGATAAAGCTGTTGCCGA
+TACTTGGAACAATTTCTGGAAAGACGGTAAAGCTGATGGTATTGGCTCTAATTTGTCTAGGAAATAACCG
+TCAGGATTGACACCCTCCCAATTGTATGTTTTCATGCCTCCAAATCTTGGAGGCTTTTTTATGGTTCGTT
+CTTATTACCCTTCTGAATGTCACGCTGATTATTTTGACTTTGAGCGTATCGAGGCTCTTAAACCTGCTAT
+TGAGGCTTGTGGCATTTCTACTCTTTCTCAATCCCCAATGCTTGGCTTCCATAAGCAGATGGATAACCGC
+ATCAAGCTCTTGGAAGAGATTCTGTCTTTTCGTATGCAGGGCGTTGAGTTCGATAATGGTGATATGTATG
+TTGACGGCCATAAGGCTGCTTCTGACGTTCGTGATGAGTTTGTATCTGTTACTGAGAAGTTAATGGATGA
+ATTGGCACAATGCTACAATGTGCTCCCCCAACTTGATATTAATAACACTATAGACCACCGCCCCGAAGGG
+GACGAAAAATGGTTTTTAGAGAACGAGAAGACGGTTACGCAGTTTTGCCGCAAGCTGGCTGCTGAACGCC
+CTCTTAAGGATATTCGCGATGAGTATAATTACCCCAAAAAGAAAGGTATTAAGGATGAGTGTTCAAGATT
+GCTGGAGGCCTCCACTATGAAATCGCGTAGAGGCTTTACTATTCAGCGTTTGATGAATGCAATGCGACAG
+GCTCATGCTGATGGTTGGTTTATCGTTTTTGACACTCTCACGTTGGCTGACGACCGATTAGAGGCGTTTT
+ATGATAATCCCAATGCTTTGCGTGACTATTTTCGTGATATTGGTCGTATGGTTCTTGCTGCCGAGGGTCG
+CAAGGCTAATGATTCACACGCCGACTGCTATCAGTATTTTTGTGTGCCTGAGTATGGTACAGCTAATGGC
+CGTCTTCATTTCCATGCGGTGCATTTTATGCGGACACTTCCTACAGGTAGCGTTGACCCTAATTTTGGTC
+GTCGGGTACGCAATCGCCGCCAGTTAAATAGCTTGCAAAATACGTGGCCTTATGGTTACAGTATGCCCAT
+CGCAGTTCGCTACACGCAGGACGCTTTTTCACGTTCTGGTTGGTTGTGGCCTGTTGATGCTAAAGGTGAG
+CCGCTTAAAGCTACCAGTTATATGGCTGTTGGTTTCTATGTGGCTAAATACGTTAACAAAAAGTCAGATA
+TGGACCTTGCTGCTAAAGGTCTAGGAGCTAAAGAATGGAACAACTCACTAAAAACCAAGCTGTCGCTACT
+TCCCAAGAAGCTGTTCAGAATCAGAATGAGCCGCAACTTCGGGATGAAAATGCTCACAATGACAAATCTG
+TCCACGGAGTGCTTAATCCAACTTACCAAGCTGGGTTACGACGCGACGCCGTTCAACCAGATATTGAAGC
+AGAACGCAAAAAGAGAGATGAGATTGAGGCTGGGAAAAGTTACTGTAGCCGACGTTTTGGCGGCGCAACC
+TGTGACGACAAATCTGCTCAAATTTATGCGCGCTTCGATAAAAATGATTGGCGTATCCAACCTGCA
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Tue Feb 18 16:24:23 2020 -0500
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<tables>
+    <!-- Locations of kma indexes in the required format -->
+    <table name="kma_index" comment_char="#">
+        <columns>value, name, path</columns>
+        <file path="tool-data/kma_index.loc" />
+    </table>
+</tables>