Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi dear monkes, i have protein file in fasta format and i ve written folloing code for finding frequency of each amino acid (alphabet), but there is a problem. the result file is very big. i mean i expect a very smaller file. please take a look at my code.
#!/usr/bin/perl -w use bio::seqIO; my $outputfile; #protein file bringing in. $outputfile="countaa"; unless(open(IN,">>$outputfile")) {print" cant open file \"$outputfile\ to write to !!\n\n"; exit;} my $proteinio=Bio::SeqIO->new (-file=>"ec 1.1.1.fasta",-format=>'fasta +'); while(my $seq=$proteinio ->next_seq() ){ foreach(my $protein=$seq->seq){ $count_A=0;$count_C=0;$count_D=0;$count_E=0;$count_F=0;$count_G=0;$cou +nt_H=0;$count_I=0; $count_K=0;$count_L=0;$count_M=0;$count_N=0;$count_P=0;$count_Q=0;$cou +nt_R=0;$count_S=0; $count_T=0;$count_V=0;$count_W=0;$count_Y=0; my @protein=split('',$protein); foreach (@protein){ if (/A/) {++$count_A;} elsif (/C/) {++$count_C;} elsif (/D/) {++$count_D;} elsif (/E/) {++$count_E;} elsif (/F/) {++$count_F;} elsif (/G/) {++$count_G;} elsif (/H/) {++$count_H;} elsif (/I/) {++$count_I;} elsif (/K/) {++$count_K;} elsif (/L/) {++$count_L;} elsif (/M/) {++$count_M;} elsif (/N/) {++$count_N;} elsif (/P/) {++$count_P;} elsif (/Q/) {++$count_Q;} elsif (/R/) {++$count_R;} elsif (/S/) {++$count_S;} elsif (/T/) {++$count_T;} elsif (/V/) {++$count_V;} elsif (/W/) {++$count_W;} elsif (/Y/) {++$count_Y;} print IN "$count_A $count_C $count_D $count_E $count_F $count_G $count +_H $count_I $count_K $count_L $count_M $count_N $count_P $count_Q $count_R $count_S $count_ +T $count_V $count_W $count_Y\n";} }} close IN;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: alphabet counting
by davido (Cardinal) on Jun 02, 2012 at 15:40 UTC | |
Re: alphabet counting
by sauoq (Abbot) on Jun 02, 2012 at 13:44 UTC | |
by Anonymous Monk on Jun 02, 2012 at 14:09 UTC | |
by sauoq (Abbot) on Jun 02, 2012 at 14:19 UTC | |
by Not_a_Number (Prior) on Jun 02, 2012 at 21:11 UTC | |
by sauoq (Abbot) on Jun 02, 2012 at 22:32 UTC | |
| |
Re: alphabet counting
by Corion (Patriarch) on Jun 02, 2012 at 13:21 UTC | |
by Anonymous Monk on Jun 02, 2012 at 13:27 UTC | |
by Corion (Patriarch) on Jun 02, 2012 at 13:29 UTC | |
by Anonymous Monk on Jun 02, 2012 at 13:40 UTC | |
Re: alphabet counting
by Cristoforo (Curate) on Jun 03, 2012 at 00:07 UTC |