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