mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add FIMO tool from MEME suite.
This commit is contained in:
@@ -90,7 +90,7 @@
|
||||
</datatype>
|
||||
<datatype extension="picard_interval_list" type="galaxy.datatypes.data:Text" subclass="True" display_in_upload="True"/>
|
||||
<datatype extension="gatk_interval" type="galaxy.datatypes.data:Text" subclass="True" display_in_upload="True"/>
|
||||
<datatype extension="gatk_dbsnp" type="galaxy.datatypes.data:Text" subclass="True" display_in_upload="True"/>
|
||||
<datatype extension="gatk_dbsnp" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"/>
|
||||
<datatype extension="jpg" type="galaxy.datatypes.images:Jpg" mimetype="image/jpeg"/>
|
||||
<datatype extension="tiff" type="galaxy.datatypes.images:Tiff" mimetype="image/tiff"/>
|
||||
<datatype extension="bmp" type="galaxy.datatypes.images:Bmp" mimetype="image/bmp"/>
|
||||
@@ -134,6 +134,7 @@
|
||||
<datatype extension="twobit" type="galaxy.datatypes.binary:TwoBit" mimetype="application/octet-stream" display_in_upload="true"/>
|
||||
<datatype extension="txt" type="galaxy.datatypes.data:Text" display_in_upload="true"/>
|
||||
<datatype extension="memexml" type="galaxy.datatypes.xml:MEMEXml" mimetype="application/xml" display_in_upload="true"/>
|
||||
<datatype extension="cisml" type="galaxy.datatypes.xml:CisML" mimetype="application/xml" display_in_upload="true"/>
|
||||
<datatype extension="blastxml" type="galaxy.datatypes.xml:BlastXml" mimetype="application/xml" display_in_upload="true"/>
|
||||
<datatype extension="vcf" type="galaxy.datatypes.tabular:Vcf" display_in_upload="true">
|
||||
<converter file="vcf_to_bgzip_converter.xml" target_datatype="bgzip"/>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<tool id="meme_fimo" name="FIMO" version="0.0.1">
|
||||
<description>- Find Individual Motif Occurrences</description>
|
||||
<command interpreter="python">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}'
|
||||
|
||||
</command>
|
||||
<inputs>
|
||||
<param format="memexml" name="input_motifs" type="data" label="'MEME output' formatted file"/>
|
||||
|
||||
<conditional name="fasta_type">
|
||||
<param name="fasta_type_selector" type="select" label="Source for sequence to search">
|
||||
<option value="cached">Locally Cached sequences</option>
|
||||
<option value="history" selected="true">Sequences from your history</option>
|
||||
</param>
|
||||
<when value="cached">
|
||||
<param name="input_database" type="select" label="Genome to search">
|
||||
<options from_data_table="all_fasta">
|
||||
</options>
|
||||
</param>
|
||||
</when>
|
||||
<when value="history">
|
||||
<param format="fasta" name="input_database" type="data" label="Sequences"/>
|
||||
</when>
|
||||
</conditional>
|
||||
|
||||
<conditional name="options_type">
|
||||
<param name="options_type_selector" type="select" label="Options Configuration">
|
||||
<option value="basic" selected="true">Basic</option>
|
||||
<option value="advanced">Advanced</option>
|
||||
</param>
|
||||
<when value="basic">
|
||||
<!-- do nothing here -->
|
||||
</when>
|
||||
<when value="advanced">
|
||||
|
||||
<conditional name="bgfile_type">
|
||||
<param name="bgfile_type_selector" type="select" label="Background file type">
|
||||
<option value="motif-file">Use Frequencies from Motif File</option>
|
||||
<option value="default" selected="true">Use frequencies from non-redundant database (default)</option>
|
||||
<option value="bgfile">Use Frequencies from Background File</option>
|
||||
</param>
|
||||
<when value="motif-file">
|
||||
<!-- do nothing here -->
|
||||
</when>
|
||||
<when value="default">
|
||||
<!-- do nothing here -->
|
||||
</when>
|
||||
<when value="bgfile">
|
||||
<param name="bgfile" type="data" format="txt" optional="True" label="Background Model" />
|
||||
</when>
|
||||
</conditional>
|
||||
|
||||
<repeat name="motifs" title="Limit to specified motif">
|
||||
<param name="motif" type="text" value="" label="Specify motif by id" />
|
||||
</repeat>
|
||||
|
||||
<param name="max_seq_length" type="integer" value="250000000" label="Maximum input sequence length" />
|
||||
<param name="max_stored_scores" type="integer" value="100000" label="Maximum score count to store" />
|
||||
<param name="motif_pseudo" type="float" value="0.1" label="Pseudocount to add to counts in motif matrix" />
|
||||
<param name="norc" label="Do not check reverse complement" type="boolean" truevalue="--norc" falsevalue="" checked="False"/>
|
||||
<param name="output_pthresh" type="float" value="1e-4" label="p-value threshold" />
|
||||
|
||||
<conditional name="qvalue_type">
|
||||
<param name="qvalue_type_selector" type="select" label="q-value options">
|
||||
<option value="no-qvalue">Do not compute q-value</option>
|
||||
<option value="q-value" selected="true">Compute q-value</option>
|
||||
</param>
|
||||
<when value="no-qvalue">
|
||||
<!-- do nothing here -->
|
||||
</when>
|
||||
<when value="q-value">
|
||||
<param name="output_qthresh" type="float" value="1.0" label="q-value threshold" />
|
||||
</when>
|
||||
</conditional>
|
||||
|
||||
</when>
|
||||
</conditional>
|
||||
|
||||
<param name="non_commercial_use" label="I certify that I am not using this tool for commercial purposes." type="boolean" truevalue="NON_COMMERCIAL_USE" falsevalue="COMMERCIAL_USE" checked="False">
|
||||
<validator type="expression" message="This tool is only available for non-commercial use.">value == True</validator>
|
||||
</param>
|
||||
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data format="html" name="html_outfile" label="${tool.name} on ${on_string} (html)">
|
||||
<actions>
|
||||
<conditional name="fasta_type.fasta_type_selector">
|
||||
<when value="cached">
|
||||
<action type="metadata" name="dbkey">
|
||||
<option type="from_data_table" name="all_fasta" column="1" offset="0">
|
||||
<filter type="param_value" column="0" value="seq" keep="True"/>
|
||||
<filter type="param_value" ref="fasta_type.input_database" column="1"/>
|
||||
</option>
|
||||
</action>
|
||||
</when>
|
||||
</conditional>
|
||||
</actions>
|
||||
</data>
|
||||
<data format="tabular" name="txt_outfile" label="${tool.name} on ${on_string} (text)">
|
||||
<actions>
|
||||
<conditional name="fasta_type.fasta_type_selector">
|
||||
<when value="cached">
|
||||
<action type="metadata" name="dbkey">
|
||||
<option type="from_data_table" name="all_fasta" column="1" offset="0">
|
||||
<filter type="param_value" ref="fasta_type.input_database" column="0"/>
|
||||
</option>
|
||||
</action>
|
||||
</when>
|
||||
</conditional>
|
||||
</actions>
|
||||
</data>
|
||||
<data format="tabular" name="gff_outfile" label="${tool.name} on ${on_string} (almost-gff)">
|
||||
<actions>
|
||||
<conditional name="fasta_type.fasta_type_selector">
|
||||
<when value="cached">
|
||||
<action type="metadata" name="dbkey">
|
||||
<option type="from_data_table" name="all_fasta" column="1" offset="0">
|
||||
<filter type="param_value" ref="fasta_type.input_database" column="0"/>
|
||||
</option>
|
||||
</action>
|
||||
</when>
|
||||
</conditional>
|
||||
</actions>
|
||||
</data>
|
||||
<data format="cisml" name="xml_outfile" label="${tool.name} on ${on_string} (xml)">
|
||||
<actions>
|
||||
<conditional name="fasta_type.fasta_type_selector">
|
||||
<when value="cached">
|
||||
<action type="metadata" name="dbkey">
|
||||
<option type="from_data_table" name="all_fasta" column="1" offset="0">
|
||||
<filter type="param_value" ref="fasta_type.input_database" column="0"/>
|
||||
</option>
|
||||
</action>
|
||||
</when>
|
||||
</conditional>
|
||||
</actions>
|
||||
</data>
|
||||
<data format="interval" name="interval_outfile" label="${tool.name} on ${on_string} (interval)">
|
||||
<actions>
|
||||
<conditional name="fasta_type.fasta_type_selector">
|
||||
<when value="cached">
|
||||
<action type="metadata" name="dbkey">
|
||||
<option type="from_data_table" name="all_fasta" column="1" offset="0">
|
||||
<filter type="param_value" ref="fasta_type.input_database" column="0"/>
|
||||
</option>
|
||||
</action>
|
||||
</when>
|
||||
</conditional>
|
||||
</actions>
|
||||
</data>
|
||||
</outputs>
|
||||
<tests>
|
||||
<test>
|
||||
<param name="input_motifs" value="meme/meme/meme_output_xml_1.xml" ftype="memexml"/>
|
||||
<param name="fasta_type_selector" value="history"/>
|
||||
<param name="input_database" value="phiX.fasta" ftype="fasta"/>
|
||||
<param name="options_type_selector" value="basic"/>
|
||||
<param name="non_commercial_use" value="True"/>
|
||||
<output name="html_outfile" file="meme/fimo/fimo_output_html_1.html" lines_diff="12"/>
|
||||
<output name="txt_outfile" file="meme/fimo/fimo_output_txt_1.txt" lines_diff="0"/>
|
||||
<output name="gff_outfile" file="meme/fimo/fimo_output_almost-gff_1.txt" lines_diff="0"/>
|
||||
<output name="xml_outfile" file="meme/fimo/fimo_output_xml_1.xml" lines_diff="8"/>
|
||||
<output name="interval_outfile" file="meme/fimo/fimo_output_interval_1.txt" lines_diff="0"/>
|
||||
</test>
|
||||
</tests>
|
||||
<help>
|
||||
|
||||
.. 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
|
||||
|
||||
</help>
|
||||
</tool>
|
||||
@@ -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()
|
||||
+1
-1
@@ -316,7 +316,7 @@
|
||||
</outputs>
|
||||
<tests>
|
||||
<test>
|
||||
<param name="input1" value="meme_input_1.fasta" ftype="fasta" dbkey="hg19"/>
|
||||
<param name="input1" value="meme/meme/meme_input_1.fasta" ftype="fasta" dbkey="hg19"/>
|
||||
<param name="options_type_selector" value="basic"/>
|
||||
<param name="non_commercial_use" value="True"/>
|
||||
<output name="html_outfile" file="meme/meme/meme_output_html_1.html" lines_diff="12"/>
|
||||
|
||||
Reference in New Issue
Block a user