forked from sgusev/GERMLINE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatchFactory.cpp
48 lines (38 loc) · 986 Bytes
/
MatchFactory.cpp
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
// MatchFactory.cpp: Generates matches from individuals
#include "MatchFactory.h"
// MatchFactory(): default constructor
MatchFactory::MatchFactory()
{}
void MatchFactory::assertShares()
{
for ( iter = segments.begin() ; iter != segments.end() ; iter++ )
{
iter->second.assertMatches();
}
}
int MatchFactory::size()
{
return (int)segments.size();
}
// initialize(): initializes object
void MatchFactory::initialize()
{
segments.clear();
}
void MatchFactory::hash( Individual * i )
{
int haps , het = i->numHet();
if ( het == 0 || HAPLOID ) haps = 1;
else haps = 2;
if ( ALLOW_HOM && het <= MAX_ERR_HOM + MAX_ERR_HET ) i->assertHomozygous();
if ( HOM_ONLY ) return;
for ( int c = 0 ; c < haps ; c++ )
{
boost::dynamic_bitset<>& ms = i->getChromosome(c)->getMarkerSet()->getMarkerBits();
if ( (iter = segments.find( ms )) == segments.end() )
segments.insert( make_pair ( ms , Share( i ) ) );
else
iter->second.add( i );
}
}
// end MatchFactory.cpp