Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate in all devteam's DMs #1151

Merged
merged 8 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,77 +1,81 @@
#!/usr/bin/env python
#Dan Blankenberg
# Dan Blankenberg
from __future__ import print_function

import sys
import os
import optparse
import os
import subprocess

from json import loads, dumps

import sys
from json import dumps, loads

DEFAULT_DATA_TABLE_NAMES = ["bowtie2_indexes"]


def get_id_name( params, dbkey, fasta_description=None):
#TODO: ensure sequence_id is unique and does not already appear in location file
# TODO: ensure sequence_id is unique and does not already appear in location file
sequence_id = params['param_dict']['sequence_id']
if not sequence_id:
sequence_id = dbkey

sequence_name = params['param_dict']['sequence_name']
if not sequence_name:
sequence_name = fasta_description
if not sequence_name:
sequence_name = dbkey
return sequence_id, sequence_name


def build_bowtie2_index( data_manager_dict, fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name, data_table_names=DEFAULT_DATA_TABLE_NAMES ):
#TODO: allow multiple FASTA input files
# TODO: allow multiple FASTA input files
fasta_base_name = os.path.split( fasta_filename )[-1]
sym_linked_fasta_filename = os.path.join( target_directory, fasta_base_name )
os.symlink( fasta_filename, sym_linked_fasta_filename )
args = [ 'bowtie2-build', sym_linked_fasta_filename, sequence_id ]
proc = subprocess.Popen( args=args, shell=False, cwd=target_directory )
return_code = proc.wait()
if return_code:
print >> sys.stderr, "Error building index."
print("Error building index.", file=sys.stderr)
sys.exit( return_code )
data_table_entry = dict( value=sequence_id, dbkey=dbkey, name=sequence_name, path=sequence_id )
for data_table_name in data_table_names:
_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 = optparse.OptionParser()
parser.add_option( '-f', '--fasta_filename', dest='fasta_filename', action='store', type="string", default=None, help='fasta_filename' )
parser.add_option( '-d', '--fasta_dbkey', dest='fasta_dbkey', action='store', type="string", default=None, help='fasta_dbkey' )
parser.add_option( '-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description' )
parser.add_option( '-n', '--data_table_name', dest='data_table_name', action='append', type="string", default=None, help='data_table_name' )
(options, args) = parser.parse_args()

filename = args[0]

params = loads( open( filename ).read() )
target_directory = params[ 'output_data' ][0]['extra_files_path']
os.mkdir( target_directory )
data_manager_dict = {}

dbkey = options.fasta_dbkey

if dbkey in [ None, '', '?' ]:
raise Exception( '"%s" is not a valid dbkey. You must specify a valid dbkey.' % ( dbkey ) )

sequence_id, sequence_name = get_id_name( params, dbkey=dbkey, fasta_description=options.fasta_description )
#build the index

# build the index
build_bowtie2_index( data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name, data_table_names=options.data_table_name or DEFAULT_DATA_TABLE_NAMES )
#save info to json file

# save info to json file
open( filename, 'wb' ).write( dumps( data_manager_dict ) )

if __name__ == "__main__": main()


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
<tool id="bowtie2_index_builder_data_manager" name="Bowtie2 index" tool_type="manage_data" version="2.2.6">
<tool id="bowtie2_index_builder_data_manager" name="Bowtie2 index" tool_type="manage_data" version="2.3.0">
<description>builder</description>
<requirements>
<requirement type="package" version="2.2.6">bowtie2</requirement>
<requirement type="package" version="2.3.0">bowtie2</requirement>
</requirements>
<command interpreter="python">bowtie2_index_builder.py "${out_file}" --fasta_filename "${all_fasta_source.fields.path}" --fasta_dbkey "${all_fasta_source.fields.dbkey}" --fasta_description "${all_fasta_source.fields.name}" --data_table_name "bowtie2_indexes" ${tophat2}</command>
<stdio>
<exit_code range=":-1" />
<exit_code range="1:" />
</stdio>
<command detect_errors="exit_code">python '$__tool_directory__/bowtie2_index_builder.py' '${out_file}' --fasta_filename '${all_fasta_source.fields.path}' --fasta_dbkey '${all_fasta_source.fields.dbkey}' --fasta_description '${all_fasta_source.fields.name}' --data_table_name bowtie2_indexes ${tophat2}</command>
<inputs>
<param name="all_fasta_source" type="select" label="Source FASTA Sequence">
<options from_data_table="all_fasta"/>
</param>
<param type="text" name="sequence_name" value="" label="Name of sequence" />
<param type="text" name="sequence_id" value="" label="ID for sequence" />
<param type="boolean" name="tophat2" label="Also make available for TopHat" checked="True" truevalue="--data_table_name tophat2_indexes" falsevalue="" help="Adds values to tophat2_indexes tool data table." />
<param name="sequence_name" type="text" value="" label="Name of sequence" />
<param name="sequence_id" type="text" value="" label="ID for sequence" />
<param name="tophat2" type="boolean" truevalue="--data_table_name tophat2_indexes" falsevalue="" checked="True" label="Also make available for TopHat" help="Adds values to tophat2_indexes tool data table" />
</inputs>
<outputs>
<data name="out_file" format="data_manager_json"/>
</outputs>

<help>

.. class:: infomark

**Notice:** If you leave name, description, or id blank, it will be generated automatically.

**Notice:** If you leave name, description, or id blank, it will be generated automatically.
</help>
</tool>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
<?xml version="1.0"?>
<tool id="kraken_database_builder" name="Kraken" tool_type="manage_data" version="1.0.1">
<tool id="kraken_database_builder" name="Kraken" tool_type="manage_data" version="1.0.2">
<description>database builder</description>
<requirements>
<requirement type="package" version="0.10.6-eaf8fb68">kraken</requirement>
<requirement type="package" version="1.1.11">jellyfish</requirement>
<requirement type="set_environment">KRAKEN_SCRIPT_PATH</requirement>
</requirements>
<stdio>
<exit_code description="Error" level="fatal" range="1:" />
</stdio>
<version_command>kraken -version | awk '{print $NF}'</version_command>
<command>
<command detect_errors="exit_code">
<![CDATA[
#set $library_list = str($libraries).split(',')
mkdir kraken-database && cd kraken-database &&
kraken-build --threads \${GALAXY_SLOTS:-1} --download-taxonomy --db "${database_name}" &&
kraken-build --threads \${GALAXY_SLOTS:-1} --download-taxonomy --db '${database_name}' &&
#for $library in $library_list:
#if str($library) != 'None':
kraken-build --threads \${GALAXY_SLOTS:-1} --download-library $library --db "${database_name}" &&
kraken-build --threads \${GALAXY_SLOTS:-1} --download-library $library --db '${database_name}' &&
#end if
#end for
#for $fasta in $input_fasta:
#if str($fasta) != 'None':
kraken-build --threads \${GALAXY_SLOTS:-1} --db "${database_name}" --add-to-library "$fasta" &&
kraken-build --threads \${GALAXY_SLOTS:-1} --db '${database_name}' --add-to-library '$fasta' &&
#end if
#end for
kraken-build --threads \${GALAXY_SLOTS:-1} --db "${database_name}" --build --kmer-len ${kmer_len} --minimizer-len ${minimizer_len} &&
cd .. && python \$KRAKEN_SCRIPT_PATH/data_manager/make_json.py --db "${database_name}" --out "${out_file}"
kraken-build --threads \${GALAXY_SLOTS:-1} --db '${database_name}' --build --kmer-len ${kmer_len} --minimizer-len ${minimizer_len} &&
cd .. &&
python '$__tool_directory__/make_json.py' --db '${database_name}' --out '${out_file}'
]]>
</command>
<inputs>
<param label="Name for this database" name="database_name" type="text" />
<param label="Select partial library to download" multiple="True" name="libraries" type="select">
<param name="database_name" type="text" label="Name for this database" />
<param name="libraries" type="select" multiple="true" label="Select partial library to download">
<option value="bacteria">Bacteria</option>
<option value="plasmids">Plasmids</option>
<option value="viruses">Viruses</option>
<option value="human">Human</option>
</param>
<param format="fasta" label="Select history item" multiple="True" name="input_fasta" optional="True" type="data" />
<param label="K-mer length in BP" name="kmer_len" type="integer" value="31" />
<param label="Minimizer length" name="minimizer_len" type="integer" value="15" />
<param name="input_fasta" type="data" format="fasta" multiple="True" optional="true" label="Select history item" />
<param name="kmer_len" type="integer" value="31" label="K-mer length in BP" />
<param name="minimizer_len" type="integer" value="15" label="Minimizer length" />
</inputs>
<outputs>
<data format="data_manager_json" name="out_file" />
<data name="out_file" format="data_manager_json" />
</outputs>
<help>
</help>
<citations>
<citation type="doi">10.1186/gb-2014-15-3-r46</citation>
</citations>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import json
import argparse
import json
import os
import shutil

parser = argparse.ArgumentParser(description='Create data manager json.')
parser.add_argument('--db', dest='database', action='store', help='Database name')
parser.add_argument('--out', dest='output', action='store', help='JSON filename')

args = parser.parse_args()

def main(args):
data_manager_entry = {}
Expand All @@ -23,6 +18,10 @@ def main(args):
shutil.move(os.path.join(output_path, filename), target_directory)
file(args.output, 'w').write(json.dumps(data_manager_json))


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Create data manager json.')
parser.add_argument('--db', dest='database', action='store', help='Database name')
parser.add_argument('--out', dest='output', action='store', help='JSON filename')
args = parser.parse_args()
main(args)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import argparse
import datetime
import json
import os
import sys
import uuid
import json
import argparse
import datetime

import requests
from requests.exceptions import ContentDecodingError

Expand Down Expand Up @@ -37,8 +38,6 @@ def url_download(url):


def main():

# Generate and parse command line args
parser = argparse.ArgumentParser(description='Create data manager JSON.')
parser.add_argument('--out', dest='output', action='store',
help='JSON filename')
Expand Down Expand Up @@ -70,5 +69,6 @@ def main():
with open(os.path.join(args.output), "w+") as f:
f.write(json.dumps(data_manager_entry))


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<?xml version="1.0"?>
<tool id="gene_annotation_fetcher_data_manager" name="Gene Annotation Fetch" tool_type="manage_data" version="1.0.0">
<tool id="gene_annotation_fetcher_data_manager" name="Gene Annotation Fetch" tool_type="manage_data" version="1.0.1">
<description>gene annotation fetcher</description>
<stdio>
<exit_code description="Error" level="fatal" range="1:" />
</stdio>
<command interpreter="python">
<requirements>
<requirement type="package" version="2.13.0">requests</requirement>
</requirements>
<command detect_errors="exit_code">
<![CDATA[
data_manager.py --out "${out_file}"
python '$__tool_directory__/data_manager.py' --out '${out_file}'
#if $gene_annotation_url:
--url "${gene_annotation_url}"
--url '${gene_annotation_url}'
#end if
#if $database_name:
--name "${database_name}"
--name '${database_name}'
#end if
]]>
</command>
<inputs>
<param help="Enter a unique identifier, or leave blank for today's date" label="Name for this database" name="database_name" type="text" optional="True" />
<param label="Enter URL for gene annotation files" name="gene_annotation_url" type="text" />
<param name="database_name" type="text" optional="true" label="Name for this database" help="Enter a unique identifier, or leave blank for today's date" />
<param name="gene_annotation_url" type="text" label="Enter URL for gene annotation files" />
</inputs>
<outputs>
<data format="data_manager_json" name="out_file" />
</outputs>
<help>
</help>
</tool>
Loading