//**********************************************************************************************************************
ClusterFragmentsCommand::ClusterFragmentsCommand(){
try {
- abort = true;
- //initialize outputTypes
+ abort = true; calledHelp = true;
vector<string> tempOutNames;
outputTypes["fasta"] = tempOutNames;
outputTypes["name"] = tempOutNames;
//**********************************************************************************************************************
ClusterFragmentsCommand::ClusterFragmentsCommand(string option) {
try {
- abort = false;
+ abort = false; calledHelp = false;
//allow user to run help
- if(option == "help") { help(); abort = true; }
+ if(option == "help") { help(); abort = true; calledHelp = true; }
else {
//valid paramters for this command
m->mothurOut("The cluster.fragments command parameters are fasta, name, diffs and percent. The fasta parameter is required. \n");
m->mothurOut("The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n");
m->mothurOut("The diffs parameter allows you to set the number of differences allowed, default=0. \n");
- m->mothurOut("The percent parameter allows you to set percentage of differences allowed, default=0. percent=2 means if the number of difference is less than two percent of the length of the fragment, then cluster.\n");
+ m->mothurOut("The percent parameter allows you to set percentage of differences allowed, default=0. percent=2 means if the number of difference is less than or equal to two percent of the length of the fragment, then cluster.\n");
m->mothurOut("You may use diffs and percent at the same time to say something like: If the number or differences is greater than 1 or more than 2% of the fragment length, don't merge. \n");
m->mothurOut("The cluster.fragments command should be in the following format: \n");
m->mothurOut("cluster.fragments(fasta=yourFastaFile, names=yourNamesFile) \n");
int ClusterFragmentsCommand::execute(){
try {
- if (abort == true) { return 0; }
+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
int start = time(NULL);
if (alignSeqs[j].active) { //this sequence has not been merged yet
string jBases = alignSeqs[j].seq.getUnaligned();
-
+
if (isFragment(iBases, jBases)) {
//merge
alignSeqs[i].names += ',' + alignSeqs[j].names;
int percentDiff = floor((seq2.length() * (percent / 100.0)));
if (percentDiff < totalDiffs) { totalDiffs = percentDiff; }
}
-
+
Alignment* alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (seq1.length()+totalDiffs+1));
//use needleman to align
}
if (numDiffs <= totalDiffs) { fragment = true; }
+
}
return fragment;