}
copyGroups.clear();
-
+
//process each distance file
for (int i = 0; i < numGroups; i++) {
else { m->mothurRemove((countfile + "." + toString(i) + ".temp")); }
}
+ //restore old fasta file name since dist.seqs overwrites it with the temp files
+ m->setFastaFile(fastafile);
+
vector<string> tempDistFiles;
for(int i=0;i<numGroups;i++){
if (outputDir == "") { outputDir = m->hasPath(fastafile); }
int numGroups = 0;
- ofstream outFile;
+ //ofstream outFile;
ifstream dFile;
m->openInputFile(distFile, dFile);
//have we reached the max buffer size
if (numOutputs[groupID] > 60) { //write out sequence
+ ofstream outFile;
outFile.open(fileName.c_str(), ios::app);
outFile << outputs[groupID] << seqA << '\t' << seqB << '\t' << dist << endl;
outFile.close();
//if groupB is written to file it is above buffer size so read and write to new merged file
if (wroteOutPut[groupIDB]) {
string fileName2 = distFile + "." + toString(groupIDB) + ".temp";
- ifstream fileB(fileName2.c_str(), ios::ate);
+ /*ifstream fileB(fileName2.c_str(), ios::ate);
outFile.open(fileName.c_str(), ios::app);
outFile << temp.substr(0, lastRead);
delete memblock;
- fileB.close();
+ fileB.close();*/
+ m->appendFiles(fileName2, fileName);
m->mothurRemove(fileName2);
+
//write out the merged memory
if (numOutputs[groupID] > 60) {
- outFile << outputs[groupID];
+ ofstream tempOut;
+ m->openOutputFile(fileName, tempOut);
+ tempOut << outputs[groupID];
outputs[groupID] = "";
numOutputs[groupID] = 0;
+ tempOut.close();
}
- outFile.close();
+ //outFile.close();
wroteOutPut[groupID] = true;
wroteOutPut[groupIDB] = false;
if (wroteOutPut[groupIDA]) {
string fileName2 = distFile + "." + toString(groupIDA) + ".temp";
- ifstream fileB(fileName2.c_str(), ios::ate);
+ /*ifstream fileB(fileName2.c_str(), ios::ate);
outFile.open(fileName.c_str(), ios::app);
delete memblock;
- fileB.close();
+ fileB.close();*/
+ m->appendFiles(fileName2, fileName);
m->mothurRemove(fileName2);
//write out the merged memory
if (numOutputs[groupID] > 60) {
- outFile << outputs[groupID];
+ ofstream tempOut;
+ m->openOutputFile(fileName, tempOut);
+ tempOut << outputs[groupID];
outputs[groupID] = "";
numOutputs[groupID] = 0;
+ tempOut.close();
}
- outFile.close();
+ //outFile.close();
wroteOutPut[groupID] = true;
wroteOutPut[groupIDA] = false;
//remove old names files just in case
if (numOutputs[i] > 0) {
+ ofstream outFile;
outFile.open(fileName.c_str(), ios::app);
outFile << outputs[i];
outFile.close();