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