20 typedef string::size_type sst;
23 struct GorC :
public unary_function< char, bool >
27 return ( ch ==
'G' || ch ==
'C' );
31 int main(
int argc,
char *argv[])
38 unsigned length = sequence.
length();
46 unsigned numgaps = count(sequence.begin(),sequence.end(),
'-');
48 unsigned num_missing = count(sequence.begin(),sequence.end(),
'N');
50 unsigned datalen = length-numgaps-num_missing;
54 G_or_C = count_if(sequence.begin(),sequence.end(),GorC());
55 double GC = double(G_or_C)/double(datalen);
62 totalCodonUsage += UsageTable;
69 string seq = sequence.GetSeq();
74 while ( (pos = seq.find(
"G",pos)) != string::npos)
80 if (
unsigned(pos+1) % 3 == 0.)
88 while ( (pos = seq.find(
"C",pos)) != string::npos )
90 if (
unsigned(pos+1) % 3 == 0.)
98 double GC3 = double(G3+C3)/( double(datalen) / 3. );
101 cout <<
"Codon Usage Table for: "<< sequence.GetName() << endl;
102 cout <<
"Sequence length is: "<< sequence.length()<<endl;
103 cout <<
"Length exluding gap characters and missing data is: "<<datalen<<endl;
104 cout <<
"GC content of coding sequence is: "<<GC<<endl;
105 cout <<
"GC3 content of coding sequence is: "<<GC3<<endl;
107 for(
unsigned i = 0 ; i < UsageTable.size() ; ++i)
111 cout << UsageTable[i].first <<
'\t' << UsageTable[i].second <<
'\t';
115 cout << UsageTable[i].first <<
'\t' << UsageTable[i].second << endl;
122 cout <<
"Codon Usage Table for all regions\n";
124 for(
unsigned i = 0 ; i < totalCodonUsage.size() ; ++i)
128 cout << totalCodonUsage[i].first <<
'\t' << totalCodonUsage[i].second <<
'\t';
132 cout << totalCodonUsage[i].first <<
'\t' << totalCodonUsage[i].second << endl;
bool operator()(const std::pair< key, value > &l, const std::pair< key, value > &r) const
The namespace in which this library resides.
std::vector< std::pair< std::string, int > > CodonUsageTable
facility to count codons in CDS sequence, function Sequence::makeCodonUsageTable
size_type length(void) const
Declaration of Sequence::Fasta streams.
Declarations of operators to add associative containers together.
CodonUsageTable makeCodonUsageTable(const Seq *sequence)