#define MIN_WEIGHT 0.1
#define MIN_TAU 0.0001
#define MIN_ITER 10
-
//**********************************************************************************************************************
-
-vector<string> ShhherCommand::getValidParameters(){
+vector<string> ShhherCommand::setParameters(){
try {
- string Array[] = {
- "file", "flow", "lookup", "cutoff", "sigma", "outputdir","inputdir", "processors"
- };
+ CommandParameter pflow("flow", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pflow);
+ CommandParameter pfile("file", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pfile);
+ CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plookup);
+ CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pcutoff);
+ CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
+ CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pmaxiter);
+ CommandParameter psigma("sigma", "Number", "", "60", "", "", "",false,false); parameters.push_back(psigma);
+ CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "",false,false); parameters.push_back(pmindelta);
+ CommandParameter porder("order", "String", "", "", "", "", "",false,false); parameters.push_back(porder);
+ CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
+ CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
- vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+ vector<string> myArray;
+ for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
return myArray;
}
catch(exception& e) {
- m->errorOut(e, "ShhherCommand", "getValidParameters");
+ m->errorOut(e, "ShhherCommand", "setParameters");
exit(1);
}
}
-
//**********************************************************************************************************************
-
-ShhherCommand::ShhherCommand(){
+string ShhherCommand::getHelpString(){
try {
- abort = true; calledHelp = true;
-
- //initialize outputTypes
- vector<string> tempOutNames;
- outputTypes["pn.dist"] = tempOutNames;
-
+ string helpString = "";
+ helpString += "The shhh.seqs command reads a file containing flowgrams and creates a file of corrected sequences.\n";
+ return helpString;
}
catch(exception& e) {
- m->errorOut(e, "ShhherCommand", "ShhherCommand");
+ m->errorOut(e, "ShhherCommand", "getHelpString");
exit(1);
}
}
-
//**********************************************************************************************************************
-vector<string> ShhherCommand::getRequiredParameters(){
+ShhherCommand::ShhherCommand(){
try {
- string Array[] = {"flow"};
- vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
- return myArray;
- }
- catch(exception& e) {
- m->errorOut(e, "ShhherCommand", "getRequiredParameters");
- exit(1);
- }
-}
-
-//**********************************************************************************************************************
+ abort = true; calledHelp = true;
+ setParameters();
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["pn.dist"] = tempOutNames;
-vector<string> ShhherCommand::getRequiredFiles(){
- try {
- vector<string> myArray;
- return myArray;
}
catch(exception& e) {
- m->errorOut(e, "ShhherCommand", "getRequiredFiles");
+ m->errorOut(e, "ShhherCommand", "ShhherCommand");
exit(1);
}
}
if(option == "help") { help(); abort = true; calledHelp = true; }
else {
-
- //valid paramters for this command
- string AlignArray[] = {
- "file", "flow", "lookup", "cutoff", "sigma", "outputdir","inputdir", "processors"
- };
-
- vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+ vector<string> myArray = setParameters();
OptionParser parser(option);
map<string,string> parameters = parser.getParameters();
else if(temp == "not open") { abort = true; }
else { lookupFileName = temp; }
- temp = validParameter.validFile(parameters, "processors", false);if (temp == "not found"){ temp = "1"; }
- convert(temp, processors);
+ temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
+ m->setProcessors(temp);
+ convert(temp, processors);
temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found"){ temp = "0.01"; }
convert(temp, cutoff);
temp = validParameter.validFile(parameters, "sigma", false);if (temp == "not found") { temp = "60"; }
convert(temp, sigma);
- globaldata = GlobalData::getInstance();
+ flowOrder = validParameter.validFile(parameters, "order", false);
+ if (flowOrder == "not found"){ flowOrder = "TACG"; }
+ else if(flowOrder.length() != 4){
+ m->mothurOut("The value of the order option must be four bases long\n");
+ }
+
}
#ifdef USE_MPI
exit(1);
}
}
-
-//**********************************************************************************************************************
-
-ShhherCommand::~ShhherCommand(){}
-
-//**********************************************************************************************************************
-
-void ShhherCommand::help(){
- try {
- m->mothurOut("The shhher command reads a file containing flowgrams and creates a file of corrected sequences.\n");
- }
- catch(exception& e) {
- m->errorOut(e, "ShhherCommand", "help");
- exit(1);
- }
-}
-
//**********************************************************************************************************************
#ifdef USE_MPI
int ShhherCommand::execute(){
int tag = 1976;
MPI_Status status;
- double begClock = clock();
- unsigned long int begTime = time(NULL);
-
if(pid == 0){
for(int i=1;i<ncpus;i++){
}
for(int i=0;i<numFiles;i++){
- flowFileName = flowFileVector[i];
+ double begClock = clock();
+ unsigned long int begTime = time(NULL);
-
+ flowFileName = flowFileVector[i];
m->mothurOut("\n>>>>>\tProcessing " + flowFileName + " (file " + toString(i+1) + " of " + toString(numFiles) + ")\t<<<<<\n");
m->mothurOut("Reading flowgrams...\n");
-
getFlowData();
+
m->mothurOut("Identifying unique flowgrams...\n");
getUniques();
MPI_Send(&nSeqsPerOTU[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
MPI_Send(&cumNumSeqs[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
}
-
+
calcCentroidsDriver(0, numOTUsOnCPU);
for(int i=1;i<ncpus;i++){
}
else{
int abort = 1;
- bool live = 1;
MPI_Recv(&abort, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
if(abort){ return 0; }
for(int i=0;i<numFiles;i++){
//Now into the pyrodist part
+ bool live = 1;
+
char fileName[1024];
MPI_Recv(&fileName, 1024, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
int total;
while(live){
-
+
MPI_Recv(&total, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
singleTau.assign(total, 0.0000);
seqNumber.assign(total, 0);
seqIndex.assign(total, 0);
-
+
MPI_Recv(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(¢roids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&singleTau[0], total, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&seqIndex[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&nSeqsPerOTU[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&cumNumSeqs[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-
+
calcCentroidsDriver(startOTU, endOTU);
MPI_Send(¢roids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD);
MPI_Send(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD);
-
MPI_Recv(¢roids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&weight[0], numOTUs, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
MPI_Recv(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
}
}
}
-
MPI_Barrier(MPI_COMM_WORLD);
+
return 0;
}
string ShhherCommand::cluster(string distFileName, string namesFileName){
try {
-
- globaldata->setNameFile(namesFileName);
- globaldata->setColumnFile(distFileName);
- globaldata->setFormat("column");
-
ReadMatrix* read = new ReadColumnMatrix(distFileName);
read->setCutoff(cutoff);
otuData.assign(numSeqs, 0);
cumNumSeqs.assign(numOTUs, 0);
nSeqsPerOTU.assign(numOTUs, 0);
- aaP.resize(numOTUs);
+ aaP.clear();aaP.resize(numOTUs);
seqNumber.clear();
aaI.clear();
for(int j=nSeqsPerOTU[i];j<numSeqs;j++){
aaP[i].push_back(0);
}
+
+
}
for(int i=1;i<numOTUs;i++){
seqIndex = seqNumber;
listFile.close();
+
}
catch(exception& e) {
m->errorOut(e, "ShhherCommand", "getOTUData");
try{
+
for(int i=start;i<finish;i++){
double count = 0;
for(int j=0;j<nSeqsPerOTU[i];j++){
count += singleTau[seqNumber[cumNumSeqs[i] + j]];
}
-
+
if(nSeqsPerOTU[i] > 0 && count > MIN_COUNT){
vector<double> adF(nSeqsPerOTU[i]);
vector<int> anL(nSeqsPerOTU[i]);
void ShhherCommand::writeSequences(vector<int> otuCounts){
try {
- string bases = "TACG";
string fastaFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".pn.fasta";
ofstream fastaFile;
if(otuCounts[i] > 0){
fastaFile << '>' << seqNameVector[aaI[i][0]] << endl;
- for(int j=8;j<numFlowCells;j++){
+ string newSeq = "";
+
+ for(int j=0;j<numFlowCells;j++){
- char base = bases[j % 4];
+ char base = flowOrder[j % 4];
for(int k=0;k<uniqueFlowgrams[index * numFlowCells + j];k++){
- fastaFile << base;
+ newSeq += base;
}
}
- fastaFile << endl;
+
+ fastaFile << newSeq.substr(4) << endl;
}
}
fastaFile.close();
ofstream otuCountsFile;
m->openOutputFile(otuCountsFileName, otuCountsFile);
- string bases = "TACG";
+ string bases = flowOrder;
for(int i=0;i<numOTUs;i++){
//output the translated version of the centroid sequence for the otu
int sequence = aaI[i][j];
otuCountsFile << seqNameVector[sequence] << '\t';
- for(int k=8;k<lengths[sequence];k++){
+ string newSeq = "";
+
+ for(int k=0;k<lengths[sequence];k++){
char base = bases[k % 4];
int freq = int(0.01 * (double)flowDataIntI[sequence * numFlowCells + k] + 0.5);
-
+
for(int s=0;s<freq;s++){
- otuCountsFile << base;
+ newSeq += base;
+ //otuCountsFile << base;
}
}
- otuCountsFile << endl;
+ otuCountsFile << newSeq.substr(4) << endl;
}
otuCountsFile << endl;
}