Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Can any Perl Monk help me to correct the mistake in counting motifs in a string in the perl program written by me?

by pvaldes (Chaplain)
on Dec 12, 2011 at 13:31 UTC ( #943077=note: print w/replies, xml ) Need Help??


in reply to Can any Perl Monk help me to correct the mistake in counting motifs in a string in the perl program written by me?

not really sure what is a motif here, but this can't stop me to fail, of course XDD ... please, save the facepalms for the end, thanks ;-)

Only a draft, unworking and untested...but can give you some ideas

use 5.010; my ($file, $motif) = @ARGV; my $warn = <<'EOF'; Number or arguments incorrect, Please run this program with 2 arguments, a file and a motif to count the number of letters between any two motifs: i.e. perl script.pl myfile mymotif EOF if (scalar @ARGV != 2) {print $warn} if (scalar @ARGV == 2){ open (my $DNAFILE, '<', $file) or die "I need that you provide a file. Cannot open file $!"; ## $DNAFILE = join( '', @DNA); ## don't understand this line ... can you explain this? $DNAFILE =~ s/\s//g; # Remove whitespace, ok if ( $DNAFILE =~ /$motif/ ) { print "\nI found it!\n"; # Count number of nt between two motifs my $string ="@DNA"; # same question, explain please, why do you need t +his? ## mmmh... are you trying to say "\@DNA"? say "Lengths are:", $_ for map { sprintf("%d", length) } split /$ +motif/, $string; # Count number of motifs my $count=($string =~ m/$motif/g); print "Number of motifs: $count.\n\n"; close DNAFILE; } else { print "The motif: $motif was not found in the file $file.\n"} } # first else block __END__

Your turn

(Updated: problem with $warn fixed)

  • Comment on Re: Can any Perl Monk help me to correct the mistake in counting motifs in a string in the perl program written by me?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://943077]
help
Chatterbox?
[LanX]: not sure what you guys are taking about, but a DOM manipulation in JS shouldn't be difficult
[Corion]: Discipulus: Yeah, that's what I would try (but so far, I can't even change the colors manually in the SVG, which is why I gave up ;) )
Discipulus bad sign..
[Discipulus]: italian doc says to modify somehow the initial SVG before using it with D3.js
[Discipulus]: LanX the fact is that my js ability is even poorer than my Perl one..
[LanX]: oh its negative? ;P
[Discipulus]: my warmest comprehension karlgoethebier ;=(

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2017-03-23 09:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.