Permalink
Browse files

Improves speed in pre.cluster

  • Loading branch information...
1 parent 6a9bc2a commit 21e71170a93101e97d7e9d93fff7d25ad247a83c @mothur-westcott mothur-westcott committed Sep 26, 2016
Showing with 40 additions and 14 deletions.
  1. +5 −7 source/commands/preclustercommand.cpp
  2. +35 −7 source/commands/preclustercommand.h
@@ -9,7 +9,7 @@
#include "preclustercommand.h"
#include "deconvolutecommand.h"
-#include "filters.h"
+
//**********************************************************************************************************************
vector<string> PreClusterCommand::setParameters(){
@@ -722,7 +722,9 @@ int PreClusterCommand::process(string newMapFile){
if (originalCount[j] > originalCount[i]) { //this sequence is more abundant than I am
//are you within "diff" bases
- int mismatch = calcMisMatches(alignSeqs[i].seq.getAligned(), alignSeqs[j].seq.getAligned());
+ int mismatch = length;
+ if (method == "unaligned") { mismatch = calcMisMatches(alignSeqs[i].seq.getAligned(), alignSeqs[j].seq.getAligned()); }
+ else { mismatch = calcMisMatches(alignSeqs[i].filteredSeq, alignSeqs[j].filteredSeq); }
if (mismatch <= diffs) {
//merge
@@ -802,12 +804,10 @@ int PreClusterCommand::readFASTA(){
inFasta.close();
if (lengths.size() > 1) { method = "unaligned"; }
- else if (lengths.size() == 1) { method = "aligned"; }
+ else if (lengths.size() == 1) { method = "aligned"; filterSeqs(); }
length = *(lengths.begin());
- random_shuffle(alignSeqs.begin(), alignSeqs.end());
-
return alignSeqs.size();
}
@@ -870,8 +870,6 @@ int PreClusterCommand::loadSeqs(map<string, string>& thisName, vector<Sequence>&
thisSeqs.clear();
- //random_shuffle(alignSeqs.begin(), alignSeqs.end());
-
return alignSeqs.size();
}
@@ -21,7 +21,7 @@
#include "needlemanoverlap.hpp"
#include "blastalign.hpp"
#include "noalign.hpp"
-
+#include "filters.h"
/************************************************************/
struct seqPNode {
@@ -241,10 +241,38 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
}
}
+ length = *(lengths.begin());
+
if (lengths.size() > 1) { pDataArray->method = "unaligned"; }
- else if (lengths.size() == 1) { pDataArray->method = "aligned"; }
+ else if (lengths.size() == 1) {
+ pDataArray->method = "aligned";
+ ////////////////////////////////////////////////////
+ //filterSeqs();
+
+ string filterString = "";
+ Filters F;
+
+ F.setLength(length);
+ F.initialize();
+ F.setFilter(string(length, '1'));
+
+ for (int i = 0; i < alignSeqs.size(); i++) { F.getFreqs(alignSeqs[i].seq);}
+
+ F.setNumSeqs(alignSeqs.size());
+ F.doVerticalAllBases();
+ filterString = F.getFilter();
+
+ //run filter
+ for (int i = 0; i < alignSeqs.size(); i++) {
+ alignSeqs[i].filteredSeq = "";
+ string align = alignSeqs[i].seq.getAligned();
+ for(int j=0;j<length;j++){
+ if(filterString[j] == '1'){ alignSeqs[i].filteredSeq += align[j]; }
+ }
+ }
+ ////////////////////////////////////////////////////
+ }
- length = *(lengths.begin());
//sanity check
if (error) { pDataArray->m->control_pressed = true; }
@@ -314,9 +342,9 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
if (mismatch > pDataArray->diffs) { mismatch = length; break; } //to far to cluster
}
}else {
- for (int k = 0; k < alignSeqs[i].seq.getAligned().length(); k++) {
+ for (int k = 0; k < alignSeqs[i].filteredSeq.length(); k++) {
//do they match
- if (alignSeqs[i].seq.getAligned()[k] != alignSeqs[j].seq.getAligned()[k]) { mismatch++; }
+ if (alignSeqs[i].filteredSeq[k] != alignSeqs[j].filteredSeq[k]) { mismatch++; }
if (mismatch > pDataArray->diffs) { mismatch = length; break; } //to far to cluster
}
}
@@ -387,9 +415,9 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
}
}else {
- for (int k = 0; k < alignSeqs[i].seq.getAligned().length(); k++) {
+ for (int k = 0; k < alignSeqs[i].filteredSeq.length(); k++) {
//do they match
- if (alignSeqs[i].seq.getAligned()[k] != alignSeqs[j].seq.getAligned()[k]) { mismatch++; }
+ if (alignSeqs[i].filteredSeq[k] != alignSeqs[j].filteredSeq[k]) { mismatch++; }
if (mismatch > pDataArray->diffs) { mismatch = length; break; } //to far to cluster
}
}

0 comments on commit 21e7117

Please sign in to comment.