Permalink
Browse files

Merge pull request #271 from mothur/TaxSpaces_265

Tax spaces 265
  • Loading branch information...
2 parents bfc09fe + 822ba85 commit a23ea7d307cbf3eaea4d05756701966750df9862 @mothur-westcott mothur-westcott committed on GitHub Sep 12, 2016
Showing with 1,170 additions and 439 deletions.
  1. +18 −7 Mothur.xcodeproj/project.pbxproj
  2. +0 −1 TestMothur/main.cpp
  3. +129 −0 TestMothur/testclassifier/testphylotree.cpp
  4. +32 −0 TestMothur/testclassifier/testphylotree.hpp
  5. +2 −2 TestMothur/testtrimoligos.hpp
  6. +0 −1 source/classifier/classify.cpp
  7. +6 −10 source/classifier/phylosummary.cpp
  8. +8 −5 source/classifier/phylotree.cpp
  9. +5 −0 source/classifier/phylotree.h
  10. +26 −15 source/classifier/taxonomyequalizer.cpp
  11. +3 −3 source/commands/classifyotucommand.cpp
  12. +2 −1 source/commands/classifyseqscommand.cpp
  13. +2 −4 source/commands/getgroupscommand.cpp
  14. +4 −6 source/commands/getlineagecommand.cpp
  15. +2 −4 source/commands/getseqscommand.cpp
  16. +2 −5 source/commands/listseqscommand.cpp
  17. +6 −2 source/commands/makebiomcommand.cpp
  18. +123 −19 source/commands/makecontigscommand.cpp
  19. +626 −166 source/commands/makecontigscommand.h
  20. +25 −10 source/commands/mergetaxsummarycommand.cpp
  21. +3 −4 source/commands/pcrseqscommand.cpp
  22. +1 −29 source/commands/phylotypecommand.cpp
  23. +0 −2 source/commands/phylotypecommand.h
  24. +2 −4 source/commands/removegroupscommand.cpp
  25. +4 −5 source/commands/removelineagecommand.cpp
  26. +3 −5 source/commands/removeseqscommand.cpp
  27. +3 −2 source/commands/screenseqscommand.cpp
  28. +4 −4 source/commands/sortseqscommand.cpp
  29. +2 −2 source/commands/subsamplecommand.cpp
  30. +56 −57 source/commands/summarytaxcommand.cpp
  31. +1 −0 source/commands/summarytaxcommand.h
  32. +43 −60 source/mothurout.cpp
  33. +1 −0 source/mothurout.h
  34. +20 −4 source/optionparser.cpp
  35. +6 −0 source/trimoligos.h
@@ -12,7 +12,6 @@
219C1DE41559BCCF004209F9 /* getcoremicrobiomecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219C1DE31559BCCD004209F9 /* getcoremicrobiomecommand.cpp */; };
480E8DB11CAB12ED00A0D137 /* testfastqread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 480E8DAF1CAB12ED00A0D137 /* testfastqread.cpp */; };
480E8DB21CAB1F5E00A0D137 /* vsearchfileparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 489B55701BCD7F0100FB7DC8 /* vsearchfileparser.cpp */; };
- 480E8DB31CAB1F7900A0D137 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2114A7671C654D7400D3D8D9 /* averagelinkage.cpp */; };
481623E21B56A2DB004C60B7 /* pcrseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 481623E11B56A2DB004C60B7 /* pcrseqscommand.cpp */; };
481FB51C1AC0A63E0076CFF3 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 481FB51B1AC0A63E0076CFF3 /* main.cpp */; };
481FB5261AC0ADA00076CFF3 /* sequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E9B7DB12D37EC400DA6239 /* sequence.cpp */; };
@@ -373,7 +372,6 @@
48705AC619BE32C50075E977 /* mergesfffilecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48705ABF19BE32C50075E977 /* mergesfffilecommand.cpp */; };
48705AC719BE32C50075E977 /* sharedrjsd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48705AC119BE32C50075E977 /* sharedrjsd.cpp */; };
487C5A871AB88B93002AF48A /* mimarksattributescommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 487C5A851AB88B93002AF48A /* mimarksattributescommand.cpp */; };
- 487D09EB1CB2CEF3007039BF /* vsearchfileparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 489B55701BCD7F0100FB7DC8 /* vsearchfileparser.cpp */; };
487D09EC1CB2CEFE007039BF /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2114A7671C654D7400D3D8D9 /* averagelinkage.cpp */; };
488841611CC515A000C5E972 /* (null) in Sources */ = {isa = PBXBuildFile; };
488841621CC515A000C5E972 /* (null) in Sources */ = {isa = PBXBuildFile; };
@@ -401,6 +399,7 @@
48DB37B41B3B27E000C372A4 /* makefilecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48DB37B11B3B27E000C372A4 /* makefilecommand.cpp */; };
48E981CF189C38FB0042BE9D /* (null) in Sources */ = {isa = PBXBuildFile; };
48EDB76C1D1320DD00F76E93 /* chimeravsearchcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48EDB76A1D1320DD00F76E93 /* chimeravsearchcommand.cpp */; };
+ 48F06CCD1D74BEC4004A45DD /* testphylotree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48F06CCB1D74BEC4004A45DD /* testphylotree.cpp */; };
48F98E4D1A9CFD670005E81B /* completelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 48F98E4C1A9CFD670005E81B /* completelinkage.cpp */; };
7E6BE10A12F710D8007ADDBE /* refchimeratest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */; };
835FE03D19F00640005AA754 /* classifysvmsharedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7B2181FE17AD777B00286E6A /* classifysvmsharedcommand.cpp */; };
@@ -853,6 +852,8 @@
48DB37B21B3B27E000C372A4 /* makefilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = makefilecommand.h; path = source/commands/makefilecommand.h; sourceTree = SOURCE_ROOT; };
48EDB76A1D1320DD00F76E93 /* chimeravsearchcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = chimeravsearchcommand.cpp; path = source/commands/chimeravsearchcommand.cpp; sourceTree = SOURCE_ROOT; };
48EDB76B1D1320DD00F76E93 /* chimeravsearchcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = chimeravsearchcommand.h; path = source/commands/chimeravsearchcommand.h; sourceTree = SOURCE_ROOT; };
+ 48F06CCB1D74BEC4004A45DD /* testphylotree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = testphylotree.cpp; path = testclassifier/testphylotree.cpp; sourceTree = "<group>"; };
+ 48F06CCC1D74BEC4004A45DD /* testphylotree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = testphylotree.hpp; path = testclassifier/testphylotree.hpp; sourceTree = "<group>"; };
48F98E4C1A9CFD670005E81B /* completelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = completelinkage.cpp; path = source/completelinkage.cpp; sourceTree = SOURCE_ROOT; };
7B2181FE17AD777B00286E6A /* classifysvmsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = classifysvmsharedcommand.cpp; path = source/commands/classifysvmsharedcommand.cpp; sourceTree = SOURCE_ROOT; };
7B2181FF17AD777B00286E6A /* classifysvmsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = classifysvmsharedcommand.h; path = source/commands/classifysvmsharedcommand.h; sourceTree = SOURCE_ROOT; };
@@ -1718,6 +1719,7 @@
children = (
481FB5201AC0A6B60076CFF3 /* catch.hpp */,
481FB51B1AC0A63E0076CFF3 /* main.cpp */,
+ 48F06CCA1D74BC6F004A45DD /* testclassifier */,
48D6E9691CA4262A008DF76B /* dataset.cpp */,
48D6E96A1CA4262A008DF76B /* dataset.h */,
4827A4DA1CB3ED2100345170 /* fastqdataset.cpp */,
@@ -1763,6 +1765,15 @@
name = testcontainers;
sourceTree = "<group>";
};
+ 48F06CCA1D74BC6F004A45DD /* testclassifier */ = {
+ isa = PBXGroup;
+ children = (
+ 48F06CCB1D74BEC4004A45DD /* testphylotree.cpp */,
+ 48F06CCC1D74BEC4004A45DD /* testphylotree.hpp */,
+ );
+ name = testclassifier;
+ sourceTree = "<group>";
+ };
7B17437A17AF6F02004C161B /* svm */ = {
isa = PBXGroup;
children = (
@@ -2537,7 +2548,7 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0620;
+ LastUpgradeCheck = 0730;
ORGANIZATIONNAME = "Schloss Lab";
TargetAttributes = {
481FB5181AC0A63E0076CFF3 = {
@@ -2796,6 +2807,7 @@
481FB5351AC1B5D90076CFF3 /* fasta.cpp in Sources */,
481FB6321AC1B7EA0076CFF3 /* groupmap.cpp in Sources */,
481FB5FF1AC1B7970076CFF3 /* removeseqscommand.cpp in Sources */,
+ 48F06CCD1D74BEC4004A45DD /* testphylotree.cpp in Sources */,
481FB6771AC1B88F0076CFF3 /* readcluster.cpp in Sources */,
481FB5831AC1B6FF0076CFF3 /* ccode.cpp in Sources */,
481FB5681AC1B6B20076CFF3 /* sharedochiai.cpp in Sources */,
@@ -2852,11 +2864,9 @@
481FB6731AC1B8820076CFF3 /* seqnoise.cpp in Sources */,
481FB5DC1AC1B75C0076CFF3 /* makelookupcommand.cpp in Sources */,
481FB53D1AC1B5F80076CFF3 /* bstick.cpp in Sources */,
- 480E8DB31CAB1F7900A0D137 /* averagelinkage.cpp in Sources */,
481FB6681AC1B8450076CFF3 /* rarecalc.cpp in Sources */,
481FB60B1AC1B7AC0076CFF3 /* sffmultiplecommand.cpp in Sources */,
481FB59F1AC1B71B0076CFF3 /* classifyrfsharedcommand.cpp in Sources */,
- 487D09EB1CB2CEF3007039BF /* vsearchfileparser.cpp in Sources */,
481FB5F51AC1B77E0076CFF3 /* primerdesigncommand.cpp in Sources */,
481FB5B41AC1B7300076CFF3 /* distancecommand.cpp in Sources */,
481FB5391AC1B5E90076CFF3 /* ace.cpp in Sources */,
@@ -3395,6 +3405,7 @@
buildSettings = {
CLANG_WARN_UNREACHABLE_CODE = YES;
DEPLOYMENT_LOCATION = NO;
+ ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = c11;
GCC_ENABLE_SSE3_EXTENSIONS = NO;
GCC_ENABLE_SSE41_EXTENSIONS = NO;
@@ -3521,7 +3532,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx10.9;
+ SDKROOT = macosx;
};
name = Debug;
};
@@ -3558,7 +3569,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
- SDKROOT = macosx10.9;
+ SDKROOT = macosx;
};
name = Release;
};
View
@@ -19,7 +19,6 @@ To compile TestMothur you need to uncomment
//MothurOut* MothurOut::_uniqueInstance; in mothurout.cpp
- //ReferenceDB* ReferenceDB::myInstance; in referencedb.cpp
*/
//***********************************************************//
@@ -0,0 +1,129 @@
+//
+// testphylotree.cpp
+// Mothur
+//
+// Created by Sarah Westcott on 8/29/16.
+// Copyright © 2016 Schloss Lab. All rights reserved.
+//
+
+#include "catch.hpp"
+#include "testphylotree.hpp"
+
+/**************************************************************************************************/
+TestPhyloTree::TestPhyloTree() { //setup
+ m = MothurOut::getInstance();
+
+ string tax1WithSpaces = "Bacteria(100);Bacteroidetes 7(100);Bacteroidia(100);Bacteroidales(100);S24-7(100);";
+ string tax2WithSpaces = "Bacteria(100);Bacteroidetes 7(100);Bacteroidia(98);Bacteroidales(98);Bacteroidaceae(98);Bacteroides(98);";
+ string tax3WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Lachnospiraceae(100);Blautia(92);";
+ string tax4WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Ruminococcaceae(100);Anaerotruncus(100);";
+ string tax5WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Lachnospiraceae(100);Incertae_Sedis(97);";
+
+ string tax1WithOutSpaces = "Bacteria(100);Bacteroidetes(100);Bacteroidia(100);Bacteroidales(100);S24-7(100);";
+ string tax2WithOutSpaces = "Bacteria(100);Bacteroidetes(100);Bacteroidia(98);Bacteroidales(98);Bacteroidaceae(98);Bacteroides(98);";
+ string tax3WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Lachnospiraceae(100);Blautia(92);";
+ string tax4WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Ruminococcaceae(100);Anaerotruncus(100);";
+ string tax5WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Lachnospiraceae(100);Incertae_Sedis(97);";
+
+ phylo.addSeqToTree("seq1", tax1WithSpaces);
+ phylo.addSeqToTree("seq2", tax2WithSpaces);
+ phylo.addSeqToTree("seq3", tax3WithSpaces);
+ phylo.addSeqToTree("seq4", tax4WithSpaces);
+ phylo.addSeqToTree("seq5", tax5WithSpaces);
+ phylo.addSeqToTree("seq6", tax1WithOutSpaces);
+ phylo.addSeqToTree("seq7", tax2WithOutSpaces);
+ phylo.addSeqToTree("seq8", tax3WithOutSpaces);
+ phylo.addSeqToTree("seq9", tax4WithOutSpaces);
+ phylo.addSeqToTree("seq10", tax5WithOutSpaces);
+}
+/**************************************************************************************************/
+TestPhyloTree::~TestPhyloTree() {}
+/**************************************************************************************************/
+
+TEST_CASE("Testing PhyloTree Class") {
+ TestPhyloTree testPTree;
+
+ string tax1WithSpaces = "Bacteria(100);Bacteroidetes 7(100);Bacteroidia(100);Bacteroidales(100);S24-7(100);";
+ string tax2WithSpaces = "Bacteria(100);Bacteroidetes 7(100);Bacteroidia(98);Bacteroidales(98);Bacteroidaceae(98);Bacteroides(98);";
+ string tax3WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Lachnospiraceae(100);Blautia(92);";
+ string tax4WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Ruminococcaceae(100);Anaerotruncus(100);";
+ string tax5WithSpaces = "Bacteria(100);Firmicutes(100);Clostridia B(100);Clostridiales(100);Lachnospiraceae(100);Incertae_Sedis(97);";
+
+ string tax1WithOutSpaces = "Bacteria(100);Bacteroidetes(100);Bacteroidia(100);Bacteroidales(100);S24-7(100);";
+ string tax2WithOutSpaces = "Bacteria(100);Bacteroidetes(100);Bacteroidia(98);Bacteroidales(98);Bacteroidaceae(98);Bacteroides(98);";
+ string tax3WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Lachnospiraceae(100);Blautia(92);";
+ string tax4WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Ruminococcaceae(100);Anaerotruncus(100);";
+ string tax5WithOutSpaces = "Bacteria(100);Firmicutes(100);Clostridia(100);Clostridiales(100);Lachnospiraceae(100);Incertae_Sedis(97);";
+
+ SECTION("Add Sequences to Tree") {
+ INFO("Using taxonomies with and without spaces") // Only appears on a FAIL
+
+ CAPTURE(testPTree.addSeqToTree("seq1", tax1WithSpaces));
+ CHECK(testPTree.addSeqToTree("seq1", tax1WithSpaces) == 5);
+
+ CAPTURE(testPTree.addSeqToTree("seq2", tax2WithSpaces));
+ CHECK(testPTree.addSeqToTree("seq2", tax2WithSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq3", tax3WithSpaces));
+ CHECK(testPTree.addSeqToTree("seq3", tax3WithSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq4", tax4WithSpaces));
+ CHECK(testPTree.addSeqToTree("seq4", tax4WithSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq5", tax5WithSpaces));
+ CHECK(testPTree.addSeqToTree("seq5", tax5WithSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq6", tax1WithOutSpaces));
+ CHECK(testPTree.addSeqToTree("seq6", tax1WithOutSpaces) == 5);
+
+ CAPTURE(testPTree.addSeqToTree("seq7", tax2WithOutSpaces));
+ CHECK(testPTree.addSeqToTree("seq7", tax2WithOutSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq8", tax3WithOutSpaces));
+ CHECK(testPTree.addSeqToTree("seq8", tax3WithOutSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq9", tax4WithOutSpaces));
+ CHECK(testPTree.addSeqToTree("seq9", tax4WithOutSpaces) == 6);
+
+ CAPTURE(testPTree.addSeqToTree("seq10", tax5WithOutSpaces));
+ CHECK(testPTree.addSeqToTree("seq10", tax5WithOutSpaces) == 6);
+ }
+
+ SECTION("Get Seqs") {
+ INFO("Using taxonomies with and without spaces") // Only appears on a FAIL
+
+ CAPTURE(testPTree.phylo.getSeqs("Bacteroidetes 7").size());
+ CHECK((testPTree.phylo.getSeqs("Bacteroidetes 7").size()) == 2);
+
+ vector<string> Bacteroidetes_7 = testPTree.phylo.getSeqs("Bacteroidetes 7");
+ CHECK(Bacteroidetes_7[0] == "seq1");
+ CHECK(Bacteroidetes_7[1] == "seq2");
+
+ CAPTURE(testPTree.phylo.getSeqs("Clostridia").size());
+ CHECK((testPTree.phylo.getSeqs("Clostridia").size()) == 3);
+
+ vector<string> Clostridia = testPTree.phylo.getSeqs("Clostridia");
+ CHECK(Clostridia[0] == "seq8");
+ CHECK(Clostridia[1] == "seq9");
+ CHECK(Clostridia[2] == "seq10");
+ }
+
+ SECTION("Get Genus Totals") {
+ INFO("Using taxonomies with and without spaces") // Only appears on a FAIL
+
+ CAPTURE(testPTree.phylo.getGenusTotals().size());
+ CHECK(testPTree.phylo.getGenusTotals().size() == 10);
+ }
+
+ SECTION("Get Full Taxonomy") {
+ INFO("Using taxonomies with and without spaces") // Only appears on a FAIL
+
+ CAPTURE(testPTree.phylo.getFullTaxonomy("seq1"));
+ CHECK(testPTree.phylo.getFullTaxonomy("seq1") == "Bacteria;Bacteroidetes 7;Bacteroidia;Bacteroidales;S24-7;");
+
+ CAPTURE(testPTree.phylo.getFullTaxonomy("seq10"));
+ CHECK(testPTree.phylo.getFullTaxonomy("seq1") == "Bacteria;Firmicutes;Clostridia;Clostridiales;Lachnospiraceae;Incertae_Sedis;");
+ }
+
+}
+/**************************************************************************************************/
@@ -0,0 +1,32 @@
+//
+// testphylotree.hpp
+// Mothur
+//
+// Created by Sarah Westcott on 8/29/16.
+// Copyright © 2016 Schloss Lab. All rights reserved.
+//
+
+#ifndef testphylotree_hpp
+#define testphylotree_hpp
+
+#include "phylotree.h"
+
+class TestPhyloTree : public PhyloTree {
+
+
+public:
+
+ TestPhyloTree();
+ ~TestPhyloTree();
+
+ MothurOut* m;
+
+ PhyloTree phylo;
+
+ //using PhyloTree::
+ //using PhyloTree::
+
+};
+
+
+#endif /* testphylotree_hpp */
@@ -29,8 +29,8 @@ class TestTrimOligos : public TrimOligos {
map<int, oligosPair> pairedPrimers;
map<int, oligosPair> pairedBarcodes;
- using TrimOligos::compareDNASeq(string, string);
- using TrimOligos::countDiffs(string, string);
+ //using TrimOligos::compareDNASeq(string, string);
+ //using TrimOligos::countDiffs(string, string);
};
@@ -101,7 +101,6 @@ void Classify::generateDatabaseAndNames(string tfile, string tempFile, string me
m->mothurOut("DONE."); m->mothurOutEndLine();
m->mothurOut("It took " + toString(time(NULL) - start) + " seconds generate search database. "); m->mothurOutEndLine();
-
readTaxonomy(taxFile);
//sanity check
@@ -292,10 +292,7 @@ int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
if (level > maxLevel) { maxLevel = level; }
- if ((seqTaxonomy == "") && (level < maxLevel)) { //if you think you are done and you are not.
- for (int k = level; k < maxLevel; k++) { seqTaxonomy += "unclassified;"; }
- }
- }
+ }
return 0;
}
catch(exception& e) {
@@ -368,9 +365,6 @@ int PhyloSummary::addSeqToTree(string seqTaxonomy, map<string, bool> containsGro
if (level > maxLevel) { maxLevel = level; }
- if ((seqTaxonomy == "") && (level < maxLevel)) { //if you think you are done and you are not.
- for (int k = level; k < maxLevel; k++) { seqTaxonomy += "unclassified;"; }
- }
}
return 0;
}
@@ -755,13 +749,15 @@ void PhyloSummary::readTreeStruct(ifstream& in){
//read the tree file
for (int i = 0; i < tree.size(); i++) {
- in >> tree[i].level >> tree[i].name >> num; //num contains the number of children tree[i] has
-
+ in >> tree[i].level >> num; m->gobble(in); //num contains the number of children tree[i] has
+ tree[i].name = m->getline(in); m->gobble(in);
+
//set children
string childName;
int childIndex;
for (int j = 0; j < num; j++) {
- in >> childName >> childIndex;
+ in >> childIndex; m->gobble(in);
+ childName = m->getline(in); m->gobble(in);
tree[i].children[childName] = childIndex;
}
@@ -46,7 +46,8 @@ PhyloTree::PhyloTree(ifstream& in, string filename){
in >> maxLevel; m->gobble(in);
for (int i = 0; i < tree.size(); i++) {
- in >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(in);
+ tree[i].name = m->getline(in); m->gobble(in);
+ in >> tree[i].level >> tree[i].parent; m->gobble(in);
}
//read genus nodes
@@ -232,7 +233,7 @@ int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){
//save maxLevel for binning the unclassified seqs
if (level > maxLevel) { maxLevel = level; }
- return 0;
+ return level;
}
catch(exception& e) {
m->errorOut(e, "PhyloTree", "addSeqToTree");
@@ -454,11 +455,12 @@ void PhyloTree::print(ofstream& out, vector<TaxNode>& copy){
for (int i = 0; i < copy.size(); i++) {
- out << copy[i].level << '\t'<< copy[i].name << '\t' << copy[i].children.size();
+ out << copy[i].level << '\t' << copy[i].children.size() << endl;
+ out << copy[i].name << endl;
map<string,int>::iterator it;
for(it=copy[i].children.begin();it!=copy[i].children.end();it++){
- out << '\t' << it->first << '\t' << it->second;
+ out << it->second << '\t' << it->first << endl;
}
out << endl;
}
@@ -485,7 +487,8 @@ void PhyloTree::printTreeNodes(string treefilename) {
outTree << maxLevel << endl;
for (int i = 0; i < tree.size(); i++) {
- outTree << tree[i].name << '\t' << tree[i].level << '\t' << tree[i].parent << endl;
+ outTree << tree[i].name << endl;
+ outTree << tree[i].level << '\t' << tree[i].parent << endl;
}
//print genus nodes
@@ -28,6 +28,11 @@ struct TaxNode {
/**************************************************************************************************/
class PhyloTree {
+
+#ifdef UNIT_TEST
+ friend class TestPhyloTree;
+#endif
+
public:
PhyloTree();
Oops, something went wrong.

0 comments on commit a23ea7d

Please sign in to comment.