jpayne@69: // Copyright © 2015, Battelle National Biodefense Institute (BNBI); jpayne@69: // all rights reserved. Authored by: Brian Ondov, Todd Treangen, jpayne@69: // Sergey Koren, and Adam Phillippy jpayne@69: // jpayne@69: // See the LICENSE.txt file included with this software for license information. jpayne@69: jpayne@69: #ifndef INCLUDED_CommandDistance jpayne@69: #define INCLUDED_CommandDistance jpayne@69: jpayne@69: #include "Command.h" jpayne@69: #include "Sketch.h" jpayne@69: jpayne@69: namespace mash { jpayne@69: jpayne@69: class CommandDistance : public Command jpayne@69: { jpayne@69: public: jpayne@69: jpayne@69: struct CompareInput jpayne@69: { jpayne@69: CompareInput(const Sketch & sketchRefNew, const Sketch & sketchQueryNew, uint64_t indexRefNew, uint64_t indexQueryNew, uint64_t pairCountNew, const Sketch::Parameters & parametersNew, double maxDistanceNew, double maxPValueNew) jpayne@69: : jpayne@69: sketchRef(sketchRefNew), jpayne@69: sketchQuery(sketchQueryNew), jpayne@69: indexRef(indexRefNew), jpayne@69: indexQuery(indexQueryNew), jpayne@69: pairCount(pairCountNew), jpayne@69: parameters(parametersNew), jpayne@69: maxDistance(maxDistanceNew), jpayne@69: maxPValue(maxPValueNew) jpayne@69: {} jpayne@69: jpayne@69: const Sketch & sketchRef; jpayne@69: const Sketch & sketchQuery; jpayne@69: jpayne@69: uint64_t indexRef; jpayne@69: uint64_t indexQuery; jpayne@69: uint64_t pairCount; jpayne@69: jpayne@69: const Sketch::Parameters & parameters; jpayne@69: double maxDistance; jpayne@69: double maxPValue; jpayne@69: }; jpayne@69: jpayne@69: struct CompareOutput jpayne@69: { jpayne@69: CompareOutput(const Sketch & sketchRefNew, const Sketch & sketchQueryNew, uint64_t indexRefNew, uint64_t indexQueryNew, uint64_t pairCountNew) jpayne@69: : jpayne@69: sketchRef(sketchRefNew), jpayne@69: sketchQuery(sketchQueryNew), jpayne@69: indexRef(indexRefNew), jpayne@69: indexQuery(indexQueryNew), jpayne@69: pairCount(pairCountNew) jpayne@69: { jpayne@69: pairs = new PairOutput[pairCount]; jpayne@69: } jpayne@69: jpayne@69: ~CompareOutput() jpayne@69: { jpayne@69: delete [] pairs; jpayne@69: } jpayne@69: jpayne@69: struct PairOutput jpayne@69: { jpayne@69: uint64_t numer; jpayne@69: uint64_t denom; jpayne@69: double distance; jpayne@69: double pValue; jpayne@69: bool pass; jpayne@69: }; jpayne@69: jpayne@69: const Sketch & sketchRef; jpayne@69: const Sketch & sketchQuery; jpayne@69: jpayne@69: uint64_t indexRef; jpayne@69: uint64_t indexQuery; jpayne@69: uint64_t pairCount; jpayne@69: jpayne@69: PairOutput * pairs; jpayne@69: }; jpayne@69: jpayne@69: CommandDistance(); jpayne@69: jpayne@69: int run() const; // override jpayne@69: jpayne@69: private: jpayne@69: jpayne@69: void writeOutput(CompareOutput * output, bool table, bool comment) const; jpayne@69: }; jpayne@69: jpayne@69: CommandDistance::CompareOutput * compare(CommandDistance::CompareInput * input); jpayne@69: void compareSketches(CommandDistance::CompareOutput::PairOutput * output, const Sketch::Reference & refRef, const Sketch::Reference & refQry, uint64_t sketchSize, int kmerSize, double kmerSpace, double maxDistance, double maxPValue); jpayne@69: double pValue(uint64_t x, uint64_t lengthRef, uint64_t lengthQuery, double kmerSpace, uint64_t sketchSize); jpayne@69: jpayne@69: } // namespace mash jpayne@69: jpayne@69: #endif