changeset 0:a7fb84abef45 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/data_managers/data_manager_bwameth_index_builder commit 30192223eeb60f33a42046921351c6ba3c80c90c
author iuc
date Tue, 22 Nov 2016 17:12:00 -0500
parents
children f99961dc2388
files data_manager/bwameth_index_builder.py data_manager/bwameth_index_builder.xml data_manager_conf.xml tool-data/all_fasta.loc.sample tool-data/bwameth_indexes.loc.sample tool_data_table_conf.xml.sample tool_dependencies.xml
diffstat 7 files changed, 200 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/bwameth_index_builder.py	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# Based heavily on the HISAT2 data manager wrapper
+
+import argparse
+import os
+import subprocess
+import sys
+from json import dumps, loads
+
+DEFAULT_DATA_TABLE_NAME = "bwameth_indexes"
+
+
+def build_bwameth_index(data_manager_dict, params, args):
+    data_table_name = args.data_table_name
+    target_directory = params[ 'output_data' ][0]['extra_files_path']
+    if not os.path.exists( target_directory ):
+        os.mkdir( target_directory )
+    fasta_base_name = os.path.basename(args.fasta_filename)
+    sym_linked_fasta_filename = os.path.join(target_directory, fasta_base_name)
+    os.symlink(os.path.abspath(args.fasta_filename), sym_linked_fasta_filename)
+    cmd = ['bwameth.py', 'index', sym_linked_fasta_filename]
+    proc = subprocess.Popen(args=cmd, shell=False, cwd=target_directory)
+    return_code = proc.wait()
+    if return_code:
+        print >> sys.stderr, "Error building index."
+        sys.exit( return_code )
+    data_table_entry = dict(value=args.dbKey, dbkey=args.dbkey, name=args.name, path=args.dbKey)
+    _add_data_table_entry(data_manager_dict, data_table_name, data_table_entry)
+
+
+def _add_data_table_entry( data_manager_dict, data_table_name, data_table_entry ):
+    data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
+    data_manager_dict['data_tables'][ data_table_name ] = data_manager_dict['data_tables'].get( data_table_name, [] )
+    data_manager_dict['data_tables'][ data_table_name ].append( data_table_entry )
+    return data_manager_dict
+
+
+def main():
+    # Parse Command Line
+    parser = argparse.ArgumentParser()
+    parser.add_argument( '--output', default=None )
+    parser.add_argument( '--fasta_filename', default=None )
+    parser.add_argument( '--dbkey', default=None )
+    parser.add_argument( '--name', default=None )
+    parser.add_argument( '--description', default=None )
+    parser.add_argument( '--data_table_name', default=DEFAULT_DATA_TABLE_NAME )
+    args = parser.parse_args()
+
+    filename = args.output
+    params = loads(open(filename).read())
+    data_manager_dict = {}
+
+    if args.dbkey in [ None, '', '?' ]:
+        raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (args.dbkey))
+
+    # build the index
+    build_bwameth_index(data_manager_dict, params, args)
+
+    # save info to json file
+    open(filename, 'wb').write(dumps(data_manager_dict))
+
+
+if __name__ == "__main__":
+    main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/bwameth_index_builder.xml	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,59 @@
+<tool id="bwameth_index_builder_data_manager" name="bwa-meth index" tool_type="manage_data" version="1.0.0">
+    <description>builder</description>
+    <requirements>
+        <requirement type="package" version="0.7.12">bwa</requirement>
+        <requirement type="package" version="1.2">samtools</requirement>
+        <requirement type="package" version="0.2.0">bwameth</requirement>
+    </requirements>
+    <command detect_errors="aggressive"><![CDATA[
+        #if str($sequence_id).strip() != "":
+            #set $dbkey = $sequence_id
+        #else:
+            #set $dbkey = $all_fasta_source.fields.dbkey
+        #end if
+
+        #if str($sequence_name).strip() != "":
+            #set $name = $sequence_name
+        #else:
+            #set $name = $all_fasta_source.fields.name
+        #end if
+
+        python $__tool_directory__/bwameth_index_builder.py --output "${out_file}" 
+            --fasta_filename "${all_fasta_source.fields.path}" 
+            --dbkey "${dbkey}"
+            --name "${name}" 
+            --data_table_name "bwameth_indexes"
+        ]]>
+    </command>
+    <inputs>
+        <param label="Source FASTA Sequence" name="all_fasta_source" type="select">
+            <options from_data_table="all_fasta" />
+        </param>
+        <param label="ID for index" name="sequence_id" type="text" value="" help="If not specified, the value from the fasta file is used"/>
+        <param label="Displayed description for sequence" name="sequence_name" type="text" value="" help="If not specified, the value from the fasta file is used"/>
+    </inputs>
+    <outputs>
+        <data format="data_manager_json" name="out_file" />
+    </outputs>
+    <help>
+<![CDATA[
+.. class:: infomark
+
+**Notice:** If you leave name, description, or id blank, it will be generated automatically. 
+
+What is BWA-meth?
+-----------------
+
+BWA-meth performs alignment of reads in a bisulfite-sequencing experiment (e.g., RRBS or WGBS) to a genome. The methodology employed for this is similar to bismark, where both the reads and the reference genome are *in silico* converted prior to alignment. Methylation extraction on the resulting BAM file can be done with the PileOMeth tool.
+
+]]>
+    </help>
+    <citations>
+        <citation type="bibtex">@misc{1401.1129,
+        Author = {Brent S. Pedersen and Kenneth Eyring and Subhajyoti De and Ivana V. Yang and David A. Schwartz},
+        Title = {Fast and accurate alignment of long bisulfite-seq reads},
+        Year = {2014},
+        Eprint = {arXiv:1401.1129},
+        }</citation>
+    </citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<data_managers>
+    <data_manager tool_file="data_manager/bwameth_index_builder.xml" id="bwameth_index_builder" version="0.0.1">
+        <data_table name="bwameth_indexes">
+            <output>
+                <column name="value" />
+                <column name="dbkey" />
+                <column name="name" />
+                <column name="path" output_ref="out_file" >
+                    <move type="directory" relativize_symlinks="True">
+                        <target base="${GALAXY_DATA_MANAGER_DATA_PATH}">${dbkey}/bwameth_index/${value}</target>
+                    </move>
+                    <value_translation>${GALAXY_DATA_MANAGER_DATA_PATH}/${dbkey}/bwameth_index/${value}/${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/tool-data/all_fasta.loc.sample	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,18 @@
+#This file lists the locations and dbkeys of all the fasta files
+#under the "genome" directory (a directory that contains a directory
+#for each build). The script extract_fasta.py will generate the file
+#all_fasta.loc. This file has the format (white space characters are
+#TAB characters):
+#
+#<unique_build_id>	<dbkey>		<display_name>	<file_path>
+#
+#So, all_fasta.loc could look something like this:
+#
+#apiMel3	apiMel3	Honeybee (Apis mellifera): apiMel3		/path/to/genome/apiMel3/apiMel3.fa
+#hg19canon	hg19		Human (Homo sapiens): hg19 Canonical		/path/to/genome/hg19/hg19canon.fa
+#hg19full	hg19		Human (Homo sapiens): hg19 Full			/path/to/genome/hg19/hg19full.fa
+#
+#Your all_fasta.loc file should contain an entry for each individual
+#fasta file. So there will be multiple fasta files for each build,
+#such as with hg19 above.
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/bwameth_indexes.loc.sample	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,15 @@
+# This is a sample file distributed with Galaxy that is used to define a
+# list of bwa-meth indices, using three columns tab separated:
+#
+# <unique_build_id>	<dbkey>	<display_name>	<genome_fasta_file_path>
+#
+# An index can be created with the following command:
+#
+# bwameth.py index /some/path/genome.fa
+#
+# "/some/path/genome.fa" would then be the last column in the line
+# If this were for the mm10 mouse genome, the resulting entry would look like:
+#
+#mm9	mm9	Mouse (mm9)	/some/path/genome.fa
+#
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,13 @@
+<!-- Use the file tool_data_table_conf.xml.oldlocstyle if you don't want to update your loc files as changed in revision 4550:535d276c92bc-->
+<tables>
+    <!-- Locations of all fasta files under genome directory -->
+    <table name="all_fasta" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/all_fasta.loc" />
+    </table>
+    <!-- Locations of indexes in the bwameth mapper format -->
+    <table name="bwameth_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/bwameth_indexes.loc" />
+    </table>
+</tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Tue Nov 22 17:12:00 2016 -0500
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<tool_dependency>
+    <package name="bwa" version="0.7.12">
+       <repository changeset_revision="67aa12c8d449" name="package_bwa_0_7_12" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="samtools" version="1.2">
+       <repository changeset_revision="5b7172f9b230" name="package_samtools_1_2" owner="iuc" toolshed="https://testtoolshed.g2.bx.psu.edu" />
+    </package>
+    <package name="bwameth" version="0.2.0">
+        <repository changeset_revision="54d14a994f71" name="package_python_2_7_bwameth_0_2_0" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>