]> git.donarmstrong.com Git - mothur.git/commitdiff
broke apart read matrix file
authorwestcott <westcott>
Tue, 21 Apr 2009 18:29:12 +0000 (18:29 +0000)
committerwestcott <westcott>
Tue, 21 Apr 2009 18:29:12 +0000 (18:29 +0000)
40 files changed:
Mothur.xcodeproj/project.pbxproj
binsequencecommand.cpp
binsequencecommand.h
bootstrapsharedcommand.cpp
bootstrapsharedcommand.h
collectcommand.cpp
collectcommand.h
collectsharedcommand.cpp
collectsharedcommand.h
getoturepcommand.cpp
getoturepcommand.h
heatmapcommand.cpp
heatmapcommand.h
parselistcommand.cpp
parselistcommand.h
rarefactcommand.cpp
rarefactcommand.h
rarefactsharedcommand.cpp
rarefactsharedcommand.h
readcolumn.cpp [new file with mode: 0644]
readcolumn.h [new file with mode: 0644]
readdistcommand.cpp
readmatrix.cpp [deleted file]
readmatrix.hpp
readotu.cpp [new file with mode: 0644]
readotu.h [new file with mode: 0644]
readotucommand.cpp
readotucommand.h
readphylip.cpp [new file with mode: 0644]
readphylip.h [new file with mode: 0644]
sharedcommand.cpp
sharedcommand.h
summarycommand.cpp
summarycommand.h
summarysharedcommand.cpp
summarysharedcommand.h
treegroupscommand.cpp
treegroupscommand.h
venncommand.cpp
venncommand.h

index aaeab8d13b86103bf0b25ab11624342f2bd3433d..1c8df765aba58235fdb4c557be80834880aa1da0 100644 (file)
@@ -32,6 +32,9 @@
                375874060F7D64EF0040F377 /* sharedkulczynskicody.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375874020F7D64EF0040F377 /* sharedkulczynskicody.cpp */; };
                3758740C0F7D64FC0040F377 /* sharedmorisitahorn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375874080F7D64FC0040F377 /* sharedmorisitahorn.cpp */; };
                3758740D0F7D64FC0040F377 /* sharedochiai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3758740B0F7D64FC0040F377 /* sharedochiai.cpp */; };
+               375AA1390F9E433D008EF9B8 /* readcolumn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1330F9E433D008EF9B8 /* readcolumn.cpp */; };
+               375AA13A0F9E433D008EF9B8 /* readotu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1350F9E433D008EF9B8 /* readotu.cpp */; };
+               375AA13B0F9E433D008EF9B8 /* readphylip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1370F9E433D008EF9B8 /* readphylip.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 */; };
@@ -79,7 +82,6 @@
                37D9287A0F21331F001D4494 /* rarefact.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928050F21331F001D4494 /* rarefact.cpp */; };
                37D9287B0F21331F001D4494 /* rarefactcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928070F21331F001D4494 /* rarefactcommand.cpp */; };
                37D9287C0F21331F001D4494 /* rarefactsharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9280A0F21331F001D4494 /* rarefactsharedcommand.cpp */; };
-               37D928800F21331F001D4494 /* readmatrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928120F21331F001D4494 /* readmatrix.cpp */; };
                37D928840F21331F001D4494 /* sabundvector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9281A0F21331F001D4494 /* sabundvector.cpp */; };
                37D928850F21331F001D4494 /* sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9281C0F21331F001D4494 /* sequence.cpp */; };
                37D928860F21331F001D4494 /* shannon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D9281E0F21331F001D4494 /* shannon.cpp */; };
                375874090F7D64FC0040F377 /* sharedochiai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedochiai.h; sourceTree = "<group>"; };
                3758740A0F7D64FC0040F377 /* sharednseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharednseqs.h; sourceTree = "<group>"; };
                3758740B0F7D64FC0040F377 /* sharedochiai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedochiai.cpp; sourceTree = "<group>"; };
+               375AA1330F9E433D008EF9B8 /* readcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readcolumn.cpp; sourceTree = "<group>"; };
+               375AA1340F9E433D008EF9B8 /* readcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readcolumn.h; sourceTree = "<group>"; };
+               375AA1350F9E433D008EF9B8 /* readotu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readotu.cpp; sourceTree = "<group>"; };
+               375AA1360F9E433D008EF9B8 /* readotu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotu.h; sourceTree = "<group>"; };
+               375AA1370F9E433D008EF9B8 /* readphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readphylip.cpp; sourceTree = "<group>"; };
+               375AA1380F9E433D008EF9B8 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylip.h; sourceTree = "<group>"; };
                379293C10F2DE73400B9034A /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treemap.h; sourceTree = "<group>"; };
                379293C20F2DE73400B9034A /* treemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treemap.cpp; sourceTree = "<group>"; };
                3792946E0F2E191800B9034A /* parsimonycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsimonycommand.h; sourceTree = "<group>"; };
                37D928090F21331F001D4494 /* rarefactioncurvedata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefactioncurvedata.h; sourceTree = "<group>"; };
                37D9280A0F21331F001D4494 /* rarefactsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rarefactsharedcommand.cpp; sourceTree = "<group>"; };
                37D9280B0F21331F001D4494 /* rarefactsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefactsharedcommand.h; sourceTree = "<group>"; };
-               37D928120F21331F001D4494 /* readmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readmatrix.cpp; sourceTree = "<group>"; };
                37D928130F21331F001D4494 /* readmatrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = readmatrix.hpp; sourceTree = "<group>"; };
                37D9281A0F21331F001D4494 /* sabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sabundvector.cpp; sourceTree = "<group>"; };
                37D9281B0F21331F001D4494 /* sabundvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sabundvector.hpp; sourceTree = "<group>"; };
                                37D928060F21331F001D4494 /* rarefact.h */,
                                37D928050F21331F001D4494 /* rarefact.cpp */,
                                37D928090F21331F001D4494 /* rarefactioncurvedata.h */,
+                               375AA1340F9E433D008EF9B8 /* readcolumn.h */,
+                               375AA1330F9E433D008EF9B8 /* readcolumn.cpp */,
                                37D928130F21331F001D4494 /* readmatrix.hpp */,
-                               37D928120F21331F001D4494 /* readmatrix.cpp */,
+                               375AA1360F9E433D008EF9B8 /* readotu.h */,
+                               375AA1350F9E433D008EF9B8 /* readotu.cpp */,
+                               375AA1380F9E433D008EF9B8 /* readphylip.h */,
+                               375AA1370F9E433D008EF9B8 /* readphylip.cpp */,
                                37AD4DC80F28F3DD00AA2D49 /* readtree.h */,
                                37AD4DC90F28F3DD00AA2D49 /* readtree.cpp */,
                                37D9281D0F21331F001D4494 /* sequence.hpp */,
                                37D9287A0F21331F001D4494 /* rarefact.cpp in Sources */,
                                37D9287B0F21331F001D4494 /* rarefactcommand.cpp in Sources */,
                                37D9287C0F21331F001D4494 /* rarefactsharedcommand.cpp in Sources */,
-                               37D928800F21331F001D4494 /* readmatrix.cpp in Sources */,
                                37D928840F21331F001D4494 /* sabundvector.cpp in Sources */,
                                37D928850F21331F001D4494 /* sequence.cpp in Sources */,
                                37D928860F21331F001D4494 /* shannon.cpp in Sources */,
                                211C38320F961DD400FEE541 /* sharedutilities.cpp in Sources */,
                                211C38380F961E1F00FEE541 /* treegroupscommand.cpp in Sources */,
                                21DDC01B0F97A8FE0060691C /* bootstrapsharedcommand.cpp in Sources */,
+                               375AA1390F9E433D008EF9B8 /* readcolumn.cpp in Sources */,
+                               375AA13A0F9E433D008EF9B8 /* readotu.cpp in Sources */,
+                               375AA13B0F9E433D008EF9B8 /* readphylip.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7c70604e39f16c20821c620769ee89cd4a71958d..375eec2dd85db754f9bb0491447d2b966b1d5a37 100644 (file)
@@ -57,7 +57,7 @@ int BinSeqCommand::execute(){
                }
                
                //read list file
-               read = new ReadPhilFile(globaldata->getListFile());     
+               read = new ReadOTUFile(globaldata->getListFile());      
                read->read(&*globaldata); 
                
                input = globaldata->ginput;
index 25f52160e6c314e300e0abd6f303c378881cf2af..617f5ec7ac98f17f358c383ca424ebd817cb3227 100644 (file)
@@ -14,7 +14,7 @@
 #include "command.hpp"
 #include "inputdata.h"
 #include "listvector.hpp"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "fastamap.h"
 
 
@@ -30,7 +30,7 @@ public:
 private:
        GlobalData* globaldata;
        ListVector* list;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        InputData* input;
        FastaMap* fasta;
        string filename, fastafile, namesfile;
index b2a64ed1116a01d39c717794424585973ba02cab..56611a8f1e5af0eea6b64eef76e3ec1588b7298f 100644 (file)
@@ -93,14 +93,14 @@ int BootSharedCommand::execute(){
                if (treeCalculators.size() == 0) { return 0; }
 
                if (format == "sharedfile") {
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
index 194aa33d457fd088e7f367c245e1a8b493a1de49..322cd28571d83ea08d080fb6c4098fbff1c67364 100644 (file)
@@ -15,7 +15,7 @@
 #include "sharedlistvector.h"
 #include "inputdata.h"
 #include "groupmap.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 #include "tree.h"
 #include "treemap.h"
@@ -36,7 +36,7 @@ private:
        
        GlobalData* globaldata;
        SharedUtil* util;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        TreeMap* tmap;
        Tree* t;
        vector<Calculator*> treeCalculators;
index 5994af594ae182f63087cd9c08ca6f96ec4a1187..62258a85661b4983ee787262f655440992087f6e 100644 (file)
@@ -99,7 +99,7 @@ int CollectCommand::execute(){
                //if the users entered no valid calculators don't execute command
                if (cDisplays.size() == 0) { return 0; }
 
-               read = new ReadPhilFile(globaldata->inputFileName);     
+               read = new ReadOTUFile(globaldata->inputFileName);      
                read->read(&*globaldata); 
                
                order = globaldata->gorder;
index 93b56073dee7955dc60d410347da82b4bf6d2dc2..016f37e225f5b065d90278d5db5db2c0331d2464 100644 (file)
@@ -15,7 +15,7 @@
 #include "groupmap.h"
 #include "collect.h"
 #include "display.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 
 /*The collect() command:
@@ -43,7 +43,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        OrderVector* order;
        InputData* input;
        Collect* cCurve;
index 41dc573bee5d8ea1a1ff1a13d02e022b15176ddf..ad392e7535ece7e6617f63e5573c7e577cfe47da 100644 (file)
@@ -127,14 +127,14 @@ int CollectSharedCommand::execute(){
                if (cDisplays.size() == 0) { return 0; }
                
                if (format == "sharedfile") {
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
index 8c7aa009ca346670482679ac17b4c9f75d58fa82..aac31c1e32a0b270d03d7b64d69ae1825b5a6af0 100644 (file)
@@ -17,7 +17,7 @@
 #include "groupmap.h"
 #include "collect.h"
 #include "display.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 #include "sharedutilities.h"
 
@@ -48,7 +48,7 @@ private:
        SharedUtil* util;
        GroupMap* groupmap;
        SharedListVector* SharedList;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedOrderVector* order;
        InputData* input;
        ValidCalculators* validCalculator;
index 6daad979d741f56290ac7e40979de956a705e1ee..45f34fef5a444eb66e78788b9107152cd2b20a7d 100644 (file)
@@ -80,7 +80,7 @@ int GetOTURepCommand::execute(){
                }
                
                //read list file
-               read = new ReadPhilFile(globaldata->getListFile());     
+               read = new ReadOTUFile(globaldata->getListFile());      
                read->read(&*globaldata); 
                
                input = globaldata->ginput;
index 4e2b3a0e685aec843624613df7bda5c7e184b4c1..706b219917eb89c99652b8e024421869eac123c1 100644 (file)
@@ -16,7 +16,7 @@
 #include "sparsematrix.hpp"
 #include "listvector.hpp"
 #include "inputdata.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "fastamap.h"
 
 
@@ -36,7 +36,7 @@ private:
        SparseMatrix* matrix;
        ListVector* list;
        ListVector* listOfNames;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        InputData* input;
        FastaMap* fasta;
        string filename, fastafile, namesfile;
index bbda2b34f30265115b82d3522e858a6b3cd7d29d..b8b38207277789ae9181e688f5a648e96ffe337c 100644 (file)
@@ -46,14 +46,14 @@ int HeatMapCommand::execute(){
                
                if (format == "sharedfile") {
                        //you have groups
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else if (format == "shared") {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
@@ -61,7 +61,7 @@ int HeatMapCommand::execute(){
                        order = SharedList->getSharedOrderVector();
                }else if (format == "list") {
                        //you are using just a list file and have only one group
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        ordersingle = globaldata->gorder;
index f75c06425e7b6af1232809fb8a2f1f98c20d98aa..edb346021ec9effb6669029e7835be3d98e93e41 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "command.hpp"
 #include "inputdata.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "sharedlistvector.h"
 #include "heatmap.h"
 #include "sharedutilities.h"
@@ -31,7 +31,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedUtil* util;
        InputData* input;
        SharedListVector* SharedList;
index 1457c62f383308fdfac0e4d9748c9797ba5af01f..f1447980cd918a6f712447a928621cb689f35efe 100644 (file)
@@ -89,7 +89,7 @@ int ParseListCommand::execute(){
                        int count = 1;
                        
                        //read in listfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        input = globaldata->ginput;
                        list = globaldata->gSharedList;
index bf8ee5daf24a014728b7ed12698ca744d56d1cd6..0477acdb06e26ada0f64a25370138a75dc7a06ff 100644 (file)
@@ -14,7 +14,7 @@
 #include "sharedlistvector.h"
 #include "inputdata.h"
 #include "groupmap.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 
 
 /* The parselist() command:
@@ -37,7 +37,7 @@ private:
        GlobalData* globaldata;
        GroupMap* groupMap;
        InputData* input;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        map<string, ofstream*> filehandles;
        map<string, SharedListVector*> groupOfLists;
        SharedListVector* list;
index a83a750c5944aecfb3e740e5caca8bd231f11148..3c7975749e126645b91b7b0b53755e5f63e35789 100644 (file)
@@ -89,7 +89,7 @@ int RareFactCommand::execute(){
                //if the users entered no valid calculators don't execute command
                if (rDisplays.size() == 0) { return 0; }
 
-               read = new ReadPhilFile(globaldata->inputFileName);     
+               read = new ReadOTUFile(globaldata->inputFileName);      
                read->read(&*globaldata); 
 
                order = globaldata->gorder;
index 28be17cf995f18ede3f851579b619862d0c82551..5ac970ee8542b7d0793734d56d813afe506e1e09 100644 (file)
@@ -14,7 +14,7 @@
 #include "inputdata.h"
 #include "rarefact.h"
 #include "display.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 
 
@@ -44,7 +44,7 @@ public:
 private:
        GlobalData* globaldata;
        vector<Display*> rDisplays;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        OrderVector* order;
        InputData* input;
        ValidCalculators* validCalculator;
index dc71b22b3cab606d13f1e86a743aee1b5bf104a5..89cf4e2732af38c6fff844490effde5f8676e76c 100644 (file)
@@ -69,14 +69,14 @@ int RareFactSharedCommand::execute(){
                if (rDisplays.size() == 0) { return 0; }
 
                if (format == "sharedfile") {
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
index 2f7920e922cf8509487aa2ae7a3060075b0e90cd..a16fdb9d8f1ff7166c6b78ca1815368a3c45e287 100644 (file)
@@ -15,7 +15,7 @@
 #include "inputdata.h"
 #include "rarefact.h"
 #include "display.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 #include "sharedutilities.h"
 
@@ -44,7 +44,7 @@ private:
        GlobalData* globaldata;
        SharedUtil* util;
        SharedListVector* SharedList;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedOrderVector* order;
        InputData* input;
        ValidCalculators* validCalculator;
diff --git a/readcolumn.cpp b/readcolumn.cpp
new file mode 100644 (file)
index 0000000..1d29208
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *  readcolumn.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readcolumn.h"
+#include "progress.hpp"
+
+/***********************************************************************/
+
+ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){
+       
+       successOpen = openInputFile(distFile, fileHandle);
+       
+}
+
+/***********************************************************************/
+
+void ReadColumnMatrix::read(NameAssignment* nameMap){
+       try {           
+       
+                       string firstName, secondName;
+                       float distance;
+                       int nseqs = nameMap->size();
+
+                       list = new ListVector(nameMap->getListVector());
+               
+                       Progress* reading = new Progress("Reading matrix:     ", nseqs * nseqs);
+       
+                       int lt = 1;
+                       int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose
+                       int refCol = 0; //shows up later - Cell(refCol,refRow).  If it does, then its a square matrix
+       
+                       //need to see if this is a square or a triangular matrix...
+                       while(fileHandle && lt == 1){  //let's assume it's a triangular matrix...
+                       
+                               fileHandle >> firstName >> secondName >> distance;      // get the row and column names and distance
+               
+                               if(nameMap->count(firstName)==0){
+                                       cerr << "AError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
+                               }
+                               if(nameMap->count(secondName)==0){
+                                       cerr << "AError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
+                               }
+                               
+                               if (distance == -1) { distance = 1000000; }
+                               
+                               if(distance < cutoff && nameMap->get(firstName) != nameMap->get(secondName)){
+                                       if(nameMap->get(firstName) > nameMap->get(secondName)){
+                                               PCell value(nameMap->get(firstName), nameMap->get(secondName), distance);
+                               
+                                               if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
+                                                       refRow = nameMap->get(firstName);
+                                                       refCol = nameMap->get(secondName);
+                                                       D->addCell(value);
+                                               }
+                                               else if(refRow == nameMap->get(firstName) && refCol == nameMap->get(secondName)){
+                                                       lt = 0;
+                                               }
+                                               else{
+                                                       D->addCell(value);
+                                               }
+                                       }
+                                       else if(nameMap->get(firstName) < nameMap->get(secondName)){
+                                               PCell value(nameMap->get(secondName), nameMap->get(firstName), distance);
+                               
+                                               if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
+                                                       refRow = nameMap->get(firstName);
+                                                       refCol = nameMap->get(secondName);
+                                                       D->addCell(value);
+                                               }
+                                               else if(refRow == nameMap->get(secondName) && refCol == nameMap->get(firstName)){
+                                                       lt = 0;
+                                               }
+                                               else{
+                                                       D->addCell(value);
+                                               }
+                                       }
+                                       reading->update(nameMap->get(firstName) * nseqs);
+                               }
+                               gobble(fileHandle);
+                       }
+
+                       if(lt == 0){  // oops, it was square
+                               fileHandle.close();  //let's start over
+                               D->clear();  //let's start over
+                          
+                               openInputFile(distFile, fileHandle);  //let's start over
+
+                               while(fileHandle){
+                                       fileHandle >> firstName >> secondName >> distance;
+                       
+                                       if(nameMap->count(firstName)==0){
+                                               cerr << "BError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
+                                       }
+                                       if(nameMap->count(secondName)==0){
+                                               cerr << "BError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
+                                       }
+                                       
+                                       if (distance == -1) { distance = 1000000; }
+                                       
+                                       if(distance < cutoff && nameMap->get(firstName) > nameMap->get(secondName)){
+                                               PCell value(nameMap->get(firstName), nameMap->get(secondName), distance);
+                                               D->addCell(value);
+                                               reading->update(nameMap->get(firstName) * nseqs);
+                                       }
+                       
+                                       gobble(fileHandle);
+                               }
+                       }
+               //      else if(lt == 0){
+               //              while(fileHandle){
+               //                      fileHandle >> firstName >> secondName >> distance;
+               //                      
+               //                      if(nameMap->count(firstName)==0){
+               //                              cerr << "CError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
+               //                      }
+               //                      if(nameMap->count(secondName)==0){
+               //                              cerr << "CError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
+               //                      }
+               //                      if (distance == -1) { distance = 1000000; }
+               
+               //                      if(distance < cutoff && (*nameMap)[firstName].second < (*nameMap)[secondName].second){
+               ////                            cout << (*nameMap)[secondName] << ' ' << (*nameMap)[firstName] << ' ' << distance << endl;
+               //                              D->addCell(Cell((*nameMap)[secondName].second, (*nameMap)[firstName].second, distance));
+               //                              reading->update((*nameMap)[secondName].second * nseqs);
+               //                      }
+               //
+               //                      gobble(fileHandle);
+               //              }
+               //      }       
+                       reading->finish();
+                       fileHandle.close();
+       
+                       list->setLabel("0");
+       
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ReadColumnMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ReadColumnMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+
+}
+
+/***********************************************************************/
+
+ReadColumnMatrix::~ReadColumnMatrix(){
+       delete D;
+       delete list;
+}
+
+
diff --git a/readcolumn.h b/readcolumn.h
new file mode 100644 (file)
index 0000000..2e0120f
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef READCOLUMN_H
+#define READCOLUMN_H
+/*
+ *  readcolumn.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readmatrix.hpp"
+
+/******************************************************/
+
+class ReadColumnMatrix : public ReadMatrix {
+       
+public:
+       ReadColumnMatrix(string);
+       ~ReadColumnMatrix();
+       void read(NameAssignment*);
+private:
+       ifstream fileHandle;
+       string distFile;
+};
+
+/******************************************************/
+
+#endif
\ No newline at end of file
index d8c3db1c896b53c2f0d270a5c2d4df1ac9eed626..f19bf115d9e5f7d084b6007f1d738bcf0d33d494 100644 (file)
@@ -8,6 +8,8 @@
  */
 
 #include "readdistcommand.h"
+#include "readphylip.h"
+#include "readcolumn.h"
 
 ReadDistCommand::ReadDistCommand(){
        try {
diff --git a/readmatrix.cpp b/readmatrix.cpp
deleted file mode 100644 (file)
index 4cf39fa..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- *  readmatrix.cpp
- *  
- *
- *  Created by Pat Schloss on 8/13/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-using namespace std;
-
-#include "sparsematrix.hpp"
-#include "progress.hpp"
-#include "listvector.hpp"
-#include "rabundvector.hpp"
-#include "readmatrix.hpp"
-
-
-/***********************************************************************/
-
-ReadPhylipMatrix::ReadPhylipMatrix(string distFile){
-       
-       successOpen = openInputFile(distFile, fileHandle);
-       
-}
-
-/***********************************************************************/
-
-void ReadPhylipMatrix::read(NameAssignment* nameMap){
-       try {
-       
-                       float distance;
-                       int square, nseqs;
-                       string name;
-                       vector<string> matrixNames;
-       
-                       fileHandle >> nseqs >> name;
-
-                       matrixNames.push_back(name);
-
-                       if(nameMap == NULL){
-                               list = new ListVector(nseqs);
-                               list->set(0, name);
-                       }
-                       else{
-                               list = new ListVector(nameMap->getListVector());
-                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
-                       }
-       
-                       char d;
-                       while((d=fileHandle.get()) != EOF){
-               
-                               if(isalnum(d)){
-                                       square = 1;
-                                       fileHandle.putback(d);
-                                       for(int i=0;i<nseqs;i++){
-                                               fileHandle >> distance;
-                                       }
-                                       break;
-                               }
-                               if(d == '\n'){
-                                       square = 0;
-                                       break;
-                               }
-                       }
-       
-                       Progress* reading;
-       
-                       if(square == 0){
-
-                               reading = new Progress("Reading matrix:     ", nseqs * (nseqs - 1) / 2);
-               
-                               int     index = 0;
-               
-                               for(int i=1;i<nseqs;i++){
-                                       fileHandle >> name;
-                                       matrixNames.push_back(name);
-       
-                                       //there's A LOT of repeated code throughout this method...
-                                       if(nameMap == NULL){
-                                               list->set(i, name);
-                                       
-                                               for(int j=0;j<i;j++){
-                                                       fileHandle >> distance;
-                                               
-                                                       if(distance < cutoff){
-                                                               PCell value(i, j, distance);
-                                                               D->addCell(value);
-                                                       }
-                                                       index++;
-                                                       reading->update(index);
-                                               }
-                               
-                                       }
-                                       else{
-                                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
-                               
-                                               for(int j=0;j<i;j++){
-                                                       fileHandle >> distance;
-                                               
-                                                       if(distance < cutoff){
-                                                               PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
-                                                               D->addCell(value);
-                                                       }
-                                                       index++;
-                                                       reading->update(index);
-                                               }
-                                       }
-                               }
-                       }
-                       else{
-
-                               reading = new Progress("Reading matrix:     ", nseqs * nseqs);
-                       
-                               int index = nseqs;
-               
-                               for(int i=1;i<nseqs;i++){
-                                       fileHandle >> name;             
-                                       matrixNames.push_back(name);
-       
-                                       if(nameMap == NULL){
-                                               list->set(i, name);
-                                               for(int j=0;j<nseqs;j++){
-                                                       fileHandle >> distance;
-                                       
-                                                       if(distance < cutoff && j < i){
-                                                               PCell value(i, j, distance);
-                                                               D->addCell(value);
-                                                       }
-                                                       index++;
-                                                       reading->update(index);
-                                               }
-                                       
-                                       }
-                                       else{
-                                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
-                               
-                                               for(int j=0;j<nseqs;j++){
-                                                       fileHandle >> distance;
-                                       
-                                                       if(distance < cutoff && j < i){
-                                                               PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
-                                                               D->addCell(value);
-                                                       }
-                                                       index++;
-                                                       reading->update(index);
-                                               }
-                                       }
-                               }
-                       }
-                       reading->finish();
-                       delete reading;
-
-                       list->setLabel("0");
-                       fileHandle.close();
-
-                       if(nameMap != NULL){
-                               for(int i=0;i<matrixNames.size();i++){
-                                       nameMap->erase(matrixNames[i]);
-                               }
-                               if(nameMap->size() > 0){
-                                       //should probably tell them what is missing if we missed something
-                                       cout << "missed something" << '\t' << nameMap->size() << endl;
-                               }
-                       }
-
-               }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadPhylipMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadPhylipMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-ReadPhylipMatrix::~ReadPhylipMatrix(){
-       delete D;
-       delete list;
-}
-
-/***********************************************************************/
-
-ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){
-       
-       successOpen = openInputFile(distFile, fileHandle);
-       
-}
-
-/***********************************************************************/
-
-void ReadColumnMatrix::read(NameAssignment* nameMap){
-       try {           
-       
-                       string firstName, secondName;
-                       float distance;
-                       int nseqs = nameMap->size();
-
-                       list = new ListVector(nameMap->getListVector());
-               
-                       Progress* reading = new Progress("Reading matrix:     ", nseqs * nseqs);
-       
-                       int lt = 1;
-                       int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose
-                       int refCol = 0; //shows up later - Cell(refCol,refRow).  If it does, then its a square matrix
-       
-                       //need to see if this is a square or a triangular matrix...
-                       while(fileHandle && lt == 1){  //let's assume it's a triangular matrix...
-                       
-                               fileHandle >> firstName >> secondName >> distance;      // get the row and column names and distance
-               
-                               if(nameMap->count(firstName)==0){
-                                       cerr << "AError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
-                               }
-                               if(nameMap->count(secondName)==0){
-                                       cerr << "AError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
-                               }
-               
-                               if(distance < cutoff && nameMap->get(firstName) != nameMap->get(secondName)){
-                                       if(nameMap->get(firstName) > nameMap->get(secondName)){
-                                               PCell value(nameMap->get(firstName), nameMap->get(secondName), distance);
-                               
-                                               if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
-                                                       refRow = nameMap->get(firstName);
-                                                       refCol = nameMap->get(secondName);
-                                                       D->addCell(value);
-                                               }
-                                               else if(refRow == nameMap->get(firstName) && refCol == nameMap->get(secondName)){
-                                                       lt = 0;
-                                               }
-                                               else{
-                                                       D->addCell(value);
-                                               }
-                                       }
-                                       else if(nameMap->get(firstName) < nameMap->get(secondName)){
-                                               PCell value(nameMap->get(secondName), nameMap->get(firstName), distance);
-                               
-                                               if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
-                                                       refRow = nameMap->get(firstName);
-                                                       refCol = nameMap->get(secondName);
-                                                       D->addCell(value);
-                                               }
-                                               else if(refRow == nameMap->get(secondName) && refCol == nameMap->get(firstName)){
-                                                       lt = 0;
-                                               }
-                                               else{
-                                                       D->addCell(value);
-                                               }
-                                       }
-                                       reading->update(nameMap->get(firstName) * nseqs);
-                               }
-                               gobble(fileHandle);
-                       }
-
-                       if(lt == 0){  // oops, it was square
-                               fileHandle.close();  //let's start over
-                               D->clear();  //let's start over
-                          
-                               openInputFile(distFile, fileHandle);  //let's start over
-
-                               while(fileHandle){
-                                       fileHandle >> firstName >> secondName >> distance;
-                       
-                                       if(nameMap->count(firstName)==0){
-                                               cerr << "BError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
-                                       }
-                                       if(nameMap->count(secondName)==0){
-                                               cerr << "BError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
-                                       }
-                       
-                                       if(distance < cutoff && nameMap->get(firstName) > nameMap->get(secondName)){
-                                               PCell value(nameMap->get(firstName), nameMap->get(secondName), distance);
-                                               D->addCell(value);
-                                               reading->update(nameMap->get(firstName) * nseqs);
-                                       }
-                       
-                                       gobble(fileHandle);
-                               }
-                       }
-               //      else if(lt == 0){
-               //              while(fileHandle){
-               //                      fileHandle >> firstName >> secondName >> distance;
-               //                      
-               //                      if(nameMap->count(firstName)==0){
-               //                              cerr << "CError: Sequence '" << firstName << "' was not found in the names file, please correct\n";
-               //                      }
-               //                      if(nameMap->count(secondName)==0){
-               //                              cerr << "CError: Sequence '" << secondName << "' was not found in the names file, please correct\n";
-               //                      }
-               //                      
-               //                      if(distance < cutoff && (*nameMap)[firstName].second < (*nameMap)[secondName].second){
-               ////                            cout << (*nameMap)[secondName] << ' ' << (*nameMap)[firstName] << ' ' << distance << endl;
-               //                              D->addCell(Cell((*nameMap)[secondName].second, (*nameMap)[firstName].second, distance));
-               //                              reading->update((*nameMap)[secondName].second * nseqs);
-               //                      }
-               //
-               //                      gobble(fileHandle);
-               //              }
-               //      }       
-                       reading->finish();
-                       fileHandle.close();
-       
-                       list->setLabel("0");
-       
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadColumnMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadColumnMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-
-}
-
-/***********************************************************************/
-
-ReadColumnMatrix::~ReadColumnMatrix(){
-       delete D;
-       delete list;
-}
-
-
-/***********************************************************************/
-
-ReadPhilFile::ReadPhilFile(string pf): philFile(pf){
-       
-       successOpen = openInputFile(philFile, fileHandle);
-       
-}
-
-/***********************************************************************/
-//This function reads the list, rabund or sabund files to be used by collect and rarefact command.
-void ReadPhilFile::read(GlobalData* globaldata){
-       try {
-               if (globaldata->getOrderFile() == "") {
-                       //you have two inputs because in the next if statement if you only have one then it moves ahead in the same file.  
-                       //So when you run the collect or summary commands you miss a line.
-                       input = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
-                       inputList = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
-                       inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund or shared.
-               }else {//there is an orderfile
-                       input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
-               }
-               
-               //memory leak prevention
-               //if (globaldata->ginput != NULL) { delete globaldata->ginput;  }
-               globaldata->ginput = input;     //saving to be used by collector and rarefact commands.
-               
-               if ((globaldata->getFormat() == "list") || (globaldata->getFormat() == "rabund") || (globaldata->getFormat() == "sabund")) {//you are reading a list, rabund or sabund file for collect, rarefaction or summary.
-                       order = input->getOrderVector();
-                       //memory leak prevention
-                       //if (globaldata->gorder != NULL) { delete globaldata->gorder;  }
-                       globaldata->gorder = order;     //saving to be used by collect and rarefact commands.
-                       sabund = inputSabund->getSAbundVector(); 
-                       globaldata->sabund = sabund; //saving to be used by summary command.
-                       list = inputList->getListVector();
-                       globaldata->gListVector = list;
-               }else if (globaldata->getFormat() == "shared") {
-                       SharedList = input->getSharedListVector(); //you are reading for collect.shared, rarefaction.shared, summary.shared, parselist command, or shared commands.
-                       //memory leak prevention
-                       //if (globaldata->gSharedList != NULL) { delete globaldata->gSharedList;  }
-                       globaldata->gSharedList = SharedList;
-               }
-       }
-       catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the ReadPhilFile class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the ReadPhilFile class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-ReadPhilFile::~ReadPhilFile(){
-//     delete input;
-//     delete order;
-}
-
-/***********************************************************************/
-
index cfa7731b45dd5b37f2b39365fc0c22a19a9534d5..66480e7a6999ed90830f45a730c49ab4b850c73f 100644 (file)
  */
 
 #include "mothur.h"
-#include "rabundvector.hpp"
 #include "listvector.hpp"
-#include "sharedlistvector.h"
 #include "sparsematrix.hpp"
 #include "nameassignment.hpp"
-#include "inputdata.h"
 #include "globaldata.hpp"
-#include "sabundvector.hpp"
-#include "groupmap.h"
 
 class SparseMatrix;
 
@@ -40,58 +35,9 @@ protected:
        SparseMatrix* D;
        ListVector* list;
        GlobalData* globaldata;
-       OrderVector* order;
-       InputData* input;
        float cutoff;
 };
 
 
 
-class ReadPhylipMatrix : public ReadMatrix {
-       
-public:
-       ReadPhylipMatrix(string);
-       ~ReadPhylipMatrix();
-       void read(NameAssignment*);
-private:
-       ifstream fileHandle;
-       string distFile;
-};
-
-
-
-class ReadColumnMatrix : public ReadMatrix {
-       
-public:
-       ReadColumnMatrix(string);
-       ~ReadColumnMatrix();
-       void read(NameAssignment*);
-private:
-       ifstream fileHandle;
-       string distFile;
-};
-
-
-class ReadPhilFile : public ReadMatrix {
-       
-public:
-       ReadPhilFile(string);
-       ~ReadPhilFile();
-       void read(GlobalData* globaldata);
-private:
-       ifstream fileHandle;
-       string philFile;
-       InputData* input;
-       InputData* inputSabund;
-       InputData* inputList;
-       ListVector* list;
-       SharedListVector* SharedList;
-       OrderVector* order;
-       SAbundVector* sabund;
-       GlobalData* globaldata;
-       // InputData* getInput()                        {       return input;   }
-};
-
-
-
 #endif
diff --git a/readotu.cpp b/readotu.cpp
new file mode 100644 (file)
index 0000000..0bcfd32
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ *  readotu.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readotu.h"
+
+/***********************************************************************/
+
+ReadOTUFile::ReadOTUFile(string pf): philFile(pf){
+       
+       openInputFile(philFile, fileHandle);
+}
+
+/***********************************************************************/
+//This function reads the list, rabund or sabund files to be used by collect and rarefact command.
+void ReadOTUFile::read(GlobalData* globaldata){
+       try {
+               if (globaldata->getOrderFile() == "") {
+                       //you have two inputs because in the next if statement if you only have one then it moves ahead in the same file.  
+                       //So when you run the collect or summary commands you miss a line.
+                       input = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
+                       inputList = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund.
+                       inputSabund = new InputData(philFile, globaldata->getFormat()); //format tells you whether philFile is list, rabund, sabund or shared.
+               }else {//there is an orderfile
+                       input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
+               }
+               
+               //memory leak prevention
+               //if (globaldata->ginput != NULL) { delete globaldata->ginput;  }
+               globaldata->ginput = input;     //saving to be used by collector and rarefact commands.
+               
+               if ((globaldata->getFormat() == "list") || (globaldata->getFormat() == "rabund") || (globaldata->getFormat() == "sabund")) {//you are reading a list, rabund or sabund file for collect, rarefaction or summary.
+                       order = input->getOrderVector();
+                       //memory leak prevention
+                       //if (globaldata->gorder != NULL) { delete globaldata->gorder;  }
+                       globaldata->gorder = order;     //saving to be used by collect and rarefact commands.
+                       sabund = inputSabund->getSAbundVector(); 
+                       globaldata->sabund = sabund; //saving to be used by summary command.
+                       list = inputList->getListVector();
+                       globaldata->gListVector = list;
+               }else if (globaldata->getFormat() == "shared") {
+                       SharedList = input->getSharedListVector(); //you are reading for collect.shared, rarefaction.shared, summary.shared, parselist command, or shared commands.
+                       //memory leak prevention
+                       //if (globaldata->gSharedList != NULL) { delete globaldata->gSharedList;  }
+                       globaldata->gSharedList = SharedList;
+               }
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ReadOTUFile class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ReadOTUFile class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+/***********************************************************************/
+
+ReadOTUFile::~ReadOTUFile(){
+//     delete input;
+//     delete order;
+}
+
+/***********************************************************************/
+
diff --git a/readotu.h b/readotu.h
new file mode 100644 (file)
index 0000000..e954cbd
--- /dev/null
+++ b/readotu.h
@@ -0,0 +1,44 @@
+#ifndef READOTU_H
+#define READOTU_H
+/*
+ *  readotu.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+
+#include "rabundvector.hpp"
+#include "listvector.hpp"
+#include "sharedlistvector.h"
+#include "inputdata.h"
+#include "globaldata.hpp"
+#include "sabundvector.hpp"
+#include "groupmap.h"
+
+
+class ReadOTUFile {
+       
+public:
+       ReadOTUFile(string);
+       ~ReadOTUFile();
+       void read(GlobalData* globaldata);
+private:
+       ifstream fileHandle;
+       string philFile;
+       InputData* input;
+       InputData* inputSabund;
+       InputData* inputList;
+       ListVector* list;
+       SharedListVector* SharedList;
+       OrderVector* order;
+       SAbundVector* sabund;
+       GlobalData* globaldata;
+       // InputData* getInput()                        {       return input;   }
+};
+
+
+#endif
\ No newline at end of file
index 7a48f2c5b3b0146c4397325ca531c0bad9005146..9f27057ece85672069c9ebf219c08b459b648efc 100644 (file)
@@ -14,7 +14,7 @@ ReadOtuCommand::ReadOtuCommand(){
        try {
                globaldata = GlobalData::getInstance();
                filename = globaldata->inputFileName;
-               read = new ReadPhilFile(filename);
+               read = new ReadOTUFile(filename);
                if (globaldata->getFormat() == "shared") {
                        //read in group map info.
                        groupMap = new GroupMap(globaldata->getGroupFile());
index 7bd1ead9dfa9e6cd62d051aa337697350703d9c3..a21167e3d07e2064c6e9a1dae736b0b1aeccf3a8 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include "command.hpp"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "inputdata.h"
 #include "groupmap.h"
 #include "sharedcommand.h"
@@ -39,7 +39,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        InputData* input;
        Command* shared;
        Command* parselist;
diff --git a/readphylip.cpp b/readphylip.cpp
new file mode 100644 (file)
index 0000000..174b7e3
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ *  readphylip.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readphylip.h"
+#include "progress.hpp"
+
+/***********************************************************************/
+
+ReadPhylipMatrix::ReadPhylipMatrix(string distFile){
+       
+       successOpen = openInputFile(distFile, fileHandle);
+       
+}
+
+/***********************************************************************/
+
+void ReadPhylipMatrix::read(NameAssignment* nameMap){
+       try {
+       
+                       float distance;
+                       int square, nseqs;
+                       string name;
+                       vector<string> matrixNames;
+       
+                       fileHandle >> nseqs >> name;
+
+                       matrixNames.push_back(name);
+
+                       if(nameMap == NULL){
+                               list = new ListVector(nseqs);
+                               list->set(0, name);
+                       }
+                       else{
+                               list = new ListVector(nameMap->getListVector());
+                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                       }
+       
+                       char d;
+                       while((d=fileHandle.get()) != EOF){
+               
+                               if(isalnum(d)){
+                                       square = 1;
+                                       fileHandle.putback(d);
+                                       for(int i=0;i<nseqs;i++){
+                                               fileHandle >> distance;
+                                       }
+                                       break;
+                               }
+                               if(d == '\n'){
+                                       square = 0;
+                                       break;
+                               }
+                       }
+       
+                       Progress* reading;
+       
+                       if(square == 0){
+
+                               reading = new Progress("Reading matrix:     ", nseqs * (nseqs - 1) / 2);
+               
+                               int     index = 0;
+               
+                               for(int i=1;i<nseqs;i++){
+                                       fileHandle >> name;
+                                       matrixNames.push_back(name);
+       
+                                       //there's A LOT of repeated code throughout this method...
+                                       if(nameMap == NULL){
+                                               list->set(i, name);
+                                       
+                                               for(int j=0;j<i;j++){
+                                                       fileHandle >> distance;
+                                               
+                                                       if (distance == -1) { distance = 1000000; }
+                                               
+                                                       if(distance < cutoff){
+                                                               PCell value(i, j, distance);
+                                                               D->addCell(value);
+                                                       }
+                                                       index++;
+                                                       reading->update(index);
+                                               }
+                               
+                                       }
+                                       else{
+                                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                               
+                                               for(int j=0;j<i;j++){
+                                                       fileHandle >> distance;
+                               
+                                                       if (distance == -1) { distance = 1000000; }
+                                                       
+                                                       if(distance < cutoff){
+                                                               PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
+                                                               D->addCell(value);
+                                                       }
+                                                       index++;
+                                                       reading->update(index);
+                                               }
+                                       }
+                               }
+                       }
+                       else{
+
+                               reading = new Progress("Reading matrix:     ", nseqs * nseqs);
+                       
+                               int index = nseqs;
+               
+                               for(int i=1;i<nseqs;i++){
+                                       fileHandle >> name;             
+                                       matrixNames.push_back(name);
+       
+                                       if(nameMap == NULL){
+                                               list->set(i, name);
+                                               for(int j=0;j<nseqs;j++){
+                                                       fileHandle >> distance;
+                                       
+                                                       if (distance == -1) { distance = 1000000; }
+                                                       
+                                                       if(distance < cutoff && j < i){
+                                                               PCell value(i, j, distance);
+                                                               D->addCell(value);
+                                                       }
+                                                       index++;
+                                                       reading->update(index);
+                                               }
+                                       
+                                       }
+                                       else{
+                                               if(nameMap->count(name)==0){    cout << "Error: Sequence '" << name << "' was not found in the names file, please correct" << endl; }
+                               
+                                               for(int j=0;j<nseqs;j++){
+                                                       fileHandle >> distance;
+                       
+                                                       if (distance == -1) { distance = 1000000; }
+                                                       
+                                                       if(distance < cutoff && j < i){
+                                                               PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
+                                                               D->addCell(value);
+                                                       }
+                                                       index++;
+                                                       reading->update(index);
+                                               }
+                                       }
+                               }
+                       }
+                       reading->finish();
+                       delete reading;
+
+                       list->setLabel("0");
+                       fileHandle.close();
+
+                       if(nameMap != NULL){
+                               for(int i=0;i<matrixNames.size();i++){
+                                       nameMap->erase(matrixNames[i]);
+                               }
+                               if(nameMap->size() > 0){
+                                       //should probably tell them what is missing if we missed something
+                                       cout << "missed something" << '\t' << nameMap->size() << endl;
+                               }
+                       }
+
+               }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ReadPhylipMatrix class Function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ReadPhylipMatrix class function read. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+
+/***********************************************************************/
+
+ReadPhylipMatrix::~ReadPhylipMatrix(){
+       delete D;
+       delete list;
+}
+
diff --git a/readphylip.h b/readphylip.h
new file mode 100644 (file)
index 0000000..eab0df4
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef READPHYLIP_H
+#define READPHYLIP_H
+/*
+ *  readphylip.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 4/21/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "readmatrix.hpp"
+
+/******************************************************/
+
+class ReadPhylipMatrix : public ReadMatrix {
+       
+public:
+       ReadPhylipMatrix(string);
+       ~ReadPhylipMatrix();
+       void read(NameAssignment*);
+private:
+       ifstream fileHandle;
+       string distFile;
+};
+
+/******************************************************/
+
+#endif
\ No newline at end of file
index a797d5408d151beddc73be085111bbcf41cd84cd..c29d5499808e13bd9246098f50706337b3f9e592 100644 (file)
@@ -38,7 +38,7 @@ int SharedCommand::execute(){
                globaldata = GlobalData::getInstance();
                        
                //read in listfile
-               read = new ReadPhilFile(globaldata->inputFileName);     
+               read = new ReadOTUFile(globaldata->inputFileName);      
                read->read(&*globaldata); 
                input = globaldata->ginput;
                SharedList = globaldata->gSharedList;
index 20e2ddb3981df57f471970da64e3631814a6c170..b3506cdbfd79650cad44de48388f93363fb3b21a 100644 (file)
@@ -13,7 +13,7 @@
 #include "sharedlistvector.h"
 #include "inputdata.h"
 #include "shared.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 
 /* The shared() command:
        The shared command can only be executed after a successful read.shared command.  
@@ -34,7 +34,7 @@ public:
 private:
        void printSharedData();
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedListVector* SharedList;
        InputData* input;
        Shared* shared;
index 05fc6e8c77057c00bd64e9c057f8784ea71a7188..8632ad4a42c9c9dba91bcccf6528e7ced436f70b 100644 (file)
@@ -101,7 +101,7 @@ int SummaryCommand::execute(){
                openOutputFile(outputFileName, outputFileHandle);
                outputFileHandle << "label";
        
-               read = new ReadPhilFile(globaldata->inputFileName);     
+               read = new ReadOTUFile(globaldata->inputFileName);      
                read->read(&*globaldata); 
 
                for(int i=0;i<sumCalculators.size();i++){
index 4b7e1616e18a99785505a6cbe1c196ce76e2cc99..8f42f459bf2de9a6c12679a42ea8bbf35c7835a1 100644 (file)
@@ -13,7 +13,7 @@
 #include "sabundvector.hpp"
 #include "inputdata.h"
 #include "calculator.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 
 /* The summary() command:
@@ -39,7 +39,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        vector<Calculator*> sumCalculators;     
        InputData* input;
        ValidCalculators* validCalculator;
index 05a5f7efa56c34e2ef452dd682aeacbbb4217ee3..eea7b25c4ade2bd6a98f5cea0eaabd9b1787ede8 100644 (file)
@@ -123,14 +123,14 @@ int SummarySharedCommand::execute(){
                if (sumCalculators.size() == 0) { return 0; }
 
                if (format == "sharedfile") {
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
index 9e4a8c87963289644f17a10ce07c3a55f7cfbb7b..e87e75e6412a36239f3c1b1e19066609aaef4527 100644 (file)
@@ -14,7 +14,7 @@
 #include "sharedrabundvector.h"
 #include "inputdata.h"
 #include "calculator.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "sharedlistvector.h"
 #include "validcalculator.h"
 #include "sharedutilities.h"
@@ -45,7 +45,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedUtil* util;
        vector<Calculator*> sumCalculators;     
        InputData* input;
index 6cc64feed9cb3b031b87ed9ea92bad616a362621..6393684f2e79380788553e978504d0f0d306253f 100644 (file)
@@ -85,14 +85,14 @@ int TreeGroupCommand::execute(){
                if (treeCalculators.size() == 0) { return 0; }
 
                if (format == "sharedfile") {
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
index 4c3b8424efa456ff20d52f8f217f2f3015d793b6..3c40eff6ab95c0dcb12e931e5f785f30654243db 100644 (file)
@@ -15,7 +15,7 @@
 #include "sharedlistvector.h"
 #include "inputdata.h"
 #include "groupmap.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "validcalculator.h"
 #include "tree.h"
 #include "treemap.h"
@@ -41,7 +41,7 @@ private:
        
        GlobalData* globaldata;
        SharedUtil* util;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        TreeMap* tmap;
        Tree* t;
        vector<Calculator*> treeCalculators;
index e305f2203b52a11d0ac809be3f35dfaf578ab1b3..5357c2560a7c75fe82f3238d482a443744b6a6f5 100644 (file)
@@ -95,14 +95,14 @@ int VennCommand::execute(){
                
                if (format == "sharedfile") {
                        //you have groups
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                        
                        input = globaldata->ginput;
                        order = input->getSharedOrderVector();
                }else if (format == "shared") {
                        //you are using a list and a groupfile
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        input = globaldata->ginput;
@@ -110,7 +110,7 @@ int VennCommand::execute(){
                        order = SharedList->getSharedOrderVector();
                }else if (format == "list") {
                        //you are using just a list file and have only one group
-                       read = new ReadPhilFile(globaldata->inputFileName);     
+                       read = new ReadOTUFile(globaldata->inputFileName);      
                        read->read(&*globaldata); 
                
                        ordersingle = globaldata->gorder;
index 30ff74eb0433240b784ef221e2e0bdc22d1f4066..063b8afdfbf4f733c6e537b6c245dc6f17aca516 100644 (file)
@@ -11,7 +11,7 @@
  
 #include "command.hpp"
 #include "inputdata.h"
-#include "readmatrix.hpp"
+#include "readotu.h"
 #include "sharedlistvector.h"
 #include "venn.h"
 #include "validcalculator.h"
@@ -30,7 +30,7 @@ public:
        
 private:
        GlobalData* globaldata;
-       ReadMatrix* read;
+       ReadOTUFile* read;
        SharedUtil* util;
        InputData* input;
        SharedListVector* SharedList;