//**********************************************************************************************************************
-PCACommand::PCACommand(string option){
+PCACommand::PCACommand(string option) {
try {
abort = false;
}
//error checking on files
- if (phylipfile == "") { mothurOut("You must provide a distance file before running the pca command."); mothurOutEndLine(); abort = true; }
+ if (phylipfile == "") { m->mothurOut("You must provide a distance file before running the pca command."); m->mothurOutEndLine(); abort = true; }
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "PCACommand");
+ m->errorOut(e, "PCACommand", "PCACommand");
exit(1);
}
}
void PCACommand::help(){
try {
- mothurOut("The pca command..."); mothurOutEndLine();
+ m->mothurOut("The pca command..."); m->mothurOutEndLine();
}
catch(exception& e) {
- errorOut(e, "PCACommand", "help");
+ m->errorOut(e, "PCACommand", "help");
exit(1);
}
}
vector<string> names;
vector<vector<double> > D;
- //fbase = filename;
- //if(fbase.find_last_of(".")!=string::npos){
- // fbase.erase(fbase.find_last_of(".")+1);
- //}
- //else{
- // fbase += ".";
- //}
-
fbase = outputDir + getRootName(getSimpleName(filename));
read(filename, names, D);
+
+ if (m->control_pressed) { return 0; }
double offset = 0.0000;
vector<double> d;
vector<vector<double> > copy_G;
//int rank = D.size();
- cout << "\nProcessing...\n";
+ m->mothurOut("\nProcessing...\n");
for(int count=0;count<2;count++){
- recenter(offset, D, G);
- tred2(G, d, e);
- qtli(d, e, G);
+ recenter(offset, D, G); if (m->control_pressed) { return 0; }
+ tred2(G, d, e); if (m->control_pressed) { return 0; }
+ qtli(d, e, G); if (m->control_pressed) { return 0; }
offset = d[d.size()-1];
if(offset > 0.0) break;
}
+ if (m->control_pressed) { return 0; }
output(fbase, names, G, d);
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
return 0;
}
catch(exception& e) {
- errorOut(e, "PCACommand", "execute");
+ m->errorOut(e, "PCACommand", "execute");
exit(1);
}
}
d = f.peek();
}
catch(exception& e) {
- errorOut(e, "PCACommand", "get_comment");
+ m->errorOut(e, "PCACommand", "get_comment");
exit(1);
}
}
/*********************************************************************************************************************************/
-void PCACommand::read_phylip(istream& f, int square_m, vector<string>& name_list, vector<vector<double> >& d){
+int PCACommand::read_phylip(istream& f, int square_m, vector<string>& name_list, vector<vector<double> >& d){
try {
// int count1=0;
// int count2=0;
f >> name_list[i];
// cout << i << "\t" << name_list[i] << endl;
for(int j=0;j<rank;j++) {
+ if (m->control_pressed) { return 0; }
+
f >> d[i][j];
if (d[i][j] == -0.0000)
d[i][j] = 0.0000;
f >> name_list[i];
d[i][i]=0.0000;
for(int j=0;j<i;j++){
+ if (m->control_pressed) { return 0; }
f >> d[i][j];
if (d[i][j] == -0.0000)
d[i][j] = 0.0000;
}
}
}
+
+ return 0;
}
catch(exception& e) {
- errorOut(e, "PCACommand", "read_phylip");
+ m->errorOut(e, "PCACommand", "read_phylip");
exit(1);
}
read_phylip(f, m, names, D);
}
catch(exception& e) {
- errorOut(e, "PCACommand", "read");
+ m->errorOut(e, "PCACommand", "read");
exit(1);
}
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "matrix_mult");
+ m->errorOut(e, "PCACommand", "matrix_mult");
exit(1);
}
matrix_mult(A,C,G);
}
catch(exception& e) {
- errorOut(e, "PCACommand", "recenter");
+ m->errorOut(e, "PCACommand", "recenter");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "tred2");
+ m->errorOut(e, "PCACommand", "tred2");
exit(1);
}
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "qtli");
+ m->errorOut(e, "PCACommand", "qtli");
exit(1);
}
}
ofstream pcaData((fnameRoot+"pca").c_str(), ios::trunc);
pcaData.setf(ios::fixed, ios::floatfield);
pcaData.setf(ios::showpoint);
+ outputNames.push_back(fnameRoot+"pca");
ofstream pcaLoadings((fnameRoot+"pca.loadings").c_str(), ios::trunc);
pcaLoadings.setf(ios::fixed, ios::floatfield);
- pcaLoadings.setf(ios::showpoint);
+ pcaLoadings.setf(ios::showpoint);
+ outputNames.push_back(fnameRoot+"pca.loadings");
pcaLoadings << "axis\tloading\n";
for(int i=0;i<rank;i++){
}
}
catch(exception& e) {
- errorOut(e, "PCACommand", "output");
+ m->errorOut(e, "PCACommand", "output");
exit(1);
}
}