User Tools

Site Tools


2018grep_motifs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
2018grep_motifs [2018/09/10 11:29]
david [Variable length patterns]
2018grep_motifs [2018/09/10 11:37] (current)
david
Line 74: Line 74:
  
 <code bash> <code bash>
-grep -bi AAT{,5}G output/* +$ egrep -bi 'AAT{,4}G' ​output/*
-grep: AAT5G: No such file or directory+
 output/​F56H9.5.1.fa:​24:​catccatttatactattgcaccgaatattgggttaatgtcggtgtttgaa output/​F56H9.5.1.fa:​24:​catccatttatactattgcaccgaatattgggttaatgtcggtgtttgaa
 output/​F56H9.5.1.fa:​75:​tatattttggttacagtttaaatgcttcaaatttaaatcaattaaatc output/​F56H9.5.1.fa:​75:​tatattttggttacagtttaaatgcttcaaatttaaatcaattaaatc
Line 81: Line 80:
 </​code>​ </​code>​
  
-We lost our R13A5.5.1.fa match. ​Let'+We lost our R13A5.5.1.fa match. ​We can restore it by increasing the upper bound to 5 or higher. 
 +<code bash> 
 +$ egrep -bi 'AAT{,​5}G'​ output/* 
 +output/​F56H9.5.1.fa:​24:​catccatttatactattgcaccgaatattgggttaatgtcggtgtttgaa 
 +output/​F56H9.5.1.fa:​75:​tatattttggttacagtttaaatgcttcaaatttaaatcaattaaatc 
 +output/​F56H9.5.2.fa:​24:​ttaaatgcttcaaatttaaatcaattaaatc 
 +output/​R13A5.5.1.fa:​24:​ttactaatttttgttatcttatcaaacaaatatattttccagc 
 +</​code>​ 
 + 
 +Here is the full set of repetition operators in regular expressions. 
 +<code bash> 
 +$ man grep 
 +</​code>​ 
 + 
 +...Scrolling way down... 
 + 
 +<​code>​ 
 +   ​Repetition 
 +       A regular expression may be followed by one of several repetition operators:​ 
 +       ? ​     The preceding item is optional and matched at most once. 
 +       ​* ​     The preceding item will be matched zero or more times. 
 +       ​+ ​     The preceding item will be matched one or more times. 
 +       ​{n} ​   The preceding item is matched exactly n times. 
 +       ​{n,​} ​  The preceding item is matched n or more times. 
 +       ​{,​m} ​  The preceding item is matched at most m times. ​ This is a GNU extension. 
 +       ​{n,​m} ​ The preceding item is matched at least n times, but not more than m times. 
 +</​code>​ 
 + 
 +Regular expressions are a general concept, but different commands may have different limitations on what they support. 
 +There are more operators, patterns, and capabilities of regular expressions,​ but like most things we've encountered,​ YOU MUST TEST each command to make sure it works as expected.
2018grep_motifs.1536600584.txt.gz · Last modified: 2018/09/10 11:29 by david