Google

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

gnFilter.h

Go to the documentation of this file.
00001 
00002 // File:            gnFilter.h
00003 // Purpose:         Filter for all Sequences
00004 // Description:     Filters sequences, translates, reverse complement, converts
00005 //                   additions, etc.
00006 // Changes:        
00007 // Version:         libGenome 0.1.0 
00008 // Author:          Aaron Darling 
00009 // Last Edited:     April 15, 2001, 10:34:50pm 
00010 // Modified by:     
00011 // Copyright:       (c) Aaron Darling 
00012 // Licenses:        Proprietary 
00014 #ifndef _gnSeqFilter_h_
00015 #define _gnSeqFilter_h_
00016 
00017 #include <string>
00018 #include "gn/gnClone.h"
00019 #include "gn/gnDefs.h"
00020 #include "gn/gnBaseFilter.h"
00021 
00022 const gnSeqC NO_REVCOMP_CHAR = 0;
00023 
00024 class GNDLLEXPORT gnFilter : public gnBaseFilter
00025 {
00026 public:
00027 
00028         static const gnFilter *alphabetCharacterFilter();
00029         static const gnFilter *numberCharacterFilter();
00030 
00031         static const gnFilter *proteinSeqFilter();
00032         static const gnFilter *basicDNASeqFilter();
00033         static const gnFilter *fullDNASeqFilter();
00034         static const gnFilter *basicRNASeqFilter();
00035         static const gnFilter *fullRNASeqFilter();
00036 
00037         static const gnFilter *DNAtoRNAFilter();
00038         static const gnFilter *RNAtoDNAFilter();
00039         static const gnFilter *DNAComplementFilter();
00040         static const gnFilter *RNAComplementFilter();
00041 
00042         enum gnFilterType{
00043                 alphabetCharacterFilterType,
00044                 numberCharacterFilterType,
00045 
00046                 proteinSeqFilterType,
00047                 basicDNASeqFilterType,
00048                 fullDNASeqFilterType,
00049                 basicRNASeqFilterType,
00050                 fullRNASeqFilterType,
00051 
00052                 DNAtoRNAFilterType,
00053                 RNAtoDNAFilterType,
00054                 DNAComplementFilterType,
00055                 RNAComplementFilterType
00056         };
00057 
00058 public:         
00059         gnFilter();
00066         gnFilter( const gnFilterType f_type );
00067         gnFilter( const gnSeqC defaultChar, const gnSeqC rdefaultChar );
00068         gnFilter( const gnFilter& sf );
00069         ~gnFilter();
00070         
00071         gnFilter* Clone() const;
00072 
00073         // gnSeqC 
00074         boolean IsValid( const gnSeqC ch ) const;
00075         gnSeqC MakeValid( const gnSeqC ch ) const;
00076         gnSeqC Filter( const gnSeqC ch ) const;
00077         // gnSeqC[]
00083         uint32 IsValid( const gnSeqC* seq, const uint32 len ) const;
00084         void MakeValid( gnSeqC* seq, const uint32 len ) const;
00085         void Filter( gnSeqC** seq, uint32& len ) const;
00086         void ReverseFilter( gnSeqC** seq, uint32& len ) const;
00087         // string
00088         uint32 IsValid( const string &seq ) const;
00089         void MakeValid( string &seq ) const;
00090         void Filter( string &seq ) const;
00091         void ReverseFilter( string &seq ) const;
00092 
00093         // Default gnSeqC
00094         void SetDefaultChar( const gnSeqC ch1, const gnSeqC ch2 );
00095         gnSeqC GetDefaultChar() const;
00096         gnSeqC GetRDefaultChar() const;
00097         // fill map
00098         void SetSingle( const gnSeqC ch );
00099         void SetPair( const gnSeqC ch1, const gnSeqC ch2 );
00100         boolean RemovePair( const gnSeqC ch );
00101         boolean RemoveSingle( const gnSeqC ch );
00102 
00103         // standard filters
00104 
00105 private:
00106         void CreateAlphabetCharacterFilter();
00107         void CreateNumberCharacterFilter();
00108 
00109         void CreateProteinFilter();
00110 
00111         void CreateBasicDNAFilter();
00112         void CreateFullDNAFilter();
00113 
00114         void CreateBasicRNAFilter();
00115         void CreateFullRNAFilter();
00116 
00117         void CreateDNAtoRNAFilter();
00118         void CreateRNAtoDNAFilter();
00119         void CreateDNAComplementFilter();
00120         void CreateRNAComplementFilter();
00121 
00122         string m_name;
00123 
00124         gnSeqC m_pairArray[GNSEQC_MAX];
00125         gnSeqC m_defaultChar;
00126         gnSeqC m_rDefaultChar;
00127         
00128 };//class gnFilter
00129 
00130 inline
00131 gnFilter* gnFilter::Clone() const
00132 {
00133         return new gnFilter(*this);
00134 }
00135 
00136 // gnSeqC
00137 inline
00138 boolean gnFilter::IsValid( const gnSeqC ch ) const
00139 {
00140         return m_pairArray[ch] != NO_REVCOMP_CHAR;
00141 }
00142 inline
00143 gnSeqC gnFilter::MakeValid( const gnSeqC ch ) const
00144 {
00145         return (m_pairArray[ch] != NO_REVCOMP_CHAR? ch: m_defaultChar);
00146 }
00147 inline
00148 gnSeqC gnFilter::Filter( const gnSeqC ch ) const
00149 {
00150         
00151         return m_pairArray[ch] != NO_REVCOMP_CHAR ? m_pairArray[ch] : m_defaultChar;
00152 }
00153 // gnSeqC[]
00154 inline
00155 uint32 gnFilter::IsValid( const gnSeqC* seq, const uint32 len ) const
00156 {
00157         for( uint32 i=0; i < len ; ++i )
00158         {
00159                 if( !IsValid( seq[i] ) )
00160                         return i;
00161         }
00162         return len;
00163 }
00164 inline
00165 void gnFilter::MakeValid( gnSeqC* seq, const uint32 len ) const
00166 {
00167         for( uint32 i=0; i < len ; ++i )
00168         {
00169                 seq[i] = MakeValid( seq[i] );
00170         }
00171 }
00172 
00173 // string
00174 inline
00175 uint32 gnFilter::IsValid( const string &seq ) const
00176 {
00177         return IsValid( (gnSeqC*)seq.data(), seq.length() );
00178 }
00179 inline
00180 void gnFilter::MakeValid( string &seq ) const
00181 {
00182         MakeValid( (gnSeqC*)seq.data(), seq.length() );
00183 }
00184 
00185 // Default gnSeqC
00186 inline
00187 void gnFilter::SetDefaultChar( const gnSeqC ch1, const gnSeqC ch2 )
00188 {
00189         m_defaultChar = ch1;
00190         m_rDefaultChar = ch2;
00191 }
00192 inline
00193 gnSeqC gnFilter::GetDefaultChar() const
00194 {
00195         return m_defaultChar;
00196 }
00197 inline
00198 gnSeqC gnFilter::GetRDefaultChar() const
00199 {
00200         return m_rDefaultChar;
00201 }
00202 // fill map
00203 inline
00204 void gnFilter::SetSingle( const gnSeqC ch )
00205 {
00206         m_pairArray[ch] = ch;
00207 }
00208 inline
00209 void  gnFilter::SetPair( const gnSeqC ch1, const gnSeqC ch2 )
00210 {
00211         m_pairArray[ch1] = ch2;
00212 //      m_pairArray[ch2] = ch1;
00213 }
00214 inline
00215 boolean gnFilter::RemovePair( const gnSeqC ch )
00216 {
00217         m_pairArray[ch] = NO_REVCOMP_CHAR;
00218 //      m_pairArray[tmp] = NO_REVCOMP_CHAR;
00219         return true;
00220 }
00221 inline
00222 boolean gnFilter::RemoveSingle( const gnSeqC ch )
00223 {
00224         m_pairArray[ch] = NO_REVCOMP_CHAR;
00225         return true;    
00226 }
00227 
00228 #endif
00229         // __blSeqFilter_h__

Generated at Fri Nov 30 15:36:51 2001 for libGenome by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001