File: PairwiseMatchFinder.cpp

package info (click to toggle)
libmems 1.6.0%2B4725-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,120 kB
  • sloc: cpp: 21,579; ansic: 4,312; xml: 115; makefile: 103; sh: 26
file content (73 lines) | stat: -rw-r--r-- 2,029 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*******************************************************************************
 * $Id: PairwiseMatchFinder.cpp,v 1.13 2004/03/01 02:40:08 darling Exp $
 * This file is copyright 2002-2007 Aaron Darling and authors listed in the AUTHORS file.
 * Please see the file called COPYING for licensing, copying, and modification
 * Please see the file called COPYING for licensing details.
 * **************
 ******************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "libMems/PairwiseMatchFinder.h"
#include <list>

using namespace std;
using namespace genome;

namespace mems {

PairwiseMatchFinder::PairwiseMatchFinder(){
}

PairwiseMatchFinder::~PairwiseMatchFinder(){
}

PairwiseMatchFinder::PairwiseMatchFinder(const PairwiseMatchFinder& mh) : MemHash(mh){

}

PairwiseMatchFinder* PairwiseMatchFinder::Clone() const{
	return new PairwiseMatchFinder(*this);
}


// enumerate out every pairwise match
boolean PairwiseMatchFinder::EnumerateMatches( IdmerList& match_list ){

	match_list.sort(&idmer_id_lessthan);
	IdmerList::iterator iter = match_list.begin();
	IdmerList::iterator iter2 = match_list.begin();
	uint cur_id_count = 1;
	IdmerList unique_list;
	// identify all of the unique seeds and add them to unique_list
	while(iter2 != match_list.end()){
		++iter2;
		if(iter2 == match_list.end() || iter->id != iter2->id){
			if( cur_id_count == 1 )
				unique_list.push_back( *iter );
			else
				cur_id_count = 1;
		}else
			cur_id_count++;
		++iter;
	}
	// hash each pair of unique seeds
	boolean success = true;
	for( iter = unique_list.begin(); iter != unique_list.end(); ++iter )
	{
		for( iter2 = iter; iter2 != unique_list.end(); ++iter2 )
		{
			if( iter == iter2 )
				continue;
			IdmerList hash_list;
			hash_list.push_back( *iter );
			hash_list.push_back( *iter2 );
			success = success && HashMatch(hash_list);
		}
	}
	return success;
}

}  // namespace mems