/tools/filters/grep.xml

https://bitbucket.org/cistrome/cistrome-harvard/ · XML · 82 lines · 71 code · 11 blank · 0 comment · 0 complexity · 2891f6dc7c9c27dd7cef3c124eaeceeb MD5 · raw file

  1. <tool id="Grep1" name="Select" version="1.0.1">
  2. <description>lines that match an expression</description>
  3. <command interpreter="python">grep.py -i $input -o $out_file1 -pattern '$pattern' -v $invert</command>
  4. <inputs>
  5. <param format="txt" name="input" type="data" label="Select lines from"/>
  6. <param name="invert" type="select" label="that">
  7. <option value="false">Matching</option>
  8. <option value="true">NOT Matching</option>
  9. </param>
  10. <param name="pattern" size="40" type="text" value="^chr([0-9A-Za-z])+" label="the pattern" help="here you can enter text or regular expression (for syntax check lower part of this frame)">
  11. <sanitizer>
  12. <valid initial="string.printable">
  13. <remove value="&apos;"/>
  14. </valid>
  15. <mapping initial="none">
  16. <add source="&apos;" target="__sq__"/>
  17. </mapping>
  18. </sanitizer>
  19. </param>
  20. </inputs>
  21. <outputs>
  22. <data format="input" name="out_file1" metadata_source="input"/>
  23. </outputs>
  24. <tests>
  25. <test>
  26. <param name="input" value="1.bed"/>
  27. <param name="invert" value="false"/>
  28. <param name="pattern" value="^chr[0-9]*"/>
  29. <output name="out_file1" file="fs-grep.dat"/>
  30. </test>
  31. </tests>
  32. <help>
  33. .. class:: infomark
  34. **TIP:** If your data is not TAB delimited, use *Text Manipulation-&gt;Convert*
  35. -----
  36. **Syntax**
  37. The select tool searches the data for lines containing or not containing a match to the given pattern. Regular Expression is introduced in this tool. A Regular Expression is a pattern describing a certain amount of text.
  38. - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
  39. - **\\A** matches the beginning of a string(but not an internal line).
  40. - **\\d** matches a digit, same as [0-9].
  41. - **\\D** matches a non-digit.
  42. - **\\s** matches a whitespace character.
  43. - **\\S** matches anything BUT a whitespace.
  44. - **\\t** matches a tab.
  45. - **\\w** matches an alphanumeric character.
  46. - **\\W** matches anything but an alphanumeric character.
  47. - **(** .. **)** groups a particular pattern.
  48. - **\\Z** matches the end of a string(but not a internal line).
  49. - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
  50. - **{n}** The preceding item is matched exactly n times.
  51. - **{n,}** The preceding item is matched n or more times.
  52. - **{n,m}** The preceding item is matched at least n times but not more than m times.
  53. - **[** ... **]** creates a character class. Within the brackets, single characters can be placed. A dash (-) may be used to indicate a range such as **a-z**.
  54. - **.** Matches any single character except a newline.
  55. - ***** The preceding item will be matched zero or more times.
  56. - **?** The preceding item is optional and matched at most once.
  57. - **+** The preceding item will be matched one or more times.
  58. - **^** has two meaning:
  59. - matches the beginning of a line or string.
  60. - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
  61. - **$** matches the end of a line or string.
  62. - **\|** Separates alternate possibilities.
  63. -----
  64. **Example**
  65. - **^chr([0-9A-Za-z])+** would match lines that begin with chromosomes, such as lines in a BED format file.
  66. - **(ACGT){1,5}** would match at least 1 "ACGT" and at most 5 "ACGT" consecutively.
  67. - **([^,][0-9]{1,3})(,[0-9]{3})\*** would match a large integer that is properly separated with commas such as 23,078,651.
  68. - **(abc)|(def)** would match either "abc" or "def".
  69. - **^\\W+#** would match any line that is a comment.
  70. </help>
  71. </tool>