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

gnFastTranslator.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // File:            gnFastTranslator.h
00003 // Purpose:         Fast translator for all Sequences
00004 // Description:     Caches translations of each possible sequence in a tree
00005 // Changes:        
00006 // Version:         libGenome 0.5.1 
00007 // Author:          Aaron Darling 
00008 // Modified by:     
00009 // Copyright:       (c) Aaron Darling 
00010 // Licenses:        See COPYING file for details 
00011 /////////////////////////////////////////////////////////////////////////////
00012 #ifndef _gnFastTranslator_h_
00013 #define _gnFastTranslator_h_
00014 
00015 
00016 #include "gn/gnDefs.h"
00017 
00018 #include <string>
00019 #include <vector>
00020 #include <map>
00021 #include "gn/gnClone.h"
00022 #include "gn/gnBaseFilter.h"
00023 #include "gn/gnTranslator.h"
00024 
00025 class GNDLLEXPORT gnFastTranslator : public gnBaseFilter
00026 {
00027 public:
00028 
00029         static const gnFastTranslator *ProteinDNATranslator();
00030         static const gnFastTranslator *DNAProteinTranslator();
00031 
00032         enum gnTranslatorType{
00033                 ProteinDNATranslatorType,
00034                 DNAProteinTranslatorType,
00035         };
00036 
00037         gnFastTranslator();
00038         gnFastTranslator( gnTranslatorType t_type );
00039         gnFastTranslator( const gnFastTranslator& sf );
00040         gnFastTranslator& operator= (const gnFastTranslator& sf);
00041         gnFastTranslator* Clone() const;
00042         
00043         /**
00044          * Queries the specified gnTranslator for every possible combination translation
00045          * of the characters specified in the inputs string.  An input_width may be specified
00046          * so that every possible combination of "input_width" characters in "inputs" will be
00047          * cached.  This is useful for DNA to protein translations, for example.
00048          * @param tranny The gnTranslator to cache.
00049          * @param inputs The characters to cache from tranny.
00050          * @param input_width The number of characters in each query to make to tranny.
00051          */
00052         virtual void CacheTranslator(const gnTranslator* tranny, string inputs, const gnSeqI input_width);
00053 
00054         // gnSeqC 
00055         virtual gnSeqC Filter( const gnSeqC ch ) const;
00056 
00057         virtual void Filter( gnSeqC** seq, uint32& len ) const;
00058         // string
00059         virtual void Filter( string &seq ) const;
00060 
00061         // Default gnSeqC
00062         void SetDefaultChar( const gnSeqC ch1 );
00063         gnSeqC GetDefaultChar() const;
00064         void UseDefaultChar( const boolean use = true);
00065         // fill map
00066         void SetPair( const string& ch1, const string& ch2 );
00067         void RemovePair( const string& ch );
00068 
00069 private:
00070 
00071         void CreateProteinDNATranslator();
00072         void CreateDNAProteinTranslator();
00073 
00074         //map an input string to an output string
00075         map<string, string> m_transCache;
00076         const gnTranslator * m_translator;
00077         
00078         boolean use_default;
00079         gnSeqC m_defaultChar;
00080 };//class gnFastTranslator
00081 
00082 inline
00083 gnFastTranslator* gnFastTranslator::Clone() const
00084 {
00085         return new gnFastTranslator(*this);
00086 }
00087 
00088 inline
00089 void gnFastTranslator::SetDefaultChar( const gnSeqC ch1 )
00090 {
00091         m_defaultChar = ch1;
00092         use_default = true;
00093 }
00094 inline
00095 gnSeqC gnFastTranslator::GetDefaultChar() const
00096 {
00097         return m_defaultChar;
00098 }
00099 
00100 inline
00101 void gnFastTranslator::UseDefaultChar(const boolean use)
00102 {
00103         use_default = use;
00104 }
00105 
00106 #endif // _gnFastTranslator_h_

Generated on Mon Feb 3 02:34:39 2003 for libGenome by doxygen1.3-rc3