// -*- 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 /// #include "starling_read_segment.hh" #include "starling_read.hh" /* #include "blt_util/bam_util.hh" #include "blt_util/log.hh" #include "starling_read.hh" #include "starling_read_util.hh" #include "starling/varling_caller_shared.hh" #include #include */ #include bool read_segment:: is_treated_as_usable_mapping() const { return sread().is_treated_as_usable_mapping(); } bam_seq read_segment:: get_bam_read() const { return bam_seq(bam1_seq(sread().get_brp()),_size,_offset); } const uint8_t* read_segment:: qual() const { return bam1_qual(sread().get_brp())+_offset; } const contig_align_t& read_segment:: contig_align() const { static const contig_align_t empty_set; if(is_full_segment()) return sread()._contig_align; return empty_set; } align_id_t read_segment:: id() const { return sread().id(); } read_key read_segment:: key() const { return sread().key(); } bool read_segment:: is_genome_align_usable_mapping() const { return sread().is_genome_align_usable_mapping; } uint8_t read_segment:: map_qual() const { return sread().map_qual(); } bool read_segment:: is_full_segment() const { return (read_size() == sread()._read_rec.read_size()); } std::pair read_segment:: get_segment_edge_pin() const { std::pair res(false,false); const seg_id_t n_seg(sread().segment_count()); for(unsigned i(0);isecond.is_overmax(max_indel_size)) return true; return false; } bool read_segment:: is_valid() const { const read_segment& rseg(*this); const unsigned rs(rseg.read_size()); if(not rseg.genome_align().empty()) { const ALIGNPATH::path_t path(rseg.genome_align().path); if(is_apath_invalid(path,rs) or is_apath_starling_invalid(path)) return false; } typedef contig_align_t cat; const cat& ct(rseg.contig_align()); cat::const_iterator i(ct.begin()),i_end(ct.end()); for(;i!=i_end;++i){ const ALIGNPATH::path_t path(i->second.path); if(is_apath_invalid(path,rs) or is_apath_starling_invalid(path)) return false; } return true; } void short_report(std::ostream& os, const read_segment& rseg) { if(not rseg.genome_align().empty()) os << "GENOME " << rseg.genome_align(); os << "is_realigned? " << rseg.is_realigned << "\n"; if(rseg.is_realigned) { os << "REALIGN_path_log_lhood: " << rseg.realign_path_lnp << "\n"; os << "REALIGN " << rseg.realignment; } } // full report for read_segment is designed to be used independently // of starling_read: // std::ostream& operator<<(std::ostream& os, const read_segment& rseg) { os << "key: " << rseg.key() << "\n"; os << "id: " << rseg.id() << "\n"; const bam_seq bseq(rseg.get_bam_read()); os << "seq: " << bseq << "\n"; os << "qual: "; { const unsigned rs(rseg.read_size()); const uint8_t* qual(rseg.qual()); for(unsigned i(0);i(qual[i]+33); } os << "\n"; short_report(os,rseg); { typedef contig_align_t cat; const cat& ct(rseg.contig_align()); cat::const_iterator i(ct.begin()),i_end(ct.end()); for(;i!=i_end;++i){ os << "CONTIG contig_id: " << i->first << " " << i->second; } } return os; }