libMems/MaskedMemHash.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * $Id: MaskedMemHash.cpp,v 1.3 2004/03/01 02:40:08 darling Exp $
00003  * This file is copyright 2002-2007 Aaron Darling and authors listed in the AUTHORS file.
00004  * Please see the file called COPYING for licensing, copying, and modification
00005  * Please see the file called COPYING for licensing details.
00006  * **************
00007  ******************************************************************************/
00008 
00009 #ifdef HAVE_CONFIG_H
00010 #include "config.h"
00011 #endif
00012 
00013 #include "libMems/MaskedMemHash.h"
00014 #include <list>
00015 
00016 using namespace std;
00017 using namespace genome;
00018 namespace mems {
00019 
00020 MaskedMemHash::MaskedMemHash(){
00021         seq_mask = 0;
00022 }
00023 
00024 
00025 MaskedMemHash::MaskedMemHash(const MaskedMemHash& mh) : MemHash(mh){
00026         *this = mh;
00027 }
00028 
00029 MaskedMemHash& MaskedMemHash::operator=( const MaskedMemHash& mh ){
00030         seq_mask = mh.seq_mask;
00031         return *this;
00032 }
00033 
00034 MaskedMemHash* MaskedMemHash::Clone() const{
00035         return new MaskedMemHash(*this);
00036 }
00037 
00038 boolean MaskedMemHash::HashMatch(list<idmer>& match_list){
00039         //check that there is at least one forward component
00040         match_list.sort(&idmer_id_lessthan);
00041         // initialize the hash entry
00042         MatchHashEntry mhe = MatchHashEntry(seq_count, GetSar(0)->SeedLength());
00043         mhe.SetLength(GetSar(0)->SeedLength());
00044         
00045         //Fill in the new Match and set direction parity if needed.
00046         list<idmer>::iterator iter = match_list.begin();
00047         for(; iter != match_list.end(); iter++)
00048                 mhe.SetStart(iter->id, iter->position + 1);
00049         SetDirection(mhe);
00050         mhe.CalculateOffset();
00051         uint64 match_number = 0;
00052         // compute "MatchNumber"
00053         for( uint seqI = 0; seqI < mhe.SeqCount(); seqI++ )
00054         {
00055                 match_number <<= 1;
00056                 if( mhe.Start(seqI) != NO_MATCH )
00057                         match_number |= 1;
00058         }
00059         if( seq_mask == 0 || match_number == seq_mask )
00060                 AddHashEntry(mhe);
00061 
00062         return true;
00063 }
00064 
00065 } // namespace mems

Generated on Fri Mar 14 06:01:03 2008 for libMems by doxygen 1.3.6