]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeraslayer.cpp
tie breaker fix to chimera.slayer
[mothur.git] / chimeraslayer.cpp
index eae6acf4e20b717d5327722ec22085fa96ecc0af..77a8695a579d64b250cf98aa3852cf4975e7f90f 100644 (file)
@@ -258,7 +258,8 @@ int ChimeraSlayer::doPrep() {
                }else if (searchMethod == "blast") {
                
                        //generate blastdb
-                       databaseLeft = new BlastDB(-2.0, -1.0, match, misMatch);
+                       databaseLeft = new BlastDB(-1.0, -1.0, 1, -3);
+
                        for (int i = 0; i < templateSeqs.size(); i++) {         databaseLeft->addSequence(*templateSeqs[i]);    }
                        databaseLeft->generateDB();
                        databaseLeft->setNumSeqs(templateSeqs.size());
@@ -384,7 +385,8 @@ vector<Sequence*> ChimeraSlayer::getTemplate(Sequence* q) {
                }else if (searchMethod == "blast") {
                        
                        //generate blastdb
-                       databaseLeft = new BlastDB(-2.0, -1.0, match, misMatch);
+                       databaseLeft = new BlastDB(-1.0, -1.0, 1, -3);
+
                        for (int i = 0; i < thisTemplate.size(); i++) { if (m->control_pressed) { return thisTemplate; }  databaseLeft->addSequence(*thisTemplate[i]);  }
                        databaseLeft->generateDB();
                        databaseLeft->setNumSeqs(thisTemplate.size());
@@ -510,15 +512,15 @@ Sequence* ChimeraSlayer::print(ostream& out, ostream& outAcc, data_results leftP
                                                        for (int i = (rightPiece.spotMap[rightPiece.results[0].winLStart]-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
                                                }else { //both sides are chimeric, keep longest piece
                                                        
-                                                       int lengthLeftLeft = leftPiece.spotMap[leftPiece.results[0].winLStart] - leftPiece.spotMap[leftPiece.results[0].winLEnd];
-                                                       int lengthLeftRight = leftPiece.spotMap[leftPiece.results[0].winRStart] - leftPiece.spotMap[leftPiece.results[0].winREnd];
+                                                       int lengthLeftLeft = leftPiece.spotMap[leftPiece.results[0].winLEnd] - leftPiece.spotMap[leftPiece.results[0].winLStart];
+                                                       int lengthLeftRight = leftPiece.spotMap[leftPiece.results[0].winREnd] - leftPiece.spotMap[leftPiece.results[0].winRStart];
                                                        
                                                        int longest = 1; // leftleft = 1, leftright = 2, rightleft = 3 rightright = 4
                                                        int length = lengthLeftLeft;
                                                        if (lengthLeftLeft < lengthLeftRight) { longest = 2;  length = lengthLeftRight; }
                                                        
-                                                       int lengthRightLeft = rightPiece.spotMap[rightPiece.results[0].winLStart] - rightPiece.spotMap[rightPiece.results[0].winLEnd];
-                                                       int lengthRightRight = rightPiece.spotMap[rightPiece.results[0].winRStart] - rightPiece.spotMap[rightPiece.results[0].winREnd];
+                                                       int lengthRightLeft = rightPiece.spotMap[rightPiece.results[0].winLEnd] - rightPiece.spotMap[rightPiece.results[0].winLStart];
+                                                       int lengthRightRight = rightPiece.spotMap[rightPiece.results[0].winREnd] - rightPiece.spotMap[rightPiece.results[0].winRStart];
                                                        
                                                        if (lengthRightLeft > length) { longest = 3; length = lengthRightLeft;  }
                                                        if (lengthRightRight > length) { longest = 4; }
@@ -626,15 +628,15 @@ Sequence* ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc, data_results lef
                                                        for (int i = (rightPiece.spotMap[rightPiece.results[0].winLStart]-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
                                                }else { //both sides are chimeric, keep longest piece
                                                        
-                                                       int lengthLeftLeft = leftPiece.spotMap[leftPiece.results[0].winLStart] - leftPiece.spotMap[leftPiece.results[0].winLEnd];
-                                                       int lengthLeftRight = leftPiece.spotMap[leftPiece.results[0].winRStart] - leftPiece.spotMap[leftPiece.results[0].winREnd];
+                                                       int lengthLeftLeft = leftPiece.spotMap[leftPiece.results[0].winLEnd] - leftPiece.spotMap[leftPiece.results[0].winLStart];
+                                                       int lengthLeftRight = leftPiece.spotMap[leftPiece.results[0].winREnd] - leftPiece.spotMap[leftPiece.results[0].winRStart];
                                                        
                                                        int longest = 1; // leftleft = 1, leftright = 2, rightleft = 3 rightright = 4
                                                        int length = lengthLeftLeft;
                                                        if (lengthLeftLeft < lengthLeftRight) { longest = 2;  length = lengthLeftRight; }
                                                        
-                                                       int lengthRightLeft = rightPiece.spotMap[rightPiece.results[0].winLStart] - rightPiece.spotMap[rightPiece.results[0].winLEnd];
-                                                       int lengthRightRight = rightPiece.spotMap[rightPiece.results[0].winRStart] - rightPiece.spotMap[rightPiece.results[0].winREnd];
+                                                       int lengthRightLeft = rightPiece.spotMap[rightPiece.results[0].winLEnd] - rightPiece.spotMap[rightPiece.results[0].winLStart];
+                                                       int lengthRightRight = rightPiece.spotMap[rightPiece.results[0].winREnd] - rightPiece.spotMap[rightPiece.results[0].winRStart];
                                                        
                                                        if (lengthRightLeft > length) { longest = 3; length = lengthRightLeft;  }
                                                        if (lengthRightRight > length) { longest = 4; }
@@ -778,7 +780,10 @@ Sequence* ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc) {
 //***************************************************************************************************************
 int ChimeraSlayer::getChimeras(Sequence* query) {
        try {
-               if (trimChimera) { trimQuery = new Sequence(query->getName(), query->getAligned()); printResults.trimQuery = *trimQuery; }
+               if (trimChimera) {
+                       trimQuery = new Sequence(query->getName(), query->getAligned());
+                       printResults.trimQuery = *trimQuery; 
+               }
                
                chimeraFlags = "no";
                printResults.flag = "no";
@@ -792,7 +797,7 @@ int ChimeraSlayer::getChimeras(Sequence* query) {
                //you must create a template
                vector<Sequence*> thisTemplate;
                if (templateFileName != "self") { thisTemplate = templateSeqs; }
-               else { thisTemplate = getTemplate(query); } //fills thistemplate and creates the databases
+               else { thisTemplate = getTemplate(query); } //fills this template and creates the databases
                
                if (m->control_pressed) {  return 0;  }
                
@@ -810,10 +815,11 @@ int ChimeraSlayer::getChimeras(Sequence* query) {
                if (m->control_pressed) {  return 0;  }
 
                string chimeraFlag = maligner.getResults(query, decalc);
+               
                if (m->control_pressed) {  return 0;  }
+               
                vector<results> Results = maligner.getOutput();
        
-               //found in testing realigning only made things worse
                if (realign) {
                        ChimeraReAligner realigner(thisTemplate, match, misMatch);
                        realigner.reAlign(query, Results);