[Bioperl-l] codon usage

subarna thakur bubli_thakur at rediffmail.com
Fri Apr 20 22:59:50 EDT 2012

I am writing a script for determining number of genes
containing a particular codon. The codons are mentioned in a separate file. The
output is coming all right for the first codon mentioned in the file but for
the other codons , the script is not working. Please suggest the error in the
script. The script is as follows ----

#!/usr/bin/perl -w

use Bio::SeqIO;



open OUT, ">out-test.txt" or die $!;

$seqio_obj = Bio::SeqIO->new( -file =>
"gopi2.txt" , '-format' => 'Fasta');

open( my $fh2, $file2 ) or die "$!";

while( my $line = <$fh2> ){


chomp $acc;

while ($seq1= $seqio_obj->next_seq){

my @output = $seq1->id;

my $string = $seq1->seq;


$l= length($string);



for ($i=1; $i <= $t; $i++){

@array2 = substr($string, $k, 3);


foreach $value (@array2)


if ($value eq "$acc")


print OUT " The sequence id is @output\n";

print OUT "$acc codon found in position $i\n\n";





if ($v==0)










print OUT "Total number of sequences with $acc

print OUT "\t";

print OUT $codon;



More information about the Bioperl-l mailing list