3746107E0F4064D100460C57 /* weighted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3746107D0F4064D100460C57 /* weighted.cpp */; };
374610830F40652400460C57 /* unweighted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374610820F40652400460C57 /* unweighted.cpp */; };
3746109D0F40657600460C57 /* unifracunweightedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */; };
+ 374CD63F0F65832000D90B4A /* libshuffcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374CD63E0F65832000D90B4A /* libshuffcommand.cpp */; };
3782163D0F616079008E1F6D /* fullmatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3782163C0F616079008E1F6D /* fullmatrix.cpp */; };
379293C30F2DE73400B9034A /* treemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379293C20F2DE73400B9034A /* treemap.cpp */; };
379294700F2E191800B9034A /* parsimonycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3792946F0F2E191800B9034A /* parsimonycommand.cpp */; };
374610820F40652400460C57 /* unweighted.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unweighted.cpp; sourceTree = "<group>"; };
3746109B0F40657600460C57 /* unifracunweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unifracunweightedcommand.h; sourceTree = "<group>"; };
3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unifracunweightedcommand.cpp; sourceTree = "<group>"; };
+ 374CD63D0F65832000D90B4A /* libshuffcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuffcommand.h; sourceTree = "<group>"; };
+ 374CD63E0F65832000D90B4A /* libshuffcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libshuffcommand.cpp; sourceTree = "<group>"; };
3782163B0F616079008E1F6D /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = "<group>"; };
3782163C0F616079008E1F6D /* fullmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fullmatrix.cpp; sourceTree = "<group>"; };
379293C10F2DE73400B9034A /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treemap.h; sourceTree = "<group>"; };
A70B53A80F4CD7AD0064797E /* getlinecommand.cpp */,
37D927E40F21331F001D4494 /* helpcommand.h */,
37D927E30F21331F001D4494 /* helpcommand.cpp */,
+ 374CD63D0F65832000D90B4A /* libshuffcommand.h */,
+ 374CD63E0F65832000D90B4A /* libshuffcommand.cpp */,
37D927F30F21331F001D4494 /* nocommand.h */,
37D927F20F21331F001D4494 /* nocommand.cpp */,
37D927FA0F21331F001D4494 /* parselistcommand.h */,
A70B53AB0F4CD7AD0064797E /* getlabelcommand.cpp in Sources */,
A70B53AC0F4CD7AD0064797E /* getlinecommand.cpp in Sources */,
3782163D0F616079008E1F6D /* fullmatrix.cpp in Sources */,
+ 374CD63F0F65832000D90B4A /* libshuffcommand.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
globaldata = GlobalData::getInstance();
groupmap = globaldata->gGroupmap;
+ float minSoFar = 0.0;
string name, group;
filehandle >> numSeqs >> name;
if(isalnum(d)){
square = true;
filehandle.putback(d);
- for(int i=0;i<numSeqs;i++){
+
+ if (numSeqs >= 2) {
+ //save first distance that is not distance to itself as minimum
+ filehandle >> matrix[0][0] >> minSoFar;
+ matrix[0][1] = minSoFar;
+ }
+
+ for(int i=2;i<numSeqs;i++){
filehandle >> matrix[0][i];
+ if (matrix[0][i] < minSoFar) { minSoFar = matrix[0][i]; }
}
+ index[0].minDist = minSoFar;
break;
}
reading = new Progress("Reading matrix: ", numSeqs * numSeqs);
int count = 0;
- float distance;
+ float distance, minSoFar;
+ minSoFar = 0.0;
string group, name;
for(int i=1;i<numSeqs;i++){
index[i].groupname = group;
index[i].seqName = name;
+ filehandle >> minSoFar;
+ matrix[i][0] = minSoFar;
+
if(group == "not found") { cout << "Error: Sequence '" << name << "' was not found in the group file, please correct." << endl; exit(1); }
- for(int j=0;j<numSeqs;j++){
+ for(int j=1;j<numSeqs;j++){
filehandle >> distance;
+
+ if ((distance < minSoFar) && (i != j)) { minSoFar = distance; }
matrix[i][j] = distance;
count++;
reading->update(count);
}
+
+ //save minimum value for each row
+ index[i].minDist = minSoFar;
}
reading->finish();
delete reading;
reading = new Progress("Reading matrix: ", numSeqs * (numSeqs - 1) / 2);
int count = 0;
- float distance;
+ float distance, minSoFar;
+ minSoFar = 0.0;
+
string group, name;
for(int i=1;i<numSeqs;i++){
group = groupmap->getGroup(name);
index[i].groupname = group;
index[i].seqName = name;
+
+ filehandle >> minSoFar;
+ matrix[i][0] = minSoFar;
if(group == "not found") { cout << "Error: Sequence '" << name << "' was not found in the group file, please correct." << endl; exit(1); }
- for(int j=0;j<i;j++){
+ for(int j=1;j<i;j++){
filehandle >> distance;
+
+ if (distance < minSoFar) { minSoFar = distance; }
matrix[i][j] = distance; matrix[j][i] = distance;
count++;
reading->update(count);
}
+
+ //save minimum value for each row
+ index[i].minDist = minSoFar;
}
reading->finish();
delete reading;
using namespace std;
struct Names {
- string groupname;
+ string groupname;
string seqName;
+ float minDist;
};
--- /dev/null
+/*
+ * libshuffcommand.cpp
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/9/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "libshuffcommand.h"
+
+//**********************************************************************************************************************
+
+
+LibShuffCommand::LibShuffCommand(){
+ try {
+ //globaldata = GlobalData::getInstance();
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function LibShuffCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the LibShuffCommand class function LibShuffCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+
+}
+
+//**********************************************************************************************************************
+
+LibShuffCommand::~LibShuffCommand(){
+
+}
+
+//**********************************************************************************************************************
+
+int LibShuffCommand::execute(){
+ try {
+ return 0;
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the LibShuffCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the LibShuffCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
--- /dev/null
+#ifndef LIBSHUFFCOMMAND_H
+#define LIBSHUFFCOMMAND_H
+
+/*
+ * libshuffcommand.h
+ * Mothur
+ *
+ * Created by Sarah Westcott on 3/9/09.
+ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+
+using namespace std;
+
+class GlobalData;
+
+class LibShuffCommand : public Command {
+
+ public:
+ LibShuffCommand();
+ ~LibShuffCommand();
+ int execute();
+
+ private:
+ GlobalData* globaldata;
+
+};
+
+#endif
char d = f.get();
if(d == EOF){
- cerr << "Error: Input file ends prematurely, expecting a " << name << "\n"; return -1;
- //exit(1);
+ cerr << "Error: Input file ends prematurely, expecting a " << name << "\n";
+ exit(1);
}
if(d != c){
- cerr << "Error: Expected " << name << " in input file. Found " << d << ".\n"; return -1;
- //exit(1);
+ cerr << "Error: Expected " << name << " in input file. Found " << d << ".\n";
+ exit(1);
}
if(d == ')' && f.peek() == '\n'){
gobble(f);
char d = f.get();
if(d == EOF){
- cerr << "Error: Input file ends prematurely, expecting a left parenthesis\n"; return -1;
- //exit(1);
+ cerr << "Error: Input file ends prematurely, expecting a left parenthesis\n";
+ exit(1);
}
return d;
}
float b;
if(!(f >> b)){
- cerr << "Error: Missing branch length in input tree.\n"; return -1;
- //exit(1);
+ cerr << "Error: Missing branch length in input tree.\n";
+ exit(1);
}
gobble(f);
return b;
try {
int n = 0;
- int lc, rc, error;
+ int lc, rc;
int rooted = 0;
if (lc == -1) { return -1; } //reports an error in reading
if(filehandle.peek()==','){
- error = readSpecialChar(filehandle,',',"comma");
- if (error == -1) { readOk = -1; return -1; }
+ readSpecialChar(filehandle,',',"comma");
}
// ';' means end of tree.
else if((ch=filehandle.peek())==';' || ch=='['){
rc = readNewickInt(filehandle, n, T);
if (rc == -1) { return -1; } //reports an error in reading
if(filehandle.peek() == ')'){
- error = readSpecialChar(filehandle,')',"right parenthesis");
- if (error == -1) { readOk = -1; return -1; }
+ readSpecialChar(filehandle,')',"right parenthesis");
}
}
}
int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T) {
try {
- int error;
-
int c = readNodeChar(f);
- if (c == -1) { readOk = -1; return -1; }
if(c == '('){
int lc = readNewickInt(f, n, T);
if (lc == -1) { return -1; } //reports an error in reading
- error = readSpecialChar(f,',',"comma");
- if (error == -1) { readOk = -1; return -1; }
+ readSpecialChar(f,',',"comma");
int rc = readNewickInt(f, n, T);
if (rc == -1) { return -1; } //reports an error in reading
if(f.peek()==')'){
- error = readSpecialChar(f,')',"right parenthesis");
- if (error == -1) { readOk = -1; return -1; }
+ readSpecialChar(f,')',"right parenthesis");
}
if(f.peek() == ':'){
- error = readSpecialChar(f,':',"colon");
- if (error == -1) { readOk = -1; return -1; }
+ readSpecialChar(f,':',"colon");
+
if(n >= numNodes){ cerr << "Error: Too many nodes in input tree\n"; readOk = -1; return -1; }
- error = readBranchLength(f);
- if (error == -1) { readOk = -1; return -1; }
- T->tree[n].setBranchLength(error);
+
+ T->tree[n].setBranchLength(readBranchLength(f));
}else{T->tree[n].setBranchLength(0.0); }
T->tree[n].setChildren(lc,rc);
if(blen == 1){
f.get();
- error = readBranchLength(f);
- if (error == -1) { readOk = -1; return -1; }
- T->tree[n1].setBranchLength(error);
+ T->tree[n1].setBranchLength(readBranchLength(f));
}else{
T->tree[n1].setBranchLength(0.0);
}
for(int k = 0; k < numComp; k++) {
//saves users score
utreeScores[k].push_back(userData[k]);
+
}
//get unweighted scores for random trees
uScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC...
weightedFile = globaldata->getTreeFile() + toString(i+1) + ".weighted";
weightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".weighted";
-
+
userData = weighted->getValues(T[i]); //userData[0] = weightedscore
//save users score
data[count] = UW;
}
-
+
+ delete copyTree;
+
return data;
}