/***********************************************************************/
-void ReadColumnMatrix::read(NameAssignment* nameMap){
+int ReadColumnMatrix::read(NameAssignment* nameMap){
try {
string firstName, secondName;
//need to see if this is a square or a triangular matrix...
while(fileHandle && lt == 1){ //let's assume it's a triangular matrix...
+
fileHandle >> firstName >> secondName >> distance; // get the row and column names and distance
+
+ if (m->control_pressed) { fileHandle.close(); delete reading; return 0; }
map<string,int>::iterator itA = nameMap->find(firstName);
map<string,int>::iterator itB = nameMap->find(secondName);
-
+
if(itA == nameMap->end()){
- cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
+ cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; exit(1);
}
if(itB == nameMap->end()){
- cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
+ cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1);
}
+//if (((itA->second == 8) && (itB->second == 1588)) || ((itA->second == 1588) && (itB->second == 8))) { cout << "found it" << endl; }
if (distance == -1) { distance = 1000000; }
+ else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert.
if(distance < cutoff && itA != itB){
if(itA->second > itB->second){
}
if(lt == 0){ // oops, it was square
+
fileHandle.close(); //let's start over
D->clear(); //let's start over
while(fileHandle){
fileHandle >> firstName >> secondName >> distance;
+
+ if (m->control_pressed) { fileHandle.close(); delete reading; return 0; }
map<string,int>::iterator itA = nameMap->find(firstName);
map<string,int>::iterator itB = nameMap->find(secondName);
}
if (distance == -1) { distance = 1000000; }
+ else if (globaldata->sim) { distance = 1.0 - distance; } //user has entered a sim matrix that we need to convert.
if(distance < cutoff && itA->second > itB->second){
PCell value(itA->second, itB->second, distance);
gobble(fileHandle);
}
}
-
+
+ if (m->control_pressed) { fileHandle.close(); delete reading; return 0; }
+
reading->finish();
fileHandle.close();
list->setLabel("0");
+
+ return 1;
}
catch(exception& e) {
- errorOut(e, "ReadColumnMatrix", "read");
+ m->errorOut(e, "ReadColumnMatrix", "read");
exit(1);
}
}