else {
//valid paramters for this command
- string Array[] = {"cutoff","precision","method","phylip","column","name","sorted","showabund","timing"};
+ string Array[] = {"cutoff","precision","method","phylip","column","name","sorted","showabund","timing","outputdir","inputdir"};
vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
OptionParser parser(option);
map<string,string> parameters = parser.getParameters();
ValidParameters validParameter;
+ map<string,string>::iterator it;
//check to make sure all parameters are valid for command
- for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
+ for (it = parameters.begin(); it != parameters.end(); it++) {
if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
abort = true;
}
globaldata->newRead();
+ //if the user changes the input directory command factory will send this info to us in the output parameter
+ string inputDir = validParameter.validFile(parameters, "inputdir", false);
+ if (inputDir == "not found"){ inputDir = ""; }
+ else {
+ string path;
+ it = parameters.find("phylip");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = 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; }
+ }
+
+ it = parameters.find("column");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = 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; }
+ }
+
+ it = parameters.find("name");
+ //user has given a template file
+ if(it != parameters.end()){
+ path = 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; }
+ }
+ }
+
+ //if the user changes the output directory command factory will send this info to us in the output parameter
+ outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; }
+
//check for required parameters
phylipfile = validParameter.validFile(parameters, "phylip", true);
if (phylipfile == "not open") { abort = true; }
if (abort == false) {
-
- fileroot = getRootName(distfile);
+
+ if (outputDir == "") { outputDir += hasPath(distfile); }
+ fileroot = outputDir + getRootName(getSimpleName(distfile));
if (method == "furthest") { tag = "fn"; }
else if (method == "nearest") { tag = "nn"; }
print_start = true;
start = time(NULL);
-
- //ifstream in;
- //openInputFile(distfile, in);
cluster = new HCluster(rabund, list, method, distfile, globaldata->nameMap, cutoff);
vector<seqDist> seqs; seqs.resize(1); // to start loop
for (int i = 0; i < seqs.size(); i++) { //-1 means skip me
if (seqs[i].seq1 != seqs[i].seq2) {
- bool clustered = cluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
+ cluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
float rndDist = roundDist(seqs[i].dist, precision);
- if (clustered) {
- if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
- printData("unique");
- }
- else if((rndDist != rndPreviousDist)){
- printData(toString(rndPreviousDist, length-1));
- }
+ if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
+ printData("unique");
}
-
+ else if((rndDist != rndPreviousDist)){
+ printData(toString(rndPreviousDist, length-1));
+ }
+
previousDist = seqs[i].dist;
rndPreviousDist = rndDist;
oldRAbund = *rabund;
}
}
}
-
- //in.close();
if(previousDist <= 0.0000){
printData("unique");