Permalink
Browse files

Adds subsetGroups to Windows pre cluster

  • Loading branch information...
1 parent ef289e2 commit 0a2af8a7764a9c6c4a9775d0d00fbc44aa6a34dc @mothur-westcott mothur-westcott committed Oct 4, 2016
@@ -641,8 +641,7 @@ int PreClusterCommand::driverGroups(string newFFile, string newNFile, string new
m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
printData(newFFile, newNFile, groups[i]);
- m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
-
+ m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
}
if (countfile != "") { delete cparser; }else { delete parser; }
@@ -1016,15 +1015,33 @@ void PreClusterCommand::printData(string newfasta, string newname, string group)
}
if ((countfile != "") && (group == "")) { outNames << "Representative_Sequence\ttotal\n"; }
- for (int i = 0; i < alignSeqs.size(); i++) {
- if (alignSeqs[i].numIdentical != 0) {
- alignSeqs[i].seq.printSequence(outFasta);
- if (countfile != "") {
- if (group != "") { outNames << group << '\t' << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl; }
- else { outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].numIdentical << endl; }
- }else { outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl; }
- }
- }
+
+ if (countfile != "") {
+ if (group != "") {
+ for (int i = 0; i < alignSeqs.size(); i++) {
+ if (alignSeqs[i].numIdentical != 0) {
+ alignSeqs[i].seq.printSequence(outFasta);
+ outNames << group << '\t' << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < alignSeqs.size(); i++) {
+ if (alignSeqs[i].numIdentical != 0) {
+ alignSeqs[i].seq.printSequence(outFasta);
+ outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].numIdentical << endl;
+ }
+ }
+ }
+ }else {
+ for (int i = 0; i < alignSeqs.size(); i++) {
+ if (alignSeqs[i].numIdentical != 0) {
+ alignSeqs[i].seq.printSequence(outFasta);
+ outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
+ }
+ }
+ }
+
outFasta.close();
outNames.close();
@@ -163,14 +163,17 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, 1000);
}
- //parse fasta and name file by group
- SequenceParser* parser;
+ vector<string> subsetGroups;
+ for (int i = pDataArray->start; i < pDataArray->end; i++) { subsetGroups.push_back(pDataArray->groups[i]); }
+
+ //parse fasta and name file by group
SequenceCountParser* cparser;
+ SequenceParser* parser;
if (pDataArray->countfile != "") {
- cparser = new SequenceCountParser(pDataArray->countfile, pDataArray->fastafile);
+ cparser = new SequenceCountParser(pDataArray->countfile, pDataArray->fastafile, subsetGroups);
}else {
- if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile); }
- else { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile); }
+ if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile, subsetGroups); }
+ else { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, subsetGroups); }
}
int numSeqs = 0;
@@ -186,7 +189,7 @@ static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){
int start = time(NULL);
- if (pDataArray->m->control_pressed) { delete parser; delete alignment;return 0; }
+ if (pDataArray->m->control_pressed) { if (pDataArray->countfile != "") { delete cparser; } else { delete parser; } delete alignment;return 0; }
pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Processing group " + pDataArray->groups[k] + ":"); pDataArray->m->mothurOutEndLine();
@@ -25,7 +25,7 @@ SequenceCountParser::SequenceCountParser(string countfile, string fastafile, vec
namesOfGroups = countTable.getNamesOfGroups();
for (int i = 0; i < allNames.size(); i++) { indexes.push_back(i); }
}else{
- SharedUtil util; util.setGroups(groupsSelected, namesOfGroups);
+ SharedUtil util; util.setGroups(groupsSelected, allNames);
namesOfGroups = groupsSelected;
map<string, int> temp;
for (int i = 0; i < allNames.size(); i++) {
@@ -69,7 +69,7 @@ SequenceCountParser::SequenceCountParser(string fastafile, CountTable& countTabl
namesOfGroups = countTable.getNamesOfGroups();
for (int i = 0; i < allNames.size(); i++) { indexes.push_back(i); }
}else{
- SharedUtil util; util.setGroups(groupsSelected, namesOfGroups);
+ SharedUtil util; util.setGroups(groupsSelected, allNames);
namesOfGroups = groupsSelected;
map<string, int> temp;
for (int i = 0; i < allNames.size(); i++) {
@@ -109,14 +109,12 @@ int SequenceCountParser::readFasta(string fastafile, CountTable& countTable) {
ifstream in;
m->openInputFile(fastafile, in);
- int fastaCount = 0;
+
while (!in.eof()) {
if (m->control_pressed) { break; }
Sequence seq(in); m->gobble(in);
- fastaCount++;
- if (m->debug) { if((fastaCount) % 1000 == 0){ m->mothurOut("[DEBUG]: reading seq " + toString(fastaCount) + "\n."); } }
if (seq.getName() != "") {

0 comments on commit 0a2af8a

Please sign in to comment.