4 * Created on: Jul 31, 2009
13 #include "assert_helpers.h"
17 * 3 types of edits; mismatch (substitution), insertion in the
18 * reference, deletion in the reference.
28 * Encapsulates an edit between the read sequence and the reference
33 Edit() : pos(1023) { }
35 Edit(int po, int ch, int ty = EDIT_TYPE_MM) :
36 chr(ch), qchr(0), type(ty), pos(po) { }
39 * Write Edit to an OutFileBuf.
41 void serialize(OutFileBuf& fb) const {
42 assert_eq(4, sizeof(Edit));
43 fb.writeChars((const char*)this, 4);
47 * Read Edit from a FileBuf.
49 void deserialize(FileBuf& fb) {
50 fb.get((char*)this, 4);
54 * Edit less-than overload.
56 int operator< (const Edit &rhs) const {
57 if(pos < rhs.pos) return 1;
58 if(pos > rhs.pos) return 0;
59 if(chr < rhs.chr) return 1;
60 if(chr > rhs.chr) return 0;
61 return (qchr < rhs.qchr)? 1 : 0;
65 * Edit equals overload.
67 int operator== (const Edit &rhs) const {
68 return(pos == rhs.pos &&
75 * Return true iff this Edit is initialized.
77 bool initialized() const {
81 uint32_t chr : 8; // reference character involved (for subst and ins)
82 uint32_t qchr : 8; // read character involved (for subst and del
83 uint32_t type : 4; // 1 -> mm, 2 -> SNP, 3 -> ins, 4 -> del
84 uint32_t pos : 10; // position w/r/t search root
85 uint32_t reserved : 2; // padding
87 friend std::ostream& operator<< (std::ostream& os, const Edit& e);