On 21/10/2011 02:50, John W. Krahn wrote:
nac wrote:
HI again,

Hello,

I have corrected myself a bit, I think the script is now giving me what I
want, having said that, I guess it is not the best way ( even if there is
more than one way), again any pointer are welcome.
many thanks
Nat
#!/usr/bin/perl
use strict;
use warnings;
my @seq;
@seq=qw{^TGGCAGTGGAGG ^TGTCTGGCAGTG ^TG....GCAGTG TCTGTCTG TCTGGCAG
GCAGTGGA TGTCTGGC ^TGTCTGGC ^..TCTGGCAGTG ^TGTCTGGCAGTG ^TGCATGGC};

open (IN,"</Users/nac/Desktop/example.fastq") or die
"can't open in:$!";
open
(OUT,">>//Users/nac/Desktop/example.fastq\_class_COUNTED2.txt")
or die "can't open out: $!";
my %final_hash;
while (<IN>) {


if (/^A|T|G|C/){
print my $seq_line=$_;
foreach my $ff (@seq){
if ($seq_line =~ /$ff/g){

if (!exists $final_hash{$ff}) {
$final_hash{$ff}=1;
} else {
$final_hash {$ff}++;
}
}
}
}
}
for my $key (sort {$final_hash {$b}<=> $final_hash {$a}}keys
%final_hash){
my $value=$final_hash{$key};
print OUT $key,"\t",$value, "\n";
}

You say that this code produces the results:

GCAGTGGA 9
TCTGGCAG 8
^TGGCAGTGGAGG 7
TCTGTCTG 2

But when I run this code on the data you provided I get:

GCAGTGGA 10
TCTGGCAG 6
^TGGCAGTGGAGG 5
TCTGTCTG 1


So I don't know if I can help you.

Hi John.

I get exactly the same results as the OP, regardless of whether I
correct the line wrapping in the data or remove the embedded command lines.

Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to