X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=formatmatrix.h;fp=formatmatrix.h;h=7e7a99c1dbcf4bf495ad7b1a7c7caec49bef3e90;hb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;hp=0000000000000000000000000000000000000000;hpb=1b73ff67c83892a025e597dabd9df6fe7b58206a;p=mothur.git diff --git a/formatmatrix.h b/formatmatrix.h new file mode 100644 index 0000000..7e7a99c --- /dev/null +++ b/formatmatrix.h @@ -0,0 +1,81 @@ +#ifndef FORMATMATRIX_H +#define FORMATMATRIX_H + +/* + * formatmatrix.h + * Mothur + * + * Created by westcott on 1/13/10. + * Copyright 2010 Schloss Lab. All rights reserved. + * + */ + +#include "mothur.h" +#include "listvector.hpp" +#include "nameassignment.hpp" + + +//********************************************************************************************************************** +// This class takes a distance matrix file and converts it to a file where each row contains all distances below the cutoff +// for a given sequence. + +// Example: + /* 5 + A + B 0.01 + C 0.015 0.03 + D 0.03 0.02 0.02 + E 0.04 0.05 0.03 0.02 + + becomes + + 0 4 1 0.01 2 0.015 3 0.03 4 0.04 + 1 4 0 0.01 2 0.03 3 0.02 4 0.05 + 2 4 0 0.015 1 0.03 3 0.02 4 0.03 + 3 4 0 0.03 1 0.02 2 0.02 4 0.02 + 4 4 0 0.04 1 0.05 2 0.03 3 0.02 + + column 1 - sequence name converted to row number + column 2 - numDists under cutoff + rest of line - sequence row -> distance, sequence row -> distance + + if you had a cutoff of 0.03 then the file would look like, + + 0 3 1 0.01 2 0.015 3 0.03 + 1 3 0 0.01 2 0.03 3 0.02 + 2 4 0 0.015 1 0.03 3 0.02 4 0.03 + 3 4 0 0.03 1 0.02 2 0.02 4 0.02 + 4 2 2 0.03 3 0.02 + + This class also creates a vector of ints, rowPos. + + rowPos[0] = position in the file of distances related to sequence 0. + If a sequence is excluded by the cutoff, it's rowPos = -1. +*/ +//********************************************************************************************************************** + +class FormatMatrix { + +public: + FormatMatrix(){ m = MothurOut::getInstance(); } + virtual ~FormatMatrix() {} + + virtual int read(NameAssignment*){ return 1; } + + void setCutoff(float c) { cutoff = c; } + ListVector* getListVector() { return list; } + string getFormattedFileName() { return distFile; } + vector getRowPositions() { return rowPos; } + +protected: + ListVector* list; + float cutoff; + string distFile; + vector rowPos; + MothurOut* m; +}; + +//********************************************************************************************************************** + +#endif +