diff CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/mash/CommandFind.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/CommandFind.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_CommandFind
+#define INCLUDED_CommandFind
+
+#include "Command.h"
+#include "Sketch.h"
+#include <string.h>
+#include <queue>
+
+namespace mash {
+
+class CommandFind : public Command
+{
+public:
+    
+    struct FindInput
+    {
+        FindInput
+        (
+            const Sketch & sketchNew,
+            const char * seqIdNew,
+            const char * seqNew,
+            uint32_t lengthNew,
+            float thresholdNew,
+            int bestNew,
+            bool selfMatchesNew
+        ) :
+        sketch(sketchNew),
+        length(lengthNew),
+        threshold(thresholdNew),
+        seqId(seqIdNew),
+        best(bestNew),
+        selfMatches(selfMatchesNew)
+        {
+            seq = new char[strlen(seqNew) + 1];
+            strcpy(seq, seqNew);
+        }
+        
+        ~FindInput()
+        {
+            delete [] seq;
+        }
+        
+        const Sketch & sketch;
+        std::string seqId;
+        char * seq;
+        uint32_t length;
+        float threshold;
+        int best;
+        bool selfMatches;
+    };
+    
+    struct FindOutput
+    {
+        struct Hit
+        {
+            Hit(uint32_t refNew, uint32_t startNew, uint32_t endNew, bool minusStrandNew, float scoreNew)
+                :
+                ref(refNew),
+                start(startNew),
+                end(endNew),
+                minusStrand(minusStrandNew),
+                score(scoreNew)
+                {}
+            
+            unsigned int ref;
+            unsigned int start;
+            unsigned int end;
+            bool minusStrand;
+            float score;
+        };
+        
+        std::string seqId;
+        std::priority_queue<Hit> hits;
+    };
+    
+    CommandFind();
+    
+    int run() const; // override
+    
+private:
+    
+    void writeOutput(const Sketch & sketch, FindOutput * output) const;
+};
+
+CommandFind::FindOutput * find(CommandFind::FindInput * data);
+void findPerStrand(const CommandFind::FindInput * input, CommandFind::FindOutput * output, bool minusStrand);
+bool operator<(const CommandFind::FindOutput::Hit & a, const CommandFind::FindOutput::Hit & b);
+
+} // namespace mash
+
+#endif