libMems/PairwiseMatchFinder.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * $Id: PairwiseMatchFinder.cpp,v 1.13 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/PairwiseMatchFinder.h"
00014 #include <list>
00015 
00016 using namespace std;
00017 using namespace genome;
00018 
00019 namespace mems {
00020 
00021 PairwiseMatchFinder::PairwiseMatchFinder(){
00022 }
00023 
00024 PairwiseMatchFinder::~PairwiseMatchFinder(){
00025 }
00026 
00027 PairwiseMatchFinder::PairwiseMatchFinder(const PairwiseMatchFinder& mh) : MemHash(mh){
00028 
00029 }
00030 
00031 PairwiseMatchFinder* PairwiseMatchFinder::Clone() const{
00032         return new PairwiseMatchFinder(*this);
00033 }
00034 
00035 
00036 // enumerate out every pairwise match
00037 boolean PairwiseMatchFinder::EnumerateMatches( IdmerList& match_list ){
00038 
00039         match_list.sort(&idmer_id_lessthan);
00040         IdmerList::iterator iter = match_list.begin();
00041         IdmerList::iterator iter2 = match_list.begin();
00042         uint cur_id_count = 1;
00043         IdmerList unique_list;
00044         // identify all of the unique seeds and add them to unique_list
00045         while(iter2 != match_list.end()){
00046                 ++iter2;
00047                 if(iter2 == match_list.end() || iter->id != iter2->id){
00048                         if( cur_id_count == 1 )
00049                                 unique_list.push_back( *iter );
00050                         else
00051                                 cur_id_count = 1;
00052                 }else
00053                         cur_id_count++;
00054                 ++iter;
00055         }
00056         // hash each pair of unique seeds
00057         boolean success = true;
00058         for( iter = unique_list.begin(); iter != unique_list.end(); ++iter )
00059         {
00060                 for( iter2 = iter; iter2 != unique_list.end(); ++iter2 )
00061                 {
00062                         if( iter == iter2 )
00063                                 continue;
00064                         IdmerList hash_list;
00065                         hash_list.push_back( *iter );
00066                         hash_list.push_back( *iter2 );
00067                         success = success && HashMatch(hash_list);
00068                 }
00069         }
00070         return success;
00071 }
00072 
00073 }  // namespace mems

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