comparison 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
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_CommandFind
8 #define INCLUDED_CommandFind
9
10 #include "Command.h"
11 #include "Sketch.h"
12 #include <string.h>
13 #include <queue>
14
15 namespace mash {
16
17 class CommandFind : public Command
18 {
19 public:
20
21 struct FindInput
22 {
23 FindInput
24 (
25 const Sketch & sketchNew,
26 const char * seqIdNew,
27 const char * seqNew,
28 uint32_t lengthNew,
29 float thresholdNew,
30 int bestNew,
31 bool selfMatchesNew
32 ) :
33 sketch(sketchNew),
34 length(lengthNew),
35 threshold(thresholdNew),
36 seqId(seqIdNew),
37 best(bestNew),
38 selfMatches(selfMatchesNew)
39 {
40 seq = new char[strlen(seqNew) + 1];
41 strcpy(seq, seqNew);
42 }
43
44 ~FindInput()
45 {
46 delete [] seq;
47 }
48
49 const Sketch & sketch;
50 std::string seqId;
51 char * seq;
52 uint32_t length;
53 float threshold;
54 int best;
55 bool selfMatches;
56 };
57
58 struct FindOutput
59 {
60 struct Hit
61 {
62 Hit(uint32_t refNew, uint32_t startNew, uint32_t endNew, bool minusStrandNew, float scoreNew)
63 :
64 ref(refNew),
65 start(startNew),
66 end(endNew),
67 minusStrand(minusStrandNew),
68 score(scoreNew)
69 {}
70
71 unsigned int ref;
72 unsigned int start;
73 unsigned int end;
74 bool minusStrand;
75 float score;
76 };
77
78 std::string seqId;
79 std::priority_queue<Hit> hits;
80 };
81
82 CommandFind();
83
84 int run() const; // override
85
86 private:
87
88 void writeOutput(const Sketch & sketch, FindOutput * output) const;
89 };
90
91 CommandFind::FindOutput * find(CommandFind::FindInput * data);
92 void findPerStrand(const CommandFind::FindInput * input, CommandFind::FindOutput * output, bool minusStrand);
93 bool operator<(const CommandFind::FindOutput::Hit & a, const CommandFind::FindOutput::Hit & b);
94
95 } // namespace mash
96
97 #endif