in reply to Re: search and print in perl
in thread search and print in perl

Thanks. A gene is like this: it is preceded by a string TATAAT and after this string there can be one or many strings of letters A,C,G,T . then ATG string follows them, then again random amount of A,C,G,T's follow it and the gene ends with one of the strings TAA, TGA or TAG. for example a gene is TATAATATTACAATGGATCATACAGTTAG ... our gene is the part between ATG and TAG but we also have to make sure it is preceded by a TATAAT.. I have to print out the genes in the txt file according to these rules.

Replies are listed 'Best First'.
Re^3: search and print in perl
by Bloodnok (Vicar) on Jun 01, 2009 at 12:42 UTC
    Assuming a definition per line i.e. not split over multiple lines, then...
    use warnings; use strict; local $/; my $data = <DATA>; while ($data =~ /TATAAT[ACGT]+ATG([ACGT]+)(:?T(:?GA|AA|AG))/cgs) { warn $1; } __DATA__ TATAATATTACAATGGATCATACAGTTAG TATAATATTACAATGGATCATACAGTTAG TATAATATT ACAATGGATCATACAGTTAG
    produces:
    $ perl tst.pl GATCATACAGT at tst.pl line 8, <DATA> chunk 1. GATCATACAGT at tst.pl line 8, <DATA> chunk 1. $
    A user level that continues to overstate my experience :-))