File: SuperInterval.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 (124 lines) | stat: -rw-r--r-- 2,841 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


#include "libMems/SuperInterval.h"

using namespace std;
using namespace genome;

namespace mems {
// working in mems

bool debug_aligner = false;

SuperInterval::SuperInterval() :
length(0),
left_end(0),
c1_siv((std::numeric_limits<size_t>::max)()),
c2_siv((std::numeric_limits<size_t>::max)()),
parent_siv((std::numeric_limits<size_t>::max)())
{}

SuperInterval::SuperInterval( const Interval& reference_iv ) :
reference_iv(reference_iv),
length(0),
left_end(0),
c1_siv((std::numeric_limits<size_t>::max)()),
c2_siv((std::numeric_limits<size_t>::max)()),
parent_siv((std::numeric_limits<size_t>::max)())
{
}

SuperInterval::SuperInterval(const SuperInterval& siv) :
left_end(siv.left_end),
length( siv.length ),
reference_iv( siv.reference_iv ),
c1_siv(siv.c1_siv),
c2_siv(siv.c2_siv),
parent_siv(siv.parent_siv)
{
}
SuperInterval& SuperInterval::operator=(const SuperInterval& siv)
{
	left_end = siv.left_end;
	length = siv.length;
	reference_iv = siv.reference_iv;
	c1_siv = siv.c1_siv;
	c2_siv = siv.c2_siv;
	parent_siv = siv.parent_siv;
	return *this;
}



/** Sets the length of this match to @param len */
void SuperInterval::SetLength( gnSeqI len )
{
	length = len;
}

void SuperInterval::CropLeft( gnSeqI amount )
{
	reference_iv.CropStart(amount);

	left_end += amount;
	length -= amount;

	if(debug_aligner)
		ValidateSelf();
}

void SuperInterval::CropRight( gnSeqI amount )
{
	reference_iv.CropEnd(amount);
	length -= amount;

	if(debug_aligner)
		ValidateSelf();
}

void SuperInterval::ValidateSelf() const
{
	vector< bitset_t > aln_mat;
	reference_iv.GetAlignment(aln_mat);
	if( aln_mat[0].size() != reference_iv.AlignmentLength() )
	{
		breakHere();
		cerr << "trouble! aln_mat[0].size() is: " << aln_mat[0].size() << " while reference_iv.AlignmentLength() is: " << reference_iv.AlignmentLength() << endl;
		cerr << "mult: " << reference_iv.Multiplicity() << endl;
		cerr << "matches.size(): " << reference_iv.GetMatches().size() << endl;
	}
	for( size_t i = 0; i < aln_mat.size(); i++ )
	{
		gnSeqI lenny = 0;
		for( size_t j = 0; j < aln_mat[i].size(); j++ )
			if( aln_mat[i][j] )
				lenny++;
		if( lenny != reference_iv.Length(i) )
		{
			cerr << "krudunkle, ref_iv.Length(" << i << "): " << reference_iv.Length(i) << "\n";
			cerr << "should be: " << lenny << endl;
			breakHere();
		}
	}
	if( reference_iv.LeftEnd(0) != NO_MATCH && reference_iv.Length(0) == 0 )
	{
		cerr << "brozooka\n";
		breakHere();
	}
	if( reference_iv.LeftEnd(1) != NO_MATCH && reference_iv.Length(1) == 0 )
	{
		cerr << "brokazooka\n";
		breakHere();
	}

	if( Length() != reference_iv.AlignmentLength() )
	{
		breakHere();
		cerr << "crapola\n";
	}
}

} // namespace mems