[Bioperl-l] codon usage
Smithies, Russell
Russell.Smithies at agresearch.co.nz
Sun May 6 20:42:58 UTC 2012
I'd be tempted to not use Perl but just use grep if all you need is a count of codons.
I suspect your code is going to be quite slow on large sequences with those nested loops.
--Russell
-----Original Message-----
From: bioperl-l-bounces at lists.open-bio.org [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of subarna thakur
Sent: Saturday, 21 April 2012 3:00 p.m.
To: bioperl-l at bioperl.org
Subject: [Bioperl-l] codon usage
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;
$file2="table.txt";
$codon=0;
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> ){
$acc=$line;
chomp $acc;
while ($seq1= $seqio_obj->next_seq){
my @output = $seq1->id;
my $string = $seq1->seq;
$v=0;
$l= length($string);
$t=$l/3;
$k=0;
for ($i=1; $i <= $t; $i++){
@array2 = substr($string, $k, 3);
$k=$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";
$v=$v+1;
}
}
}
if ($v==0)
{
$h=0;
}
else
{
$h=1;
}
$codon=$codon+$h;
}
print OUT "Total number of sequences with $acc codon";
print OUT "\t";
print OUT $codon;
}
exit;
_______________________________________________
Bioperl-l mailing list
Bioperl-l at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/bioperl-l
=======================================================================
Attention: The information contained in this message and/or attachments
from AgResearch Limited is intended only for the persons or entities
to which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipients is prohibited by AgResearch
Limited. If you have received this message in error, please notify the
sender immediately.
=======================================================================
More information about the Bioperl-l
mailing list