+ if (!large) {
+ //read distance files
+ if (format == "column") { readMatrix = new ReadColumnMatrix(distFile); }
+ else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(distFile); }
+ else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0; }
+
+ readMatrix->setCutoff(cutoff);
+
+ if(namefile != ""){
+ nameMap = new NameAssignment(namefile);
+ nameMap->readMap();
+ }else{ nameMap = NULL; }
+
+ readMatrix->read(nameMap);
+
+ if (m->control_pressed) { delete readMatrix; return 0; }
+
+ //get matrix
+ if (globaldata->gListVector != NULL) { delete globaldata->gListVector; }
+ globaldata->gListVector = readMatrix->getListVector();
+
+ SparseMatrix* matrix = readMatrix->getMatrix();
+
+ // Create a data structure to quickly access the distance information.
+ // It consists of a vector of distance maps, where each map contains
+ // all distances of a certain sequence. Vector and maps are accessed
+ // via the index of a sequence in the distance matrix
+ seqVec = vector<SeqMap>(globaldata->gListVector->size());
+ for (MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++) {
+ if (m->control_pressed) { delete readMatrix; return 0; }
+ seqVec[currentCell->row][currentCell->column] = currentCell->dist;
+ }
+
+ delete matrix;
+ delete readMatrix;
+ delete nameMap;
+
+ if (m->control_pressed) { return 0; }
+ }else {
+ //process file and set up indexes
+ if (format == "column") { formatMatrix = new FormatColumnMatrix(distFile); }
+ else if (format == "phylip") { formatMatrix = new FormatPhylipMatrix(distFile); }
+ else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0; }
+
+ formatMatrix->setCutoff(cutoff);
+
+ if(namefile != ""){
+ nameMap = new NameAssignment(namefile);
+ nameMap->readMap();
+ }else{ nameMap = NULL; }
+
+ formatMatrix->read(nameMap);
+
+ if (m->control_pressed) { delete formatMatrix; return 0; }
+
+ //get matrix
+ if (globaldata->gListVector != NULL) { delete globaldata->gListVector; }
+ globaldata->gListVector = formatMatrix->getListVector();
+
+ distFile = formatMatrix->getFormattedFileName();
+
+ //positions in file where the distances for each sequence begin
+ //rowPositions[1] = position in file where distance related to sequence 1 start.
+ rowPositions = formatMatrix->getRowPositions();
+
+ delete formatMatrix;
+ delete nameMap;
+
+ //openfile for getMap to use
+ openInputFile(distFile, inRow);
+
+ if (m->control_pressed) { inRow.close(); remove(distFile.c_str()); return 0; }
+ }