//set global data to calc trees
globaldata->gTree = trees[k];
- string filename = getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
+ string filename = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + treeCalculators[k]->getName() + ".boot" + order->getLabel();
consensus = new ConcensusCommand(filename);
consensus->execute();
delete consensus;
if ((globaldata->getFormat() != "sharedfile")) { inputFileNames.push_back(globaldata->inputFileName); }
else { inputFileNames = parseSharedFile(globaldata->getSharedFile()); globaldata->setFormat("rabund"); }
-
+
for (int p = 0; p < inputFileNames.size(); p++) {
-
+
if (outputDir == "") { outputDir += hasPath(inputFileNames[p]); }
string fileNameRoot = outputDir + getRootName(getSimpleName(inputFileNames[p]));
globaldata->inputFileName = inputFileNames[p];
-
+
if (inputFileNames.size() > 1) {
mothurOutEndLine(); mothurOut("Processing group " + groups[p]); mothurOutEndLine(); mothurOutEndLine();
}
-
+
validCalculator = new ValidCalculators();
for (int i=0; i<Estimators.size(); i++) {
}
}
-
//if the users entered no valid calculators don't execute command
if (cDisplays.size() == 0) { return 0; }
read = new ReadOTUFile(inputFileNames[p]);
read->read(&*globaldata);
-
+
order = globaldata->gorder;
string lastLabel = order->getLabel();
input = globaldata->ginput;
//if the users entered no valid calculators don't execute command
if (cDisplays.size() == 0) { return 0; }
for(int i=0;i<cDisplays.size();i++){ cDisplays[i]->setAll(all); }
-
+
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
-
+
input = globaldata->ginput;
order = input->getSharedOrderVector();
string lastLabel = order->getLabel();
commands["phylotype"] = "phylotype";
commands["mgcluster"] = "mgcluster";
commands["pre.cluster"] = "pre.cluster";
- commands["pca"] = "pca";
+ commands["pcoa"] = "pcoa";
commands["otu.hierarchy"] = "otu.hierarchy";
commands["set.dir"] = "set.dir";
}
else if(commandName == "phylotype") { command = new PhylotypeCommand(optionString); }
else if(commandName == "mgcluster") { command = new MGClusterCommand(optionString); }
else if(commandName == "pre.cluster") { command = new PreClusterCommand(optionString); }
- else if(commandName == "pca") { command = new PCACommand(optionString); }
+ else if(commandName == "pcoa") { command = new PCACommand(optionString); }
else if(commandName == "otu.hierarchy") { command = new OtuHierarchyCommand(optionString); }
else if(commandName == "set.dir") { command = new SetDirectoryCommand(optionString); }
else { command = new NoCommand(optionString); }
remove(inName.c_str());
renameOk = rename(outName.c_str(), inName.c_str());
+ //renameFile(outName, inName);
+
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
mothurOut("Unable to rename " + outName); mothurOutEndLine();
remove(inName.c_str());
renameOk = rename(outName.c_str(), inName.c_str());
+ //renameFile(outName, inName);
+
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
mothurOut("Unable to rename " + outName); mothurOutEndLine();
outFile.close();
}
counter = 1;
+
remove(inName.c_str());
renameOk = rename(outName.c_str(), inName.c_str());
+ //renameFile(outName, inName);
+
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
mothurOut("Unable to rename " + outName); mothurOutEndLine();
if(counter != 0){
outFile.close();
inFile.close();
- }
- else{
+ }else{
outFile.close();
}
counter = 1;
+
remove(inName.c_str());
renameOk = rename(outName.c_str(), inName.c_str());
+ //renameFile(outName, inName);
+
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
mothurOut("Unable to rename " + outName); mothurOutEndLine();
perror(" : ");
}
+
}
catch(exception& e) {
errorOut(e, "OneColumnFile", "resetFile");
counter = 1;
remove(inName.c_str());
-
renameOk = rename(outName.c_str(), inName.c_str());
+ //renameFile(outName, inName);
+
//checks to make sure user was able to rename and remove successfully
if ((renameOk != 0)) {
mothurOut("Unable to rename " + outName); mothurOutEndLine();
class ThreeColumnFile : public FileOutput {
public:
- ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp") { };
+ ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(n + ".temp") { };
~ThreeColumnFile();
void initFile(string);
void output(int, vector<double>);
public:
- OneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
+ OneColumnFile(string n) : inName(n), counter(0), outName(n + ".temp") {};
~OneColumnFile();
void output(int, vector<double>);
void initFile(string);
public:
- SharedOneColumnFile(string n) : inName(n), counter(0), outName(getPathName(n) + ".temp") {};
+ SharedOneColumnFile(string n) : inName(n), counter(0), outName(n + ".temp") {};
~SharedOneColumnFile();
void output(int, vector<double>);
void initFile(string);
class SharedThreeColumnFile : public FileOutput {
public:
- SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(getPathName(n) + ".temp") { };
+ SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(n + ".temp") { };
~SharedThreeColumnFile();
void initFile(string);
void output(int, vector<double>);
class ColumnFile : public FileOutput {
public:
- ColumnFile(string n, string i) : FileOutput(), iters(i), inName(n), counter(0), outName(getPathName(n) + ".temp") {};
+ ColumnFile(string n, string i) : FileOutput(), iters(i), inName(n), counter(0), outName(n + ".temp") {};
~ColumnFile();
//to make compatible with parent class
//close and remove formatted matrix file
if (large) {
inRow.close();
- //remove(distFile.c_str());
+ remove(distFile.c_str());
}
globaldata->gListVector = NULL;
openInputFile(fastafile, inFasta);
while(!inFasta.eof()) {
- Sequence seq(inFasta);
+ Sequence seq(inFasta); gobble(inFasta);
if (seq.getName() != "") { seqs.push_back(seq); }
}
inFasta.close();
}
outFasta << seqs[k].getAligned() << endl;
- }else { mothurOut(seqs[k].getName() + " is not in your fasta file. Please correct."); mothurOutEndLine(); }
+ }
}
outFasta.close();
class RAbundVector;
class ListVector;
-/***********************************************************************/
-struct linkNode {
- int links;
- float dist;
-
- linkNode() {};
- linkNode(int l, float a) : links(l), dist(a) {};
- ~linkNode() {};
-};
-
/***********************************************************************/
class HCluster {
string rootPathName = longName;
- if(longName.find_last_of('/') != longName.npos){
- int pos = longName.find_last_of('/')+1;
+ if(longName.find_last_of("/\\") != longName.npos){
+ int pos = longName.find_last_of("/\\")+1;
rootPathName = longName.substr(0, pos);
}
//get full path name
string completeFileName = getFullPathName(fileName);
- //string completeFileName = fileName;
fileHandle.open(completeFileName.c_str());
if(!fileHandle) {
- mothurOut("Error: Could not open " + completeFileName); mothurOutEndLine();
return 1;
- }
- else {
+ }else {
//check for blank file
gobble(fileHandle);
return 0;
- }
-
+ }
}
/***********************************************************************/
}
}
+/***********************************************************************/
+
+inline int renameFile(string oldName, string newName){
+
+ ifstream inTest;
+ int exist = openInputFile(newName, inTest, "");
+
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ if (exist == 0) { //you could open it so you want to delete it
+ inTest.close();
+ string command = "rm " + newName;
+ system(command.c_str());
+ }
+
+ string command = "mv " + oldName + " " + newName;
+ system(command.c_str());
+#else
+ remove(newName.c_str());
+ renameOk = rename(oldName.c_str(), newName.c_str());
+#endif
+ return 0;
+}
/***********************************************************************/
}
}
/**************************************************************************************************/
-
+//this seems to require the names and fasta file to be in the same order???
int PreClusterCommand::readNamesFASTA(){
try {
ifstream inNames;
size++;
secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
}
- Sequence seq(inFasta);
+
+ Sequence seq(inFasta); gobble(inFasta);
if (seq.getName() != firstCol) { mothurOut(seq.getName() + " is not in your names file, please correct."); mothurOutEndLine(); exit(1); }
else{
seqPNode tempNode(size, seq, nameString);
globaldata->setListFile("");
globaldata->setGroupFile("");
globaldata->setSharedFile("");
- }else{
-
- //change format to shared to speed up commands
- globaldata->setFormat("sharedfile");
- globaldata->setListFile("");
- globaldata->setGroupFile("");
}
+
delete shared;
}
return 0;
//lookup.clear();
string errorOff = "no error";
//errorOff = "";
-cout << globaldata->inputFileName << endl;
+
//read in listfile
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
groups += globaldata->Groups[i] + ".";
}
- string newGroupFile = getRootName(globaldata->inputFileName) + groups + "groups";
+ string newGroupFile = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + groups + "groups";
ofstream outGroups;
openOutputFile(newGroupFile, outGroups);
delete it3->second;
}
+
+ //change format to shared to speed up commands
+ globaldata->setFormat("sharedfile");
+ globaldata->setListFile("");
+ globaldata->setGroupFile("");
globaldata->setSharedFile(filename);
+
return 0;
}
void SharedCommand::createMisMatchFile() {
try {
ofstream outMisMatch;
- string outputMisMatchName = getRootName(globaldata->inputFileName);
+ string outputMisMatchName = outputDir + getRootName(getSimpleName(globaldata->inputFileName));
//you have sequences in your list file that are not in your group file
if (SharedList->getNumSeqs() > groupMap->getNumSeqs()) {
temp = validParameter.validFile(parameters, "qfile", true);
if (temp == "not found") { qFileName = ""; }
- else if(temp == "not open") { abort = 0; }
+ else if(temp == "not open") { abort = true; }
else { qFileName = temp; }
temp = validParameter.validFile(parameters, "qthreshold", false); if (temp == "not found") { temp = "0"; }
try{
if (abort == true) { return 0; }
-
+
+ numFPrimers = 0; //this needs to be initialized
+ numRPrimers = 0;
+
ifstream inFASTA;
openInputFile(fastaFile, inFASTA);
if(qFileName != "") { openInputFile(qFileName, qFile); }
bool success;
-
+
while(!inFASTA.eof()){
Sequence currSeq(inFASTA);
+
string origSeq = currSeq.getUnaligned();
if (origSeq != "") {
int group;
}
if(!success) { trashCode += 'q'; }
}
-
+
if(barcodes.size() != 0){
success = stripBarcode(currSeq, group);
if(!success){ trashCode += 'b'; }
}
-
+
if(numFPrimers != 0){
success = stripForward(currSeq);
if(!success){ trashCode += 'f'; }
}
-
+
if(numRPrimers != 0){
success = stripReverse(currSeq);
if(!success){ trashCode += 'r'; }
}
+
if(minLength > 0 || maxLength > 0){
success = cullLength(currSeq);
if(!success){ trashCode += 'l'; }
outGroups.close();
inFASTA.close();
}
-
-
+
return 0;
}
catch(exception& e) {