X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readblast.cpp;h=e98b69c68bfdb8f90fa841429cf4d607ba6fe1c3;hb=38029939675c5bf5e449eac90f801b35064b3a36;hp=2d4947745be0a52fafba4c33f38fb6504ede2288;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/readblast.cpp b/readblast.cpp index 2d49477..e98b69c 100644 --- a/readblast.cpp +++ b/readblast.cpp @@ -54,7 +54,8 @@ int ReadBlast::read(NameAssignment* nameMap) { //create objects needed for read if (!hclusterWanted) { - matrix = new SparseMatrix(); + matrix = new SparseDistanceMatrix(); + matrix->resize(nseqs); }else{ overlapFile = m->getRootName(blastfile) + "overlap.dist"; distFile = m->getRootName(blastfile) + "hclusterDists.dist"; @@ -109,8 +110,9 @@ int ReadBlast::read(NameAssignment* nameMap) { } } }else { m->mothurOut("Error in your blast file, cannot read."); m->mothurOutEndLine(); exit(1); } - - +string outDistFilem = "../kathryn/blastDist.dist"; + ofstream outMDist; + m->openOutputFile(outDistFilem, outMDist); //read file while(!fileHandle.eof()){ @@ -185,8 +187,14 @@ int ReadBlast::read(NameAssignment* nameMap) { //is this distance below cutoff if (distance < cutoff) { if (!hclusterWanted) { - PCell value(itA->second, it->first, distance); - matrix->addCell(value); + if (itA->second < it->first) { + PDistCell value(it->first, distance); + matrix->addCell(itA->second, value); + }else { + PDistCell value(itA->second, distance); + matrix->addCell(it->first, value); + } + outMDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl; }else{ outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl; } @@ -252,8 +260,13 @@ int ReadBlast::read(NameAssignment* nameMap) { //is this distance below cutoff if (distance < cutoff) { if (!hclusterWanted) { - PCell value(itA->second, it->first, distance); - matrix->addCell(value); + if (itA->second < it->first) { + PDistCell value(it->first, distance); + matrix->addCell(itA->second, value); + }else { + PDistCell value(itA->second, distance); + matrix->addCell(it->first, value); + } }else{ outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl; } @@ -313,8 +326,8 @@ int ReadBlast::readNames(NameAssignment* nameMap) { ifstream in; m->openInputFile(blastfile, in); - //ofstream outName; - //m->openOutputFile((blastfile + ".tempOutNames"), outName); + ofstream outName; + m->openOutputFile((blastfile + ".tempOutNames"), outName); //read first line in >> prevName; @@ -338,6 +351,7 @@ int ReadBlast::readNames(NameAssignment* nameMap) { if (name != prevName) { prevName = name; nameMap->push_back(name); + outName << name << '\t' << name << endl; num++; } }