// -*- 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 __POS_PROCESSOR_HH #define __POS_PROCESSOR_HH #include #include #include #include #include #include #include struct diploid_genotype; struct nploid_info; /// \brief accumulate sequential position specific information and /// send to a snp-calling routine after all position information is /// found /// /// pos_processor assumes that information related to each position /// will be available in an approximately sequential fashion, where all /// position values submitted after position X will be greater than /// X-POS_BUFFER_SIZE+1. A violation of this assumption will trigger a /// runtime error. /// /// The implementation should be split into a generic semi-sequential /// position-processor and an object with the application-specific /// position code (here, snp-calling). Maybe once a second application /// comes up... /// struct pos_processor : private boost::noncopyable { pos_processor(const blt_options& client_opt, const blt_deriv_options& client_dopt, const char* const ref_seq, const pos_t ref_size, const blt_streams& client_io); ~pos_processor(); void add_pos_snp_info(const pos_t pos, const char ref, const base_call& bc); private: // process any remaining positions void reset(); void handle_new_pos_value(const pos_t pos); bool is_pos_reportable(const pos_t pos){ return _client_dopt.report_range_limit.is_pos_intersect(pos); } void process_pos(const pos_t pos); void process_pos_snp(const pos_t pos); void clear_pos(const pos_t pos){ snp_pos_info& pi(_counts[pos_to_pindex(pos)]); pi.clear(); } static unsigned pos_to_pindex(const pos_t pos){ if(pos<0){ return pos+POS_BUFFER_SIZE*(1-(pos/POS_BUFFER_SIZE)); } else { return pos%POS_BUFFER_SIZE; } } std::ostream& get_report_os() const { return _client_io.report_os(); } const diploid_genotype& get_empty_dgt(const char ref) const; enum { POS_BUFFER_SIZE = 500 }; snp_pos_info _counts[POS_BUFFER_SIZE]; pos_t _max_pos; pos_t _min_pos; bool _is_first_pos_set; const blt_options& _client_opt; const blt_deriv_options& _client_dopt; stream_stat _ss; stream_stat _used_ss; stream_stat _ssn; stream_stat _used_ssn; double* _ws; const char* const _ref_seq; const pos_t _ref_size; const blt_streams& _client_io; std::auto_ptr _ninfo; unsigned _flank_size; std::auto_ptr _empty_dgt[N_BASE]; bool _is_dependent_eprob; }; #endif