0\.0 is better than 0.0 in your grep instruction or it will catch things like 010, etc.
Hi,
I am having hard time with greping e-value 0.0 in blast outfmt 6 I cant find right combination of non printing characters as tabs are coded as '^I' .
How do you do it?
Example:
query1 Contig_0004161 98.69 381 5 0 3 383 233134 233514 0.0 676
cat -A outputs
query1^IContig_0004161^I98.69^I381^I5^I0^I3^I383^I233134^I233514^I0.0^I 676
Thanks in advance!
3 answers
Don't use grep, use awk instead like awk -v FS='\t' '$11 < 1e-6', replace 1e-6 with a number small enough for your needs. I wouldn't use 0.0 though as in theory it is not meaningful.
By the way, if you really want to use grep maybe grep -P '\t0\.0\t\d+$'?
Thanks, good point, I edited my answer. This reminds me: A programmer has a problem and thinks "I know, I'll use regular expressions". Now he has two problems.
Query1^IContig1^I100.00^I582^I0^I0^I62^I643^I39330^I39911^I0.0^I1075$
Query2^IContig2^I96.22^I582^I22^I0^I62^I643^I67349^I66768^I0.0^I 953$
Rob's grep -P '\t0\.0\t' would catch both lines
but
Dariober's grep -P '\t0\.0\t\d+$' only the first one.
+ does not match zero occurrences like the 1st character in last column.
In fact, it did not match any line in my file with e value 0.0 and Bit score lower than 1000.
The second line is not grep'd by '\t0\.0\t\d+$' because you have a space after the tab character. Is your input actually tab separated? Take care also that '\t0\.0\t' will match any line containing 0.0 surrounded by tab anywhere not just in the second last column (hence my suggestion of using '\t0.0\t\d+$').
In my opinion, parsing tabular data with regexes is a very bad idea. awk is better but still brittle, python is even better as you have much more control of what you are doing.
You can do:
grep $'\t0.0\t'
or:
egrep "\s0\.0\s"
or better:
grep -P '\t0\.0\t'
but the solution of dariober with awk is really prettier.
egrep "\s0\.0\s"
or
grep -P '\t0\.0\t'
both work as expected, thanks! I realise that it may catch all instances of '0.0', not only in e-value column.
Indeed awk seems better fitted for searching 0.0 in 11th, e-value column.
I'm a big fan of APIs so I usually use BioPerl or BioPython to parse BLAST results. In BioPerl and BioPython, there are modules handling different BLAST results without hick-ups like this one.
http://bioperl.org/howtos/SearchIO_HOWTO.html http://biopython.org/DIST/docs/tutorial/Tutorial.html
Log in to answer this question.
You can do that using simple awk
If you want to specific column, u could output that using the column number