]> git.donarmstrong.com Git - mothur.git/blobdiff - pintail.cpp
pat's edits from 1/26/2010
[mothur.git] / pintail.cpp
index 7b99cab9e7eed714a0cefeee4b45ed8057429c6f..2698fe48b278fff835ec9c1a5c40dfe8dc76a9f3 100644 (file)
@@ -74,7 +74,7 @@ void Pintail::print(ostream& out) {
 }
 
 //***************************************************************************************************************
-void Pintail::getChimeras() {
+int Pintail::getChimeras() {
        try {
                
                //read in query sequences and subject sequences
@@ -85,6 +85,8 @@ void Pintail::getChimeras() {
                
                int numSeqs = querySeqs.size();
                
+               if (unaligned) { mothurOut("Your sequences need to be aligned when you use the pintail method."); mothurOutEndLine(); return 1;  }
+               
                obsDistance.resize(numSeqs);
                expectedDistance.resize(numSeqs);
                seqCoef.resize(numSeqs);
@@ -146,18 +148,15 @@ void Pintail::getChimeras() {
                        mothurOut("Done."); mothurOutEndLine();
                }else {         createProcessesPairs();         }
                
-/*string o = "foronlinepintailpairs-eachgap";
-ofstream out7;
-openOutputFile(o, out7);
+//string o = "closestmatch.eachgap.fasta";
+//ofstream out7;
+//openOutputFile(o, out7);
 
-for (int i = 0; i < bestfit.size(); i++) {
-       out7 << querySeqs[i]->getName() << endl;
-       out7 << querySeqs[i]->getUnaligned() << endl << endl;
-       
-       out7 << bestfit[i]->getName() << endl;
-       out7 << bestfit[i]->getUnaligned() << endl << endl << endl;
-}              
-out7.close();/*/       
+//for (int i = 0; i < bestfit.size(); i++) {
+       //out7 << ">" << querySeqs[i]->getName() << "-"<< bestfit[i]->getName() << endl;
+       //out7 << bestfit[i]->getAligned() << endl;
+//}            
+//out7.close();        
                //find P
                mothurOut("Getting conservation... "); cout.flush();
                if (consfile == "") { 
@@ -385,6 +384,8 @@ out7.close();/*/
                        
                delete distcalculator;
                delete decalc;
+               
+               return 0;
        }
        catch(exception& e) {
                errorOut(e, "Pintail", "getChimeras");
@@ -442,28 +443,9 @@ vector<Sequence*> Pintail::findPairs(int start, int end) {
                vector<Sequence*> seqsMatches;  
                
                for(int i = start; i < end; i++){
-               
-                       float smallest = 10000.0;
-                       Sequence query = *(querySeqs[i]);
-                       Sequence* match;
-                       
-                       for(int j = 0; j < templateSeqs.size(); j++){
-                               
-                               Sequence temp = *(templateSeqs[j]);
-                               
-                               distcalculator->calcDist(query, temp);
-                               float dist = distcalculator->getDist();
-                               
-                               if (dist < smallest) { 
-                                       match = templateSeqs[j];
-                                       smallest = dist;
-                               }
-                       }
-                       
-                       //make copy so trimSeqs doesn't overtrim
-                       Sequence* copy = new Sequence(match->getName(), match->getAligned());
                        
-                       seqsMatches.push_back(copy);
+                       vector<Sequence*> copy = decalc->findClosest(querySeqs[i], templateSeqs, 1);
+                       seqsMatches.push_back(copy[0]);
                }
                
                return seqsMatches;