set<string> types;
types.insert("fasta");
+ types.insert("summary");
types.insert("accnos");
types.insert("column");
types.insert("design");
if (biomfile != "") { mothurOut("biom=" + biomfile); mothurOutEndLine(); }
if (counttablefile != "") { mothurOut("count=" + counttablefile); mothurOutEndLine(); }
if (processors != "1") { mothurOut("processors=" + processors); mothurOutEndLine(); }
+ if (summaryfile != "") { mothurOut("summary=" + summaryfile); mothurOutEndLine(); }
}
catch(exception& e) {
if (flowfile != "") { return true; }
if (biomfile != "") { return true; }
if (counttablefile != "") { return true; }
+ if (summaryfile != "") { return true; }
if (processors != "1") { return true; }
return hasCurrent;
flowfile = "";
biomfile = "";
counttablefile = "";
+ summaryfile = "";
processors = "1";
}
catch(exception& e) {
}
}
/*********************************************************************************************/
+void MothurOut::mothurOutJustToScreen(string output) {
+ try {
+
+#ifdef USE_MPI
+ int pid;
+ MPI_Comm_rank(MPI_COMM_WORLD, &pid);
+
+ if (pid == 0) { //only one process should output to screen
+#endif
+ logger() << output;
+
+#ifdef USE_MPI
+ }
+#endif
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "MothurOut");
+ exit(1);
+ }
+}
+/*********************************************************************************************/
void MothurOut::mothurOutEndLine() {
try {
#ifdef USE_MPI
}
}
+//**********************************************************************************************************************
+
+map<string, vector<string> > MothurOut::parseClasses(string classes){
+ try {
+ map<string, vector<string> > parts;
+
+ //treatment<Early|Late>-age<young|old>
+ vector<string> pieces; splitAtDash(classes, pieces); // -> treatment<Early|Late>, age<young|old>
+
+ for (int i = 0; i < pieces.size(); i++) {
+ string category = ""; string value = "";
+ bool foundOpen = false;
+ for (int j = 0; j < pieces[i].length(); j++) {
+ if (control_pressed) { return parts; }
+
+ if (pieces[i][j] == '<') { foundOpen = true; }
+ else if (pieces[i][j] == '>') { j += pieces[i].length(); }
+ else {
+ if (!foundOpen) { category += pieces[i][j]; }
+ else { value += pieces[i][j]; }
+ }
+ }
+ vector<string> values; splitAtChar(value, values, '|');
+ parts[category] = values;
+ }
+
+ return parts;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "parseClasses");
+ exit(1);
+ }
+}
/***********************************************************************/
string MothurOut::hasPath(string longName){
char c = inFASTA.get(); count++;
if (c == '>') {
positions.push_back(count-1);
- //cout << count << endl;
+ if (debug) { mothurOut("[DEBUG]: numSeqs = " + toString(positions.size()) + " count = " + toString(count) + ".\n"); }
}
}
inFASTA.close();
num = positions.size();
-
- /*FILE * pFile;
- long size;
+ if (debug) { mothurOut("[DEBUG]: num = " + toString(num) + ".\n"); }
+ FILE * pFile;
+ unsigned long long size;
//get num bytes in file
pFile = fopen (filename.c_str(),"rb");
fseek (pFile, 0, SEEK_END);
size=ftell (pFile);
fclose (pFile);
- }*/
+ }
- unsigned long long size = positions[(positions.size()-1)];
+ /*unsigned long long size = positions[(positions.size()-1)];
ifstream in;
openInputFile(filename, in);
if(in.eof()) { break; }
else { size++; }
}
- in.close();
-
+ in.close();*/
+
+ if (debug) { mothurOut("[DEBUG]: size = " + toString(size) + ".\n"); }
+
positions.push_back(size);
positions[0] = 0;
exit(1);
}
}
+//**********************************************************************************************************************
+vector<consTax> MothurOut::readConsTax(string inputfile){
+ try {
+
+ vector<consTax> taxes;
+
+ ifstream in;
+ openInputFile(inputfile, in);
+
+ //read headers
+ getline(in);
+
+ while (!in.eof()) {
+
+ if (control_pressed) { break; }
+
+ string otu = ""; string tax = "unknown";
+ int size = 0;
+
+ in >> otu >> size >> tax; gobble(in);
+ consTax temp(otu, tax, size);
+ taxes.push_back(temp);
+ }
+ in.close();
+
+ return taxes;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "readConsTax");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+int MothurOut::readConsTax(string inputfile, map<string, consTax2>& taxes){
+ try {
+ ifstream in;
+ openInputFile(inputfile, in);
+
+ //read headers
+ getline(in);
+
+ while (!in.eof()) {
+
+ if (control_pressed) { break; }
+
+ string otu = ""; string tax = "unknown";
+ int size = 0;
+
+ in >> otu >> size >> tax; gobble(in);
+ consTax2 temp(tax, size);
+ taxes[otu] = temp;
+ }
+ in.close();
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "readConsTax");
+ exit(1);
+ }
+}
/**************************************************************************************************/
vector<unsigned long long> MothurOut::setFilePosEachLine(string filename, int& num) {
try {
/************************************************************/
int MothurOut::checkName(string& name) {
try {
- for (int i = 0; i < name.length(); i++) {
- if (name[i] == ':') { name[i] = '_'; changedSeqNames = true; }
- }
+ if (modifyNames) {
+ for (int i = 0; i < name.length(); i++) {
+ if (name[i] == ':') { name[i] = '_'; changedSeqNames = true; }
+ }
+ }
return 0;
}
catch(exception& e) {
in.read(buffer, 4096);
vector<string> pieces = splitWhiteSpace(rest, buffer, in.gcount());
- for (int i = 0; i < pieces.size(); i++) { checkName(pieces[i]); names.insert(pieces[i]); }
+ for (int i = 0; i < pieces.size(); i++) { checkName(pieces[i]);
+ names.insert(pieces[i]);
+ }
}
in.close();
exit(1);
}
}
+/**************************************************************************************************/
+double MothurOut::getAverage(vector<double> dists) {
+ try{
+ double average = 0;
+
+ for (int i = 0; i < dists.size(); i++) {
+ average += dists[i];
+ }
+
+ //finds average.
+ average /= (double) dists.size();
+
+ return average;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getAverage");
+ exit(1);
+ }
+}
+
/**************************************************************************************************/
vector<double> MothurOut::getStandardDeviation(vector< vector<double> >& dists) {
try{