gnPosSpecificTranslator.cpp Source File

Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# gnPosSpecificTranslator.cpp

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnPosSpecificTranslator.cpp
    00003 // Purpose:         Special case ORF translation
    00004 // Description:     Used to translate sequences differently based on the position of
    00005 //                                      input characters.  Useful for tranlating genes because the first
    00006 //                                      codon is translated differently
    00007 // Changes:
    00008 // Version:         libGenome 0.5.1
    00009 // Author:          Aaron Darling
    00010 // Modified by:
    00011 // Copyright:       (c) Aaron Darling
    00012 // Licenses:        See COPYING file for details
    00013 /////////////////////////////////////////////////////////////////////////////
    00014
    00015 #include "gn/gnPosSpecificTranslator.h"
    00016
    00017 //      static data access, avoids static initialization order fiasco
    00018 const gnPosSpecificTranslator *gnPosSpecificTranslator::ProteinDNATranslator(){
    00019         const static gnPosSpecificTranslator* t_trans = new gnPosSpecificTranslator(ProteinDNATranslatorType);
    00020         return t_trans;
    00021 }
    00022 const gnPosSpecificTranslator *gnPosSpecificTranslator::DNAProteinTranslator(){
    00023         const static gnPosSpecificTranslator* t_trans = new gnPosSpecificTranslator(DNAProteinTranslatorType);
    00024         return t_trans;
    00025 }
    00026
    00027 //      public:
    00028 gnPosSpecificTranslator::gnPosSpecificTranslator()
    00029 {
    00030 }
    00031
    00032 gnPosSpecificTranslator::gnPosSpecificTranslator( const gnPosSpecificTranslator &sf )
    00033 {
    00034         m_name = sf.m_name;
    00035 }
    00036 gnPosSpecificTranslator::gnPosSpecificTranslator( gnTranslatorType t_type )
    00037 {
    00038         m_type = t_type;
    00039         switch(t_type){
    00040                 case ProteinDNATranslatorType:
    00041                         // not special done for this case
    00042                         filter = gnFastTranslator::ProteinDNATranslator();
    00043                         break;
    00044                 case DNAProteinTranslatorType:
    00045                         filter = gnFastTranslator::DNAProteinTranslator();
    00046                         break;
    00047         }
    00048 }
    00049
    00050 // gnSeqC
    00051 gnSeqC gnPosSpecificTranslator::Filter( const gnSeqC ch ) const{
    00052         return filter->Filter(ch);
    00053 }
    00054
    00055 void gnPosSpecificTranslator::Filter( gnSeqC** seq, uint32& len ) const{
    00056         return filter->Filter(seq, len);
    00057 }
    00058         // string
    00059 void gnPosSpecificTranslator::Filter( string &seq ) const{
    00060         switch(m_type){
    00061                 case ProteinDNATranslatorType:
    00062                         filter->Filter( seq );
    00063                         break;
    00064                 case DNAProteinTranslatorType:
    00065                         string first_codon = seq.substr(0,3);
    00066                         filter->Filter( seq );
    00067                         for(int charI = 0; charI < first_codon.length(); charI++ )
    00068                                 first_codon[charI] = tolower(first_codon[charI]);
    00069                         if( first_codon == "ttg" || first_codon == "gtg" )
    00070                                 seq[0] = 'M';
    00071                         break;
    00072         }
    00073 }