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