Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Think about Loose Coupling
 
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 (Hermit)
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2014-04-23 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls