@@ -43,24 +43,35 @@ Clustering::Clustering(const std::string &seqDB, const std::string &seqDBIndex,
43
43
originalseqDbr->open (DBReader<unsigned int >::NOSORT);
44
44
DBReader<unsigned int >::Index * seqIndex = originalseqDbr->getIndex ();
45
45
46
- unsigned int lastKey = originalseqDbr->getLastKey ();
47
- keyToSet = new unsigned int [lastKey+1 ];
48
- std::vector<bool > keysInSeq (lastKey+1 , false );
49
- std::map<unsigned int , unsigned int > setToLength;
50
-
51
46
std::ifstream mappingStream (seqDB + " .lookup" );
52
47
std::string line;
53
48
unsigned int setkey = 0 ;
54
49
unsigned int maxsetkey = 0 ;
50
+ unsigned int maxkey = 0 ;
55
51
while (std::getline (mappingStream, line)) {
56
52
std::vector<std::string> split = Util::split (line, " \t " );
57
53
unsigned int key = strtoul (split[0 ].c_str (), NULL , 10 );
58
54
setkey = strtoul (split[2 ].c_str (), NULL , 10 );
59
- keyToSet[key] = setkey;
60
55
if (maxsetkey < setkey) {
61
56
maxsetkey = setkey;
62
57
}
58
+ maxkey = key;
63
59
}
60
+ unsigned int lastKey = maxkey;
61
+ keyToSet = new unsigned int [lastKey+1 ];
62
+ std::vector<bool > keysInSeq (lastKey+1 , false );
63
+ std::map<unsigned int , unsigned int > setToLength;
64
+
65
+ mappingStream.close ();
66
+ mappingStream.open (seqDB + " .lookup" );
67
+ line = " " ;
68
+ while (std::getline (mappingStream, line)) {
69
+ std::vector<std::string> split = Util::split (line, " \t " );
70
+ unsigned int key = strtoul (split[0 ].c_str (), NULL , 10 );
71
+ setkey = strtoul (split[2 ].c_str (), NULL , 10 );
72
+ keyToSet[key] = setkey;
73
+ }
74
+
64
75
for (size_t id = 0 ; id < originalseqDbr->getSize (); id++) {
65
76
setToLength[keyToSet[seqIndex[id].id ]] += seqIndex[id].length ;
66
77
keysInSeq[seqIndex[id].id ] = 1 ;
0 commit comments