// -*- 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_HH #define __STARLING_READ_HH #include "starling_read_key.hh" #include "starling_read_segment.hh" #include "blt_util/bam_dumper.hh" #include "boost/utility.hpp" #include #include namespace READ_ALIGN { enum index_t { GENOME, CONTIG }; const char* label(const index_t i); } // helper class for starling_read to support the recently nailed-on // notion of exons // struct starling_segmented_read { starling_segmented_read(const seg_id_t size); void set_segment(const seg_id_t seg_no, const read_segment& rseg); read_segment& get_segment(const seg_id_t seg_no); const read_segment& get_segment(const seg_id_t seg_no) const; seg_id_t segment_count() const { return _seg_info.size(); } private: std::vector _seg_info; }; // // captures the concept of read as required by starling: namely // potentially aligned by both ELAND and/or GROUPER // // all alignments must be on the same strand and 'reasonably' proximate. // // all alignment info is fwd-strand // struct starling_read : private boost::noncopyable { starling_read(const bam_record& br, const bool is_bam_record_genomic); ~starling_read(); // bool // is_bam_record_genomic() { // return _is_bam_record_genomic; // } void set_genomic_bam_record(const bam_record& br) { assert(not _is_bam_record_genomic); _read_rec.copy(br); _is_bam_record_genomic=true; } // is new alignment compatible with pre-existing information? // bool is_compatible_alignment(const alignment& al, const READ_ALIGN::index_t rat, const align_id_t contig_id, const unsigned max_indel_size) const; // enters full alignment, and handles segment setup for splice // sites: void set_genome_align(const alignment& al); // nonconst because we update the BAM record with the best // alignment if the read has been realigned: void write_bam(bam_dumper& bamd); bool is_fwd_strand() const { return _read_rec.is_fwd_strand(); } uint8_t map_qual() const; align_id_t& id() { return _id; } align_id_t id() const { return _id; } read_key key() const { return read_key(_read_rec); } bool is_segmented() const { return (NULL!=_segment_ptr.get()); } seg_id_t segment_count() const { if(is_segmented()) { return _segment_ptr->segment_count(); } return 0; } read_segment& get_segment(seg_id_t seg_no) { if(seg_no>0) { assert(is_segmented() and (seg_no<=segment_count())); return _segment_ptr->get_segment(seg_no); } return _full_read; } const read_segment& get_segment(seg_id_t seg_no) const { if(seg_no>0) { assert(is_segmented() and (seg_no<=segment_count())); return _segment_ptr->get_segment(seg_no); } return _full_read; } read_segment& get_full_segment() { return get_segment(0); } const read_segment& get_full_segment() const { return get_segment(0); } contig_align_t& contig_align() { return _contig_align; } const contig_align_t& contig_align() const { return _contig_align; } private: friend struct read_segment; const bam1_t* get_brp() const { return _read_rec._bp; } bool is_treated_as_usable_mapping() const; // update full segment with sub-segment realignments void update_full_segment(); public: bool is_genome_align_usable_mapping; private: bool _is_bam_record_genomic; // indicates that this was the original (and thus, complete) alignment before grouper. align_id_t _id; contig_align_t _contig_align; // key is contig id bam_record _read_rec; read_segment _full_read; std::auto_ptr _segment_ptr; }; // debugging output: std::ostream& operator<<(std::ostream& os, const starling_read& sr); #endif