#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", "maxiter", "mindelta", "order"
- };
+ 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", "maxiter", "mindelta", "order"
- };
-
- 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);
m->mothurOut("The value of the order option must be four bases long\n");
}
- globaldata = GlobalData::getInstance();
}
#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(){
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);
void ShhherCommand::writeSequences(vector<int> otuCounts){
try {
- flowOrder = "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 = 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;
}