Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^2: motif finding

by educated_foo (Vicar)
on Jan 31, 2012 at 13:55 UTC ( #950975=note: print w/ replies, xml ) Need Help??

in reply to Re: motif finding
in thread motif finding

Or, even more Perl-ish, with a bit less extra work (e.g. only one //g loop):

use Term::ANSIColor; open(READ,"<dna.txt"); $m = 'AGGGGG'; $_ = do { local $/; <READ> }; # read whole file s/\s+//g; # remove blanks s{$m}{ # search the string push @c, 1 - length($m) + pos; # remember position color('bold green').$m.color('reset'); # remember to reset! }eg; print "$_\n"; # print transformed string print "NUMBER OF SITES THE MOTIF ($m) IS PRESENT: ".@c."\n"; print "AND THE POSITION IN THE STRING IS:", join(',', @c), "\n\n";

Comment on Re^2: motif finding
Download Code
Replies are listed 'Best First'.
Re^3: motif finding
by Anonymous Monk on Oct 05, 2013 at 21:07 UTC
    my motif input is a file, how i can modified the program to make it work?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950975]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2015-10-10 09:52 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (255 votes), past polls