Permalink
Browse files

Checks group names in file file

  • Loading branch information...
1 parent 5ae7e78 commit 91d56bfcfdfb206bb133528dd3aeff8d994b655e @mothur-westcott mothur-westcott committed Jul 14, 2016
@@ -467,6 +467,7 @@ int GetMIMarksPackageCommand::readFile(){
thisFileName1 = pieces[1];
thisFileName2 = pieces[2];
group = pieces[0];
+ m->checkGroupName(group);
}else if (pieces.size() == 4) {
if (!setOligosParameter) { m->mothurOut("[ERROR]: You must have an oligosfile with the index file option. Aborting. \n"); m->control_pressed = true; }
thisFileName1 = pieces[0];
@@ -2940,6 +2940,7 @@ vector< vector<string> > MakeContigsCommand::readFileNames(string filename){
rindex = "";
}else if (pieces.size() == 3) {
group = pieces[0];
+ m->checkGroupName(group);
forward = pieces[1];
reverse = pieces[2];
findex = "";
@@ -1018,6 +1018,7 @@ vector< vector<string> > ParseFastaQCommand::readFile(){
if (oligosfile != "") { m->mothurOut("[ERROR]: You cannot have an oligosfile and 3 column file option at the same time. Aborting. \n"); m->control_pressed = true; }
if (groupfile != "") { m->mothurOut("[ERROR]: You cannot have an groupfile and 3 column file option at the same time. Aborting. \n"); m->control_pressed = true; }
group = pieces[0];
+ m->checkGroupName(group);
forward = pieces[1];
reverse = pieces[2];
findex = "";
@@ -771,6 +771,7 @@ vector<map<string, string> > RenameSeqsCommand::readFiles(){
}else if (pieces.size() == 3) {
thisFileName = pieces[0]+"-"+pieces[1];
group = pieces[2];
+ m->checkGroupName(group);
}else {
m->mothurOut("[ERROR]: Your file contains " + toString(pieces.size()) + " columns. TThe file option allows you to provide a 2 or 3 column file. The first column contains the file type: fasta or qfile. The second column is the filename, and the optional third column can be a group name. If there is a third column, all sequences in the file will be assigned to that group. This can be helpful when renaming data separated into samples.\n"); m->control_pressed = true;
}
@@ -963,6 +963,7 @@ int SRACommand::readFile(map<string, vector<string> >& files){
thisFileName1 = pieces[1];
thisFileName2 = pieces[2];
group = pieces[0];
+ m->checkGroupName(group);
if (setOligosParameter) { m->mothurOut("[ERROR]: You cannot have an oligosfile and 3 column file option at the same time. Aborting. \n"); m->control_pressed = true; }
if ((thisFileName2 != "none") && (thisFileName2 != "NONE" )) { if (!using3NONE) { libLayout = "paired"; } else { m->mothurOut("[ERROR]: You cannot have a 3 column file with paired and unpaired files at the same time. Aborting. \n"); m->control_pressed = true; } }
else { thisFileName2 = ""; libLayout = "single"; using3NONE = true; }
View
@@ -2979,6 +2979,28 @@ int MothurOut::checkName(string& name) {
exit(1);
}
}
+/************************************************************/
+bool MothurOut::checkGroupName(string name) {
+ try {
+
+ bool goodName = true;
+ for (int i = 0; i < name.length(); i++) {
+ if (name[i] == ':') { goodName = false; break; }
+ else if (name[i] == '-') { goodName = false; break; }
+ else if (name[i] == '/') { goodName = false; break; }
+ }
+
+ if (!goodName) {
+ mothurOut("[ERROR]: group " + name + " contains illegal characters in the name. Group names cannot include :, -, or / characters. The ':' character is a special character used in trees. Using ':' will result in your tree being unreadable by tree reading software. The '-' character is a special character used by mothur to parse group names. Using the '-' character will prevent you from selecting groups. The '/' character will created unreadable filenames when mothur includes the group in an output filename.\n"); control_pressed = true;
+ }
+
+ return goodName;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "checkGroupName");
+ exit(1);
+ }
+}
/**********************************************************************************************************************/
int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, map<string, string>& fastamap) {
try {
View
@@ -193,6 +193,7 @@ class MothurOut {
string makeList(vector<string>&);
bool isSubset(vector<string>, vector<string>); //bigSet, subset
int checkName(string&);
+ bool checkGroupName(string name);
map<string, vector<string> > parseClasses(string);
string addUnclassifieds(string tax, int maxlevel, bool probs);

0 comments on commit 91d56bf

Please sign in to comment.