combine-msa-vcf/overlap_counter.cc
// Update the overlap count list.
Update the overlap count list.
Update the overlap count list .
void overlap_counter::push_count(variant_record const &var, std::size_t const expected_ploidy)
	{
		auto const overlap_count_size(m_overlap_counts.size());
		libbio_assert_lt(0, overlap_count_size);
		{
			bool can_continue(false);
			for (auto const &var_alt : var.variant.alts())
			{
				if (! ("*" == var_alt.alt || "." == var_alt.alt))
				{
					can_continue = true;
					break;
				}
			}
			if (!can_continue)
				return;
		}
		auto const [var_overlap_count, ploidy] = count_set_genotype_values(var.variant, 0);
		libbio_always_assert_eq_msg(ploidy, expected_ploidy, "Line ", var.variant.lineno(), ": expected the sample ploidy to match the passed value, got ", ploidy, '.');
		if (0 == var_overlap_count)
			return;
		auto const var_pos(var.variant.zero_based_pos());
		auto const var_end(var_pos + var.size);
		m_overlap_counts.emplace_back(var_pos, var_overlap_count);
		m_overlap_counts.emplace_back(var_end, -1 * var_overlap_count);
		libbio_assert_lte(m_overlap_counts.front().position, m_overlap_counts[overlap_count_size].position);
		std::inplace_merge(
			m_overlap_counts.begin(),
			m_overlap_counts.begin() + overlap_count_size,
			m_overlap_counts.end(),
			[](auto const &lhs, auto const &rhs){
				return lhs.position < rhs.position;
			}
		);
		libbio_assert(
			std::is_sorted(
				m_overlap_counts.begin(),
				m_overlap_counts.end(),
				[](auto const &lhs, auto const &rhs){ return lhs.position < rhs.position; }
			)
		);
	}
void overlap_counter :: push_count ( variant_record const & var , std :: size_t const expected_ploidy ) { auto const overlap_count_size ( m_overlap_counts . size ( ) ) ; libbio_assert_lt ( 0 , overlap_count_size ) ; { bool can_continue ( false ) ; for ( auto const & var_alt : var . variant . alts ( ) ) { if ( ! ( " " == var_alt . alt || " " == var_alt . alt ) ) { can_continue = true ; break ; } } if ( ! can_continue ) return ; } auto const [ var_overlap_count , ploidy ] = count_set_genotype_values ( var . variant , 0 ) ; libbio_always_assert_eq_msg ( ploidy , expected_ploidy , " " , var . variant . lineno ( ) , " " , ploidy , ' ' ) ; if ( 0 == var_overlap_count ) return ; auto const var_pos ( var . variant . zero_based_pos ( ) ) ; auto const var_end ( var_pos + var . size ) ; m_overlap_counts . emplace_back ( var_pos , var_overlap_count ) ; m_overlap_counts . emplace_back ( var_end , -1 * var_overlap_count ) ; libbio_assert_lte ( m_overlap_counts . front ( ) . position , m_overlap_counts [ overlap_count_size ] . position ) ; std :: inplace_merge ( m_overlap_counts . begin ( ) , m_overlap_counts . begin ( ) + overlap_count_size , m_overlap_counts . end ( ) , [ ] ( auto const & lhs , auto const & rhs ) { return lhs . position < rhs . position ; } ) ; libbio_assert ( std :: is_sorted ( m_overlap_counts . begin ( ) , m_overlap_counts . end ( ) , [ ] ( auto const & lhs , auto const & rhs ) { return lhs . position < rhs . position ; } ) ) ; }
Update the overlap count list.
Update the overlap count list .
// By adding the starting and ending position of the new variant, // we will end up with two sorted lists the second one having two elements. // These can then be merged. // Check that there are known ALTs. // Calculate the overlap count. // Don’t add counts if no GT values were set. // Sort. // Make sure that no counts were added before the front element that is supposed to store the previously calculated running sum.