]> git.donarmstrong.com Git - mothur.git/blobdiff - readblast.cpp
moved utilities out of mothur.h and into mothurOut class.
[mothur.git] / readblast.cpp
index 49e370836bb2c9e2edd59e99d9835de8acfc5582..1efaf5b5e3526b8ec53ff3651f9de4b540720b7e 100644 (file)
@@ -40,7 +40,7 @@ int ReadBlast::read(NameAssignment* nameMap) {
                if (m->control_pressed) { return 0; }
 
                ifstream fileHandle;
-               openInputFile(blastfile, fileHandle);
+               m->openInputFile(blastfile, fileHandle);
                
                string firstName, secondName, eScore, currentRow;
                string repeatName = "";
@@ -56,11 +56,11 @@ int ReadBlast::read(NameAssignment* nameMap) {
                if (!hclusterWanted) {
                        matrix = new SparseMatrix();
                }else{
-                       overlapFile = getRootName(blastfile) + "overlap.dist";
-                       distFile = getRootName(blastfile) + "hclusterDists.dist";
+                       overlapFile = m->getRootName(blastfile) + "overlap.dist";
+                       distFile = m->getRootName(blastfile) + "hclusterDists.dist";
                        
-                       openOutputFile(overlapFile, outOverlap);
-                       openOutputFile(distFile, outDist);
+                       m->openOutputFile(overlapFile, outOverlap);
+                       m->openOutputFile(distFile, outDist);
                }
                
                if (m->control_pressed) { 
@@ -79,7 +79,7 @@ int ReadBlast::read(NameAssignment* nameMap) {
                if (!fileHandle.eof()) {
                        //read in line from file
                        fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
-                       gobble(fileHandle);
+                       m->gobble(fileHandle);
                        
                        currentRow = firstName;
                        lengthThisSeq = numBases;
@@ -125,7 +125,7 @@ int ReadBlast::read(NameAssignment* nameMap) {
                        //read in line from file
                        fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
                        //cout << firstName << '\t' << secondName << '\t' << percentId << '\t' << numBases << '\t' << mismatch << '\t' << gap << '\t' << startQuery << '\t' << endQuery << '\t' << startRef << '\t' << endRef << '\t' << eScore << '\t' << score << endl;       
-                       gobble(fileHandle);
+                       m->gobble(fileHandle);
                        
                        string temp = firstName + secondName; //to check if this file has repeat lines, ie. is this a blast instead of a blscreen file
                        
@@ -169,6 +169,7 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                        map<int, float>::iterator itDist;
                                        for(it=thisRowsBlastScores.begin(); it!=thisRowsBlastScores.end(); it++) {  
                                                distance = 1.0 - (it->second / refScore);
+               
                                                
                                                //do we already have the distance calculated for b->a
                                                map<string,int>::iterator itA = nameMap->find(currentRow);
@@ -176,10 +177,11 @@ int ReadBlast::read(NameAssignment* nameMap) {
                                                
                                                //if we have it then compare
                                                if (itDist != dists[it->first].end()) {
+       
                                                        //if you want the minimum blast score ratio, then pick max distance
                                                        if(minWanted) {  distance = max(itDist->second, distance);  }
                                                        else{   distance = min(itDist->second, distance);  }
-                                                       
+
                                                        //is this distance below cutoff
                                                        if (distance < cutoff) {
                                                                if (!hclusterWanted) {
@@ -309,13 +311,17 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
                int num = 1;
                
                ifstream in;
-               openInputFile(blastfile, in);
+               m->openInputFile(blastfile, in);
+               
+               //ofstream outName;
+               //m->openOutputFile((blastfile + ".tempOutNames"), outName);
                
                //read first line
                in >> prevName;
+       
                for (int i = 0; i < 11; i++) {  in >> hold;  }
-               gobble(in);
-               
+               m->gobble(in);
+                               
                //save name in nameMap
                nameMap->push_back(prevName);
                
@@ -324,8 +330,9 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
                        
                        //read line
                        in >> name;
+       
                        for (int i = 0; i < 11; i++) {  in >> hold;  }
-                       gobble(in);
+                       m->gobble(in);
                        
                        //is this a new name?
                        if (name != prevName) {
@@ -338,11 +345,12 @@ int ReadBlast::readNames(NameAssignment* nameMap) {
                in.close();
                
                //write out names file
-               //string outNames = getRootName(blastfile) + "names";
+               //string outNames = m->getRootName(blastfile) + "names";
                //ofstream out;
-               //openOutputFile(outNames, out);
+               //m->openOutputFile(outNames, out);
                //nameMap->print(out);
                //out.close();
+               
                if (m->control_pressed) { return 0; }
                
                m->mothurOut(toString(num) + " names read."); m->mothurOutEndLine();