+ m = MothurOut::getInstance();
+
+ string name, group;
+
+ filehandle >> numSeqs >> name;
+
+ //make the matrix filled with zeros
+ matrix.resize(numSeqs);
+ for(int i = 0; i < numSeqs; i++) {
+ matrix[i].resize(numSeqs, 0.0);
+ }
+ group = groupmap->getGroup(name);
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
+ index.resize(numSeqs);
+ index[0].seqName = name;
+ index[0].groupName = group;
+
+ //determine if matrix is square or lower triangle
+ //if it is square read the distances for the first sequence
+ char d;
+ bool square;
+ while((d=filehandle.get()) != EOF){
+
+ //is d a number meaning its square
+ if(isalnum(d)){
+ square = true;
+ filehandle.putback(d);
+
+ for(int i=0;i<numSeqs;i++){
+ filehandle >> matrix[0][i];
+ if (sim) { matrix[0][i] = 1.0 - matrix[0][i]; }
+ }
+ break;
+ }
+
+ //is d a line return meaning its lower triangle
+ if(d == '\n'){
+ square = false;
+ break;
+ }
+ }
+
+ //read rest of matrix
+ if (square == true) { readSquareMatrix(filehandle); }
+ else { readLTMatrix(filehandle); }
+
+ filehandle.close();
+
+ if (!m->control_pressed) { sortGroups(0, numSeqs-1); }
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "FullMatrix", "FullMatrix");
+ exit(1);
+ }
+}
+/**************************************************************************/
+int FullMatrix::readSquareMatrix(ifstream& filehandle) {
+ try {
+
+ Progress* reading;
+ reading = new Progress("Reading matrix: ", numSeqs * numSeqs);
+
+ int count = 0;
+
+ string group, name;
+
+ for(int i=1;i<numSeqs;i++){
+ filehandle >> name;
+
+ group = groupmap->getGroup(name);
+ index[i].seqName = name;
+ index[i].groupName = group;
+
+ if(group == "not found") { m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
+
+ for(int j=0;j<numSeqs;j++){
+ if (m->control_pressed) { delete reading; return 0; }
+
+ filehandle >> matrix[i][j];
+ if (sim) { matrix[i][j] = 1.0 - matrix[i][j]; }
+
+ count++;
+ reading->update(count);
+ }
+ }
+
+ if (m->control_pressed) { delete reading; return 0; }
+
+ reading->finish();
+ delete reading;