Mercurial > repos > kellrott > regex_search
changeset 0:71f6f91d5ca3 draft default tip
Uploaded
author | kellrott |
---|---|
date | Thu, 05 Dec 2013 14:49:10 -0500 |
parents | |
children | |
files | regex_search/regex_search.xml |
diffstat | 1 files changed, 80 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/regex_search/regex_search.xml Thu Dec 05 14:49:10 2013 -0500 @@ -0,0 +1,80 @@ +<tool id="regex_search" name="Regex Search" version="1.0.0"> + <description>Regular Expression search using the Python re module</description> + <command interpreter="python">$script_file</command> + <inputs> + <param name="infile" type="data" label="Input File"/> + <param name="search_str" type="text" size="70" label="Search String"> + <sanitizer> + <valid initial="string.printable"> + <remove value="""/> + <remove value="\"/> + </valid> + <mapping initial="none"> + <add source=""" target="\""/> + <add source="\" target="\\"/> + </mapping> + </sanitizer> + </param> + <param name="ignore_case" type="boolean" label="Ignore Case" checked="False"/> + <param name="return_miss" type="boolean" label="Return Misses" checked="False"/> + </inputs> + <outputs> + <data name="outfile" format="txt"/> + </outputs> + <configfiles> + <configfile name="script_file"><![CDATA[#!/usr/bin/env python + +import re + +search_str = """${search_str}""" + +opts = 0 +#if $ignore_case: +opts |= re.IGNORECASE +#end if + +cmd = re.compile(search_str, opts) + +ihandle = open("""${infile}""") +ohandle = open("""${outfile}""", "w") + +for line in ihandle: +#if $return_miss: + if not cmd.match(line): + ohandle.write(line) +#else + if cmd.match(line): + ohandle.write(line) +#end if + +ihandle.close() +ohandle.close() + +]]></configfile> + </configfiles> + + <help> +Perform regular expression search using the Python re engine. You can find documentation on the Python regular +expression syntax `here <http://docs.python.org/2/library/re.html#regular-expression-syntax>`_ +This is very similar to the 'Select' tool that is included with Galaxy, however this version is powered by +Python's RE package, rather then grep, which should eliminate some of the minor differences between the versions of Grep +one would find in Mac or Linux. + +Example: +======== + Search String:: + + [^\s]+_\w+.* + + +Additional Options +================== + +Ignore Case: + Make searches case insensitive + +Return Misses: + Return lines that don't match the search string. + + </help> +</tool>