// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright 2009 Illumina, Inc. // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). // // /// \file /// /// \author Chris Saunders /// #ifndef __STARLING_READ_BUFFER_HH #define __STARLING_READ_BUFFER_HH #include "starling_read.hh" #include "boost/utility.hpp" #include #include struct read_segment_iter; // // Must be able to look up reads by // (1) first alignment pos // (2) key or // (3) read_id_no // (4) contig_id_no(s) // // multiple reads may be associated with (1) and (4), but (2) and (3) // can produce at most a single result. // struct starling_read_buffer : private boost::noncopyable { starling_read_buffer() : _head_read_id(0) {} ~starling_read_buffer(); // note pos_processor is responsible for checking that the // position of the read is not too low -- the read_buffer itself // is agnostic to the data management process: // std::pair add_read_alignment(const unsigned max_indel_size, const bam_record& br, const alignment& al, const bool is_usable_mapping, const READ_ALIGN::index_t rat, const align_id_t contig_id); #if 0 // adjust read's buffer position to new_buffer_pos, // change buffer pos and mark read as moved: void rebuffer_read(const align_id_t read_id, const pos_t new_buffer_pos); #endif read_segment_iter get_pos_read_segment_iter(const pos_t pos); // returns NULL if read_id isn't present: starling_read* get_read(const align_id_t read_id) { const read_data_t::iterator k(_read_data.find(read_id)); if(k == _read_data.end()) return NULL; return (k->second); } // returns NULL if read_id isn't present: const starling_read* get_read(const align_id_t read_id) const { const read_data_t::const_iterator k(_read_data.find(read_id)); if(k == _read_data.end()) return NULL; return (k->second); } void clear_pos(const pos_t pos); void dump_pos(const pos_t pos, std::ostream& os) const; private: friend struct read_segment_iter; // typedef read_key read_key_t; typedef std::map read_data_t; typedef std::map read_key_lup_t; typedef std::set read_group_t; typedef std::pair segment_t; typedef std::set segment_group_t; typedef std::map pos_group_t; typedef std::map align_id_group_t; static const segment_group_t _empty_segment_group; align_id_t _head_read_id; // tracks head read_id number for next read added read_data_t _read_data; read_key_lup_t _read_key; pos_group_t _pos_group; align_id_group_t _contig_group; }; // not a real iterator // struct read_segment_iter { typedef std::pair ret_val; // returns first=NULL if no read segments left: // ret_val get_ptr(); // returns false if no more reads // bool next() { if(_head!=_end) _head++; return (_head!=_end); } private: friend struct starling_read_buffer; typedef starling_read_buffer::segment_group_t::const_iterator piter; read_segment_iter(starling_read_buffer& buff, const piter begin, const piter end) : _buff(buff), _head(begin), _end(end) {} starling_read_buffer& _buff; piter _head; const piter _end; }; #endif