yes but here the result of $count will always be 0, it should see the
imput file and count tell me how many processed lines I hve in total, for
the momento it is presentig all the precessed lines, so it gives an out
put that says proceseed line 1 procesed line 2 and so on, but for th
fineal report I would like to know how many in tootal were procesed....
how can I do that? here is the whole source
#!/usr/bin/perl
use strict;
my $REPORT_FILE="report.htm";
my $blast_file=$ARGV[0]||'blast.dat';
unless (-e $blast_file)
{
die "$0: error:missing file: $blast_file";
}
#slurp all the seqs in to the scalar
my ($query_src,$sbjct_src);
#open the blast data file and end prg (DIE) if we can't find it open(IN,
#$blast_file) or die
open (IN, $blast_file) or die "$0: ERROR: $blast_file: $!";
#go trought the blast file line by line, concat all the query and sbj seqs
my $line;
while ($line=<IN>)
{
chomp $line;
print "processing line $. \n";
my @words=split /\s+/, $line;
if ($line=~ /^Query/)
{
$query_src .=$words[2];
}
elsif ($line =~ /^Sbjct/)
{
$sbjct_src .=$words[2];
}
}
#next line closes the blast file
close IN;
#analysis part
my @patterns=('gtccca', 'gcaatg', 'cagct', 'tcggga', '-');
#find the patterns and sotore them in to the hashes
my (%query_counts, %sbjct_counts);
#search and store
foreach my $pattern (@patterns)
{
while ($query_src=~ /$pattern/g)
{
$query_counts{$pattern}++;
}
while ($sbjct_src=~ /$pattern/g)
{
$sbjct_counts{ $pattern }++;
}
}
#create an empty report fele
open (OUT, ">$REPORT_FILE") or die "$0: ERROR: cant write $REPORT_FILE";
#print the header of the report file
#print OUT "Seq report \n",
"lo que sea ", scalar localtime, "\n",
"\nnote in the sakasl saklkskfkdkskskjfkddkfj \n",
"total lenght of the 'Query' seq: \n" ,"\nlenght $query_src,
characters $
#adds agc
my $count=0;
while ( <IN> )
{
$count++;
print "prsdf line $count\n";
}
print "process $count lines\n";
my $thetime = scalar (localtime);
print OUT <<"END_OF_REPORT";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>Blast report</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2 FACE="Arial">Seq report,</FONT>
<P>local time for this report $thetime
<p>Note: A dash - represents missing data in the chromosomal seq
<br>total lenght of the query seq $query_src
<p> Results for query
<p>nueva var $count
</BODY>
</HEAD>
</HTML>
END_OF_REPORT
#print the query mathces
#foreach my $key (sort @patterns)
#{
# print OUT "\t '$key' seen $query_counts{$key}\n";
#}
#print OUT "\nTOTAL lenght of 'Sbjct' seq: ","\nlenght $sbjct_src",
"cahracter$
#print the sbjct mathces
#foreach my $key (sort @patterns)
#{
# print OUT "\t'$key' seen $sbjct_counts{$key}\n";
#}
close OUT;
__END__
an imput file looks like this
Query: 1 tcgggaaagaa--aatggtggc-ttcaagtttccagtcagctgctctctgtcccttttag
60
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sbjct: 1 ctacaca-gaaagaatggtgg---tcaagtttcttcttgctctctctctgtcccttttag
60
so for example at the momento it is not giving me the number of
characters on the quey line .... again how can I do that?
On Wed, 22 Aug 2001, Troy Denkinger wrote:
> Date: Wed, 22 Aug 2001 11:31:09 -0400
> From: Troy Denkinger <[EMAIL PROTECTED]>
> To: webmaster <[EMAIL PROTECTED]>, perl <[EMAIL PROTECTED]>
> Subject: Re: counting
>
> On Wednesday 22 August 2001 11:58, webmaster wrote:
> > #!/usr/bin/perl
> > $REPORT_file="report.htm";
> > $ imput_file=$ARGV[0]||'imput.dat';
> > unless (-e $imput_file)
> > {
> > die "$0: error:missing file: $imput_file";
> > }
> > open (IN, $imput_file) or die "$0 : error: $imput_file: $!";
>
> All of this ( except the #! line ) can be replaced by this:
>
> open( IN, shift ) or die( "Open failed: $!" );
>
> > #print $imput_file;
> > my $line;
> > while ($line=<IN>)
> > {
> > chomp $line;
> > print "processing line $. \n";
> > }
>
> If I understand the question, you want to be told by the while look what line
> is processing and then, at the end, be told how many lines were processed.
>
> I'd use a counter to keep track of it all:
>
> my $count = 0;
> while( <IN> ){
> $count++;
> print "Processing line $count\n";
> }
> print "Processed $count lines\n";
>
> Also, use strict and use warnings, you'll be happy to did - maybe not now,
> but someday.
>
> Regards,
>
> Troy
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]