[wplug] Text searching

Doug Green diego96 at mac.com
Wed Mar 26 17:55:11 EST 2003


Thank you all for the solutions to my problem. I picked up a copy of 
"Beginning Perl for Bioinformatics" as well as "Developing 
Bioinformatics Skills", both from O'Reilly press and both really 
worthwhile. Between your suggestions and those books, I was able to 
finish the task at hand. Nevertheless, I can't believe that there isn't 
one unified tool that will do what I needed to do. I think this is a 
huge opportunity if anyone wants a perl side project. Molecular biology 
bores some people to tears, so I won't go into details, but if anyone 
wants to contribute their perl skills to making a useful tool, please 
let me know... Unfortunately, I can't contribute much on the perl side, 
but I definitely know the "user" side! :) Thanks again for the help!
Doug


On Friday, March 21, 2003, at 07:59 PM, Tom Moertel wrote:

> On Mon, 2003-03-17 at 09:07, Doug Green wrote:
>> Hi all-
>>
>> I have some large text files that I need to search. [...]
>> Essentially, the format
>> looks like this (obviously, the content is different):
>>
>> 1       atacaatagg atacaatagg atacaatagg atacaatagg atacaatagg 
>> atacaatagg
>> 61     atacaatagg atacaatagg atacaatagg atacaatagg atacaatagg 
>> atacaatagg
>>
>> I need to be able to search within this kind of text file for a 
>> string of
>> letters that is maybe 30-40 letters long, ignoring the spaces and 
>> numbers.
>
> (Sorry I didn't respond to your query earlier.  I saw your email only
> just now.)
>
> The following Perl one-liner will do what you need:
>
>   perl -nle 'tr/a-z//cd; print "$ARGV:$." if /PATTERN/' FILES...
>
> Just replace PATTERN with the string you want to find and FILES with 
> the
> list of files you want to search.  The output will indicate matches by
> filename and line number:
>
>   file1:39
>   file1:993
>   file2:23
>
> If you want a full explanation of the techniques used in this 
> one-liner,
> read the perlrun man page for explanations of the -n, -l, and -e
> switches; the perlvar manpage for the $ARGV and $. variables; and the
> perlop manpage for the tr// and // "regex quote-like" operators.
>
> Cheers,
> Tom Moertel
> Moertel Consulting / www.moertel.com
>
>
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
>




More information about the wplug mailing list