annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/mash/CommandDistance.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // Copyright © 2015, Battelle National Biodefense Institute (BNBI);
jpayne@69 2 // all rights reserved. Authored by: Brian Ondov, Todd Treangen,
jpayne@69 3 // Sergey Koren, and Adam Phillippy
jpayne@69 4 //
jpayne@69 5 // See the LICENSE.txt file included with this software for license information.
jpayne@69 6
jpayne@69 7 #ifndef INCLUDED_CommandDistance
jpayne@69 8 #define INCLUDED_CommandDistance
jpayne@69 9
jpayne@69 10 #include "Command.h"
jpayne@69 11 #include "Sketch.h"
jpayne@69 12
jpayne@69 13 namespace mash {
jpayne@69 14
jpayne@69 15 class CommandDistance : public Command
jpayne@69 16 {
jpayne@69 17 public:
jpayne@69 18
jpayne@69 19 struct CompareInput
jpayne@69 20 {
jpayne@69 21 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 22 :
jpayne@69 23 sketchRef(sketchRefNew),
jpayne@69 24 sketchQuery(sketchQueryNew),
jpayne@69 25 indexRef(indexRefNew),
jpayne@69 26 indexQuery(indexQueryNew),
jpayne@69 27 pairCount(pairCountNew),
jpayne@69 28 parameters(parametersNew),
jpayne@69 29 maxDistance(maxDistanceNew),
jpayne@69 30 maxPValue(maxPValueNew)
jpayne@69 31 {}
jpayne@69 32
jpayne@69 33 const Sketch & sketchRef;
jpayne@69 34 const Sketch & sketchQuery;
jpayne@69 35
jpayne@69 36 uint64_t indexRef;
jpayne@69 37 uint64_t indexQuery;
jpayne@69 38 uint64_t pairCount;
jpayne@69 39
jpayne@69 40 const Sketch::Parameters & parameters;
jpayne@69 41 double maxDistance;
jpayne@69 42 double maxPValue;
jpayne@69 43 };
jpayne@69 44
jpayne@69 45 struct CompareOutput
jpayne@69 46 {
jpayne@69 47 CompareOutput(const Sketch & sketchRefNew, const Sketch & sketchQueryNew, uint64_t indexRefNew, uint64_t indexQueryNew, uint64_t pairCountNew)
jpayne@69 48 :
jpayne@69 49 sketchRef(sketchRefNew),
jpayne@69 50 sketchQuery(sketchQueryNew),
jpayne@69 51 indexRef(indexRefNew),
jpayne@69 52 indexQuery(indexQueryNew),
jpayne@69 53 pairCount(pairCountNew)
jpayne@69 54 {
jpayne@69 55 pairs = new PairOutput[pairCount];
jpayne@69 56 }
jpayne@69 57
jpayne@69 58 ~CompareOutput()
jpayne@69 59 {
jpayne@69 60 delete [] pairs;
jpayne@69 61 }
jpayne@69 62
jpayne@69 63 struct PairOutput
jpayne@69 64 {
jpayne@69 65 uint64_t numer;
jpayne@69 66 uint64_t denom;
jpayne@69 67 double distance;
jpayne@69 68 double pValue;
jpayne@69 69 bool pass;
jpayne@69 70 };
jpayne@69 71
jpayne@69 72 const Sketch & sketchRef;
jpayne@69 73 const Sketch & sketchQuery;
jpayne@69 74
jpayne@69 75 uint64_t indexRef;
jpayne@69 76 uint64_t indexQuery;
jpayne@69 77 uint64_t pairCount;
jpayne@69 78
jpayne@69 79 PairOutput * pairs;
jpayne@69 80 };
jpayne@69 81
jpayne@69 82 CommandDistance();
jpayne@69 83
jpayne@69 84 int run() const; // override
jpayne@69 85
jpayne@69 86 private:
jpayne@69 87
jpayne@69 88 void writeOutput(CompareOutput * output, bool table, bool comment) const;
jpayne@69 89 };
jpayne@69 90
jpayne@69 91 CommandDistance::CompareOutput * compare(CommandDistance::CompareInput * input);
jpayne@69 92 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 93 double pValue(uint64_t x, uint64_t lengthRef, uint64_t lengthQuery, double kmerSpace, uint64_t sketchSize);
jpayne@69 94
jpayne@69 95 } // namespace mash
jpayne@69 96
jpayne@69 97 #endif