X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=readdistcommand.cpp;h=0445eec63328e2cf7a646f1cc662bb36fdd3bb98;hb=dd173a49e37f6bae73a63c32dd7c98d317bb4a79;hp=60d300f177f1deec1720ceeefec71d73ccd7579b;hpb=aa9238c0a9e6e7aa0ed8b8b606b08ad4fd7dcfe3;p=mothur.git diff --git a/readdistcommand.cpp b/readdistcommand.cpp index 60d300f..0445eec 100644 --- a/readdistcommand.cpp +++ b/readdistcommand.cpp @@ -22,7 +22,7 @@ ReadDistCommand::ReadDistCommand(string option) { else { //valid paramters for this command - string Array[] = {"phylip", "column", "name", "cutoff", "precision", "group","outputdir","inputdir"}; + string Array[] = {"phylip", "column", "name", "cutoff", "precision", "group","outputdir","inputdir","sim"}; vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); OptionParser parser(option); @@ -46,7 +46,7 @@ ReadDistCommand::ReadDistCommand(string option) { it = parameters.find("phylip"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["phylip"] = inputDir + it->second; } } @@ -54,7 +54,7 @@ ReadDistCommand::ReadDistCommand(string option) { it = parameters.find("column"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["column"] = inputDir + it->second; } } @@ -62,7 +62,7 @@ ReadDistCommand::ReadDistCommand(string option) { it = parameters.find("name"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["name"] = inputDir + it->second; } } @@ -70,7 +70,7 @@ ReadDistCommand::ReadDistCommand(string option) { it = parameters.find("group"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["group"] = inputDir + it->second; } } @@ -119,12 +119,16 @@ ReadDistCommand::ReadDistCommand(string option) { // ...at some point should added some additional type checking... //get user cutoff and precision or use defaults string temp; - temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; } + temp = validParameter.validFile(parameters, "precision", false); if (temp == "not found") { temp = "100"; } convert(temp, precision); + temp = validParameter.validFile(parameters, "sim", false); if (temp == "not found") { temp = "F"; } + sim = m->isTrue(temp); + globaldata->sim = sim; + temp = validParameter.validFile(parameters, "cutoff", false); if (temp == "not found") { temp = "10"; } convert(temp, cutoff); - cutoff += (5 / (precision * 10.0)); + cutoff += (5 / (precision * 10.0)); if (abort == false) { distFileName = globaldata->inputFileName; @@ -166,11 +170,12 @@ ReadDistCommand::ReadDistCommand(string option) { void ReadDistCommand::help(){ try { - m->mothurOut("The read.dist command parameter options are phylip or column, group, name, cutoff and precision\n"); + m->mothurOut("The read.dist command parameter options are phylip or column, group, name, sim, cutoff and precision\n"); m->mothurOut("The read.dist command can be used in two ways. The first is to read a phylip or column and run the cluster command\n"); m->mothurOut("For this use the read.dist command should be in the following format: \n"); m->mothurOut("read.dist(phylip=yourDistFile, name=yourNameFile, cutoff=yourCutoff, precision=yourPrecision) \n"); m->mothurOut("The phylip or column parameter is required, but only one may be used. If you use a column file the name filename is required. \n"); + m->mothurOut("The sim parameter is used to indicate that your distance file contains similarity values instead of distance values. The default is false, if sim=true then mothur will convert the similarity values to distances. \n"); m->mothurOut("If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n"); m->mothurOut("The second way to use the read.dist command is to read a phylip or column and a group, so you can use the libshuff command.\n"); m->mothurOut("For this use the read.dist command should be in the following format: \n"); @@ -204,10 +209,10 @@ int ReadDistCommand::execute(){ size_t numDists = 0; vector outputNames; -cout << format << endl; + if (format == "matrix") { ifstream in; - openInputFile(distFileName, in); + m->openInputFile(distFileName, in); matrix = new FullMatrix(in); //reads the matrix file in.close(); @@ -217,12 +222,12 @@ cout << format << endl; if (matrix->getNumSeqs() < groupMap->getNumSeqs()) { m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences."); m->mothurOutEndLine(); //create new group file - if(outputDir == "") { outputDir += hasPath(groupfile); } + if(outputDir == "") { outputDir += m->hasPath(groupfile); } - string newGroupFile = outputDir + getRootName(getSimpleName(groupfile)) + "editted.groups"; + string newGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "editted.groups"; outputNames.push_back(newGroupFile); ofstream outGroups; - openOutputFile(newGroupFile, outGroups); + m->openOutputFile(newGroupFile, outGroups); for (int i = 0; i < matrix->getNumSeqs(); i++) { if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); remove(newGroupFile.c_str()); return 0; }