378C1B050FB0644E004D63F5 /* readclustal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF20FB0644D004D63F5 /* readclustal.cpp */; };
378C1B060FB0644E004D63F5 /* readfasta.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF40FB0644D004D63F5 /* readfasta.cpp */; };
378C1B070FB0644E004D63F5 /* readnexus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF60FB0644D004D63F5 /* readnexus.cpp */; };
- 378C1B080FB0644E004D63F5 /* readseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF90FB0644D004D63F5 /* readseqscommand.cpp */; };
378C1B090FB0644E004D63F5 /* readseqsphylip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */; };
378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */; };
378C1B0B0FB0644E004D63F5 /* sharedjackknife.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AFF0FB0644D004D63F5 /* sharedjackknife.cpp */; };
379293C30F2DE73400B9034A /* treemap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379293C20F2DE73400B9034A /* treemap.cpp */; };
379294700F2E191800B9034A /* parsimonycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3792946F0F2E191800B9034A /* parsimonycommand.cpp */; };
3792948A0F2E258500B9034A /* parsimony.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379294890F2E258500B9034A /* parsimony.cpp */; };
+ 379643ED0FB9B5A80081FDB6 /* readseqs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 379643EB0FB9B5A80081FDB6 /* readseqs.cpp */; };
37AD4CE40F28AEA300AA2D49 /* sharedlistvector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */; };
37AD4DBB0F28E2FE00AA2D49 /* tree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DBA0F28E2FE00AA2D49 /* tree.cpp */; };
37AD4DCA0F28F3DD00AA2D49 /* readtree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */; };
378C1AF60FB0644D004D63F5 /* readnexus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readnexus.cpp; sourceTree = "<group>"; };
378C1AF70FB0644D004D63F5 /* readnexus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readnexus.h; sourceTree = "<group>"; };
378C1AF80FB0644D004D63F5 /* readnexusal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readnexusal.h; sourceTree = "<group>"; };
- 378C1AF90FB0644D004D63F5 /* readseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readseqscommand.cpp; sourceTree = "<group>"; };
- 378C1AFA0FB0644D004D63F5 /* readseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readseqscommand.h; sourceTree = "<group>"; };
378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readseqsphylip.cpp; sourceTree = "<group>"; };
378C1AFC0FB0644D004D63F5 /* readseqsphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readseqsphylip.h; sourceTree = "<group>"; };
378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sequencedb.cpp; sourceTree = "<group>"; };
379294880F2E258500B9034A /* parsimony.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsimony.h; sourceTree = "<group>"; };
379294890F2E258500B9034A /* parsimony.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parsimony.cpp; sourceTree = "<group>"; };
3792948D0F2E271100B9034A /* treecalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treecalculator.h; sourceTree = "<group>"; };
+ 379643EB0FB9B5A80081FDB6 /* readseqs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readseqs.cpp; sourceTree = "<group>"; };
+ 379643EC0FB9B5A80081FDB6 /* readseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readseqs.h; sourceTree = "<group>"; };
37AD4CE20F28AEA300AA2D49 /* sharedlistvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedlistvector.h; sourceTree = "<group>"; };
37AD4CE30F28AEA300AA2D49 /* sharedlistvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedlistvector.cpp; sourceTree = "<group>"; };
37AD4DB90F28E2FE00AA2D49 /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
7E4130F70F8E58FA00381DD0 /* dlibshuff.h */,
7E4130F60F8E58FA00381DD0 /* dlibshuff.cpp */,
37D927D60F21331F001D4494 /* display.h */,
- 37C753DF0FB3492400DBD02E /* dist.h */,
37D927D80F21331F001D4494 /* engine.hpp */,
37D927D70F21331F001D4494 /* engine.cpp */,
37D928B10F213472001D4494 /* errorcheckor */,
37D928060F21331F001D4494 /* rarefact.h */,
37D928050F21331F001D4494 /* rarefact.cpp */,
37D928090F21331F001D4494 /* rarefactioncurvedata.h */,
- 378C1AF30FB0644D004D63F5 /* readclustal.h */,
- 378C1AF20FB0644D004D63F5 /* readclustal.cpp */,
- 375AA1340F9E433D008EF9B8 /* readcolumn.h */,
- 375AA1330F9E433D008EF9B8 /* readcolumn.cpp */,
- 378C1AF50FB0644D004D63F5 /* readfasta.h */,
- 378C1AF40FB0644D004D63F5 /* readfasta.cpp */,
- 37D928130F21331F001D4494 /* readmatrix.hpp */,
- 378C1AF70FB0644D004D63F5 /* readnexus.h */,
- 378C1AF60FB0644D004D63F5 /* readnexus.cpp */,
- 378C1AF80FB0644D004D63F5 /* readnexusal.h */,
- 375AA1360F9E433D008EF9B8 /* readotu.h */,
- 375AA1350F9E433D008EF9B8 /* readotu.cpp */,
- 375AA1380F9E433D008EF9B8 /* readphylip.h */,
- 375AA1370F9E433D008EF9B8 /* readphylip.cpp */,
- 378C1AFC0FB0644D004D63F5 /* readseqsphylip.h */,
- 378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */,
- 37AD4DC80F28F3DD00AA2D49 /* readtree.h */,
- 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */,
+ 3796441D0FB9B9650081FDB6 /* read */,
37D928210F21331F001D4494 /* shared.h */,
37D928200F21331F001D4494 /* shared.cpp */,
211C38310F961DD400FEE541 /* sharedutilities.h */,
name = Products;
sourceTree = "<group>";
};
+ 3796441D0FB9B9650081FDB6 /* read */ = {
+ isa = PBXGroup;
+ children = (
+ 378C1AF30FB0644D004D63F5 /* readclustal.h */,
+ 378C1AF20FB0644D004D63F5 /* readclustal.cpp */,
+ 375AA1340F9E433D008EF9B8 /* readcolumn.h */,
+ 375AA1330F9E433D008EF9B8 /* readcolumn.cpp */,
+ 378C1AF50FB0644D004D63F5 /* readfasta.h */,
+ 378C1AF40FB0644D004D63F5 /* readfasta.cpp */,
+ 37D928130F21331F001D4494 /* readmatrix.hpp */,
+ 378C1AF70FB0644D004D63F5 /* readnexus.h */,
+ 378C1AF60FB0644D004D63F5 /* readnexus.cpp */,
+ 378C1AF80FB0644D004D63F5 /* readnexusal.h */,
+ 375AA1360F9E433D008EF9B8 /* readotu.h */,
+ 375AA1350F9E433D008EF9B8 /* readotu.cpp */,
+ 375AA1380F9E433D008EF9B8 /* readphylip.h */,
+ 375AA1370F9E433D008EF9B8 /* readphylip.cpp */,
+ 378C1AFC0FB0644D004D63F5 /* readseqsphylip.h */,
+ 378C1AFB0FB0644D004D63F5 /* readseqsphylip.cpp */,
+ 379643EB0FB9B5A80081FDB6 /* readseqs.cpp */,
+ 379643EC0FB9B5A80081FDB6 /* readseqs.h */,
+ 37AD4DC80F28F3DD00AA2D49 /* readtree.h */,
+ 37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */,
+ );
+ name = read;
+ sourceTree = "<group>";
+ };
37D928A60F2133C0001D4494 /* calculators */ = {
isa = PBXGroup;
children = (
37D927BF0F21331F001D4494 /* chao1.cpp */,
7EC3D4510FA0FFF900338DA5 /* coverage.h */,
7EC3D4500FA0FFF900338DA5 /* coverage.cpp */,
+ 37C753DF0FB3492400DBD02E /* dist.h */,
37C753F00FB34AE800DBD02E /* eachgapdist.h */,
37C753F40FB34C0300DBD02E /* eachgapignore.h */,
EB9303F70F53517300E8EF26 /* geom.h */,
372E12950F263D5A0095CF7E /* readdistcommand.cpp */,
372E126E0F26365B0095CF7E /* readotucommand.h */,
372E126F0F26365B0095CF7E /* readotucommand.cpp */,
- 378C1AFA0FB0644D004D63F5 /* readseqscommand.h */,
- 378C1AF90FB0644D004D63F5 /* readseqscommand.cpp */,
37E5F4900F2A3DA800F8D827 /* readtreecommand.h */,
37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */,
37D928270F21331F001D4494 /* sharedcommand.h */,
378C1B050FB0644E004D63F5 /* readclustal.cpp in Sources */,
378C1B060FB0644E004D63F5 /* readfasta.cpp in Sources */,
378C1B070FB0644E004D63F5 /* readnexus.cpp in Sources */,
- 378C1B080FB0644E004D63F5 /* readseqscommand.cpp in Sources */,
378C1B090FB0644E004D63F5 /* readseqsphylip.cpp in Sources */,
378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */,
378C1B0B0FB0644E004D63F5 /* sharedjackknife.cpp in Sources */,
378C1B0C0FB0644E004D63F5 /* sharedmarczewski.cpp in Sources */,
37C753CE0FB3415200DBD02E /* distancecommand.cpp in Sources */,
+ 379643ED0FB9B5A80081FDB6 /* readseqs.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "readdistcommand.h"
#include "readtreecommand.h"
#include "readotucommand.h"
-#include "readseqscommand.h"
#include "clustercommand.h"
#include "parselistcommand.h"
#include "collectcommand.h"
#include "treegroupscommand.h"
#include "bootstrapsharedcommand.h"
#include "concensuscommand.h"
+#include "distancecommand.h"
/***********************************************************/
if(commandName == "read.dist") { command = new ReadDistCommand(); }
else if(commandName == "read.otu") { command = new ReadOtuCommand(); }
- else if(commandName == "read.seqs") { command = new ReadSeqsCommand(); }
else if(commandName == "read.tree") { command = new ReadTreeCommand(); }
else if(commandName == "cluster") { command = new ClusterCommand(); }
else if(commandName == "deconvolute") { command = new DeconvoluteCommand(); }
else if(commandName == "tree.shared") { command = new TreeGroupCommand(); }
else if(commandName == "bootstrap.shared") { command = new BootSharedCommand(); }
else if(commandName == "concensus") { command = new ConcensusCommand(); }
+ else if(commandName == "distance") { command = new DistanceCommand(); }
else { command = new NoCommand(); }
return command;
globaldata = GlobalData::getInstance();
validCalculator = new ValidCalculators();
ends = globaldata->getEnds();
- seqDB = globaldata->gSequenceDB;
convert(globaldata->getProcessors(), processors);
convert(globaldata->getCutOff(), cutoff);
- distFile = getRootName(globaldata->getFastaFile()) + "dist";
int i;
if (ends != "T") {
}
}
-
//reset calc for next command
globaldata->setCalc("");
int DistanceCommand::execute(){
try {
+
+ //read file
+ string filename = globaldata->inputFileName;
+
+ if(globaldata->getFastaFile() != "") {
+ readSeqs = new ReadFasta(filename); }
+ else if(globaldata->getNexusFile() != "") {
+ readSeqs = new ReadNexus(filename); }
+ else if(globaldata->getClustalFile() != "") {
+ readSeqs = new ReadClustal(filename); }
+ else if(globaldata->getPhylipFile() != "") {
+ readSeqs = new ReadPhylip(filename); }
+
+ readSeqs->read();
+ seqDB = readSeqs->getDB();
+
int numSeqs = seqDB->getNumSeqs();
- system(("rm "+distFile).c_str() );
+ string distFile = getRootName(globaldata->getFastaFile()) + "dist";
+
+ remove(distFile.c_str());
+
if(processors == 1){
driver(distCalculator, seqDB, 0, numSeqs, distFile, cutoff);
}
int pid = fork();
if(pid > 0){
driver(distCalculator, seqDB, 0, (numSeqs/sqrt(2)), distFile + "tempa", cutoff);
-// system(("cat " + distFile + "tempa" + " >> " + distFile).c_str());
-// system(("rm " + distFile + "tempa").c_str());
+ appendFiles((distFile+"tempa"), distFile);
+ remove((distFile + "tempa").c_str());
}
else{
driver(distCalculator, seqDB, (numSeqs/sqrt(2)), numSeqs, distFile + "tempb", cutoff);
-// system(("cat " + distFile + "tempb" + " >> " + distFile).c_str());
-// system(("rm " + distFile + "tempb").c_str());
+ appendFiles((distFile+"tempb"), distFile);
+ remove((distFile + "tempb").c_str());
}
wait(NULL);
int pid2 = fork();
if(pid2 > 0){
driver(distCalculator, seqDB, 0, sqrt(3) * numSeqs / 3, distFile + "tempa", cutoff);
- #ifdef HAVE_CAT
- system(("cat " + distFile + "tempa" + " >> " + distFile).c_str());
- #else
- #ifdef HAVE_COPY
-//get system call from pat system(("copy " + distFile + "tempa").c_str());
- #else
- cout << "Sorry but I can't continue because this operating system doesn't appear to support the cat() or copy() system calls." << endl;
- #endif
- #endif
-
- #ifdef HAVE_RM
- system(("rm " + distFile + "tempa").c_str());
- #else
- #ifdef HAVE_ERASE
- system(("erase " + distFile + "tempa").c_str());
- #else
- cout << "Sorry but I can't remove the required files because this operating system doesn't appear to support the rm() or erase() system calls." << endl;
- #endif
- #endif
+ appendFiles(distFile+"tempa", distFile);
+ remove((distFile + "tempa").c_str());
}
else{
driver(distCalculator, seqDB, sqrt(3) * numSeqs / 3, sqrt(6) * numSeqs / 3, distFile + "tempb", cutoff);
- system(("cat " + distFile + "tempb" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempb").c_str());
+ appendFiles(distFile+"tempb", distFile);
+ remove((distFile + "tempb").c_str());
}
wait(NULL);
}
else{
driver(distCalculator, seqDB, sqrt(6) * numSeqs / 3, numSeqs, distFile + "tempc", cutoff);
- system(("cat " + distFile + "tempc" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempc").c_str());
+ appendFiles(distFile+"tempc", distFile);
+ remove((distFile + "tempc").c_str());
}
wait(NULL);
}
int pid2 = fork();
if(pid2 > 0){
driver(distCalculator, seqDB, 0, numSeqs / 2, distFile + "tempa", cutoff);
- system(("cat " + distFile + "tempa" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempa").c_str());
+ //system(("cat " + distFile + "tempa" + " >> " + distFile).c_str());
+ appendFiles(distFile+"tempa", distFile);
+ //system(("rm " + distFile + "tempa").c_str());
+ remove((distFile + "tempa").c_str());
}
else{
driver(distCalculator, seqDB, numSeqs / 2, (numSeqs/sqrt(2)), distFile + "tempb", cutoff);
- system(("cat " + distFile + "tempb" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempb").c_str());
+ //system(("cat " + distFile + "tempb" + " >> " + distFile).c_str());
+ appendFiles(distFile+"tempb", distFile);
+ //system(("rm " + distFile + "tempb").c_str());
+ remove((distFile + "tempb").c_str());
}
wait(NULL);
}
int pid3 = fork();
if(pid3 > 0){
driver(distCalculator, seqDB, (numSeqs/sqrt(2)), (sqrt(3) * numSeqs / 2), distFile + "tempc", cutoff);
- system(("cat " + distFile + "tempc" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempc").c_str());
+ //system(("cat " + distFile + "tempc" + " >> " + distFile).c_str());
+ appendFiles(distFile+"tempc", distFile);
+ //system(("rm " + distFile + "tempc").c_str());
+ remove((distFile + "tempc").c_str());
}
else{
driver(distCalculator, seqDB, (sqrt(3) * numSeqs / 2), numSeqs, distFile + "tempd", cutoff);
- system(("cat " + distFile + "tempd" + " >> " + distFile).c_str());
- system(("rm " + distFile + "tempd").c_str());
+ //system(("cat " + distFile + "tempd" + " >> " + distFile).c_str());
+ appendFiles(distFile+"tempd", distFile);
+ //system(("rm " + distFile + "tempd").c_str());
+ remove((distFile + "tempd").c_str());
}
wait(NULL);
}
for(int i=startLine;i<endLine;i++){
- for(int j=0;j<i;j++){
-
+ for(int j=0;j<i;j++){
distCalculator->calcDist(align->get(i), align->get(j));
double dist = distCalculator->getDist();
+
if(dist <= cutoff){
- distFile << align->get(i).getName() << ' ' << align->get(j).getName() << ' ' << dist << endl;
+ distFile << align->get(i).getName() << ' ' << align->get(j).getName() << ' ' << dist << endl;
+//cout << align->get(i).getName() << ' ' << align->get(j).getName() << ' ' << dist << endl;
}
}
}
/**************************************************************************************************/
-
+void DistanceCommand::appendFiles(string temp, string filename) {
+ try{
+ ofstream output;
+ ifstream input;
+
+ //open output file in append mode
+ openOutputFileAppend(filename, output);
+
+ //open temp file for reading
+ openInputFile(temp, input);
+
+ string line;
+ //read input file and write to output file
+ while(input.eof() != true) {
+ getline(input, line); //getline removes the newline char
+ if (line != "") {
+ output << line << endl; // Appending back newline char
+ }
+ }
+
+ input.close();
+ output.close();
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the DistanceCommand class Function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the DistanceCommand class function appendFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
#include "validcalculator.h"
#include "dist.h"
#include "sequencedb.h"
+#include "readfasta.h"
+#include "readnexus.h"
+#include "readclustal.h"
+#include "readseqsphylip.h"
using namespace std;
ValidCalculators* validCalculator;
Dist* distCalculator;
SequenceDB* seqDB;
+ ReadSeqs* readSeqs;
ofstream out;
string outputFileName;
- string ends, distFile;
+ string ends;
int processors;
float cutoff;
+ void appendFiles(string, string);
int driver(Dist*, SequenceDB*, int, int, string, float);
};
int start = 0;
for(int i=0; i<A.getLength(); i++){
- if(A.getAligned()[i] != '.' || B.getAligned()[i] != '.'){
+ if(A.getUnaligned()[i] != '.' || B.getUnaligned()[i] != '.'){
start = i;
break;
}
}
for(int i=start;i<A.getLength();i++){
- if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (A.getAligned()[i] == '.' || B.getAligned()[i] == '.')){}
- else if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+ if((A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-') && (A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.')){}
+ else if(A.getUnaligned()[i] == '.' && B.getUnaligned()[i] == '.'){
break;
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
- if(A.getAligned()[i] != B.getAligned()[i]){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){
+ if(A.getUnaligned()[i] != B.getUnaligned()[i]){
diff++;
}
length++;
}
- else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){
+ else if(A.getUnaligned()[i] != '-' || B.getUnaligned()[i] != '-'){
diff++;
length++;
}
int end = 0;
for(int i=0;i<A.getLength();i++){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
start = i;
}
}
for(int i=A.getLength()-1;i>=0;i--){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
end = i;
}
for(int i=start;i<=end;i++){
- if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){}
- else if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){
+ if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] == '-'){}
+ else if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.'){
break;
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
- if(A.getAligned()[i] != B.getAligned()[i]){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){
+ if(A.getUnaligned()[i] != B.getUnaligned()[i]){
diff++;
}
length++;
}
- else if(A.getAligned()[i] != '-' || B.getAligned()[i] != '-'){
+ else if(A.getUnaligned()[i] != '-' || B.getUnaligned()[i] != '-'){
diff++;
length++;
}
}
}else if (commandName == "read.tree") {
validateTreeFiles(); //checks the treefile and groupfile parameters
- }else if (commandName == "read.seqs") {
- if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) { cout << "You must enter a fastafile, nexusfile, or clustalfile with the read.seqs() command." << endl; return false; }
}else if (commandName == "deconvolute") {
if (fastafile == "") { cout << "You must enter a fastafile with the deconvolute() command." << endl; return false; }
validateReadFiles();
}
}
- if (commandName == "filter.seqs"){
- if ((globaldata->getFastaFile() == "") && (globaldata->getNexusFile() == "") && (globaldata->getClustalFile() == "") && (globaldata->getPhylipFile() == "")) {
+ if ((commandName == "filter.seqs") || (commandName == "distance")) {
+ if ((fastafile == "") && (nexusfile == "") && (clustalfile == "") && (phylipfile == "")) {
cout << "You must read either a fasta, nexus, clustal, or phylip file before you can use the filter.seqs command." << endl; return false;
}
+ validateSeqsFiles();
}
if ((commandName == "bin.seqs")) {
}
/*******************************************************/
+/******************************************************/
+//This function checks to make sure the user entered appropriate
+// format parameters on a distfile read
+void ErrorCheck::validateSeqsFiles() {
+ try {
+ ifstream filehandle;
+ int ableToOpen;
+
+ //checks to make sure only one file type is given
+ if (phylipfile != "") {
+ if ((nexusfile != "") || (fastafile != "") || (clustalfile != "")) {
+ cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
+ else {
+ ableToOpen = openInputFile(phylipfile, filehandle);
+ filehandle.close();
+ if (ableToOpen == 1) { //unable to open
+ errorFree = false;
+ }
+ }
+ }else if (nexusfile != "") {
+ if ((phylipfile != "") || (fastafile != "") || (clustalfile != "")) {
+ cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
+ else {
+ ableToOpen = openInputFile(nexusfile, filehandle);
+ filehandle.close();
+ if (ableToOpen == 1) { //unable to open
+ errorFree = false;
+ }
+ }
+ }else if (fastafile != "") {
+ if ((phylipfile != "") || (nexusfile != "") || (clustalfile != "")) {
+ cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
+ else {
+ ableToOpen = openInputFile(fastafile, filehandle);
+ filehandle.close();
+ if (ableToOpen == 1) { //unable to open
+ errorFree = false;
+ }
+ }
+ }else if (clustalfile != "") {
+ if ((phylipfile != "") || (nexusfile != "") || (fastafile != "")) {
+ cout << "You may enter ONLY ONE of the following: phylip, fasta, nexus or clustal." << endl; errorFree = false; }
+ else {
+ ableToOpen = openInputFile(clustalfile, filehandle);
+ filehandle.close();
+ if (ableToOpen == 1) { //unable to open
+ errorFree = false;
+ }
+ }
+
+ }
+
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ErrorCheck class Function validateSeqsFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ErrorCheck class function validateSeqsFiles. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+
+/*******************************************************/
+
/******************************************************/
//This function checks to make sure the user entered appropriate
// format parameters on a bin.seq command
void validateParseFiles();
void validateTreeFiles();
void validateBinFiles();
+ void validateSeqsFiles();
void clear();
void refresh();
string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, nexusfile, clustalfile, treefile, sharedfile, cutoff, format;
*/
#include "filterseqscommand.h"
-#include <iostream>
-#include <fstream>
/**************************************************************************************/
void FilterSeqsCommand::doTrump() {
trump = globaldata->getTrump();
for(int i = 0; i < db->size(); i++) {
Sequence cur = db->get(i);
- string curAligned = cur.getAligned();
+ string curAligned = cur.getUnaligned();
for(int j = 0; j < curAligned.length(); j++) {
string curChar = curAligned.substr(j, 1);
if(curChar.compare(trump) == 0)
for(int i = 0; i < db->size(); i++) {
Sequence cur = db->get(i);
- string curAligned = cur.getAligned();
+ string curAligned = cur.getUnaligned();
for(int j = 0; j < curAligned.length(); j++) {
string curChar = curAligned.substr(j, 1);
int FilterSeqsCommand::execute() {
try {
globaldata = GlobalData::getInstance();
- db = globaldata->gSequenceDB;
+ filename = globaldata->inputFileName;
+ if(globaldata->getFastaFile() != "") {
+ readSeqs = new ReadFasta(filename); }
+ else if(globaldata->getNexusFile() != "") {
+ readSeqs = new ReadNexus(filename); }
+ else if(globaldata->getClustalFile() != "") {
+ readSeqs = new ReadClustal(filename); }
+ else if(globaldata->getPhylipFile() != "") {
+ readSeqs = new ReadPhylip(filename); }
+
+ readSeqs->read();
+ db = readSeqs->getDB();
+
+ //for(int i = 0; i < db->size(); i++) {
+// cout << db->get(i).getLength() << "\n" << db->get(i).getName() << ": " << db->get(i).getUnaligned() << "\n\n";
+// }
+
for(int i = 0; i < db->get(0).getLength(); i++)
columnsToRemove.push_back(false);
doTrump();
else if(globaldata->getSoft().compare("") != 0)
doSoft();
-
else if(globaldata->getFilter().compare("") != 0)
doFilter();
// else
// cout << "false\n";
// }
+
+
//Creating the new SequenceDB
SequenceDB newDB;
for(int i = 0; i < db->size(); i++) {
Sequence curSeq = db->get(i);
- string curAligned = curSeq.getAligned();
+ string curAligned = curSeq.getUnaligned();
string curName = curSeq.getName();
string newAligned = "";
for(int j = 0; j < curAligned.length(); j++)
newDB.add(newSeq);
}
+ string newFileName = getRootName(filename) + "filter.fa";
ofstream outfile;
- outfile.open("filtertest.txt");
+ outfile.open(newFileName.c_str());
newDB.print(outfile);
outfile.close();
+ globaldata->clear();
+ //delete db;
+ //delete newDB;
+
return 0;
}
catch(exception& e) {
cout << "An unknown error has occurred in the FilterSeqsCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
exit(1);
}
-}
-/**************************************************************************************/
+}
\ No newline at end of file
GlobalData* globaldata;
string filename, trump, filter;
- ReadFasta* readFasta;
- ReadNexus* readNexus;
- ReadClustal* readClustal;
- ReadPhylip* readPhylip;
+ ReadSeqs* readSeqs;
vector<bool> columnsToRemove;
SequenceDB* db;
int end = 0;
for(int i=0;i<A.getLength();i++){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
start = i;
}
}
for(int i=A.getLength()-1;i>=0;i--){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
end = i;
}
for(int i=start; i<=end; i++){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.'){
break;
}
- else if((A.getAligned()[i] != '-' && B.getAligned()[i] != '-')){
- if(A.getAligned()[i] != B.getAligned()[i]){
+ else if((A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-')){
+ if(A.getUnaligned()[i] != B.getUnaligned()[i]){
diff++;
}
length++;
}
}
+/***********************************************************************/
+
+inline int openOutputFileAppend(string fileName, ofstream& fileHandle){
+
+ fileHandle.open(fileName.c_str(), ios::app);
+ if(!fileHandle) {
+ cerr << "Error: Could not open " << fileName << endl;
+ return 1;
+ }
+ else {
+ return 0;
+ }
+
+}
+
/***********************************************************************/
int start = 0;
for(int i=0;i<A.getLength();i++){
- if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+ if(A.getUnaligned()[i] == '.' && B.getUnaligned()[i] == '.'){
}
else{
start = i;
}
}
for(int i=start;i<A.getLength();i++){
- if((A.getAligned()[i] == '-' || B.getAligned()[i] == '-') && (A.getAligned()[i] == '.' || B.getAligned()[i] == '.')){}
- else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-' && B.getAligned()[i] != '.'){
+ if((A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-') && (A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.')){}
+ else if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '.'){
if(openGapA == 0){
difference++;
minLength++;
openGapB = 0;
}
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-' && A.getAligned()[i] != '.'){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] == '-' && A.getUnaligned()[i] != '.'){
if(openGapB == 0){
difference++;
minLength++;
openGapB = 1;
}
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
- if(A.getAligned()[i] != B.getAligned()[i]){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){
+ if(A.getUnaligned()[i] != B.getUnaligned()[i]){
difference++;
minLength++;
openGapA = 0;
openGapB = 0;
}
}
- else if(A.getAligned()[i] == '.' && B.getAligned()[i] == '.'){
+ else if(A.getUnaligned()[i] == '.' && B.getUnaligned()[i] == '.'){
break;
}
}
int end = 0;
for(int i=0;i<A.getLength();i++){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
start = i;
}
}
for(int i=A.getLength()-1;i>=0;i--){
- if(A.getAligned()[i] == '.' || B.getAligned()[i] == '.' || A.getAligned()[i] == '-' || B.getAligned()[i] == '-'){
+ if(A.getUnaligned()[i] == '.' || B.getUnaligned()[i] == '.' || A.getUnaligned()[i] == '-' || B.getUnaligned()[i] == '-'){
}
else{
end = i;
for(int i=start;i<=end;i++){
- if(A.getAligned()[i] == '-' && B.getAligned()[i] == '-'){}
- else if(A.getAligned()[i] == '-' && B.getAligned()[i] != '-'){
+ if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] == '-'){}
+ else if(A.getUnaligned()[i] == '-' && B.getUnaligned()[i] != '-'){
if(openGapA == 0){
difference++;
minLength++;
openGapB = 0;
}
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] == '-'){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] == '-'){
if(openGapB == 0){
difference++;
minLength++;
openGapB = 1;
}
}
- else if(A.getAligned()[i] != '-' && B.getAligned()[i] != '-'){
- if(A.getAligned()[i] != B.getAligned()[i]){
+ else if(A.getUnaligned()[i] != '-' && B.getUnaligned()[i] != '-'){
+ if(A.getUnaligned()[i] != B.getUnaligned()[i]){
difference++;
minLength++;
openGapA = 0;
#include <fstream>
/*******************************************************************************/
-ReadClustal::ReadClustal(string file) {
+ReadClustal::ReadClustal(string file) : ReadSeqs(file){
try {
- openInputFile(file, filehandle);
- clustalFile = file;
- globaldata = GlobalData::getInstance();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
int count = 0;
int numSeqs = 0;
+ int lastSeqLength = 0;
bool firstDone = false;
while(!filehandle.eof()) {
if(name.find_first_of("*") == -1) {
filehandle >> sequence;
+ lastSeqLength = sequence.length();
if(!firstDone) {
Sequence newSeq(name, sequence);
sequencedb.add(newSeq);
}
else
- sequencedb.set(count, sequencedb.get(count).getAligned() + sequence);
+ sequencedb.set(count, sequencedb.get(count).getUnaligned() + sequence);
count++;
}
}
+ if(count == 1)
+ sequencedb.set(0, sequencedb.get(0).getUnaligned().substr(0, sequencedb.get(0).getUnaligned().length() - lastSeqLength));
+
filehandle.close();
}
*/
using namespace std;
+#include "readseqs.h"
#include "globaldata.hpp"
#include "sequencedb.h"
#include "mothur.h"
/**********************************************************************************/
-class ReadClustal {
+class ReadClustal : public ReadSeqs {
public:
ReadClustal(string);
~ReadClustal();
void read();
- SequenceDB* getDB();
-
- private:
- GlobalData* globaldata;
- string clustalFile;
- ifstream filehandle;
- SequenceDB sequencedb;
- int readOk; // readOk = 0 means success, readOk = 1 means error(s).
-
-
+ SequenceDB* getDB();
};
#endif
\ No newline at end of file
#include <fstream>
/*******************************************************************************/
-ReadFasta::ReadFasta(string file) {
+ReadFasta::ReadFasta(string file) : ReadSeqs(file) {
try {
- openInputFile(file, filehandle);
- fastaFile = file;
- globaldata = GlobalData::getInstance();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
string sequence = "";
string temp;
int count = 0;
+
while(!filehandle.eof()){
if(count == 0)
filehandle >> temp;
count++;
name = temp.substr(1,temp.length()-1);
}
- else
+ else {
sequence += temp;
+ }
filehandle >> temp;
+ gobble(filehandle);
+
+ if(filehandle.eof())
+ sequence += temp;
+
}
Sequence newSequence(name, sequence);
sequencedb.add(newSequence);
using namespace std;
+#include "readseqs.h"
#include "globaldata.hpp"
#include "sequencedb.h"
#include "mothur.h"
/**********************************************************************************/
-class ReadFasta {
+class ReadFasta : public ReadSeqs {
public:
ReadFasta(string);
~ReadFasta();
void read();
SequenceDB* getDB();
-
- private:
- GlobalData* globaldata;
- string fastaFile;
- ifstream filehandle;
- SequenceDB sequencedb;
- int readOk; // readOk = 0 means success, readOk = 1 means error(s).
-
-
};
#endif
\ No newline at end of file
#include <fstream>
/*******************************************************************************/
-ReadNexus::ReadNexus(string file) {
+ReadNexus::ReadNexus(string file) : ReadSeqs(file) {
try {
- openInputFile(file, filehandle);
- nexusFile = file;
- globaldata = GlobalData::getInstance();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
sequencedb.add(newSeq);
}
else
- sequencedb.set(count, sequencedb.get(count).getAligned() + sequence);
+ sequencedb.set(count, sequencedb.get(count).getUnaligned() + sequence);
count++;
if(count == numSeqs) {
*/
using namespace std;
+#include "readseqs.h"
#include "globaldata.hpp"
#include "sequencedb.h"
#include "mothur.h"
/**********************************************************************************/
-class ReadNexus {
+class ReadNexus : public ReadSeqs {
public:
ReadNexus(string);
~ReadNexus();
void read();
- SequenceDB* getDB();
-
- private:
- GlobalData* globaldata;
- string nexusFile;
- ifstream filehandle;
- SequenceDB sequencedb;
- int readOk; // readOk = 0 means success, readOk = 1 means error(s).
-
-
+ SequenceDB* getDB();
};
#endif
\ No newline at end of file
--- /dev/null
+/*
+ * readseqs.cpp
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/11/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include "readseqs.h"
+#include <iostream>
+#include <fstream>
+
+
+/*******************************************************************************/
+ReadSeqs::ReadSeqs(string file) {
+ try {
+ openInputFile(file, filehandle);
+ seqFile = file;
+ globaldata = GlobalData::getInstance();
+ }
+ catch(exception& e) {
+ cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+ catch(...) {
+ cout << "An unknown error has occurred in the ReadTree class function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ exit(1);
+ }
+}
+/*******************************************************************************/
+ReadSeqs::~ReadSeqs(){
+ //for(int i = 0; i < sequencedb.getNumSeqs(); i++)
+ //delete sequencedb.get(i);
+}
+/*******************************************************************************/
+void ReadSeqs::read() {
+}
+
+/*********************************************************************************/
+SequenceDB* ReadSeqs::getDB() {
+ return &sequencedb;
+}
--- /dev/null
+#ifndef READSEQS_H
+#define READSEQS_H
+
+/*
+ * readseqs.h
+ * Mothur
+ *
+ * Created by Thomas Ryabin on 5/11/09.
+ * Copyright 2009 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+using namespace std;
+
+#include "globaldata.hpp"
+#include "sequencedb.h"
+#include "mothur.h"
+
+/**********************************************************************************/
+
+class ReadSeqs {
+
+ public:
+ ReadSeqs(string);
+ ~ReadSeqs();
+ virtual void read();
+ virtual SequenceDB* getDB();
+
+ protected:
+ GlobalData* globaldata;
+ string seqFile;
+ ifstream filehandle;
+ SequenceDB sequencedb;
+ int readOk; // readOk = 0 means success, readOk = 1 means error(s).
+};
+
+#endif
+++ /dev/null
-/*
- * readseqscommand.cpp
- * Mothur
- *
- * Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readseqscommand.h"
-
-//**********************************************************************************************************************
-ReadSeqsCommand::ReadSeqsCommand(){
- try {
- globaldata = GlobalData::getInstance();
- filename = globaldata->inputFileName;
- if(globaldata->getFastaFile().compare("") != 0) {
- readFasta = new ReadFasta(filename);
- readFasta->read();
- globaldata->gSequenceDB = readFasta->getDB();
- }
- else if(globaldata->getNexusFile().compare("") != 0) {
- readNexus = new ReadNexus(filename);
- readNexus->read();
- globaldata->gSequenceDB = readNexus->getDB();
- }
- else if(globaldata->getClustalFile().compare("") != 0) {
- readClustal = new ReadClustal(filename);
- readClustal->read();
- globaldata->gSequenceDB = readClustal->getDB();
- }
- else if(globaldata->getPhylipFile().compare("") != 0) {
- readPhylip = new ReadPhylip(filename);
- readPhylip->read();
- globaldata->gSequenceDB = readPhylip->getDB();
- }
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ReadSeqsCommand class Function ReadSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the ReadSeqsCommand class function ReadSeqsCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-
-//**********************************************************************************************************************
-
-ReadSeqsCommand::~ReadSeqsCommand(){
- //delete readFasta->getDB();
-// delete readNexus->getDB();
-// delete readClustal->getDB();
-// delete readPhylip->getDB();
-}
-
-//**********************************************************************************************************************
-
-int ReadSeqsCommand::execute(){
- try {
- filebuf fb;
-
- //fb.open ("fasta.txt",ios::out);
- //readFasta->read();
-// SequenceDB* db = readFasta->getDB();
-
- //fb.open("nexus.txt",ios::out);
-// readNexus->read();
-// SequenceDB* db = readNexus->getDB();
-
- //fb.open("clustal.txt",ios::out);
-// readClustal->read();
-// SequenceDB* db = readClustal->getDB();
-
- //fb.open("phylip.txt",ios::out);
-// readPhylip->read();
-// SequenceDB* db = readPhylip->getDB();
-
-
-
- //for(int i = 0; i < db->size(); i++) {
-// cout << db->get(i).getLength() << "\n" << db->get(i).getName() << ": " << db->get(i).getAligned() << "\n\n";
-// }
-
- //ostream os(&fb);
-// db->print(os);
-// fb.close();
-
- return 0;
- }
- catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the ReadOtuCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the ReadOtuCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-}
-//**********************************************************************************************************************
+++ /dev/null
-#ifndef READSEQSCOMMAND_H
-#define READSEQSCOMMAND_H
-/*
- * readseqscommand.h
- * Mothur
- *
- * Created by Thomas Ryabin on 4/13/09.
- * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readfasta.h"
-#include "readnexus.h"
-#include "readclustal.h"
-#include "readseqsphylip.h"
-
-class GlobalData;
-
-class ReadSeqsCommand : public Command {
-public:
- ReadSeqsCommand();
- ~ReadSeqsCommand();
- int execute();
-
-private:
- GlobalData* globaldata;
- ReadFasta* readFasta;
- ReadNexus* readNexus;
- ReadClustal* readClustal;
- ReadPhylip* readPhylip;
- string filename;
-};
-
-#endif
}
/*******************************************************************************/
-ReadPhylip::ReadPhylip(string file) {
+ReadPhylip::ReadPhylip(string file) : ReadSeqs(file) {
try {
- openInputFile(file, filehandle);
- phylipFile = file;
- globaldata = GlobalData::getInstance();
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the ReadTree class Function ReadTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
}
}
if(!(last && count == 0))
- sequencedb.set(count, sequencedb.get(count).getAligned() + sequence);
+ sequencedb.set(count, sequencedb.get(count).getUnaligned() + sequence);
if(letterCount == numLetters && count == 0)
last = true;
}
*/
using namespace std;
+#include "readseqs.h"
#include "globaldata.hpp"
#include "sequencedb.h"
#include "mothur.h"
/**********************************************************************************/
-class ReadPhylip {
+class ReadPhylip : public ReadSeqs {
public:
ReadPhylip(string);
SequenceDB* getDB();
private:
- GlobalData* globaldata;
- string phylipFile;
- ifstream filehandle;
- SequenceDB sequencedb;
- int readOk; // readOk = 0 means success, readOk = 1 means error(s).
-
bool isSeq(string);
};
//********************************************************************************************************************
-void Sequence::printSequence(ofstream& out){
+void Sequence::printSequence(ostream& out){
string toPrint = unaligned;
if(aligned.length() > unaligned.length())
toPrint = aligned;
string getPairwise();
string getUnaligned();
int getLength();
- void printSequence(ofstream&);
+ void printSequence(ostream&);
private:
string name;
/***********************************************************************/
-void SequenceDB::print(ofstream& out) {
+void SequenceDB::print(ostream& out) {
for(int i = 0; i < data.size(); i++)
data[i].printSequence(out);
}
void changeSize(int); //resizes data
void clear(); //clears data - remeber to loop through and delete the sequences inside or you will have a memory leak
int size(); //returns datas size
- void print(ofstream&); //loops through data using sequence class print
+ void print(ostream&); //loops through data using sequence class print
private:
vector<Sequence> data;
string readtreeArray[] = {"tree","group"};
commandParameters["read.tree"] = addParameters(readtreeArray, sizeof(readtreeArray)/sizeof(string));
- string readseqsArray[] = {"fasta","phylip","clustal","nexus","line"};
- commandParameters["read.seqs"] = addParameters(readseqsArray, sizeof(readseqsArray)/sizeof(string));
-
string clusterArray[] = {"cutoff","precision","method"};
commandParameters["cluster"] = addParameters(clusterArray, sizeof(clusterArray)/sizeof(string));
string heatmapArray[] = {"groups","line","label","sorted","scale"};
commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
- string filterseqsArray[] = {"trump", "soft", "filter"};
+ string filterseqsArray[] = {"fasta","phylip","clustal","nexus", "trump", "soft", "filter"};
commandParameters["filter.seqs"] = addParameters(filterseqsArray, sizeof(filterseqsArray)/sizeof(string));
string vennArray[] = {"groups","line","label","calc"};
string concensusArray[] = {};
commandParameters["concensus"] = addParameters(concensusArray, sizeof(concensusArray)/sizeof(string));
- string distanceArray[] = {"calc", "ends", "cutoff", "processors"};
+ string distanceArray[] = {"fasta","phylip","clustal","nexus", "calc", "ends", "cutoff", "processors"};
commandParameters["distance"] = addParameters(distanceArray, sizeof(distanceArray)/sizeof(string));
string quitArray[] = {};