jpayne@69: // Copyright © 2015, Battelle National Biodefense Institute (BNBI); jpayne@69: // all rights reserved. Authored by: Brian Ondov, Todd Treangen, jpayne@69: // Sergey Koren, and Adam Phillippy jpayne@69: // jpayne@69: // See the LICENSE.txt file included with this software for license information. jpayne@69: jpayne@69: #ifndef INCLUDED_CommandFind jpayne@69: #define INCLUDED_CommandFind jpayne@69: jpayne@69: #include "Command.h" jpayne@69: #include "Sketch.h" jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: namespace mash { jpayne@69: jpayne@69: class CommandFind : public Command jpayne@69: { jpayne@69: public: jpayne@69: jpayne@69: struct FindInput jpayne@69: { jpayne@69: FindInput jpayne@69: ( jpayne@69: const Sketch & sketchNew, jpayne@69: const char * seqIdNew, jpayne@69: const char * seqNew, jpayne@69: uint32_t lengthNew, jpayne@69: float thresholdNew, jpayne@69: int bestNew, jpayne@69: bool selfMatchesNew jpayne@69: ) : jpayne@69: sketch(sketchNew), jpayne@69: length(lengthNew), jpayne@69: threshold(thresholdNew), jpayne@69: seqId(seqIdNew), jpayne@69: best(bestNew), jpayne@69: selfMatches(selfMatchesNew) jpayne@69: { jpayne@69: seq = new char[strlen(seqNew) + 1]; jpayne@69: strcpy(seq, seqNew); jpayne@69: } jpayne@69: jpayne@69: ~FindInput() jpayne@69: { jpayne@69: delete [] seq; jpayne@69: } jpayne@69: jpayne@69: const Sketch & sketch; jpayne@69: std::string seqId; jpayne@69: char * seq; jpayne@69: uint32_t length; jpayne@69: float threshold; jpayne@69: int best; jpayne@69: bool selfMatches; jpayne@69: }; jpayne@69: jpayne@69: struct FindOutput jpayne@69: { jpayne@69: struct Hit jpayne@69: { jpayne@69: Hit(uint32_t refNew, uint32_t startNew, uint32_t endNew, bool minusStrandNew, float scoreNew) jpayne@69: : jpayne@69: ref(refNew), jpayne@69: start(startNew), jpayne@69: end(endNew), jpayne@69: minusStrand(minusStrandNew), jpayne@69: score(scoreNew) jpayne@69: {} jpayne@69: jpayne@69: unsigned int ref; jpayne@69: unsigned int start; jpayne@69: unsigned int end; jpayne@69: bool minusStrand; jpayne@69: float score; jpayne@69: }; jpayne@69: jpayne@69: std::string seqId; jpayne@69: std::priority_queue hits; jpayne@69: }; jpayne@69: jpayne@69: CommandFind(); jpayne@69: jpayne@69: int run() const; // override jpayne@69: jpayne@69: private: jpayne@69: jpayne@69: void writeOutput(const Sketch & sketch, FindOutput * output) const; jpayne@69: }; jpayne@69: jpayne@69: CommandFind::FindOutput * find(CommandFind::FindInput * data); jpayne@69: void findPerStrand(const CommandFind::FindInput * input, CommandFind::FindOutput * output, bool minusStrand); jpayne@69: bool operator<(const CommandFind::FindOutput::Hit & a, const CommandFind::FindOutput::Hit & b); jpayne@69: jpayne@69: } // namespace mash jpayne@69: jpayne@69: #endif