libsequence  1.9.5

Ka and Ks by Comeron's (1995) method. More...

#include <Sequence/Comeron95.hpp>

Public Member Functions

 Comeron95 (GeneticCodes code=GeneticCodes::UNIVERSAL)
 
 Comeron95 (const Comeron95 &)=delete
 
Comeron95operator= (const Comeron95 &)=delete
 
Com95_t operator() (const Sequence::Seq &seqa, const Sequence::Seq &seqb, int maxdiffs=3)
 
Com95_t operator() (const Sequence::Seq &seqa, const Sequence::Seq &seqb, const WeightingScheme2 *weights2, const WeightingScheme3 *weights3, int maxdiffs=3)
 

Detailed Description

Ka and Ks by Comeron's (1995) method.

A definition of an object to implement Comeron's (1995) method to calculate Ka and Ks The reference is: Comeron, J. (1995) J. Molecular Evolution, 41: 1152-1159. The object has a simple purpose, but it requires a lot of code to do it. The calculation depends upon the following classes:
Sequence::RedundancyCom95
Sequence::Sites
Sequence::SingleSub
Sequence::TwoSubs
Sequence::ThreeSubs

The calculation can be done on any objects of type Sequence::Seq *, or anything derived from there.

You should be warned that this class depends heavily on namespace Sequence (the libsequence library), and may throw any and all exceptions defined in that library, so you should see the documentation for that library.

Note
This class allows weighting of pathways where codons differ at more than 1 site to be done using any arbitrary weighting scheme. To do so, however, requires deriving classes from Sequence::WeightingScheme2 and Sequence::WeightingScheme2. See the code for Sequence::GranthamWeights2 and Sequence::GranthamWeights3 for an example of how to do this (in the files GranthamWeights.cc and GranthamWeights.hpp). You will also need to study TwoSubs.cc/.hpp and ThreeSubs.cc/.hpp to understand how branches and intermediate codons are labelled (because you need to do it correctly in your implementation of weighting schemes)
This class is best used in the form auto_ptr<Comeron95>, as illustrated in the example below. The reason to use auto_ptr is to prevent resource leaks in case an exception is thrown. This class has strict requirements about the data it is passed, resulting in several places where exceptions can be thrown. Most of these situations are caught in the constructor, which will prevent most leaks. However, anything is possible, so use auto_ptr
Example: a simple program to calculate Ka and Ks:
#include<iostream>
#include<memory>
#include <Sequence/SeqExceptions.hpp>
//using namespace std;
using namespace Sequence;
int main
{
char *filename = argv[1];
vector<Fasta > data;
//read data in from a file in Fasta Format
//program will exit if file is badly format
//the reason for the exit will be an uncaught
//exception Sequence::badFormat
Alignment::GetData(data,filename);
//abort() unless all sequence objects are the same length
assert(Alignment::IsAlignment(data));
//iterate over the data
for(unsigned i = 0 ; i < data.size()-1 ; ++i)
{
for(unsigned j = i+1 ; j < data.size() ; ++j)
{
//calculate and output results
try
{
auto_ptr<Comeron95> C(new Comeron95(&data[i],&data[j]));
cout << data[i].GetName() << '\t' << data[j].GetName() << '\t';
cout << C->ka() << '\t' << C->ks() << '\t' << C->ratio() << endl;
if (std::isfinite(C->ratio()) && C->ratio() > 1.0)
cout << "congratulations, you win!" << endl;
}
catch (SeqException &e)
{
cout << e << endl;
}
}
}
}

Definition at line 125 of file Comeron95.hpp.

Member Function Documentation

◆ operator()()

Com95_t Sequence::Comeron95::operator() ( const Sequence::Seq seqa,
const Sequence::Seq seqb,
int  max = 3 
)

Initialize and calculate synonymous and nonsynonymous distances between two sequence objects

Parameters
seqaan object of type or derived from type Sequence::Seq
seqban object of type or derived from type Sequence::Seq
maxmaximum number of substitutions per codon to allow in the analysis
codegenetic code, see Sequence::GeneticCodes
_weights2a weighting scheme for codons differing at 2 positions. If NULL, Sequence::GranthamWeights2 is used
_weights3a weighting scheme for codons differing at 3 positions. If NULL, Sequence::GranthamWeights3 is used
Warning
Note that the pointers to weighting schemes are dumb pointers. This allows me to check for NULL and then assign a default. If you use your own classes, make sure they clean up after themselves if they throw exceptions!!!

Definition at line 157 of file Comeron95.cc.


The documentation for this class was generated from the following files: