diff --git a/datatypes_conf.xml.sample b/datatypes_conf.xml.sample index c3e16ab19f2..baaf220e5df 100644 --- a/datatypes_conf.xml.sample +++ b/datatypes_conf.xml.sample @@ -90,7 +90,7 @@ - + @@ -134,6 +134,7 @@ + diff --git a/lib/galaxy/datatypes/xml.py b/lib/galaxy/datatypes/xml.py index ad24137045e..2766982af26 100644 --- a/lib/galaxy/datatypes/xml.py +++ b/lib/galaxy/datatypes/xml.py @@ -102,3 +102,18 @@ class MEMEXml( GenericXml ): dataset.blurb = 'file purged from disk' def sniff( self, filename ): return False + +class CisML( GenericXml ): + """CisML XML data""" #see: http://www.ncbi.nlm.nih.gov/pubmed/15001475 + file_ext = "cisml" + + def set_peek( self, dataset, is_multi_byte=False ): + """Set the peek and blurb text""" + if not dataset.dataset.purged: + dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) + dataset.blurb = 'CisML data' + else: + dataset.peek = 'file does not exist' + dataset.blurb = 'file purged from disk' + def sniff( self, filename ): + return False diff --git a/tools/meme/fimo.xml b/tools/meme/fimo.xml new file mode 100644 index 00000000000..464ce7005f7 --- /dev/null +++ b/tools/meme/fimo.xml @@ -0,0 +1,230 @@ + + - Find Individual Motif Occurrences + fimo_wrapper.py 'fimo --o "${$html_outfile.files_path}" --verbosity "1" + + #if str( $options_type.options_type_selector ) == 'advanced': + --max-seq-length "${options_type.max_seq_length}" + --max-stored-scores "${options_type.max_stored_scores }" + --motif-pseudo "${options_type.motif_pseudo}" + ${options_type.norc} + --output-pthresh "${options_type.output_pthresh}" + + + #for $motif in $options_type.motifs: + --motif "${motif.motif}" + #end for + + #if str( $options_type.bgfile_type.bgfile_type_selector ) == 'motif-file': + --bgfile "motif-file" + #elif str( $options_type.bgfile_type.bgfile_type_selector ) == 'motif-file': + --bgfile "${options_type.bgfile_type.bgfile}" + #end if + + #if str( $options_type.qvalue_type.qvalue_type_selector ) == 'no-qvalue': + --no-qvalue + #else: + --output-qthresh "${options_type.qvalue_type.output_qthresh}" + #end if + #end if + + "${input_motifs}" + + #if str( $fasta_type.fasta_type_selector ) == 'history': + "${fasta_type.input_database}" + #else: + "${ filter( lambda x: str( x[0] ) == str( $fasta_type.input_database ), $__app__.tool_data_tables[ 'all_fasta' ].get_fields() )[0][3] }" + #end if + + ' + + '${html_outfile.files_path}' + + '${html_outfile}' + + '${interval_outfile}' + + '${txt_outfile}' + + '${xml_outfile}' + + '${gff_outfile}' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + value == True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.. class:: warningmark + +**WARNING: This tool is only available for non-commercial use. Use for educational, research and non-profit purposes is permitted. Before using, be sure to review, agree, and comply with the license.** + +.. class:: infomark + +**To cite FIMO:** +`Grant CE, Bailey TL, Noble WS. FIMO: scanning for occurrences of a given motif. Bioinformatics. 2011 Apr 1;27(7):1017-8. <http://www.ncbi.nlm.nih.gov/pubmed/21330290>`_ + + +For detailed information on FIMO, click here_. To view the license_. + +.. _here: http://meme.nbcr.net/meme/fimo-intro.html +.. _license: http://meme.nbcr.net/meme/COPYRIGHT.html + + + diff --git a/tools/meme/fimo_wrapper.py b/tools/meme/fimo_wrapper.py new file mode 100644 index 00000000000..467fa3979c3 --- /dev/null +++ b/tools/meme/fimo_wrapper.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +#Dan Blankenberg + +""" +Read text output from FIMO and create an interval file. +""" +import sys, tempfile, subprocess, shutil, os +from galaxy_utils.sequence.transform import DNA_reverse_complement + +buffsize = 1048576 + +def stop_err( msg ): + sys.stderr.write( msg ) + sys.exit() + +def main(): + assert len( sys.argv ) == 8, "Wrong number of arguments" + sys.argv.pop(0) + fimo_cmd = sys.argv.pop(0) + html_path = sys.argv.pop(0) + html_out = sys.argv.pop(0) + interval_out = sys.argv.pop(0) + txt_out = sys.argv.pop(0) + xml_out = sys.argv.pop(0) + gff_out = sys.argv.pop(0) + + #run fimo + try: + tmp_stderr = tempfile.NamedTemporaryFile() + #tmp_stderr = open( tmp_filename, 'wb' ) + proc = subprocess.Popen( args=fimo_cmd, shell=True, stderr=tmp_stderr ) + returncode = proc.wait() + #tmp_stderr.close() + # get stderr, allowing for case where it's very large + #tmp_stderr = open( tmp, 'rb' ) + tmp_stderr.seek(0) + stderr = '' + try: + while True: + stderr += tmp_stderr.read( buffsize ) + if not stderr or len( stderr ) % buffsize != 0: + break + except OverflowError: + pass + + if returncode != 0: + raise Exception, stderr + except Exception, e: + raise Exception, 'Error running FIMO:\n' + str( e ) + + shutil.move( os.path.join( html_path, 'fimo.txt' ), txt_out ) + shutil.move( os.path.join( html_path, 'fimo.gff' ), gff_out ) + shutil.move( os.path.join( html_path, 'fimo.xml' ), xml_out ) + shutil.move( os.path.join( html_path, 'fimo.html' ), html_out ) + + out_file = open( interval_out, 'wb' ) + out_file.write( "#%s\n" % "\t".join( ( "chr", "start", "end", "pattern name", "score", "strand", "matched sequence", "p-value", "q-value" ) ) ) + for line in open( txt_out ): + if line.startswith( '#' ): continue + fields = line.rstrip( "\n\r" ).split( "\t" ) + start, end = int( fields[2] ), int( fields[3] ) + sequence = fields[7] + if start > end: + start, end = end, start #flip start and end, and set strand + strand = "-" + sequence = DNA_reverse_complement( sequence ) #we want sequences relative to strand; FIMO always provides + stranded sequence + else: + strand = "+" + start -= 1 #make 0-based start position + out_file.write( "%s\n" % "\t".join( [ fields[1], str( start ), str( end ), fields[0], fields[4], strand, sequence, fields[5], fields[6] ] ) ) + out_file.close() + +if __name__ == "__main__": main() diff --git a/tools/meme/meme.xml b/tools/meme/meme.xml index 3d480794a0e..fef690527de 100644 --- a/tools/meme/meme.xml +++ b/tools/meme/meme.xml @@ -316,7 +316,7 @@ - +