|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_FORMATS_VARIANT_PARALLEL_INPUT_ITERATOR_H_
2 #define GENESIS_POPULATION_FORMATS_VARIANT_PARALLEL_INPUT_ITERATOR_H_
50 namespace population {
240 std::vector<utils::Optional<Variant>>
const *
operator->()
const
250 std::vector<utils::Optional<Variant>>
const &
operator*()
const
266 std::vector<utils::Optional<Variant>>
const&
variants()
const
286 std::vector<VariantInputIterator>
const&
inputs()
const
289 assert( generator_ );
290 return generator_->inputs_;
302 return generator_->inputs_[index];
317 return variants_.at( index );
326 return variants_.at( index );
354 bool allow_ref_base_mismatches =
false,
355 bool allow_alt_base_mismatches =
true,
356 bool move_samples =
false
364 return current_locus_;
384 operator bool()
const
386 return generator_ !=
nullptr;
399 return generator_ == it.generator_;
404 return !(*
this == it);
419 assert( generator_ );
420 assert( generator_->inputs_.size() == generator_->selections_.size() );
421 assert( generator_->inputs_.size() == iterators_.size() );
425 if( generator_->has_carrying_input_ ) {
426 advance_using_carrying_();
428 advance_using_only_following_();
435 void advance_using_carrying_();
443 void advance_using_only_following_();
462 void update_variants_();
472 GenomeLocus current_locus_;
476 std::vector<VariantInputIterator::Iterator> iterators_;
482 std::vector<size_t> variant_sizes_;
483 size_t variant_size_sum_;
492 std::vector<utils::Optional<Variant>> variants_;
496 std::set<GenomeLocus>::const_iterator carrying_locus_it_;
553 inputs_.emplace_back( input );
554 selections_.emplace_back( selection );
555 assert( inputs_.size() == selections_.size() );
558 has_carrying_input_ =
true;
570 std::function<
bool(
Variant&)> input_element_generator,
580 std::vector<VariantInputIterator>
const&
inputs()
const
595 std::vector<VariantInputIterator>&
inputs()
605 return inputs_[index];
613 return inputs_[index];
621 assert( inputs_.size() == selections_.size() );
622 return inputs_.size();
654 throw std::invalid_argument(
655 "Cannot add a carrying locus with empty chromosome or position 0 "
656 "to VariantParallelInputIterator"
663 carrying_loci_.insert( locus );
664 has_carrying_input_ =
true;
683 template<
class ForwardIterator>
686 while( first != last ) {
715 std::vector<VariantInputIterator> inputs_;
716 std::vector<ContributionType> selections_;
717 bool has_carrying_input_ =
false;
724 std::set<GenomeLocus> carrying_loci_;
731 #endif // include guard
Type erasure for iterators, using std::function to eliminate the underlying input type.
A single locus, that is, a position (or coordinate) on a chromosome.
Simplistic optional: requires T to be default constructible, copyable.
A single variant at a position in a chromosome, along with BaseCounts for a set of samples.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
utils::LambdaIterator< Variant, VariantInputIteratorData > VariantInputIterator
Iterate Variants, using a variety of input file formats.