From: westcott Date: Thu, 14 May 2009 13:22:38 +0000 (+0000) Subject: fixed bug in venn command X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=b01e4c8527e66f227eff16cf296eeadf060306b6 fixed bug in venn command --- diff --git a/commandfactory.cpp b/commandfactory.cpp index c037515..2e8aca7 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -92,7 +92,7 @@ Command* CommandFactory::getCommand(string commandName){ else if(commandName == "tree.shared") { command = new TreeGroupCommand(); } else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(); } else if(commandName == "concensus") { command = new ConcensusCommand(); } - else if(commandName == "dist.seq") { command = new DistanceCommand(); } + else if(commandName == "dist.seqs") { command = new DistanceCommand(); } else { command = new NoCommand(); } return command; diff --git a/distancecommand.cpp b/distancecommand.cpp index 90ffb8d..140aa60 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -88,81 +88,87 @@ int DistanceCommand::execute(){ remove(distFile.c_str()); - if(processors == 1){ - driver(distCalculator, seqDB, 0, numSeqs, distFile, cutoff); - } - else if(processors == 2){ + // # if defined (WIN_VERSION) + // driver(distCalculator, seqDB, 0, numSeqs, distFile, cutoff); + // # endif - int pid = fork(); - if(pid > 0){ - driver(distCalculator, seqDB, 0, (numSeqs/sqrt(2)), distFile + "tempa", cutoff); - appendFiles((distFile+"tempa"), distFile); - remove((distFile + "tempa").c_str()); - } - else{ - driver(distCalculator, seqDB, (numSeqs/sqrt(2)), numSeqs, distFile + "tempb", cutoff); - appendFiles((distFile+"tempb"), distFile); - remove((distFile + "tempb").c_str()); - } - wait(NULL); - - } - else if(processors == 3){ - int pid1 = fork(); - if(pid1 > 0){ - int pid2 = fork(); - if(pid2 > 0){ - driver(distCalculator, seqDB, 0, sqrt(3) * numSeqs / 3, distFile + "tempa", cutoff); - appendFiles(distFile+"tempa", distFile); + // # if defined (LINUX_VERSION) + if(processors == 1){ + driver(distCalculator, seqDB, 0, numSeqs, distFile, cutoff); + } + else if(processors == 2){ + + int pid = fork(); + if(pid > 0){ + driver(distCalculator, seqDB, 0, (numSeqs/sqrt(2)), distFile + "tempa", cutoff); + appendFiles((distFile+"tempa"), distFile); remove((distFile + "tempa").c_str()); } else{ - driver(distCalculator, seqDB, sqrt(3) * numSeqs / 3, sqrt(6) * numSeqs / 3, distFile + "tempb", cutoff); - appendFiles(distFile+"tempb", distFile); - remove((distFile + "tempb").c_str()); + driver(distCalculator, seqDB, (numSeqs/sqrt(2)), numSeqs, distFile + "tempb", cutoff); + appendFiles((distFile+"tempb"), distFile); + remove((distFile + "tempb").c_str()); } wait(NULL); + } - else{ - driver(distCalculator, seqDB, sqrt(6) * numSeqs / 3, numSeqs, distFile + "tempc", cutoff); - appendFiles(distFile+"tempc", distFile); - remove((distFile + "tempc").c_str()); - } - wait(NULL); - } - else if(processors == 4){ - int pid1 = fork(); - if(pid1 > 0){ - int pid2 = fork(); - if(pid2 > 0){ - driver(distCalculator, seqDB, 0, numSeqs / 2, distFile + "tempa", cutoff); - appendFiles(distFile+"tempa", distFile); - remove((distFile + "tempa").c_str()); + else if(processors == 3){ + int pid1 = fork(); + if(pid1 > 0){ + int pid2 = fork(); + if(pid2 > 0){ + driver(distCalculator, seqDB, 0, sqrt(3) * numSeqs / 3, distFile + "tempa", cutoff); + appendFiles(distFile+"tempa", distFile); + remove((distFile + "tempa").c_str()); + } + else{ + driver(distCalculator, seqDB, sqrt(3) * numSeqs / 3, sqrt(6) * numSeqs / 3, distFile + "tempb", cutoff); + appendFiles(distFile+"tempb", distFile); + remove((distFile + "tempb").c_str()); + } + wait(NULL); } else{ - driver(distCalculator, seqDB, numSeqs / 2, (numSeqs/sqrt(2)), distFile + "tempb", cutoff); - appendFiles(distFile+"tempb", distFile); - remove((distFile + "tempb").c_str()); + driver(distCalculator, seqDB, sqrt(6) * numSeqs / 3, numSeqs, distFile + "tempc", cutoff); + appendFiles(distFile+"tempc", distFile); + remove((distFile + "tempc").c_str()); } wait(NULL); } - else{ - int pid3 = fork(); - if(pid3 > 0){ - driver(distCalculator, seqDB, (numSeqs/sqrt(2)), (sqrt(3) * numSeqs / 2), distFile + "tempc", cutoff); - appendFiles(distFile+"tempc", distFile); - remove((distFile + "tempc").c_str()); + else if(processors == 4){ + int pid1 = fork(); + if(pid1 > 0){ + int pid2 = fork(); + if(pid2 > 0){ + driver(distCalculator, seqDB, 0, numSeqs / 2, distFile + "tempa", cutoff); + appendFiles(distFile+"tempa", distFile); + remove((distFile + "tempa").c_str()); + } + else{ + driver(distCalculator, seqDB, numSeqs / 2, (numSeqs/sqrt(2)), distFile + "tempb", cutoff); + appendFiles(distFile+"tempb", distFile); + remove((distFile + "tempb").c_str()); + } + wait(NULL); } else{ - driver(distCalculator, seqDB, (sqrt(3) * numSeqs / 2), numSeqs, distFile + "tempd", cutoff); - appendFiles(distFile+"tempd", distFile); - remove((distFile + "tempd").c_str()); + int pid3 = fork(); + if(pid3 > 0){ + driver(distCalculator, seqDB, (numSeqs/sqrt(2)), (sqrt(3) * numSeqs / 2), distFile + "tempc", cutoff); + appendFiles(distFile+"tempc", distFile); + remove((distFile + "tempc").c_str()); + } + else{ + driver(distCalculator, seqDB, (sqrt(3) * numSeqs / 2), numSeqs, distFile + "tempd", cutoff); + appendFiles(distFile+"tempd", distFile); + remove((distFile + "tempd").c_str()); + } + wait(NULL); } wait(NULL); } wait(NULL); - } - wait(NULL); + //# endif delete distCalculator; @@ -191,7 +197,11 @@ int DistanceCommand::driver(Dist* distCalculator, SequenceDB* align, int startLi for(int i=startLine;iget(i).getUnaligned() << " " << align->get(j).getUnaligned() << endl; +//cout << "aligned" << endl; +//cout << align->get(i).getAligned() << " " << align->get(j).getAligned() << endl; distCalculator->calcDist(align->get(i), align->get(j)); double dist = distCalculator->getDist(); diff --git a/eachgapdist.h b/eachgapdist.h index f4f00c1..767c4bf 100644 --- a/eachgapdist.h +++ b/eachgapdist.h @@ -22,24 +22,24 @@ public: int start = 0; for(int i=0; i=0;i--){ - if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ } else{ end = i; @@ -42,17 +42,17 @@ public: } for(int i=start;i<=end;i++){ - if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] == '-'){} - else if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.'){ + if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){} + else if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){ break; } - else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){ - if(A.getUnaligned()[i] != B.getUnaligned()[i]){ + else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){ + if(A.getAligned()[i] != B.getAligned()[i]){ diff++; } length++; } - else if(A.getUnaligned()[i] != '-' || B.getUnaligned()[i] != '-'){ + else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){ diff++; length++; } diff --git a/errorchecking.cpp b/errorchecking.cpp index c866ca0..8aaa8b0 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -246,7 +246,7 @@ bool ErrorCheck::checkInput(string input) { } } - if ((commandName == "filter.seqs") || (commandName == "dist.seq")) { + if ((commandName == "filter.seqs") || (commandName == "dist.seqs")) { if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) { cout << "You must read either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs command." << endl; return false; } diff --git a/globaldata.cpp b/globaldata.cpp index fddb5c9..4dfcbc1 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -43,7 +43,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ } //set default value for cutoff - if (commandName == "dist.seq") { cutoff = "1.0"; } + if (commandName == "dist.seqs") { cutoff = "1.0"; } string key, value; //reads in parameters and values @@ -215,7 +215,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ Estimators.clear(); splitAtDash(calc, Estimators); } - if (commandName == "dist.seq") { + if (commandName == "dist.seqs") { if ((calc == "default") || (calc == "")) { calc = "onegap"; } Estimators.clear(); splitAtDash(calc, Estimators); diff --git a/helpcommand.cpp b/helpcommand.cpp index 9d7f5c8..c259e1f 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -70,17 +70,17 @@ int HelpCommand::execute(){ cout << "The deconvolute command parameter is fasta and it is required." << "\n"; cout << "The deconvolute command should be in the following format: " << "\n"; cout << "deconvolute(fasta=yourFastaFile) " << "\n"; - }else if (globaldata->helpRequest == "dist.seq") { - cout << "The dist.seq command reads a file containing sequences and creates a distance file." << "\n"; - cout << "The dist.seq command parameters are fasta, phylip, clustal, nexus, calc, ends, cutoff and processors. " << "\n"; + }else if (globaldata->helpRequest == "dist.seqs") { + cout << "The dist.seqs command reads a file containing sequences and creates a distance file." << "\n"; + cout << "The dist.seqs command parameters are fasta, phylip, clustal, nexus, calc, ends, cutoff and processors. " << "\n"; cout << "You must use one of the following parameters for your filename: fasta, phylip, clustal or nexus. " << "\n"; cout << "The calc parameter allows you to specify the method of calculating the distances. Your options are: nogaps, onegap or eachgap. The default is onegap." << "\n"; cout << "The ends parameter allows you to specify whether to include terminal gaps in distance. Your options are: T or F. The default is T." << "\n"; cout << "The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0." << "\n"; cout << "The processors parameter allows you to specify number of processors to use. The default is 1, but you can use up to 4 processors." << "\n"; - cout << "The dist.seq command should be in the following format: " << "\n"; - cout << "dist.seq(fasta=yourFastaFile, calc=yourCalc, ends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) " << "\n"; - cout << "Example dist.seq(fasta=amazon.fasta, calc=eachgap, ends=F, cutoff= 2.0, processors=3)." << "\n"; + cout << "The dist.seqs command should be in the following format: " << "\n"; + cout << "dist.seqs(fasta=yourFastaFile, calc=yourCalc, ends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) " << "\n"; + cout << "Example dist.seqs(fasta=amazon.fasta, calc=eachgap, ends=F, cutoff= 2.0, processors=3)." << "\n"; cout << "Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc)." << "\n" << "\n"; }else if (globaldata->helpRequest == "collect.single") { cout << "The collect.single command can only be executed after a successful read.otu command. WITH ONE EXECEPTION. " << "\n"; diff --git a/ignoregaps.h b/ignoregaps.h index aa106c9..8127b62 100644 --- a/ignoregaps.h +++ b/ignoregaps.h @@ -27,7 +27,7 @@ public: int end = 0; for(int i=0;i=0;i--){ - if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ } else{ end = i; @@ -44,11 +44,11 @@ public: } for(int i=start; i<=end; i++){ - if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.'){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){ break; } - else if((A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-')){ - if(A.getUnaligned()[i] != B.getUnaligned()[i]){ + else if((A.getAligned()[i] != '-' && B.getAligned()[i] != '-')){ + if(A.getAligned()[i] != B.getAligned()[i]){ diff++; } length++; diff --git a/onegapdist.h b/onegapdist.h index ef290fe..b6b257c 100644 --- a/onegapdist.h +++ b/onegapdist.h @@ -26,7 +26,7 @@ public: int start = 0; for(int i=0;i=0;i--){ - if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){ + if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){ } else{ end = i; @@ -44,8 +44,8 @@ public: for(int i=start;i<=end;i++){ - if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] == '-'){} - else if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] != '-'){ + if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){} + else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-'){ if(openGapA == 0){ difference++; minLength++; @@ -53,7 +53,7 @@ public: openGapB = 0; } } - else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] == '-'){ + else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-'){ if(openGapB == 0){ difference++; minLength++; @@ -61,8 +61,8 @@ public: openGapB = 1; } } - else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){ - if(A.getUnaligned()[i] != B.getUnaligned()[i]){ + else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){ + if(A.getAligned()[i] != B.getAligned()[i]){ difference++; minLength++; openGapA = 0; diff --git a/venn.cpp b/venn.cpp index 9e75cdb..2c57960 100644 --- a/venn.cpp +++ b/venn.cpp @@ -115,7 +115,7 @@ void Venn::getPic(vector lookup, vector vCalcs delete singleCalc; } - + delete sabund; /******************* 2 Groups **************************/ }else if (lookup.size() == 2) { @@ -183,11 +183,10 @@ void Venn::getPic(vector lookup, vector vCalcs //close file outsvg << "\n\n"; outsvg.close(); - delete sabundA; - delete sabundB; delete singleCalc; } - + delete sabundA; + delete sabundB; /******************* 3 Groups **************************/ }else if (lookup.size() == 3) { @@ -352,7 +351,9 @@ void Venn::getPic(vector lookup, vector vCalcs outsvg.close(); delete singleCalc; } - + delete sabundA; + delete sabundB; + delete sabundC; /******************* 4 Groups **************************/ }else if (lookup.size() == 4) { @@ -516,7 +517,10 @@ void Venn::getPic(vector lookup, vector vCalcs delete singleCalc; } } - + delete sabundA; + delete sabundB; + delete sabundC; + delete sabundD; } }