Silva seed causes crash in v1.36

Hi,
Any attempt to work with the Silva seed on v1.36 (Win64) causes immediate crash, e.g.:

mothur >
align.seqs(fasta=stability.trim.contigs.good.unique.fasta, reference=silva.seed_v123.align)
[ERROR]: has occurred in the MothurOut class function mothurConvert. Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.

Changing the file name or extension doesn’t help. Changing to Mothur v1.35 solves the problem :frowning:
P.

Thanks for reporting this bug. When we added the option to seed random in version 1.36, we did not account for “seed” being part of a filename. We have fixed this issue and the change will be part of the next release. As a workaround you can change the name of the reference to not include the word seed.

mothur > align.seqs(fasta=stability.trim.contigs.good.unique.fasta, reference=silva.seed_v123.align)

could be:

mothur > align.seqs(fasta=stability.trim.contigs.good.unique.fasta, reference=silva.v123.align)

I looked into the code, and find where the problem is.
File: commandfactory.cpp
Here is my fix:
int CommandFactory::checkForRedirects(string optionString) {
cerr << “CommandFactory::checkForRedirects(”
<< optionString << “)\n”
<< " Kemin has implemented this function!\n";
// trying to parse out outputdir=string, inputdir=blabla, seed=123
// and ignoring all others
string::size_type i=0, ii=0, j; // don’t use unsigned int, cause infinite loop
map<string, string> kvpair;
ii = optionString.find(’,’, i);
string kv;
while (ii != string::npos) {
kv = optionString.substr(i, ii-i);
kvpair.insert(extractPair(kv));
i=ii+1;
while (i != string::npos && isspace(optionString_))
++i;
if (i == string::npos) {
cerr << “while looking for ‘,’ inside " << optionString
<< " reached the end of string!\n”;
break;
}
ii = optionString.find(’,’, i);
}
// last option
kv = optionString.substr(i);
kvpair.insert(extractPair(kv));
// process the options
map<string,string>::const_iterator mit;
for (mit = kvpair.begin(); mit != kvpair.end(); ++mit) {
if (mit->first == “outputdir”) {
//user has set outputdir in command option string
string outputOption = mit->second;
if(m->mkDir(outputOption)) {
setOutputDirectory(outputOption);
m->mothurOut("Setting output directory to: " + outputOption);
m->mothurOutEndLine();
}
else {
cerr << "failed to mkdir: " << outputOption << endl;
}
}
else if (mit->first == “inputdir”) {
//user has set inputdir in command option string
string inputOption = mit->second;
if(m->dirCheck(inputOption)) {
setInputDirectory(inputOption);
m->mothurOut(“Setting input directory to: " + inputOption);
m->mothurOutEndLine();
}
else {
cerr << “Failed to find input directory: " << inputOption << endl;
}
}
else if (mit->first == “seed”) {
// intended to parse the seed=123 option
string intputOption = mit->second;
bool seed = false;
int random;
if (intputOption == “clear”) {
random = time(NULL);
seed = true;
}
else {
if (m->isInteger(intputOption)) {
m->mothurConvert(intputOption, random);
seed=true;
}
else {
m->mothurOut(”[ERROR]: Seed must be an integer.”);
m->mothurOutEndLine(); seed = false;
}
}
if (seed) {
srand(random);
m->mothurOut("Setting random seed to " + toString(random) + “.\n\n”);
}
}
}
return 0;


The incorrect part of the original fraction:

pos = optionString.find(“seed”);
if (pos != string::npos) { //user has set inputdir in command option string
string intputOption;
bool foundEquals = false;
for(int i=pos; i<optionString.length(); i++){
if(optionString == ‘,’) break;
else if(optionString == ‘=’) {
foundEquals = true;
}
if (foundEquals) {
intputOption += optionString
;
}
}
if (intputOption[0] == ‘=’) {
intputOption = intputOption.substr(1);
}
bool seed = false;
int random;
if (intputOption == “clear”) {
random = time(NULL);
seed = true;
}
else {
if (m->isInteger(intputOption)) {
m->mothurConvert(intputOption, random); seed=true;
}
else {
m->mothurOut("[ERROR]: Seed must be an integer.");
m->mothurOutEndLine(); seed = false;
}
}
if (seed) {
srand(random);
m->mothurOut("Setting random seed to " + toString(random) + “.\n\n”);
}
}
___