[Bioperl-l] Sequence matching problem!
Kurt Gobain
enrique_rulz at yahoo.com
Sat Feb 24 21:23:59 UTC 2007
Heikki Lehvaslaiho wrote:
>
> Kurt,
>
> There are few things in your code to note:
>
> - regexp /C*T/ matches any T preceded by zero or more Cs,
> not what you meant
> - $- and $+ are among the "expensive" perl functions worth
> not using unless you have to. Using them once in your
> code slows execution down considerable. There is always
> an other way.
> - Keep in mind what you want to use the match positions for:
> Human readable locations usually start counting with 1 but
> perl code uses 0 as the first location. The code below assumes
> you want to print the locations out.
>
> Study my example code below.
>
> Yours,
> -Heikki
>
> ###################################################################
> #!/usr/bin/perl
> $seq = "GATCAAT";
> #$pattern= 'C*T';
> $pattern= 'C.*T';
>
> while ($seq =~ m/($pattern)/gi) {
>
> $match = $1;
> $end = pos($seq);
> $start = $end - length($match) +1;
>
> print "$match : $start - $end\n";
> }
>
> ###################################################################
>
>
Thanx for the instant reply!...Sorry cudn reply earlier..
Code works perfectly fine...but...sum time its not givin reqd o/p..For eg.
If I type sequence as "GATCAAGTCAGGAT" & pattern to be matched as T.*A..then
o/p which I am getting frm above prog is TCAAGTCAGGA instead of TCA...
& 1 more thing Is there n e chance by which I can replace T*A to T.*A cos
the code which I need to write says T*A shod be only the input not T.*A..So
Can we use replacment reg ex...sumthing like
$pattern =~ s/.*/*/...or sumthing else...
But its kinda givin sum error again...Dam! Regex is really hairy!!...:P
N e ways thanx a lot again for the code...Hope to listen frm you soon!
Kurt!
--
View this message in context: http://www.nabble.com/Sequence-matching-problem%21-tf3275153.html#a9137941
Sent from the Perl - Bioperl-L mailing list archive at Nabble.com.
More information about the Bioperl-l
mailing list