# HG changeset patch
# User jeremyjliu
# Date 1421022112 18000
# Node ID ba049ce6569314a20f5105c689879e6d8c2c520e
Initial upload
diff -r 000000000000 -r ba049ce65693 data_manager/data_manager_fetch_motifs.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager_fetch_motifs.py Sun Jan 11 19:21:52 2015 -0500
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#Dan Blankenberg
+
+import sys
+import os
+import tempfile
+import shutil
+import optparse
+import urllib2
+#import uuid
+from ftplib import FTP
+import tarfile
+import zipfile
+import gzip
+import bz2
+
+from galaxy.util.json import from_json_string, to_json_string
+
+CHUNK_SIZE = 2**20 #1mb
+
+def download_motif_databases( data_manager_dict, params, target_directory, motif_db ):
+ TEST_DOWNLOAD_URL = 'http://gehlenborg.com/wp-content/uploads/motif/pouya_test_motifs.bed.bgz'
+ #TO DO: Add tbi file
+
+ url = TEST_DOWNLOAD_URL
+ fasta_reader = urllib2.urlopen( url )
+
+ data_table_entry = _stream_fasta_to_file( fasta_reader, target_directory, params )
+ _add_data_table_entry( data_manager_dict, data_table_entry )
+
+def _add_data_table_entry( data_manager_dict, data_table_entry ):
+ data_manager_dict['data_tables'] = data_manager_dict.get( 'data_tables', {} )
+ data_manager_dict['data_tables']['all_fasta'] = data_manager_dict['data_tables'].get( 'all_fasta', [] )
+ data_manager_dict['data_tables']['all_fasta'].append( data_table_entry )
+ return data_manager_dict
+
+def _stream_fasta_to_file( fasta_stream, target_directory, params, close_stream=True ):
+ fasta_base_filename = "pouya_test_motifs.bed.bgz"
+ fasta_filename = os.path.join( target_directory, fasta_base_filename )
+ fasta_writer = open( fasta_filename, 'wb+' )
+
+ while True:
+ buffer = fasta_stream.read(CHUNK_SIZE)
+ if not buffer:
+ break
+
+ fasta_writer.write(buffer)
+
+ fasta_stream.close()
+ fasta_writer.close()
+
+ return dict( value="test", name="Test Pouya Subset (hg19)", path=fasta_base_filename )
+
+def main():
+ #Parse Command Line
+ parser = optparse.OptionParser()
+ parser.add_option( '-m', '--motif_db', dest='motif_db', action='store', type="string", default=None, help='motif_db' )
+ (options, args) = parser.parse_args()
+
+ filename = args[0]
+
+ params = from_json_string( open( filename ).read() )
+ target_directory = params[ 'output_data' ][0]['extra_files_path']
+ os.mkdir( target_directory )
+ data_manager_dict = {}
+
+ #Fetch the Motif Database
+ download_motif_databases( data_manager_dict, params, target_directory, motif_db )
+
+ #save info to json file
+ open( filename, 'wb' ).write( to_json_string( data_manager_dict ) )
+
+if __name__ == "__main__": main()
diff -r 000000000000 -r ba049ce65693 data_manager/data_manager_fetch_motifs.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/data_manager_fetch_motifs.xml Sun Jan 11 19:21:52 2015 -0500
@@ -0,0 +1,22 @@
+
+ fetching
+ data_manager_fetch_motifs.py "${out_file}" --motif_db ${motif_db_selector}
+
+
+
+
+
+
+
+
+
+
+
+
+ **What it does**
+
+ Fetches a reference genome from various sources (UCSC, NCBI, URL, Galaxy History, or a server directory) and populates the "all_fasta" data table.
+
+ **Notice:** If you leave name, description, or id blank, it will be generated automatically.
+
+
diff -r 000000000000 -r ba049ce65693 data_manager/test.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager/test.py Sun Jan 11 19:21:52 2015 -0500
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+import optparse
+
+def main():
+ #Parse Command Line
+ parser = optparse.OptionParser()
+ parser.add_option( '-d', '--dbkey_description', dest='dbkey_description', action='store', type="string", default=None, help='dbkey_description' )
+ (options, args) = parser.parse_args()
+
+ filename = args[0]
+ print(args)
+
+main()
\ No newline at end of file
diff -r 000000000000 -r ba049ce65693 data_manager_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/data_manager_conf.xml Sun Jan 11 19:21:52 2015 -0500
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r ba049ce65693 tool-data/all_fasta.loc.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/all_fasta.loc.sample Sun Jan 11 19:21:52 2015 -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):
+#
+#
+#
+#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.
+#
diff -r 000000000000 -r ba049ce65693 tool_data_table_conf.xml.sample
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample Sun Jan 11 19:21:52 2015 -0500
@@ -0,0 +1,7 @@
+
+
+
+