User Tools

Site Tools


bio:tools:codonopttable

Bio-Tools-CodonOptTable

A codon quality check tool, it produces a Codon Optimization table to see the quality of each codon.

The simplest way of depiction is to plot the codon usage frequency that can be found in common codon usage tables. A more elaborate way to depict the codon quality is to convert the codon usage frequency into relative adaptiveness values. In contrast to the codon usage frequency the relative adaptiveness takes into account the number of codons which code for the respective amino acid.

http://kobesearch.cpan.org/htdocs/Bio-Tools-CodonOptTable/README.html

Installation from cpan

cpan>install  Bio::Tools::CodonOptTable

depends on GD::Graph and Bio::Perl

http://search.cpan.org/~shardiwal/Bio-Tools-CodonOptTable-0.07/lib/Bio/Tools/CodonOptTable.pm

USES or Examples

You can use this module in the following ways

use Bio::Tools::CodonOptTable;

my $seqobj = Bio::Tools::CodonOptTable->new ( -seq => 'ATGGGGTGGGCACCATGCTGCTGTCGTGAATTTGGGCACGATGGTGTACGTGCTCGTAGCTAGGGTGGGTGGTTTG',

                                                -id  => 'GeneFragment-12',
                                                -accession_number => 'Myseq1',
                                                -alphabet => 'dna',
                                                -is_circular => 1,
                                                -genetic_code => 1,
                                   );

B<#If you wanna read from file>

my $seqobj = Bio::Tools::CodonOptTable->new(-file => "contig.fasta",

                                             -format => 'Fasta',
                                             -genetic_code => 1,
                                             );

B<#If you have Accession number and want to get file from NCBI>

my $seqobj = Bio::Tools::CodonOptTable->new(-ncbi_id => "J00522",

-genetic_code => 1,);

my $myCodons = $seqobj->rscu_rac_table();

if($myCodons)

        {
            for my $each_aa (@$myCodons)
        {
        print "Codon      : ",$each_aa->{'codon'},"\t";
        print "Frequency  : ",$each_aa->{'frequency'},"\t";
        print "AminoAcid  : ",$each_aa->{'aa_name'},"\t";
        print "RSCU Value : ",$each_aa->{'rscu'},"\t"; #Relative Synonymous Codons Uses
        print "RAC Value  : ",$each_aa->{'rac'},"\t"; #Relative Adaptiveness of a Codon
        print "\n";
        }
        }

B<# To get the prefered codon list based on RSCU & RAC Values >

 my $prefered_codons = $seqobj->prefered_codon($myCodons);

while ( my ($amino_acid, $codon) = each(%$prefered_codons) ) {

print "AminoAcid : $amino_acid \t Codon : $codon\n"; }

B<# To produce a graph between RSCU & RAC> # Graph output file extension should be GIF, we support GIF only

$seqobj->generate_graph($myCodons,"myoutput.gif");

Creating a gui for CodonOptTable

Here is a python script that provides a Graphical User Interface: You need to have wxpython installed on your system.

#!/usr/bin/python
import wx
import os
import random
import re
class testgui(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(683,360))
        # Menu stuff
        menubar =wx.MenuBar()
        menufile =wx.Menu()
        menuhelp =wx.Menu()
        self.SetMenuBar(menubar)
        menubar.Append(menufile, '&File')
        menubar.Append(menuhelp, '&Help')
        exitmenu =menufile.Append(-1, 'Quit', 'Exit Application')
        about =menuhelp.Append(-1, 'About', 'About us')
        #panel creation and sizer
        panel =wx.Panel(self, -1)
        hbsizer =wx.BoxSizer(wx.VERTICAL)
        self.orig_text =wx.TextCtrl(panel,-1,size=(679,275),style=wx.TE_MULTILINE)
       # self.orig_text =wx.TextCtrl(panel,-1)
       #Objects
        self.orig_label =wx.StaticText(panel,-1, 'Paste Your Sequence here:')
        ok_button =wx.Button(panel,-1,'Run CodonOptTable')
        cancel_button =wx.Button(panel,-1,'Clear')
        format_seq =wx.Button(panel,-1,'Format Seq')
        rhead =wx.Button(panel,-1,'Remove Header')
        exit_button=wx.Button(panel,-1,'Exit')
        disp =wx.StaticText(panel,-1,'')
     	vsizer1 =wx.BoxSizer(wx.HORIZONTAL)
     	vsizer4 =wx.BoxSizer(wx.HORIZONTAL)
     	vsizer5 =wx.BoxSizer(wx.HORIZONTAL)
     	vsizer6 =wx.BoxSizer(wx.HORIZONTAL)
     	vsizer2 =wx.BoxSizer(wx.HORIZONTAL)
 
     	vsizer1.Add(self.orig_label,1,wx.CENTRE,10)
     	vsizer2.Add(self.orig_text,1,wx.CENTRE,10)
 
     	vsizer5.Add(rhead,1,wx.RIGHT,1)
     	vsizer5.Add(format_seq,1,wx.RIGHT,1)
     	vsizer5.Add(ok_button,1,wx.RIGHT,1)
     	vsizer5.Add(cancel_button,1,wx.RIGHT,1)
     	vsizer5.Add(exit_button,1,wx.RIGHT,1)
 
     	vsizer6.Add(disp,1,wx.CENTER,1)
 
     	hbsizer.Add(vsizer1,0,wx.CENTER|wx.ALL,1)
#    	   hbsizer.Add(self.orig_text,0, wx.CENTER|wx.ALL,1)
     	hbsizer.Add(vsizer2,0, wx.CENTER|wx.ALL,1)
     	hbsizer.Add(vsizer4,0, wx.CENTER|wx.ALL,1)
     	hbsizer.Add(vsizer5,0,wx.ALIGN_RIGHT|wx.RIGHT,1)
     	hbsizer.Add(vsizer6,0,wx.CENTER,1)
 
	#events
     	self.Bind(wx.EVT_BUTTON,self.executa,ok_button)
     	self.Bind(wx.EVT_BUTTON,self.rheader,rhead)
     	self.Bind(wx.EVT_BUTTON,self.format_seq,format_seq)
     	self.Bind(wx.EVT_MENU, self.soja, exitmenu)
     	self.Bind(wx.EVT_BUTTON,self.clear,cancel_button)
     	self.Bind(wx.EVT_BUTTON,self.soja,exit_button)
#pane	l.CreateStatusBar()
     	panel.SetSizer(hbsizer) 
     	self.Centre()
     	self.Show(True)
    def clear(self,event=None):
	self.orig_text.SetValue('')
    def format_seq(self,event=None):
	originator=self.orig_text.GetValue()
	comm=re.sub('[ \t\r\n]','',originator)
        self.orig_text.SetValue(comm)
    def rheader(self,event=None):
	originator=self.orig_text.GetValue()
	comm=re.sub('>.*','>',originator)
        self.orig_text.SetValue(comm)
    def soja(self, event=None):
    	self.Close(True)
    def executa(self,event=None):
	recordid=random.randint(20,10055)
	originator=self.orig_text.GetValue()
	os.system('perl /home/obiero/codonopt/codonOpt-test.pl %s' %originator)
	wx.MessageBox('DONE! check the output in you folder', 'CodonOptTable Info')    
app =wx.App()
testgui(None, -1, 'CodonOptTable GUI')
app.MainLoop()

This is used together with the perl script:

#!/bin/perl
use Bio::Tools::CodonOptTable;
$sequence = $ARGV[0];
sub codon {
my ($mysequence)=@_;
print $mysequence;
my $seqobj = Bio::Tools::CodonOptTable->new ( -seq => $mysequence,
                                                -id  => 'GeneFragment-12',
                                                -accession_number => 'Myseq1',
                                                -alphabet => 'dna',
                                                -is_circular => 1,
                                                -genetic_code => 1,
                                   );
#my $seqobj = Bio::Tools::CodonOptTable->new(-file => $mysequence,
#
#                                             -format => 'Fasta',
#                                             -genetic_code => 1,
#                                             );
my $myCodons = $seqobj->rscu_rac_table();
 
if($myCodons)
 
        {   
            for my $each_aa (@$myCodons)
        {
        print "Codon      : ",$each_aa->{'codon'},"\t";
        print "Frequency  : ",$each_aa->{'frequency'},"\t";
        print "AminoAcid  : ",$each_aa->{'aa_name'},"\t";
        print "RSCU Value : ",$each_aa->{'rscu'},"\t"; #Relative Synonymous Codons Uses
        print "RAC Value  : ",$each_aa->{'rac'},"\t"; #Relative Adaptiveness of a Codon
        print "\n";
        }
        }
 
 while ( my ($amino_acid, $codon) = each(%$prefered_codons) ) {
 
print "AminoAcid : $amino_acid \t Codon : $codon\n"; }
$seqobj->generate_graph($myCodons,"/home/obiero/codonopt/myoutput.gif");
}
codon($sequence); 

Note: You have to edit the paths to suite your setup.

Usefull ReGex


Merge sequence lines using sed:

$ grep -v Tp sequence | tr -d "\n" > new_sequence_file
$ grep -o <pattern> 

This will grep only the part of matching line that matching the pattern eg How many occurence of "ATCG" in a sequence?

bio/tools/codonopttable.txt · Last modified: 2010/06/30 22:52 by 172.26.15.75