diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/mash/CommandDistance.h	Tue Mar 18 17:55:14 2025 -0400
@@ -0,0 +1,97 @@
+// Copyright © 2015, Battelle National Biodefense Institute (BNBI);
+// all rights reserved. Authored by: Brian Ondov, Todd Treangen,
+// Sergey Koren, and Adam Phillippy
+//
+// See the LICENSE.txt file included with this software for license information.
+
+#ifndef INCLUDED_CommandDistance
+#define INCLUDED_CommandDistance
+
+#include "Command.h"
+#include "Sketch.h"
+
+namespace mash {
+
+class CommandDistance : public Command
+{
+public:
+    
+    struct CompareInput
+    {
+        CompareInput(const Sketch & sketchRefNew, const Sketch & sketchQueryNew, uint64_t indexRefNew, uint64_t indexQueryNew, uint64_t pairCountNew, const Sketch::Parameters & parametersNew, double maxDistanceNew, double maxPValueNew)
+            :
+            sketchRef(sketchRefNew),
+            sketchQuery(sketchQueryNew),
+            indexRef(indexRefNew),
+            indexQuery(indexQueryNew),
+            pairCount(pairCountNew),
+            parameters(parametersNew),
+            maxDistance(maxDistanceNew),
+            maxPValue(maxPValueNew)
+            {}
+        
+        const Sketch & sketchRef;
+        const Sketch & sketchQuery;
+        
+        uint64_t indexRef;
+        uint64_t indexQuery;
+        uint64_t pairCount;
+        
+        const Sketch::Parameters & parameters;
+        double maxDistance;
+        double maxPValue;
+    };
+    
+    struct CompareOutput
+    {
+        CompareOutput(const Sketch & sketchRefNew, const Sketch & sketchQueryNew, uint64_t indexRefNew, uint64_t indexQueryNew, uint64_t pairCountNew)
+            :
+            sketchRef(sketchRefNew),
+            sketchQuery(sketchQueryNew),
+            indexRef(indexRefNew),
+            indexQuery(indexQueryNew),
+            pairCount(pairCountNew)
+        {
+            pairs = new PairOutput[pairCount];
+        }
+        
+        ~CompareOutput()
+        {
+            delete [] pairs;
+        }
+        
+        struct PairOutput
+        {
+            uint64_t numer;
+            uint64_t denom;
+            double distance;
+            double pValue;
+            bool pass;
+        };
+        
+        const Sketch & sketchRef;
+        const Sketch & sketchQuery;
+        
+        uint64_t indexRef;
+        uint64_t indexQuery;
+        uint64_t pairCount;
+        
+        PairOutput * pairs;
+    };
+    
+    CommandDistance();
+    
+    int run() const; // override
+    
+private:
+    
+    void writeOutput(CompareOutput * output, bool table, bool comment) const;
+};
+
+CommandDistance::CompareOutput * compare(CommandDistance::CompareInput * input);
+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);
+double pValue(uint64_t x, uint64_t lengthRef, uint64_t lengthQuery, double kmerSpace, uint64_t sketchSize);
+
+} // namespace mash
+
+#endif