Permalink
Please sign in to comment.
Showing
with
51,738 additions
and 1,310 deletions.
- +58 −10 Mothur.xcodeproj/project.pbxproj
- +1 −9 TestMothur/dataset.h
- +46,955 −0 TestMothur/distcdataset.cpp
- +32 −0 TestMothur/distcdataset.h
- +2,578 −0 TestMothur/distpdataset.cpp
- +30 −0 TestMothur/distpdataset.h
- +3 −2 TestMothur/testcontainers/testfastqread.cpp
- +101 −0 TestMothur/testcontainers/testoptimatrix.cpp
- +31 −0 TestMothur/testcontainers/testoptimatrix.h
- +142 −0 TestMothur/testopticluster.cpp
- +36 −0 TestMothur/testopticluster.h
- +3 −3 TestMothur/testvsearchfileparser.cpp
- +0 −1 TestMothur/testvsearchfileparser.h
- +2 −2 source/cluster.cpp
- +4 −6 source/cluster.hpp
- +199 −16 source/commands/clustercommand.cpp
- +10 −5 source/commands/clustercommand.h
- +227 −48 source/commands/clustersplitcommand.cpp
- +11 −6 source/commands/clustersplitcommand.h
- +0 −432 source/commands/getotuscommand.cpp
- +0 −55 source/commands/getotuscommand.h
- +4 −6 source/commands/mgclustercommand.cpp
- +0 −439 source/commands/removeotuscommand.cpp
- +0 −52 source/commands/removeotuscommand.h
- +24 −21 source/commands/sensspeccommand.cpp
- +1 −1 source/commands/sensspeccommand.h
- +3 −11 source/commands/sffinfocommand.cpp
- +4 −2 source/commands/sharedcommand.cpp
- +5 −1 source/commands/sracommand.cpp
- +1 −1 source/commands/sracommand.h
- +1 −1 source/datastructures/counttable.h
- +445 −0 source/datastructures/optimatrix.cpp
- +60 −0 source/datastructures/optimatrix.h
- +1 −1 source/datastructures/sequencecountparser.cpp
- +1 −1 source/linearalgebra.cpp
- +0 −171 source/makefile
- +4 −3 source/mothur.cpp
- +46 −1 source/mothurout.cpp
- +2 −0 source/mothurout.h
- +632 −0 source/opticluster.cpp
- +66 −0 source/opticluster.h
- +12 −1 source/read/splitmatrix.cpp
- +3 −1 source/read/splitmatrix.h
- +0 −1 source/singlelinkage.cpp
| @@ -0,0 +1,32 @@ | ||
| +// | ||
| +// distcdataset.h | ||
| +// Mothur | ||
| +// | ||
| +// Created by Sarah Westcott on 6/8/16. | ||
| +// Copyright (c) 2016 Schloss Lab. All rights reserved. | ||
| +// | ||
| + | ||
| +#ifndef __Mothur__distcdataset__ | ||
| +#define __Mothur__distcdataset__ | ||
| + | ||
| +#include "mothurout.h" | ||
| + | ||
| +class DistCDataSet { | ||
| + | ||
| +public: | ||
| + | ||
| + DistCDataSet(); | ||
| + ~DistCDataSet() {} | ||
| + string getColumnFile() { return writeColumnFile(); } | ||
| + vector<string> getFiles(int); | ||
| + string getCountFile() { return writeCountFile(); } | ||
| + | ||
| +private: | ||
| + MothurOut* m; | ||
| + string writeColumnFile(); | ||
| + string writeCountFile(); | ||
| + | ||
| +}; | ||
| + | ||
| + | ||
| +#endif /* defined(__Mothur__distcdataset__) */ |
| @@ -0,0 +1,30 @@ | ||
| +// | ||
| +// distdataset.h | ||
| +// Mothur | ||
| +// | ||
| +// Created by Sarah Westcott on 6/6/16. | ||
| +// Copyright (c) 2016 Schloss Lab. All rights reserved. | ||
| +// | ||
| + | ||
| +#ifndef __Mothur__distdataset__ | ||
| +#define __Mothur__distdataset__ | ||
| + | ||
| +#include "mothurout.h" | ||
| + | ||
| +class DistPDataSet { | ||
| + | ||
| +public: | ||
| + | ||
| + DistPDataSet(); | ||
| + ~DistPDataSet() {} | ||
| + | ||
| + string getPhylipFile() { return writePhylipFile(); } | ||
| + | ||
| +private: | ||
| + MothurOut* m; | ||
| + string writePhylipFile(); | ||
| + | ||
| +}; | ||
| + | ||
| + | ||
| +#endif /* defined(__Mothur__distdataset__) */ |
| @@ -0,0 +1,101 @@ | ||
| +// | ||
| +// testoptimatrix.cpp | ||
| +// Mothur | ||
| +// | ||
| +// Created by Sarah Westcott on 6/6/16. | ||
| +// Copyright (c) 2016 Schloss Lab. All rights reserved. | ||
| +// | ||
| + | ||
| +#include "catch.hpp" | ||
| +#include "testoptimatrix.h" | ||
| +#include "distancecommand.h" | ||
| +#include "dataset.h" | ||
| + | ||
| +/**************************************************************************************************/ | ||
| +TestOptiMatrix::TestOptiMatrix() { //setup | ||
| + m = MothurOut::getInstance(); | ||
| + TestDataSet data; | ||
| + filenames = data.getSubsetFNGFiles(100); //Fasta, name, group returned | ||
| + | ||
| + string inputString = "fasta=" + filenames[0]; | ||
| + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); | ||
| + m->mothurOut("Running command: dist.seqs(" + inputString + ")"); m->mothurOutEndLine(); | ||
| + m->mothurCalling = true; | ||
| + | ||
| + Command* distCommand = new DistanceCommand(inputString); | ||
| + distCommand->execute(); | ||
| + | ||
| + map<string, vector<string> > outputFilenames = distCommand->getOutputFiles(); | ||
| + | ||
| + delete distCommand; | ||
| + m->mothurCalling = false; | ||
| + | ||
| + columnFile = outputFilenames["column"][0]; | ||
| + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); | ||
| + | ||
| + inputString = "fasta=" + filenames[0] + ", output=lt"; | ||
| + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); | ||
| + m->mothurOut("Running command: dist.seqs(" + inputString + ")"); m->mothurOutEndLine(); | ||
| + m->mothurCalling = true; | ||
| + | ||
| + Command* dist2Command = new DistanceCommand(inputString); | ||
| + dist2Command->execute(); | ||
| + | ||
| + outputFilenames = dist2Command->getOutputFiles(); | ||
| + | ||
| + delete dist2Command; | ||
| + m->mothurCalling = false; | ||
| + | ||
| + phylipFile = outputFilenames["phylip"][0]; | ||
| + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); | ||
| +} | ||
| +/**************************************************************************************************/ | ||
| +TestOptiMatrix::~TestOptiMatrix() { | ||
| + for (int i = 0; i < filenames.size(); i++) { m->mothurRemove(filenames[i]); } //teardown | ||
| + m->mothurRemove(columnFile); | ||
| + m->mothurRemove(phylipFile); | ||
| +} | ||
| +/**************************************************************************************************/ | ||
| +TEST_CASE("Testing OptiMatrix Class") { | ||
| + TestOptiMatrix testOMatrix; | ||
| + OptiMatrix matrix(testOMatrix.columnFile, testOMatrix.filenames[1], "name", 0.03, false); | ||
| + OptiMatrix pmatrix(testOMatrix.phylipFile, "", "", 0.03, false); | ||
| + | ||
| + SECTION("Testing Column Read") { | ||
| + INFO("Using First 100 sequences of final.fasta and final.names") // Only appears on a FAIL | ||
| + | ||
| + CAPTURE(matrix.print(cout)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK(matrix.print(cout) == 112); //numdists in matrix | ||
| + } | ||
| + | ||
| + SECTION("Testing Phylip Read") { | ||
| + INFO("Using First 100 sequences of final.fasta and final.names") // Only appears on a FAIL | ||
| + | ||
| + CAPTURE(pmatrix.print(cout)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK(pmatrix.print(cout) == 112); //numdists in matrix | ||
| + } | ||
| + | ||
| + /* First few rows of matrix | ||
| + 12 23 44 | ||
| + 10 23 32 36 | ||
| + 16 25 33 48 | ||
| + 38 | ||
| + 22 45 52 | ||
| + */ | ||
| + | ||
| + SECTION("Testing isClose") { | ||
| + INFO("Sequences 0 and 1") // Only appears on a FAIL | ||
| + | ||
| + CAPTURE(matrix.isClose(0, 12)); | ||
| + CHECK(matrix.isClose(0, 12) == true); | ||
| + CAPTURE(matrix.isClose(0, 44)); | ||
| + CHECK(matrix.isClose(0, 44) == true); | ||
| + CAPTURE(matrix.isClose(1, 23)); | ||
| + CHECK(matrix.isClose(1, 23) == true); | ||
| + CAPTURE(matrix.isClose(1, 36)); | ||
| + CHECK(matrix.isClose(1, 36) == true); | ||
| + } | ||
| +} | ||
| +/**************************************************************************************************/ |
| @@ -0,0 +1,31 @@ | ||
| +// | ||
| +// testoptimatrix.h | ||
| +// Mothur | ||
| +// | ||
| +// Created by Sarah Westcott on 6/6/16. | ||
| +// Copyright (c) 2016 Schloss Lab. All rights reserved. | ||
| +// | ||
| + | ||
| +#ifndef __Mothur__testoptimatrix__ | ||
| +#define __Mothur__testoptimatrix__ | ||
| + | ||
| +#include "optimatrix.h" | ||
| + | ||
| +class TestOptiMatrix : public OptiMatrix { | ||
| + | ||
| +public: | ||
| + | ||
| + TestOptiMatrix(); | ||
| + ~TestOptiMatrix(); | ||
| + | ||
| + using OptiMatrix::getCloseSeqs; | ||
| + using OptiMatrix::findDistFormat; | ||
| + using OptiMatrix::readPhylip; | ||
| + using OptiMatrix::readColumn; | ||
| + | ||
| + string columnFile, phylipFile; | ||
| + vector<string> filenames; | ||
| + | ||
| +}; | ||
| + | ||
| +#endif /* defined(__Mothur__testoptimatrix__) */ |
| @@ -0,0 +1,142 @@ | ||
| +// | ||
| +// testopticluster.cpp | ||
| +// Mothur | ||
| +// | ||
| +// Created by Sarah Westcott on 6/15/16. | ||
| +// Copyright (c) 2016 Schloss Lab. All rights reserved. | ||
| +// | ||
| + | ||
| +#include "testopticluster.h" | ||
| +#include "catch.hpp" | ||
| +#include "optimatrix.h" | ||
| +#include "distancecommand.h" | ||
| +#include "dataset.h" | ||
| + | ||
| +/**************************************************************************************************/ | ||
| +TestOptiCluster::TestOptiCluster() { //setup | ||
| + m = MothurOut::getInstance(); | ||
| + TestDataSet data; | ||
| + filenames = data.getSubsetFNGFiles(100); //Fasta, name, group returned | ||
| + | ||
| + string inputString = "fasta=" + filenames[0]; | ||
| + m->mothurOut("/******************************************/"); m->mothurOutEndLine(); | ||
| + m->mothurOut("Running command: dist.seqs(" + inputString + ")"); m->mothurOutEndLine(); | ||
| + m->mothurCalling = true; | ||
| + | ||
| + Command* distCommand = new DistanceCommand(inputString); | ||
| + distCommand->execute(); | ||
| + | ||
| + map<string, vector<string> > outputFilenames = distCommand->getOutputFiles(); | ||
| + | ||
| + delete distCommand; | ||
| + m->mothurCalling = false; | ||
| + | ||
| + columnFile = outputFilenames["column"][0]; | ||
| +} | ||
| +/**************************************************************************************************/ | ||
| +TestOptiCluster::~TestOptiCluster() { | ||
| + for (int i = 0; i < filenames.size(); i++) { m->mothurRemove(filenames[i]); } //teardown | ||
| + m->mothurRemove(columnFile); | ||
| +} | ||
| +/**************************************************************************************************/ | ||
| +TEST_CASE("Testing OptiCluster Class") { | ||
| + TestOptiCluster testOcluster; | ||
| + OptiMatrix matrix(testOcluster.columnFile, testOcluster.filenames[1], "name", 0.03, false); | ||
| + testOcluster.setVariables(&matrix, "mcc"); | ||
| + | ||
| + SECTION("Testing Initialize") { | ||
| + INFO("Using First 100 sequences of final.fasta and final.names") // Only appears on a FAIL | ||
| + | ||
| + double initialMetricValue; | ||
| + | ||
| + CAPTURE(testOcluster.initialize(initialMetricValue, true)); // | ||
| + | ||
| + CHECK(testOcluster.initialize(initialMetricValue, true) == 0); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcMCC") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcMCC(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcMCC(tp,tn,fp,fn)*10000) == 9694); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcSens") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcSens(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcSens(tp,tn,fp,fn)*10000) == 9615); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcSpec") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcSpec(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcSpec(tp,tn,fp,fn)*10000) == 9990); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcTPTN") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcTPTN(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcTPTN(tp,tn,fp,fn)*10000) == 9861); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcTP2TN") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcTP2TN(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcTP2TN(tp,tn,fp,fn)*10000) == 16436); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing calcFPFN") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + | ||
| + CAPTURE(testOcluster.calcFPFN(tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.calcFPFN(tp,tn,fp,fn)*10000) == 9861); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing moveAdjustTFValues") { | ||
| + INFO("Using tp=5000, tn=10000, fp=10, fn=200 and mcc") // Only appears on a FAIL | ||
| + | ||
| + double tp,tn,fp,fn; tp=5000; tn=10000; fp=10; fn=200; | ||
| + double initialMetricValue; | ||
| + testOcluster.initialize(initialMetricValue, false); //no randomization | ||
| + | ||
| + CAPTURE(testOcluster.moveAdjustTFValues(0, 10, 1, tp,tn,fp,fn)); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(testOcluster.moveAdjustTFValues(0, 10, 1, tp,tn,fp,fn)*10000) == 9700); //metric value | ||
| + } | ||
| + | ||
| + SECTION("Testing update") { | ||
| + INFO("Using mcc") // Only appears on a FAIL | ||
| + | ||
| + double initialMetricValue; | ||
| + testOcluster.initialize(initialMetricValue, false); //no randomization | ||
| + testOcluster.update(initialMetricValue); | ||
| + | ||
| + CAPTURE(initialMetricValue); // Displays this variable on a FAIL | ||
| + | ||
| + CHECK((int)(initialMetricValue*10000) == 7853); //metric value | ||
| + } | ||
| + | ||
| +} | ||
| +/**************************************************************************************************/ |
Oops, something went wrong.
0 comments on commit
3d3d27f