|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_STREAM_VARIANT_PARALLEL_INPUT_STREAM_H_
2 #define GENESIS_POPULATION_STREAM_VARIANT_PARALLEL_INPUT_STREAM_H_
52 namespace population {
297 std::vector<utils::Optional<Variant>>
const *
operator->()
const
307 std::vector<utils::Optional<Variant>>
const &
operator*()
const
323 std::vector<utils::Optional<Variant>>
const&
variants()
const
343 std::vector<VariantInputStream>
const&
inputs()
const
347 return parent_->inputs_;
359 return parent_->inputs_[index];
374 return variants_.at( index );
383 return variants_.at( index );
403 return current_locus_;
423 operator bool()
const
425 return parent_ !=
nullptr;
438 return parent_ == it.parent_;
443 return !(*
this == it);
459 assert( parent_->inputs_.size() == parent_->selections_.size() );
460 assert( parent_->inputs_.size() == iterators_.size() );
464 if( parent_->has_carrying_input_ ) {
465 advance_using_carrying_();
467 advance_using_only_following_();
474 void advance_using_carrying_();
482 void advance_using_only_following_();
501 void update_variants_();
511 GenomeLocus current_locus_;
515 std::vector<VariantInputStream::Iterator> iterators_;
521 std::vector<size_t> variant_sizes_;
522 size_t variant_size_sum_;
531 std::vector<utils::Optional<Variant>> variants_;
535 std::set<GenomeLocus>::const_iterator carrying_locus_it_;
571 throw std::runtime_error(
572 "VariantParallelInputStream implements an input iterator (single pass); "
573 "begin() can hence not be called multiple times."
600 throw std::runtime_error(
601 "VariantParallelInputStream::add_variant_input_stream() cannot be called "
602 "once the iteration has been started with begin()."
606 inputs_.emplace_back( input );
607 selections_.emplace_back( selection );
608 assert( inputs_.size() == selections_.size() );
611 has_carrying_input_ =
true;
623 std::function<
bool(
Variant&)> input_element_generator,
633 std::vector<VariantInputStream>
const&
inputs()
const
648 std::vector<VariantInputStream>&
inputs()
658 return inputs_[index];
666 return inputs_[index];
674 assert( inputs_.size() == selections_.size() );
675 return inputs_.size();
706 throw std::runtime_error(
707 "VariantParallelInputStream::add_carrying_locus() cannot be called "
708 "once the iteration has been started with begin()."
714 throw std::invalid_argument(
715 "Cannot add a carrying locus with empty chromosome or position 0 "
716 "to VariantParallelInputStream"
723 carrying_loci_.insert( locus );
724 has_carrying_input_ =
true;
743 template<
class ForwardIterator>
746 while( first != last ) {
775 return sequence_dict_;
795 throw std::runtime_error(
796 "VariantParallelInputStream::sequence_dict() cannot be called "
797 "once the iteration has been started with begin()."
800 sequence_dict_ = value;
813 std::vector<VariantInputStream> inputs_;
814 std::vector<ContributionType> selections_;
815 bool has_carrying_input_ =
false;
816 bool started_ =
false;
823 std::set<GenomeLocus> carrying_loci_;
828 std::shared_ptr<genesis::sequence::SequenceDict> sequence_dict_;
835 #endif // include guard
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 SampleCounts for a set of samples.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
utils::GenericInputStream< Variant, VariantInputStreamData > VariantInputStream
Iterate Variants, using a variety of input file formats.