From: westcott Date: Fri, 20 May 2011 13:30:51 +0000 (+0000) Subject: changed blastdb.cpp to no include sequence names in blast input filenames. modified... X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=commitdiff_plain;h=d154abda2a21879424002f28c50c6e0965865acf changed blastdb.cpp to no include sequence names in blast input filenames. modified phylo.diversity to allow for no group file. --- diff --git a/blastdb.cpp b/blastdb.cpp index b1a7b48..b995bd3 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -67,7 +67,8 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { vector topMatches; ofstream queryFile; - m->openOutputFile((queryFileName+seq->getName()), queryFile); + int randNumber = rand(); + m->openOutputFile((queryFileName+toString(randNumber)), queryFile); queryFile << '>' << seq->getName() << endl; queryFile << seq->getUnaligned() << endl; queryFile.close(); @@ -80,18 +81,18 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { string blastCommand; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - blastCommand = path + "blast/bin/blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);; - blastCommand += (" -i " + (queryFileName+seq->getName()) + " -o " + blastFileName+seq->getName()); + blastCommand = path + "blast/bin/blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n); + blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber)); #else blastCommand = "\"" + path + "blast\\bin\\blastall\" -p blastn -d " + "\"" + dbFileName + "\"" + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n); - blastCommand += (" -i " + (queryFileName+seq->getName()) + " -o " + blastFileName+seq->getName()); + blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber)); //wrap entire string in "" blastCommand = "\"" + blastCommand + "\""; #endif system(blastCommand.c_str()); ifstream m8FileHandle; - m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error"); + m->openInputFile(blastFileName+toString(randNumber), m8FileHandle, "no error"); string dummy; int templateAccession; @@ -107,8 +108,8 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { topMatches.push_back(templateAccession); } m8FileHandle.close(); - remove((queryFileName+seq->getName()).c_str()); - remove((blastFileName+seq->getName()).c_str()); + remove((queryFileName+toString(randNumber)).c_str()); + remove((blastFileName+toString(randNumber)).c_str()); return topMatches; } @@ -127,8 +128,8 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { Scores.clear(); ofstream queryFile; - - m->openOutputFile((queryFileName+seq->getName()), queryFile); + int randNumber = rand(); + m->openOutputFile((queryFileName+toString(randNumber)), queryFile); queryFile << '>' << seq->getName() << endl; queryFile << seq->getUnaligned() << endl; queryFile.close(); @@ -140,10 +141,10 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { string blastCommand; #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) blastCommand = path + "blast/bin/megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn - blastCommand += (" -i " + (queryFileName+seq->getName()) + " -o " + blastFileName+seq->getName()); + blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber)); #else blastCommand = "\"" + path + "blast\\bin\\megablast\" -e 1e-10 -d " + "\"" + dbFileName + "\"" + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn - blastCommand += (" -i " + (queryFileName+seq->getName()) + " -o " + blastFileName+seq->getName()); + blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber)); //wrap entire string in "" blastCommand = "\"" + blastCommand + "\""; @@ -152,7 +153,7 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { system(blastCommand.c_str()); ifstream m8FileHandle; - m->openInputFile(blastFileName+seq->getName(), m8FileHandle, "no error"); + m->openInputFile(blastFileName+toString(randNumber), m8FileHandle, "no error"); string dummy, eScore; int templateAccession; @@ -173,8 +174,8 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { //cout << templateAccession << endl; } m8FileHandle.close(); - remove((queryFileName+seq->getName()).c_str()); - remove((blastFileName+seq->getName()).c_str()); + remove((queryFileName+toString(randNumber)).c_str()); + remove((blastFileName+toString(randNumber)).c_str()); //cout << "\n" ; return topMatches; } diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp index bf502ab..8e8c7b6 100644 --- a/phylodiversitycommand.cpp +++ b/phylodiversitycommand.cpp @@ -154,13 +154,8 @@ PhyloDiversityCommand::PhyloDiversityCommand(string option) { //check for required parameters groupfile = validParameter.validFile(parameters, "group", true); - if (groupfile == "not open") { abort = true; } - else if (groupfile == "not found") { - //if there is a current design file, use it - groupfile = m->getGroupFile(); - if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); } - else { m->mothurOut("You have no current group file and the group parameter is required."); m->mothurOutEndLine(); abort = true; } - } + if (groupfile == "not open") { groupfile = ""; abort = true; } + else if (groupfile == "not found") { groupfile = ""; } namefile = validParameter.validFile(parameters, "name", true); if (namefile == "not open") { abort = true; } @@ -217,9 +212,16 @@ int PhyloDiversityCommand::execute(){ m->setTreeFile(treefile); - //read in group map info. - tmap = new TreeMap(groupfile); - tmap->readMap(); + if (groupfile != "") { + //read in group map info. + tmap = new TreeMap(groupfile); + tmap->readMap(); + }else{ //fake out by putting everyone in one group + Tree* tree = new Tree(treefile); delete tree; //extracts names from tree to make faked out groupmap + tmap = new TreeMap(); + + for (int i = 0; i < m->Treenames.size(); i++) { tmap->addSeq(m->Treenames[i], "Group1"); } + } if (namefile != "") { readNamesFile(); } @@ -273,7 +275,7 @@ int PhyloDiversityCommand::execute(){ } SharedUtil* util = new SharedUtil(); - util->setGroups(m->Groups, tmap->namesOfGroups, "treegroup"); //sets the groups the user wants to analyze + util->setGroups(m->Groups, tmap->namesOfGroups, "phylo.diversity"); //sets the groups the user wants to analyze delete util; //incase the user had some mismatches between the tree and group files we don't want group xxx to be analyzed