From 0e0024ec50b4552de27bb2c1109894b5335689c9 Mon Sep 17 00:00:00 2001 From: Lucas Czech Date: Wed, 28 Feb 2024 15:17:50 -0300 Subject: [PATCH] Rename all Window Iterators into Streams --- lib/genesis/population.hpp | 14 +- ...ow_iterator.hpp => base_window_stream.hpp} | 98 ++++++------- ...ome_iterator.hpp => chromosome_stream.hpp} | 138 +++++++++--------- ..._iterator.hpp => region_window_stream.hpp} | 134 ++++++++--------- ....hpp => sliding_entries_window_stream.hpp} | 132 ++++++++--------- ...hpp => sliding_interval_window_stream.hpp} | 134 ++++++++--------- ...iterator.hpp => variant_window_stream.hpp} | 28 ++-- ...ew_iterator.hpp => window_view_stream.hpp} | 136 ++++++++--------- ...ome_iterator.cpp => chromosome_stream.cpp} | 34 ++--- test/src/population/diversity.cpp | 6 +- test/src/population/fst_pool.cpp | 6 +- ..._iterator.cpp => region_window_stream.cpp} | 6 +- ....cpp => sliding_entries_window_stream.cpp} | 44 +++--- ...cpp => sliding_interval_window_stream.cpp} | 34 ++--- ...r.cpp => variant_gapless_input_stream.cpp} | 0 ..._iterator.cpp => variant_input_stream.cpp} | 0 ....cpp => variant_parallel_input_stream.cpp} | 0 ...ew_iterator.cpp => window_view_stream.cpp} | 12 +- 18 files changed, 478 insertions(+), 478 deletions(-) rename lib/genesis/population/window/{base_window_iterator.hpp => base_window_stream.hpp} (87%) rename lib/genesis/population/window/{chromosome_iterator.hpp => chromosome_stream.hpp} (83%) rename lib/genesis/population/window/{region_window_iterator.hpp => region_window_stream.hpp} (90%) rename lib/genesis/population/window/{sliding_entries_window_iterator.hpp => sliding_entries_window_stream.hpp} (79%) rename lib/genesis/population/window/{sliding_interval_window_iterator.hpp => sliding_interval_window_stream.hpp} (80%) rename lib/genesis/population/window/{variant_window_iterator.hpp => variant_window_stream.hpp} (70%) rename lib/genesis/population/window/{window_view_iterator.hpp => window_view_stream.hpp} (66%) rename test/src/population/{chromosome_iterator.cpp => chromosome_stream.cpp} (88%) rename test/src/population/{region_window_iterator.cpp => region_window_stream.cpp} (99%) rename test/src/population/{sliding_entries_window_iterator.cpp => sliding_entries_window_stream.cpp} (88%) rename test/src/population/{sliding_interval_window_iterator.cpp => sliding_interval_window_stream.cpp} (90%) rename test/src/population/{variant_gapless_input_iterator.cpp => variant_gapless_input_stream.cpp} (100%) rename test/src/population/{variant_input_iterator.cpp => variant_input_stream.cpp} (100%) rename test/src/population/{variant_parallel_input_iterator.cpp => variant_parallel_input_stream.cpp} (100%) rename test/src/population/{window_view_iterator.cpp => window_view_stream.cpp} (94%) diff --git a/lib/genesis/population.hpp b/lib/genesis/population.hpp index a455dc01..3b6c3e14 100644 --- a/lib/genesis/population.hpp +++ b/lib/genesis/population.hpp @@ -81,17 +81,17 @@ #include "genesis/population/streams/variant_parallel_input_stream.hpp" #include "genesis/population/variant.hpp" #include "genesis/population/window/base_window.hpp" -#include "genesis/population/window/base_window_iterator.hpp" -#include "genesis/population/window/chromosome_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" +#include "genesis/population/window/chromosome_stream.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/region_window_iterator.hpp" -#include "genesis/population/window/sliding_entries_window_iterator.hpp" -#include "genesis/population/window/sliding_interval_window_iterator.hpp" +#include "genesis/population/window/region_window_stream.hpp" +#include "genesis/population/window/sliding_entries_window_stream.hpp" +#include "genesis/population/window/sliding_interval_window_stream.hpp" #include "genesis/population/window/sliding_window_generator.hpp" -#include "genesis/population/window/variant_window_iterator.hpp" +#include "genesis/population/window/variant_window_stream.hpp" #include "genesis/population/window/vcf_window.hpp" #include "genesis/population/window/window.hpp" #include "genesis/population/window/window_view.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/window_view_stream.hpp" #endif // include guard diff --git a/lib/genesis/population/window/base_window_iterator.hpp b/lib/genesis/population/window/base_window_stream.hpp similarity index 87% rename from lib/genesis/population/window/base_window_iterator.hpp rename to lib/genesis/population/window/base_window_stream.hpp index 910ca0bf..6d9c4328 100644 --- a/lib/genesis/population/window/base_window_iterator.hpp +++ b/lib/genesis/population/window/base_window_stream.hpp @@ -1,5 +1,5 @@ -#ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_BASE_WINDOW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. @@ -48,23 +48,23 @@ namespace genesis { namespace population { // ================================================================================================= -// Base Window Iterator +// Base Window Stream // ================================================================================================= /** - * @brief Base iterator class for Window%s over the chromosomes of a genome. + * @brief Base class for streams of Window%s over the chromosomes of a genome. * * This base class serves for sliding windows, windows over regions of a genome, etc. * * The template parameters are: - * * `InputIterator`: The type of the underlying iterator over the genome data (that is, the input - * iterator from which the windows take their data). Needs to have a member type - * `value_type` that specifies the actual input type that the iterator produces, which we here + * * `InputStreamIterator`: The type of the underlying stream over the genome data (that is, the input + * stream from which the windows take their data). Needs to have a member type + * `value_type` that specifies the actual input type that the stream produces, which we here * call the `InputType` (and typedef it as that). * * `Data`: The data type of the Window::Data that is stored in Window::Entry. The functor * #entry_input_function needs to be provided to convert from `InputType` to this `Data`. * By default, we take this to be the same as the `InputType`, meaning that the Window contains - * the same data type as the underlying iterator that we get our data from. + * the same data type as the underlying stream that we get our data from. * * The three functors * @@ -74,12 +74,12 @@ namespace population { * * have to be set in the class prior to starting the iteration. * - * The general usage of the derived classes that actually implement this iterator is as follows, - * on the example of the SlidingIntervalWindowIterator: + * The general usage of the derived classes that actually implement this stream is as follows, + * on the example of the SlidingIntervalWindowStream: * - * // Make an iterator using some underlying data iterator + * // Make a window stream using some underlying data stream * // that yields data for one position in the genome at a time. - * auto win_it = SlidingIntervalWindowIterator( data_begin, data_end ); + * auto win_it = SlidingIntervalWindowStream( data_begin, data_end ); * * // Set functors to access the underlying data. * win_it.entry_input_function = []( Data const& variant ) { @@ -104,11 +104,11 @@ namespace population { * Other derived classes work accordingly. */ template< - class InputIterator, - class Data = typename InputIterator::value_type, + class InputStreamIterator, + class Data = typename InputStreamIterator::value_type, class WindowType = typename ::genesis::population::Window > -class BaseWindowIterator +class BaseWindowStream { public: @@ -116,11 +116,11 @@ class BaseWindowIterator // Typedefs and Enums // ------------------------------------------------------------------------- - using InputIteratorType = InputIterator; + using InputStreamType = InputStreamIterator; using DataType = Data; - using self_type = BaseWindowIterator; - using InputType = typename InputIterator::value_type; + using self_type = BaseWindowStream; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = WindowType; @@ -133,19 +133,19 @@ class BaseWindowIterator // ------------------------------------------------------------------------- /** - * @brief Functor to convert from the underlying input iterator that provides the data + * @brief Functor to convert from the underlying input stream that provides the data * to fill the windows to the data that is stored per window. */ std::function entry_input_function; /** - * @brief Functor that yields the current chromosome, given the input iterator data. + * @brief Functor that yields the current chromosome, given the input stream data. */ std::function chromosome_function; /** * @brief Functor that yields the current position on the chromosome, - * given the input iterator data. + * given the input stream data. */ std::function position_function; @@ -183,10 +183,10 @@ class BaseWindowIterator // Constructors and Rule of Five // ------------------------------------------------------------------------- - using self_type = typename BaseWindowIterator< - InputIteratorType, DataType, WindowType + using self_type = typename BaseWindowStream< + InputStreamType, DataType, WindowType >::Iterator; - using InputType = typename InputIteratorType::value_type; + using InputType = typename InputStreamType::value_type; using iterator_category = std::input_iterator_tag; using value_type = WindowType; @@ -228,7 +228,7 @@ class BaseWindowIterator return *this; } - friend BaseWindowIterator; + friend BaseWindowStream; // ------------------------------------------------------------------------- // Properties @@ -320,7 +320,7 @@ class BaseWindowIterator * Any two iterators that are copies of each other or started from the same parent * will compare equal, as long as neither of them is past-the-end. * A valid (not past-the-end) iterator and an end() iterator will not compare equal, - * no matter from which BaseWindowIterator they were created. + * no matter from which BaseWindowStream they were created. * Two past-the-end iterators compare equal. */ bool operator==( self_type const& other ) const @@ -388,10 +388,10 @@ class BaseWindowIterator // Constructors and Rule of Five // ------------------------------------------------------------------------- - using self_type = typename BaseWindowIterator< - InputIteratorType, DataType, WindowType + using self_type = typename BaseWindowStream< + InputStreamType, DataType, WindowType >::BaseIterator; - using InputType = typename InputIteratorType::value_type; + using InputType = typename InputStreamType::value_type; using iterator_category = std::input_iterator_tag; using value_type = WindowType; @@ -409,7 +409,7 @@ class BaseWindowIterator * @brief Construct the base class, which does initialization checks on its member * variables to ensure that the user has set up the functors correctly. */ - BaseIterator( BaseWindowIterator const* parent ) + BaseIterator( BaseWindowStream const* parent ) { init_( parent ); } @@ -426,7 +426,7 @@ class BaseWindowIterator // BaseIterator& operator= ( self_type const& ) = default; // BaseIterator& operator= ( self_type&& ) = default; - friend BaseWindowIterator; + friend BaseWindowStream; friend Iterator; // ------------------------------------------------------------------------- @@ -438,7 +438,7 @@ class BaseWindowIterator /** * @brief Initialize the base iterator class and check that it is set up correctly. */ - void init_( BaseWindowIterator const* parent ) + void init_( BaseWindowStream const* parent ) { // We use the parent as a check if this Iterator is intended to be a begin() // or end() iterator. If its the former, init. If the latter, we are done here. @@ -454,19 +454,19 @@ class BaseWindowIterator // Check that the functors are set up. if( ! parent->entry_input_function ) { throw std::runtime_error( - "Need to set BaseWindowIterator::entry_input_function " + "Need to set BaseWindowStream::entry_input_function " "before iterating over Windows with a Window Iterator." ); } if( ! parent->chromosome_function ) { throw std::runtime_error( - "Need to set BaseWindowIterator::chromosome_function " + "Need to set BaseWindowStream::chromosome_function " "before iterating over Windows with a Window Iterator." ); } if( ! parent->position_function ) { throw std::runtime_error( - "Need to set BaseWindowIterator::position_function " + "Need to set BaseWindowStream::position_function " "before iterating over Windows with a Window Iterator." ); } @@ -498,7 +498,7 @@ class BaseWindowIterator * In the derived class implementation, this should be a pointer to the _derived_ parent * class, to make sure that it contains the correct settings etc needed for the iteration. */ - virtual BaseWindowIterator const* get_parent_() const = 0; + virtual BaseWindowStream const* get_parent_() const = 0; protected: @@ -506,9 +506,9 @@ class BaseWindowIterator bool is_first_window_ = true; bool is_last_window_ = false; - // Underlying iterator - InputIterator current_; - InputIterator end_; + // Underlying data stream + InputStreamIterator current_; + InputStreamIterator end_; }; @@ -522,18 +522,18 @@ class BaseWindowIterator // Constructors and Rule of Five // ------------------------------------------------------------------------- - BaseWindowIterator( InputIterator begin, InputIterator end ) + BaseWindowStream( InputStreamIterator begin, InputStreamIterator end ) : begin_(begin) , end_(end) {} - virtual ~BaseWindowIterator() = default; + virtual ~BaseWindowStream() = default; - BaseWindowIterator( BaseWindowIterator const& ) = default; - BaseWindowIterator( BaseWindowIterator&& ) = default; + BaseWindowStream( BaseWindowStream const& ) = default; + BaseWindowStream( BaseWindowStream&& ) = default; - BaseWindowIterator& operator= ( BaseWindowIterator const& ) = default; - BaseWindowIterator& operator= ( BaseWindowIterator&& ) = default; + BaseWindowStream& operator= ( BaseWindowStream const& ) = default; + BaseWindowStream& operator= ( BaseWindowStream&& ) = default; friend Iterator; @@ -588,8 +588,8 @@ class BaseWindowIterator protected: - // Need a default for WindowViewIterator. - BaseWindowIterator() = default; + // Need a default for WindowViewStream. + BaseWindowStream() = default; virtual std::unique_ptr get_begin_iterator_() = 0; virtual std::unique_ptr get_end_iterator_() = 0; @@ -601,8 +601,8 @@ class BaseWindowIterator private: // Underlying iterator to the data that we want to put in windows. - InputIterator begin_; - InputIterator end_; + InputStreamIterator begin_; + InputStreamIterator end_; // Keep the observers for each window view. std::vector> observers_; diff --git a/lib/genesis/population/window/chromosome_iterator.hpp b/lib/genesis/population/window/chromosome_stream.hpp similarity index 83% rename from lib/genesis/population/window/chromosome_iterator.hpp rename to lib/genesis/population/window/chromosome_stream.hpp index 55e5ce62..3f14e836 100644 --- a/lib/genesis/population/window/chromosome_iterator.hpp +++ b/lib/genesis/population/window/chromosome_stream.hpp @@ -1,9 +1,9 @@ -#ifndef GENESIS_POPULATION_WINDOW_CHROMOSOME_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_CHROMOSOME_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_CHROMOSOME_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_CHROMOSOME_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. - Copyright (C) 2014-2023 Lucas Czech + Copyright (C) 2014-2024 Lucas Czech This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ * @ingroup population */ -#include "genesis/population/window/base_window_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/sequence/sequence_dict.hpp" @@ -48,11 +48,11 @@ namespace genesis { namespace population { // ================================================================================================= -// Chromosome Iterator +// Chromosome Stream // ================================================================================================= /** - * @brief Iterator for traversing each chromosome as a whole, or the entire genome, + * @brief Stream for traversing each chromosome as a whole, or the entire genome, * with an inner WindowView iterator over the positions of each chromosome. * * With each step of the iteration, an inner WindowView iterator is yielded that traverses all @@ -78,23 +78,23 @@ namespace population { * have to be set in the class prior to starting the iteration for the chromosome iterator. * For the whole genome case, only the first of them has to be set, as we internally do not need * access to the chromosome and position information of the underlying data iterator. - * See make_chromosome_iterator() and make_default_chromosome_iterator() + * See make_chromosome_stream() and make_default_chromosome_stream() * for helper functions that take care of this for most of our data types. * - * See BaseWindowIterator for more details on the three functors, the template parameters. - * This class here however does not derive from the BaseWindowIterator over normal Window%s, + * See BaseWindowStream for more details on the three functors, the template parameters. + * This class here however does not derive from the BaseWindowStream over normal Window%s, * but behaves in a similar way - with the exception that it does not produce Window%s in each * step of the iteration, as we do not want to keep the positions of a whole chromosome in memory. * Hence, instead, it yields a WindowView iterator, directly streaming over the positions of the * chromosome, without keeping all data in memory. * * - * @see make_chromosome_iterator() - * @see make_default_chromosome_iterator() + * @see make_chromosome_stream() + * @see make_default_chromosome_stream() */ -template -class ChromosomeIterator final : public BaseWindowIterator< - InputIterator, DataType, ::genesis::population::WindowView +template +class ChromosomeStream final : public BaseWindowStream< + InputStreamIterator, DataType, ::genesis::population::WindowView > { public: @@ -104,11 +104,11 @@ class ChromosomeIterator final : public BaseWindowIterator< // ------------------------------------------------------------------------- using WindowViewType = ::genesis::population::WindowView; - using self_type = ChromosomeIterator; - using base_type = BaseWindowIterator; + using self_type = ChromosomeStream; + using base_type = BaseWindowStream; - // The input types that we take from the underlying iterator over genome positions. - using InputType = typename InputIterator::value_type; + // The input types that we take from the underlying stream over genome positions. + using InputType = typename InputStreamIterator::value_type; // using Entry = typename Window::Entry; // This class produces an iterator of type WindowView. @@ -126,8 +126,8 @@ class ChromosomeIterator final : public BaseWindowIterator< /** * @brief Internal iterator that produces WindowView%s. */ - class DerivedIterator final : public BaseWindowIterator< - InputIterator, DataType, WindowViewType + class DerivedIterator final : public BaseWindowStream< + InputStreamIterator, DataType, WindowViewType >::BaseIterator { public: @@ -136,19 +136,19 @@ class ChromosomeIterator final : public BaseWindowIterator< // Constructors and Rule of Five // ------------------------------------------------------------------------- - using self_type = typename ChromosomeIterator< - InputIterator, DataType + using self_type = typename ChromosomeStream< + InputStreamIterator, DataType >::DerivedIterator; // using base_iterator_type = typename base_type::BaseIterator; - using base_iterator_type = typename BaseWindowIterator< - InputIterator, DataType, WindowViewType + using base_iterator_type = typename BaseWindowStream< + InputStreamIterator, DataType, WindowViewType >::BaseIterator; // using WindowViewType = WindowViewType; // using Window = ::genesis::population::Window; // using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = WindowViewType; @@ -161,7 +161,7 @@ class ChromosomeIterator final : public BaseWindowIterator< DerivedIterator() = default; DerivedIterator( - ChromosomeIterator const* parent + ChromosomeStream const* parent ) : base_iterator_type( parent ) , parent_( parent ) @@ -198,7 +198,7 @@ class ChromosomeIterator final : public BaseWindowIterator< DerivedIterator& operator= ( self_type const& ) = default; DerivedIterator& operator= ( self_type&& ) = default; - friend ChromosomeIterator; + friend ChromosomeStream; // ------------------------------------------------------------------------- // Internal and Virtual Members @@ -277,7 +277,7 @@ class ChromosomeIterator final : public BaseWindowIterator< auto const dict_entry = parent_->sequence_dict_->find( chr ); if( dict_entry == parent_->sequence_dict_->end() ) { throw std::invalid_argument( - "In ChromosomeIterator: Cannot iterate chromosome \"" + chr + + "In ChromosomeStream: Cannot iterate chromosome \"" + chr + "\", as the provided sequence dictionary or reference genome " "does not contain the chromosome." ); @@ -319,7 +319,7 @@ class ChromosomeIterator final : public BaseWindowIterator< // looking up the chromosome in the dict in every iteration. if( seq_dict && old_pos > seq_dict->get( chr ).length ) { throw std::invalid_argument( - "In ChromosomeIterator: Chromosome \"" + chr + "\" has length " + + "In ChromosomeStream: Chromosome \"" + chr + "\" has length " + std::to_string( seq_dict->get( chr ).length ) + " in the provided sequence dictionary or reference genome, " "but the input data contains positions up to " + @@ -409,7 +409,7 @@ class ChromosomeIterator final : public BaseWindowIterator< private: // Parent. Needs to live here to have the correct derived type. - ChromosomeIterator const* parent_ = nullptr; + ChromosomeStream const* parent_ = nullptr; // Store the iterator for the window. WindowViewType window_; @@ -428,19 +428,19 @@ class ChromosomeIterator final : public BaseWindowIterator< // Constructors and Rule of Five // ------------------------------------------------------------------------- - ChromosomeIterator( - InputIterator begin, InputIterator end + ChromosomeStream( + InputStreamIterator begin, InputStreamIterator end ) : base_type( begin, end ) {} - virtual ~ChromosomeIterator() = default; + virtual ~ChromosomeStream() = default; - ChromosomeIterator( ChromosomeIterator const& ) = default; - ChromosomeIterator( ChromosomeIterator&& ) = default; + ChromosomeStream( ChromosomeStream const& ) = default; + ChromosomeStream( ChromosomeStream&& ) = default; - ChromosomeIterator& operator= ( ChromosomeIterator const& ) = default; - ChromosomeIterator& operator= ( ChromosomeIterator&& ) = default; + ChromosomeStream& operator= ( ChromosomeStream const& ) = default; + ChromosomeStream& operator= ( ChromosomeStream&& ) = default; friend DerivedIterator; @@ -534,37 +534,37 @@ class ChromosomeIterator final : public BaseWindowIterator< // ================================================================================================= /** - * @brief Helper function to instantiate a ChromosomeIterator for each chromosome, + * @brief Helper function to instantiate a ChromosomeStream for each chromosome, * without the need to specify the template parameters manually. */ -template -ChromosomeIterator -make_chromosome_iterator( - InputIterator begin, InputIterator end +template +ChromosomeStream +make_chromosome_stream( + InputStreamIterator begin, InputStreamIterator end ) { - return ChromosomeIterator( begin, end ); + return ChromosomeStream( begin, end ); } /** - * @brief Helper function to instantiate a ChromosomeIterator for each chromosome, + * @brief Helper function to instantiate a ChromosomeStream for each chromosome, * for a default use case. * * This helper assumes that the underlying type of the input data stream and of the data * that we are sliding over are of the same type, that is, we do no conversion in the - * `entry_input_function` functor of the ChromosomeIterator. It further assumes that this + * `entry_input_function` functor of the ChromosomeStream. It further assumes that this * data type has public member variables `chromosome` and `position` that are accessed by the - * `chromosome_function` and `position_function` functors of the ChromosomeIterator. + * `chromosome_function` and `position_function` functors of the ChromosomeStream. * For example, a data type that this works for is Variant data. */ -template -ChromosomeIterator -make_default_chromosome_iterator( - InputIterator begin, InputIterator end +template +ChromosomeStream +make_default_chromosome_stream( + InputStreamIterator begin, InputStreamIterator end ) { - using DataType = typename InputIterator::value_type; + using DataType = typename InputStreamIterator::value_type; // Set functors. - auto it = ChromosomeIterator( begin, end ); + auto it = ChromosomeStream( begin, end ); it.entry_input_function = []( DataType const& variant ) { return variant; }; @@ -584,39 +584,39 @@ make_default_chromosome_iterator( // ================================================================================================= /** - * @brief Helper function to instantiate a ChromosomeIterator for the whole genome, + * @brief Helper function to instantiate a ChromosomeStream for the whole genome, * without the need to specify the template parameters manually. * - * This helper function creates a ChromosomeIterator from the given pair of iterators, - * and sets ChromosomeIterator::whole_genome() to `true`, so that the whole genome is traversed + * This helper function creates a ChromosomeStream from the given pair of iterators, + * and sets ChromosomeStream::whole_genome() to `true`, so that the whole genome is traversed * without stopping at individual chromosomes in each iteration. */ -template -ChromosomeIterator -make_genome_iterator( - InputIterator begin, InputIterator end +template +ChromosomeStream +make_genome_stream( + InputStreamIterator begin, InputStreamIterator end ) { - auto it = ChromosomeIterator( begin, end ); + auto it = ChromosomeStream( begin, end ); it.whole_genome( true ); return it; } /** - * @brief Helper function to instantiate a ChromosomeIterator for the whole genome, + * @brief Helper function to instantiate a ChromosomeStream for the whole genome, * for a default use case. * - * @copydetails make_default_chromosome_iterator + * @copydetails make_default_chromosome_stream * - * This helper function creates a ChromosomeIterator from the given pair of iterators, - * and sets ChromosomeIterator::whole_genome() to `true`, so that the whole genome is traversed + * This helper function creates a ChromosomeStream from the given pair of iterators, + * and sets ChromosomeStream::whole_genome() to `true`, so that the whole genome is traversed * without stopping at individual chromosomes in each iteration. */ -template -ChromosomeIterator -make_default_genome_iterator( - InputIterator begin, InputIterator end +template +ChromosomeStream +make_default_genome_stream( + InputStreamIterator begin, InputStreamIterator end ) { - auto it = make_default_chromosome_iterator( begin, end ); + auto it = make_default_chromosome_stream( begin, end ); it.whole_genome( true ); return it; } diff --git a/lib/genesis/population/window/region_window_iterator.hpp b/lib/genesis/population/window/region_window_stream.hpp similarity index 90% rename from lib/genesis/population/window/region_window_iterator.hpp rename to lib/genesis/population/window/region_window_stream.hpp index 935e9e6d..e482f444 100644 --- a/lib/genesis/population/window/region_window_iterator.hpp +++ b/lib/genesis/population/window/region_window_stream.hpp @@ -1,9 +1,9 @@ -#ifndef GENESIS_POPULATION_WINDOW_REGION_WINDOW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_REGION_WINDOW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_REGION_WINDOW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_REGION_WINDOW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. - Copyright (C) 2014-2023 Lucas Czech + Copyright (C) 2014-2024 Lucas Czech This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,8 +34,8 @@ #include "genesis/population/genome_locus.hpp" #include "genesis/population/genome_region_list.hpp" #include "genesis/population/genome_region.hpp" -#include "genesis/population/window/base_window_iterator.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" +#include "genesis/population/window/window_view_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/range.hpp" @@ -55,15 +55,15 @@ namespace genesis { namespace population { // ================================================================================================= -// Region Window Iterator +// Region Window Stream // ================================================================================================= /** - * @brief Iterator for Window%s representing regions of a genome. + * @brief Stream for Window%s representing regions of a genome. * * This class allows to iterate a set of regions, each yielded to the caller as a Window. * That is, with each step of the iteration of this class, one region (interval) of the input - * region list is yielded as a Window, containing the data of the input `InputIterator` + * region list is yielded as a Window, containing the data of the input `InputStreamIterator` * (which is of type `DataType`). These regions can for example be genes, linkage blocks, or * other genomic intervals of interest. Each can have an arbitrary length, and the can potentially * be overlapping or be nested. @@ -76,17 +76,17 @@ namespace population { * * have to be set prior to the iteration. * All other settings are option and/or defaulted to reasonable values. - * See make_region_window_iterator() and make_default_region_window_iterator() + * See make_region_window_stream() and make_default_region_window_stream() * for helper functions that take care of this for most of our data types. * - * See BaseWindowIterator for more details on the three functors, the template parameters, + * See BaseWindowStream for more details on the three functors, the template parameters, * and general usage examples of the class. * - * @see make_region_window_iterator() - * @see make_default_region_window_iterator() + * @see make_region_window_stream() + * @see make_default_region_window_stream() */ -template -class RegionWindowIterator final : public BaseWindowIterator +template +class RegionWindowStream final : public BaseWindowStream { public: @@ -94,12 +94,12 @@ class RegionWindowIterator final : public BaseWindowIterator; - using base_type = BaseWindowIterator; + using self_type = RegionWindowStream; + using base_type = BaseWindowStream; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -114,7 +114,7 @@ class RegionWindowIterator final : public BaseWindowIterator::BaseIterator + class DerivedIterator final : public BaseWindowStream::BaseIterator { public: @@ -122,17 +122,17 @@ class RegionWindowIterator final : public BaseWindowIterator::DerivedIterator; - using base_iterator_type = typename BaseWindowIterator< - InputIterator, DataType + using base_iterator_type = typename BaseWindowStream< + InputStreamIterator, DataType >::BaseIterator; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -145,7 +145,7 @@ class RegionWindowIterator final : public BaseWindowIterator( windows_.front() ); } - BaseWindowIterator const* get_parent_() const override final + BaseWindowStream const* get_parent_() const override final { return parent_; } @@ -707,7 +707,7 @@ class RegionWindowIterator final : public BaseWindowIterator region_list ) : base_type( begin, end ) @@ -738,18 +738,18 @@ class RegionWindowIterator final : public BaseWindowIterator::BaseIterator> + std::unique_ptr::BaseIterator> get_begin_iterator_() override final { // Cannot use make_unique here, as the Iterator constructor is private, @@ -783,7 +783,7 @@ class RegionWindowIterator final : public BaseWindowIterator( this ); } - std::unique_ptr::BaseIterator> + std::unique_ptr::BaseIterator> get_end_iterator_() override final { return std::unique_ptr( new DerivedIterator() ); @@ -805,48 +805,48 @@ class RegionWindowIterator final : public BaseWindowIterator -RegionWindowIterator -make_region_window_iterator( - InputIterator begin, InputIterator end, +template +RegionWindowStream +make_region_window_stream( + InputStreamIterator begin, InputStreamIterator end, std::shared_ptr region_list ) { - auto it = RegionWindowIterator( begin, end, region_list ); + auto it = RegionWindowStream( begin, end, region_list ); return it; } /** - * @brief Helper function to instantiate a RegionWindowIterator for a default use case. + * @brief Helper function to instantiate a RegionWindowStream for a default use case. * * This helper assumes that the underlying type of the input data stream and of the Window%s * that we are iterating over are of the same type, that is, we do no conversion in the - * `entry_input_function` functor of the RegionWindowIterator. It further assumes that this + * `entry_input_function` functor of the RegionWindowStream. It further assumes that this * data type has public member variables `chromosome` and `position` that are accessed by the - * `chromosome_function` and `position_function` functors of the RegionWindowIterator. + * `chromosome_function` and `position_function` functors of the RegionWindowStream. * For example, a data type that this works for is Variant data. */ -template -RegionWindowIterator -make_default_region_window_iterator( - InputIterator begin, InputIterator end, +template +RegionWindowStream +make_default_region_window_stream( + InputStreamIterator begin, InputStreamIterator end, std::shared_ptr region_list ) { - using DataType = typename InputIterator::value_type; + using DataType = typename InputStreamIterator::value_type; // Set functors. - auto it = RegionWindowIterator( begin, end, region_list ); + auto it = RegionWindowStream( begin, end, region_list ); it.entry_input_function = []( DataType const& variant ) { return variant; }; @@ -862,24 +862,24 @@ make_default_region_window_iterator( } /** - * @brief Helper class that creates a RegionWindowIterator - * and wraps it in a WindowViewIterator. + * @brief Helper class that creates a RegionWindowStream + * and wraps it in a WindowViewStream. * - * See make_default_region_window_iterator() for the base functionality, - * and see make_window_view_iterator() for the wrapping behaviour. + * See make_default_region_window_stream() for the base functionality, + * and see make_window_view_stream() for the wrapping behaviour. * - * Note that because this is a simple wrapper around the constructor of RegionWindowIterator, + * Note that because this is a simple wrapper around the constructor of RegionWindowStream, * we lose access to that class itself, so that its more specialized member functions cannot be called * any more. If this is needed, use the two aforementioned `make_...()` functions individually. */ -template -WindowViewIterator -make_default_region_window_view_iterator( - InputIterator begin, InputIterator end, +template +WindowViewStream +make_default_region_window_view_stream( + InputStreamIterator begin, InputStreamIterator end, std::shared_ptr region_list ) { - return make_window_view_iterator( - make_default_region_window_iterator( begin, end, region_list ) + return make_window_view_stream( + make_default_region_window_stream( begin, end, region_list ) ); } diff --git a/lib/genesis/population/window/sliding_entries_window_iterator.hpp b/lib/genesis/population/window/sliding_entries_window_stream.hpp similarity index 79% rename from lib/genesis/population/window/sliding_entries_window_iterator.hpp rename to lib/genesis/population/window/sliding_entries_window_stream.hpp index 9e3683f1..d05c72a1 100644 --- a/lib/genesis/population/window/sliding_entries_window_iterator.hpp +++ b/lib/genesis/population/window/sliding_entries_window_stream.hpp @@ -1,9 +1,9 @@ -#ifndef GENESIS_POPULATION_WINDOW_SLIDING_ENTRIES_WINDOW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_SLIDING_ENTRIES_WINDOW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_SLIDING_ENTRIES_WINDOW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_SLIDING_ENTRIES_WINDOW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. - Copyright (C) 2014-2023 Lucas Czech + Copyright (C) 2014-2024 Lucas Czech This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ * @ingroup population */ -#include "genesis/population/window/base_window_iterator.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" +#include "genesis/population/window/window_view_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/population/window/window.hpp" @@ -47,17 +47,17 @@ namespace genesis { namespace population { // ================================================================================================= -// Sliding Entries Window Iterator +// Sliding Entries Window Stream // ================================================================================================= /** - * @brief Iterator for sliding Window%s of a fixed number of (variant) positions in a genome. + * @brief Stream for sliding Window%s of a fixed number of (variant) positions in a genome. * * With each step of the iteration, a window consisting of count() many entries of the underlying - * input iterator is yielded. Then, when incrementing, we move forward stride() many entries, + * input stream is yielded. Then, when incrementing, we move forward stride() many entries, * which can correspond to an arbitrary number of positions in the genome, depending on how far * the entries are spread out. Hence, any filterin on positions in the genome should be done - * beforehand on the inputs, so that only those entries are used by this iterator that are + * beforehand on the inputs, so that only those entries are used by this stream that are * meant to be considered. * * The three functors @@ -69,17 +69,17 @@ namespace population { * have to be set in the class prior to starting the iteration, as well as the count() of how many * entries shall be used in each iteration. * All other settings are optional and/or defaulted to reasonable values. - * See make_sliding_entries_window_iterator() and make_default_sliding_entries_window_iterator() + * See make_sliding_entries_window_stream() and make_default_sliding_entries_window_stream() * for helper functions that take care of this for most of our data types. * - * See BaseWindowIterator for more details on the three functors, the template parameters, + * See BaseWindowStream for more details on the three functors, the template parameters, * and general usage examples of the class. * - * @see make_sliding_entries_window_iterator() - * @see make_default_sliding_entries_window_iterator() + * @see make_sliding_entries_window_stream() + * @see make_default_sliding_entries_window_stream() */ -template -class SlidingEntriesWindowIterator final : public BaseWindowIterator +template +class SlidingEntriesWindowStream final : public BaseWindowStream { public: @@ -87,12 +87,12 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator; - using base_type = BaseWindowIterator; + using self_type = SlidingEntriesWindowStream; + using base_type = BaseWindowStream; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -107,7 +107,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator::BaseIterator + class DerivedIterator final : public BaseWindowStream::BaseIterator { public: @@ -115,17 +115,17 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator::DerivedIterator; - using base_iterator_type = typename BaseWindowIterator< - InputIterator, DataType + using base_iterator_type = typename BaseWindowStream< + InputStreamIterator, DataType >::BaseIterator; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -138,7 +138,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIteratorcount_ == 0 ) { throw std::runtime_error( - "Cannot use SlidingEntriesWindowIterator with count == 0." + "Cannot use SlidingEntriesWindowStream with count == 0." ); } if( parent_->stride_ == 0 ) { @@ -162,7 +162,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIteratorstride_ > parent_->count_ ) { throw std::runtime_error( - "Cannot use SlidingEntriesWindowIterator with stride > count." + "Cannot use SlidingEntriesWindowStream with stride > count." ); } @@ -186,7 +186,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator( window_ ); } - BaseWindowIterator const* get_parent_() const override final + BaseWindowStream const* get_parent_() const override final { return parent_; } @@ -351,7 +351,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator::BaseIterator> + std::unique_ptr::BaseIterator> get_begin_iterator_() override final { // Cannot use make_unique here, as the Iterator constructor is private, @@ -440,7 +440,7 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator( this ); } - std::unique_ptr::BaseIterator> + std::unique_ptr::BaseIterator> get_end_iterator_() override final { return std::unique_ptr( new DerivedIterator( nullptr )); @@ -460,43 +460,43 @@ class SlidingEntriesWindowIterator final : public BaseWindowIterator -SlidingEntriesWindowIterator -make_sliding_entries_window_iterator( - InputIterator begin, InputIterator end, size_t count = 0, size_t stride = 0 +template +SlidingEntriesWindowStream +make_sliding_entries_window_stream( + InputStreamIterator begin, InputStreamIterator end, size_t count = 0, size_t stride = 0 ) { - auto it = SlidingEntriesWindowIterator( begin, end ); + auto it = SlidingEntriesWindowStream( begin, end ); it.count( count ); it.stride( stride ); return it; } /** - * @brief Helper function to instantiate a SlidingEntriesWindowIterator for a default use case. + * @brief Helper function to instantiate a SlidingEntriesWindowStream for a default use case. * * This helper assumes that the underlying type of the input data stream and of the Window%s * that we are sliding over are of the same type, that is, we do no conversion in the - * `entry_input_function` functor of the SlidingEntriesWindowIterator. It further assumes that this + * `entry_input_function` functor of the SlidingEntriesWindowStream. It further assumes that this * data type has public member variables `chromosome` and `position` that are accessed by the - * `chromosome_function` and `position_function` functors of the SlidingEntriesWindowIterator. + * `chromosome_function` and `position_function` functors of the SlidingEntriesWindowStream. * For example, a data type that this works for is Variant data. */ -template -SlidingEntriesWindowIterator -make_default_sliding_entries_window_iterator( - InputIterator begin, InputIterator end, size_t count = 0, size_t stride = 0 +template +SlidingEntriesWindowStream +make_default_sliding_entries_window_stream( + InputStreamIterator begin, InputStreamIterator end, size_t count = 0, size_t stride = 0 ) { - using DataType = typename InputIterator::value_type; + using DataType = typename InputStreamIterator::value_type; // Set functors. - auto it = SlidingEntriesWindowIterator( begin, end ); + auto it = SlidingEntriesWindowStream( begin, end ); it.entry_input_function = []( DataType const& variant ) { return variant; }; @@ -514,23 +514,23 @@ make_default_sliding_entries_window_iterator( } /** - * @brief Helper class that creates a SlidingEntriesWindowIterator - * and wraps it in a WindowViewIterator. + * @brief Helper class that creates a SlidingEntriesWindowStream + * and wraps it in a WindowViewStream. * - * See make_default_sliding_entries_window_iterator() for the base functionality, - * and see make_window_view_iterator() for the wrapping behaviour. + * See make_default_sliding_entries_window_stream() for the base functionality, + * and see make_window_view_stream() for the wrapping behaviour. * - * Note that because this is a simple wrapper around the constructor of SlidingEntriesWindowIterator, + * Note that because this is a simple wrapper around the constructor of SlidingEntriesWindowStream, * we lose access to that class itself, so that its more specialized member functions cannot be called * any more. If this is needed, use the two aforementioned `make_...()` functions individually. */ -template -WindowViewIterator -make_default_sliding_entries_window_view_iterator( - InputIterator begin, InputIterator end, size_t count = 0, size_t stride = 0 +template +WindowViewStream +make_default_sliding_entries_window_view_stream( + InputStreamIterator begin, InputStreamIterator end, size_t count = 0, size_t stride = 0 ) { - return make_window_view_iterator( - make_default_sliding_entries_window_iterator( begin, end, count, stride ) + return make_window_view_stream( + make_default_sliding_entries_window_stream( begin, end, count, stride ) ); } diff --git a/lib/genesis/population/window/sliding_interval_window_iterator.hpp b/lib/genesis/population/window/sliding_interval_window_stream.hpp similarity index 80% rename from lib/genesis/population/window/sliding_interval_window_iterator.hpp rename to lib/genesis/population/window/sliding_interval_window_stream.hpp index ad809806..cff89b21 100644 --- a/lib/genesis/population/window/sliding_interval_window_iterator.hpp +++ b/lib/genesis/population/window/sliding_interval_window_stream.hpp @@ -1,9 +1,9 @@ -#ifndef GENESIS_POPULATION_WINDOW_SLIDING_INTERVAL_WINDOW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_SLIDING_INTERVAL_WINDOW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_SLIDING_INTERVAL_WINDOW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_SLIDING_INTERVAL_WINDOW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. - Copyright (C) 2014-2023 Lucas Czech + Copyright (C) 2014-2024 Lucas Czech This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ * @ingroup population */ -#include "genesis/population/window/base_window_iterator.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" +#include "genesis/population/window/window_view_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/population/window/window.hpp" @@ -47,11 +47,11 @@ namespace genesis { namespace population { // ================================================================================================= -// Sliding Interval Window Iterator +// Sliding Interval Window Stream // ================================================================================================= /** - * @brief Iterator for sliding Window%s of fixed sized intervals over the chromosomes of a genome. + * @brief Stream for sliding Window%s of fixed sized intervals over the chromosomes of a genome. * * The three functors * @@ -61,17 +61,17 @@ namespace population { * * have to be set in the class prior to starting the iteration, as well as the width(). * All other settings are optional and/or defaulted to reasonable values. - * See make_sliding_interval_window_iterator() and make_default_sliding_interval_window_iterator() + * See make_sliding_interval_window_stream() and make_default_sliding_interval_window_stream() * for helper functions that take care of this for most of our data types. * - * See BaseWindowIterator for more details on the three functors, the template parameters, + * See BaseWindowStream for more details on the three functors, the template parameters, * and general usage examples of the class. * - * @see make_sliding_interval_window_iterator() - * @see make_default_sliding_interval_window_iterator() + * @see make_sliding_interval_window_stream() + * @see make_default_sliding_interval_window_stream() */ -template -class SlidingIntervalWindowIterator final : public BaseWindowIterator +template +class SlidingIntervalWindowStream final : public BaseWindowStream { public: @@ -79,12 +79,12 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator; - using base_type = BaseWindowIterator; + using self_type = SlidingIntervalWindowStream; + using base_type = BaseWindowStream; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -99,7 +99,7 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator::BaseIterator + class DerivedIterator final : public BaseWindowStream::BaseIterator { public: @@ -107,17 +107,17 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator::DerivedIterator; - using base_iterator_type = typename BaseWindowIterator< - InputIterator, DataType + using base_iterator_type = typename BaseWindowStream< + InputStreamIterator, DataType >::BaseIterator; using Window = ::genesis::population::Window; using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = Window; @@ -130,7 +130,7 @@ class SlidingIntervalWindowIterator final : public BaseWindowIteratorwidth_ == 0 ) { - throw std::runtime_error( "Cannot use SlidingIntervalWindowIterator of width 0." ); + throw std::runtime_error( "Cannot use SlidingIntervalWindowStream of width 0." ); } if( parent_->stride_ == 0 ) { parent_->stride_ = parent_->width_; } if( parent_->stride_ > parent_->width_ ) { throw std::runtime_error( - "Cannot use SlidingIntervalWindowIterator with stride > width." + "Cannot use SlidingIntervalWindowStream with stride > width." ); } @@ -176,7 +176,7 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator( window_ ); } - BaseWindowIterator const* get_parent_() const override final + BaseWindowStream const* get_parent_() const override final { return parent_; } @@ -348,7 +348,7 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator::BaseIterator> + std::unique_ptr::BaseIterator> get_begin_iterator_() override final { // Cannot use make_unique here, as the Iterator constructor is private, @@ -456,7 +456,7 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator( this ); } - std::unique_ptr::BaseIterator> + std::unique_ptr::BaseIterator> get_end_iterator_() override final { return std::unique_ptr( new DerivedIterator() ); @@ -481,48 +481,48 @@ class SlidingIntervalWindowIterator final : public BaseWindowIterator -SlidingIntervalWindowIterator -make_sliding_interval_window_iterator( - InputIterator begin, InputIterator end, size_t width = 0, size_t stride = 0 +template +SlidingIntervalWindowStream +make_sliding_interval_window_stream( + InputStreamIterator begin, InputStreamIterator end, size_t width = 0, size_t stride = 0 ) { - auto it = SlidingIntervalWindowIterator( begin, end ); + auto it = SlidingIntervalWindowStream( begin, end ); it.width( width ); it.stride( stride ); return it; } /** - * @brief Helper function to instantiate a SlidingIntervalWindowIterator for a default use case. + * @brief Helper function to instantiate a SlidingIntervalWindowStream for a default use case. * * This helper assumes that the underlying type of the input data stream and of the Window%s * that we are sliding over are of the same type, that is, we do no conversion in the - * `entry_input_function` functor of the SlidingIntervalWindowIterator. It further assumes that this + * `entry_input_function` functor of the SlidingIntervalWindowStream. It further assumes that this * data type has public member variables `chromosome` and `position` that are accessed by the - * `chromosome_function` and `position_function` functors of the SlidingIntervalWindowIterator. + * `chromosome_function` and `position_function` functors of the SlidingIntervalWindowStream. * For example, a data type that this works for is Variant data. */ -template -SlidingIntervalWindowIterator -make_default_sliding_interval_window_iterator( - InputIterator begin, InputIterator end, size_t width = 0, size_t stride = 0 +template +SlidingIntervalWindowStream +make_default_sliding_interval_window_stream( + InputStreamIterator begin, InputStreamIterator end, size_t width = 0, size_t stride = 0 ) { - using DataType = typename InputIterator::value_type; + using DataType = typename InputStreamIterator::value_type; // Set functors. - auto it = SlidingIntervalWindowIterator( begin, end ); + auto it = SlidingIntervalWindowStream( begin, end ); it.entry_input_function = []( DataType const& variant ) { return variant; }; @@ -540,23 +540,23 @@ make_default_sliding_interval_window_iterator( } /** - * @brief Helper class that creates a SlidingIntervalWindowIterator - * and wraps it in a WindowViewIterator. + * @brief Helper class that creates a SlidingIntervalWindowStream + * and wraps it in a WindowViewStream. * - * See make_default_sliding_interval_window_iterator() for the base functionality, - * and see make_window_view_iterator() for the wrapping behaviour. + * See make_default_sliding_interval_window_stream() for the base functionality, + * and see make_window_view_stream() for the wrapping behaviour. * - * Note that because this is a simple wrapper around the constructor of SlidingIntervalWindowIterator, + * Note that because this is a simple wrapper around the constructor of SlidingIntervalWindowStream, * we lose access to that class itself, so that its more specialized member functions cannot be called * any more. If this is needed, use the two aforementioned `make_...()` functions individually. */ -template -WindowViewIterator -make_default_sliding_interval_window_view_iterator( - InputIterator begin, InputIterator end, size_t width = 0, size_t stride = 0 +template +WindowViewStream +make_default_sliding_interval_window_view_stream( + InputStreamIterator begin, InputStreamIterator end, size_t width = 0, size_t stride = 0 ) { - return make_window_view_iterator( - make_default_sliding_interval_window_iterator( begin, end, width, stride ) + return make_window_view_stream( + make_default_sliding_interval_window_stream( begin, end, width, stride ) ); } diff --git a/lib/genesis/population/window/variant_window_iterator.hpp b/lib/genesis/population/window/variant_window_stream.hpp similarity index 70% rename from lib/genesis/population/window/variant_window_iterator.hpp rename to lib/genesis/population/window/variant_window_stream.hpp index c4db518e..42fd74a3 100644 --- a/lib/genesis/population/window/variant_window_iterator.hpp +++ b/lib/genesis/population/window/variant_window_stream.hpp @@ -1,5 +1,5 @@ -#ifndef GENESIS_POPULATION_WINDOW_VARIANT_WINDOW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_VARIANT_WINDOW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_VARIANT_WINDOW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_VARIANT_WINDOW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. @@ -32,8 +32,8 @@ */ #include "genesis/population/streams/variant_input_stream.hpp" -#include "genesis/population/window/base_window_iterator.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" +#include "genesis/population/window/window_view_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/population/window/window.hpp" @@ -43,7 +43,7 @@ namespace genesis { namespace population { // ================================================================================================= -// Generic Variant Window Iterator +// Generic Variant Window Stream // ================================================================================================= // Quick check to avoid future bugs if we ever change that definition. @@ -53,29 +53,29 @@ static_assert( ); /** - * @brief Typedef for a uniform Window iterator type. + * @brief Typedef for a uniform Window stream type. * - * This typedef is used for any Window iterator over an VariantInputStream. It's simply a more + * This typedef is used for any Window stream over an VariantInputStream. It's simply a more * convenient name that the full template specialization. */ -using VariantWindowIterator = BaseWindowIterator< +using VariantWindowStream = BaseWindowStream< VariantInputStream::Iterator, VariantInputStream::value_type, Window >; /** - * @brief Typedef for our uniform WindowView iterator type. + * @brief Typedef for our uniform WindowView stream type. * - * This typedef is used for any WindowView iterator over an VariantInputStream. It's simply a more + * This typedef is used for any WindowView stream over an VariantInputStream. It's simply a more * convenient name that the full template specialization. * - * In particular, we use this type as an abstraction that captures iterators over both Window and - * WindowView, for instance when using make_window_view_iterator() to wrap a WindowIterator into - * a WindowViewIterator. as Because we want to model different types of window iterators, some of + * In particular, we use this type as an abstraction that captures streams over both Window and + * WindowView, for instance when using make_window_view_stream() to wrap a WindowStream into + * a WindowViewStream. as Because we want to model different types of window streams, some of * which use Window, some of which use WindowView, this abstraction allows us to have a single type. */ -using VariantWindowViewIterator = BaseWindowIterator< +using VariantWindowViewStream = BaseWindowStream< VariantInputStream::Iterator, VariantInputStream::value_type, WindowView diff --git a/lib/genesis/population/window/window_view_iterator.hpp b/lib/genesis/population/window/window_view_stream.hpp similarity index 66% rename from lib/genesis/population/window/window_view_iterator.hpp rename to lib/genesis/population/window/window_view_stream.hpp index f16b4d84..7e0f9ab5 100644 --- a/lib/genesis/population/window/window_view_iterator.hpp +++ b/lib/genesis/population/window/window_view_stream.hpp @@ -1,9 +1,9 @@ -#ifndef GENESIS_POPULATION_WINDOW_WINDOW_VIEW_ITERATOR_H_ -#define GENESIS_POPULATION_WINDOW_WINDOW_VIEW_ITERATOR_H_ +#ifndef GENESIS_POPULATION_WINDOW_WINDOW_VIEW_STREAM_H_ +#define GENESIS_POPULATION_WINDOW_WINDOW_VIEW_STREAM_H_ /* Genesis - A toolkit for working with phylogenetic data. - Copyright (C) 2014-2023 Lucas Czech + Copyright (C) 2014-2024 Lucas Czech This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ * @ingroup population */ -#include "genesis/population/window/base_window_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" #include "genesis/population/window/window.hpp" #include "genesis/population/window/window_view.hpp" @@ -45,34 +45,34 @@ namespace genesis { namespace population { // ================================================================================================= -// Window View Iterator +// Window View Stream // ================================================================================================= /** - * @brief Iterator wrapper that turns a BaseWindowIterator over Window into a BaseWindowIterator + * @brief Stream wrapper that turns a BaseWindowStream over Window into a BaseWindowStream * over WindowView. * - * This serves as an abstraction to be able to use WindowViewIterator everywhere, instead - * of having to switch between WindowViewIterator and WindowIterator depending on the type - * of windowing that is being done. For example, SlidingIntervalWindowIterator, - * SlidingEntriesWindowIterator, and RegionWindowIterator yield iterators over Window%s, - * while the ChromosomeIterator (and the whole genome iterator that can be created with it as well) - * yield iterators over WindowView%s instead. This makes it cumbersome to switch between the two + * This serves as an abstraction to be able to use WindowViewStream everywhere, instead + * of having to switch between WindowViewStream and WindowStream depending on the type + * of windowing that is being done. For example, SlidingIntervalWindowStream, + * SlidingEntriesWindowStream, and RegionWindowStream yield streams over Window%s, + * while the ChromosomeStream (and the whole genome stream that can be created with it as well) + * yield streams over WindowView%s instead. This makes it cumbersome to switch between the two * types downstream. Hence, yet another abstraction. * - * In more technical terms, some of our window iterators are inheriting from - * `BaseWindowIterator`, while others are inheriting from - * `BaseWindowIterator`, making their base clases incompatible, + * In more technical terms, some of our window streams are inheriting from + * `BaseWindowStream`, while others are inheriting from + * `BaseWindowStream`, making their base classes incompatible, * so that they cannot be assigned to the same pointer variable. This class here solves this, * by wrapping the former into a class derived from the latter, and hence using the latter type - * as the one that we can use for uniform access to window iterators. + * as the one that we can use for uniform access to window streams. * - * The class takes the BaseWindowIterator to be iterated over as input, and iteraters its windows, + * The class takes the BaseWindowStream to be iterated over as input, and iteraters its windows, * and then simply wraps them into a WindowView whose elements point to these windows. */ -template -class WindowViewIterator final : public BaseWindowIterator< - InputIterator, Data, ::genesis::population::WindowView +template +class WindowViewStream final : public BaseWindowStream< + InputStreamIterator, Data, ::genesis::population::WindowView > { public: @@ -81,24 +81,24 @@ class WindowViewIterator final : public BaseWindowIterator< // Typedefs and Enums // ------------------------------------------------------------------------- - using InputIteratorType = InputIterator; + using InputStreamType = InputStreamIterator; using DataType = Data; using WindowType = ::genesis::population::WindowView; using WindowViewType = WindowType; - using base_type = BaseWindowIterator; - using self_type = WindowViewIterator; + using base_type = BaseWindowStream; + using self_type = WindowViewStream; - using WrappedWindowIterator = BaseWindowIterator; + using WrappedWindowStream = BaseWindowStream; static_assert( - std::is_same::value, "WindowViewIterator != self_type" + std::is_same::value, "WindowViewStream != self_type" ); // The input types that we take from the underlying iterator over genome positions. - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; // using Entry = typename Window::Entry; - using WrappedWindowIteratorIterator = typename WrappedWindowIterator::Iterator; + using WrappedWindowStreamIterator = typename WrappedWindowStream::Iterator; // This class produces an iterator of type WindowView. // That WindowView then iterates over the actual values of the input. @@ -115,8 +115,8 @@ class WindowViewIterator final : public BaseWindowIterator< /** * @brief Internal iterator that produces WindowView%s. */ - class DerivedIterator final : public BaseWindowIterator< - InputIterator, DataType, WindowViewType + class DerivedIterator final : public BaseWindowStream< + InputStreamIterator, DataType, WindowViewType >::BaseIterator { public: @@ -125,19 +125,19 @@ class WindowViewIterator final : public BaseWindowIterator< // Constructors and Rule of Five // ------------------------------------------------------------------------- - using self_type = typename WindowViewIterator< - InputIterator, DataType + using self_type = typename WindowViewStream< + InputStreamIterator, DataType >::DerivedIterator; // using base_iterator_type = typename base_type::BaseIterator; - using base_iterator_type = typename BaseWindowIterator< - InputIterator, DataType, WindowViewType + using base_iterator_type = typename BaseWindowStream< + InputStreamIterator, DataType, WindowViewType >::BaseIterator; // using WindowViewType = WindowViewType; // using Window = ::genesis::population::Window; // using Entry = typename Window::Entry; - using InputType = typename InputIterator::value_type; + using InputType = typename InputStreamIterator::value_type; using iterator_category = std::input_iterator_tag; using value_type = WindowViewType; @@ -154,7 +154,7 @@ class WindowViewIterator final : public BaseWindowIterator< DerivedIterator() = default; DerivedIterator( - WindowViewIterator const* parent + WindowViewStream const* parent ) // We here call the base class constructor without arguments, // in order to not trigger the full setup of the base class, which we don't want here. @@ -168,8 +168,8 @@ class WindowViewIterator final : public BaseWindowIterator< } // Store the underlying window iterators. - current_ = parent_->window_iterator_->begin(); - end_ = parent_->window_iterator_->end(); + current_ = parent_->window_stream_->begin(); + end_ = parent_->window_stream_->end(); // Start a view into the first window. This creates a view that mirrors the underlying // window, and iteratres through it, using the WindowView constructor that takes a Window. @@ -186,7 +186,7 @@ class WindowViewIterator final : public BaseWindowIterator< DerivedIterator& operator= ( self_type const& ) = default; DerivedIterator& operator= ( self_type&& ) = default; - friend WindowViewIterator; + friend WindowViewStream; // ------------------------------------------------------------------------- // Internal and Virtual Members @@ -225,11 +225,11 @@ class WindowViewIterator final : public BaseWindowIterator< private: // Parent. Needs to live here to have the correct derived type. - WindowViewIterator const* parent_ = nullptr; + WindowViewStream const* parent_ = nullptr; // Base window iterators - WrappedWindowIteratorIterator current_; - WrappedWindowIteratorIterator end_; + WrappedWindowStreamIterator current_; + WrappedWindowStreamIterator end_; // Store the iterator for the window. WindowViewType window_view_; @@ -244,19 +244,19 @@ class WindowViewIterator final : public BaseWindowIterator< // Constructors and Rule of Five // ------------------------------------------------------------------------- - WindowViewIterator( - std::unique_ptr window_iterator + WindowViewStream( + std::unique_ptr window_iterator ) - : window_iterator_( std::move( window_iterator )) + : window_stream_( std::move( window_iterator )) {} - virtual ~WindowViewIterator() = default; + virtual ~WindowViewStream() = default; - WindowViewIterator( WindowViewIterator const& ) = default; - WindowViewIterator( WindowViewIterator&& ) = default; + WindowViewStream( WindowViewStream const& ) = default; + WindowViewStream( WindowViewStream&& ) = default; - WindowViewIterator& operator= ( WindowViewIterator const& ) = default; - WindowViewIterator& operator= ( WindowViewIterator&& ) = default; + WindowViewStream& operator= ( WindowViewStream const& ) = default; + WindowViewStream& operator= ( WindowViewStream&& ) = default; friend DerivedIterator; @@ -289,7 +289,7 @@ class WindowViewIterator final : public BaseWindowIterator< private: // Need a pointer here, in order to allow to take derived classes. - std::unique_ptr window_iterator_; + std::unique_ptr window_stream_; }; @@ -298,45 +298,45 @@ class WindowViewIterator final : public BaseWindowIterator< // ================================================================================================= /** - * @brief Create a WindowViewIterator that iterates some underlying BaseWindowIterator. + * @brief Create a WindowViewStream that iterates some underlying BaseWindowStream. * - * The template parameter `T` is expected to be a BaseWindowIterator. + * The template parameter `T` is expected to be a BaseWindowStream. * - * This serves as an abstraction to be able to use WindowViewIterator everywhere, instead - * of having to switch between WindowViewIterator and WindowIterator depending on the type - * of windowing that is being done. See WindowViewIterator for details. + * This serves as an abstraction to be able to use WindowViewStream everywhere, instead + * of having to switch between WindowViewStream and WindowStream depending on the type + * of windowing that is being done. See WindowViewStream for details. */ template -WindowViewIterator -make_window_view_iterator( +WindowViewStream +make_window_view_stream( T const& window_iterator ) { - using InputIteratorType = typename T::InputIteratorType; + using InputStreamType = typename T::InputStreamType; using DataType = typename T::DataType; - using BaseWindowIteratorType = BaseWindowIterator; + using BaseWindowStreamType = BaseWindowStream; - return WindowViewIterator( - std::unique_ptr( new T{ window_iterator }) + return WindowViewStream( + std::unique_ptr( new T{ window_iterator }) ); } /** - * @copydoc make_window_view_iterator( T const& ) + * @copydoc make_window_view_stream( T const& ) * * This overload of the function takes the underlying iterator by r-value ref, * so that it can be provided directly without copy. */ template -WindowViewIterator -make_window_view_iterator( +WindowViewStream +make_window_view_stream( T&& window_iterator ) { - using InputIteratorType = typename T::InputIteratorType; + using InputStreamType = typename T::InputStreamType; using DataType = typename T::DataType; - using BaseWindowIteratorType = BaseWindowIterator; + using BaseWindowStreamType = BaseWindowStream; - return WindowViewIterator( - std::unique_ptr( new T{ std::move( window_iterator )}) + return WindowViewStream( + std::unique_ptr( new T{ std::move( window_iterator )}) ); } diff --git a/test/src/population/chromosome_iterator.cpp b/test/src/population/chromosome_stream.cpp similarity index 88% rename from test/src/population/chromosome_iterator.cpp rename to test/src/population/chromosome_stream.cpp index 11b3c7f6..8b01aab3 100644 --- a/test/src/population/chromosome_iterator.cpp +++ b/test/src/population/chromosome_stream.cpp @@ -34,7 +34,7 @@ #include "genesis/population/formats/simple_pileup_reader.hpp" #include "genesis/population/streams/variant_input_stream.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/chromosome_iterator.hpp" +#include "genesis/population/window/chromosome_stream.hpp" #include "genesis/population/window/window.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/utils/containers/generic_input_stream.hpp" @@ -42,7 +42,7 @@ using namespace genesis::population; using namespace genesis::utils; -void test_window_iterator_chromosome_iterator_chromosome_empty_() +void test_window_stream_chromosome_stream_chromosome_empty_() { // LOG_DBG << "empty"; std::string const infile = environment->data_dir + "population/empty.pileup"; @@ -51,7 +51,7 @@ void test_window_iterator_chromosome_iterator_chromosome_empty_() // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_pileup_file( infile ); - auto win_it = make_default_chromosome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_chromosome_stream( data_gen.begin(), data_gen.end() ); // Run the tests. std::vector pos_per_chr; @@ -76,7 +76,7 @@ void test_window_iterator_chromosome_iterator_chromosome_empty_() EXPECT_EQ( 0, pos_per_chr.size() ); } -void test_window_iterator_chromosome_iterator_chromosome_single_( +void test_window_stream_chromosome_stream_chromosome_single_( std::shared_ptr sequence_dict = nullptr ) { // LOG_DBG << "single"; @@ -86,7 +86,7 @@ void test_window_iterator_chromosome_iterator_chromosome_single_( // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_pileup_file( infile ); - auto win_it = make_default_chromosome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_chromosome_stream( data_gen.begin(), data_gen.end() ); win_it.sequence_dict( sequence_dict ); // Run the tests. @@ -121,7 +121,7 @@ void test_window_iterator_chromosome_iterator_chromosome_single_( EXPECT_EQ( 50000, pos_per_chr[0] ); } -void test_window_iterator_chromosome_iterator_chromosome_multi_( +void test_window_stream_chromosome_stream_chromosome_multi_( std::shared_ptr sequence_dict = nullptr ) { // Avoid compiler complaints about unused variable. @@ -136,7 +136,7 @@ void test_window_iterator_chromosome_iterator_chromosome_multi_( // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_sam_file( infile ); - auto win_it = make_default_chromosome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_chromosome_stream( data_gen.begin(), data_gen.end() ); win_it.sequence_dict( sequence_dict ); // Run the tests. @@ -180,7 +180,7 @@ void test_window_iterator_chromosome_iterator_chromosome_multi_( #endif } -TEST( WindowIterator, ChromosomeIteratorChromosome ) +TEST( WindowStream, ChromosomeStreamChromosome ) { using namespace genesis::sequence; @@ -188,23 +188,23 @@ TEST( WindowIterator, ChromosomeIteratorChromosome ) NEEDS_TEST_DATA; // Without sequence dict. - test_window_iterator_chromosome_iterator_chromosome_empty_(); - test_window_iterator_chromosome_iterator_chromosome_single_(); - test_window_iterator_chromosome_iterator_chromosome_multi_(); + test_window_stream_chromosome_stream_chromosome_empty_(); + test_window_stream_chromosome_stream_chromosome_single_(); + test_window_stream_chromosome_stream_chromosome_multi_(); // Repeat single with sequence dict. auto single_dict = std::make_shared(); single_dict->add( "2R", 8000000 ); - test_window_iterator_chromosome_iterator_chromosome_single_( single_dict ); + test_window_stream_chromosome_stream_chromosome_single_( single_dict ); // Repeat multi with sequence dict. auto multi_dict = std::make_shared(); multi_dict->add( "seq1", 2000 ); multi_dict->add( "seq2", 3000 ); - test_window_iterator_chromosome_iterator_chromosome_multi_( multi_dict ); + test_window_stream_chromosome_stream_chromosome_multi_( multi_dict ); } -TEST( WindowIterator, ChromosomeIteratorWholeGenome ) +TEST( WindowStream, ChromosomeStreamWholeGenome ) { // Almost exactly the same as above... we could refactor this to avoid the duplication... // Good enough for now, fix later. @@ -220,7 +220,7 @@ TEST( WindowIterator, ChromosomeIteratorWholeGenome ) // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_pileup_file( infile ); - auto win_it = make_default_genome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_genome_stream( data_gen.begin(), data_gen.end() ); // Run the tests. std::vector pos_per_chr; @@ -247,7 +247,7 @@ TEST( WindowIterator, ChromosomeIteratorWholeGenome ) // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_pileup_file( infile ); - auto win_it = make_default_genome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_genome_stream( data_gen.begin(), data_gen.end() ); // Run the tests. std::vector pos_per_chr; @@ -275,7 +275,7 @@ TEST( WindowIterator, ChromosomeIteratorWholeGenome ) // Make a generic input stream over the data stream, // and set up the window iterator. Rename to `win_it` to use it with the below test code. auto data_gen = make_variant_input_stream_from_sam_file( infile ); - auto win_it = make_default_genome_iterator( data_gen.begin(), data_gen.end() ); + auto win_it = make_default_genome_stream( data_gen.begin(), data_gen.end() ); // Run the tests. std::vector pos_per_chr; diff --git a/test/src/population/diversity.cpp b/test/src/population/diversity.cpp index 68ba103a..b8e6e093 100644 --- a/test/src/population/diversity.cpp +++ b/test/src/population/diversity.cpp @@ -36,7 +36,7 @@ #include "genesis/population/streams/variant_input_stream.hpp" #include "genesis/population/functions/diversity_pool_calculator.hpp" #include "genesis/population/functions/diversity_pool_functions.hpp" -#include "genesis/population/window/sliding_interval_window_iterator.hpp" +#include "genesis/population/window/sliding_interval_window_stream.hpp" #include "genesis/population/window/sliding_window_generator.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/filter_iterator.hpp" @@ -372,8 +372,8 @@ TEST( Population, DiversityMeasuresIterator ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - // LOG_DBG << "make_default_sliding_interval_window_iterator()"; - auto win_it = make_default_sliding_interval_window_iterator( + // LOG_DBG << "make_default_sliding_interval_window_stream()"; + auto win_it = make_default_sliding_interval_window_stream( pileup_begin, pileup_end, window_width, window_stride ); win_it.emit_leading_empty_windows( true ); diff --git a/test/src/population/fst_pool.cpp b/test/src/population/fst_pool.cpp index 6bd32d86..97c81ad4 100644 --- a/test/src/population/fst_pool.cpp +++ b/test/src/population/fst_pool.cpp @@ -39,7 +39,7 @@ #include "genesis/population/functions/fst_pool_functions.hpp" #include "genesis/population/functions/fst_pool_processor.hpp" #include "genesis/population/functions/functions.hpp" -#include "genesis/population/window/sliding_interval_window_iterator.hpp" +#include "genesis/population/window/sliding_interval_window_stream.hpp" #include "genesis/population/window/sliding_window_generator.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/transform_iterator.hpp" @@ -296,7 +296,7 @@ TEST( Structure, FstPoolIterator ) }); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_interval_window_iterator( + auto win_it = make_default_sliding_interval_window_stream( data_gen.begin(), data_gen.end(), window_width, window_stride ); @@ -425,7 +425,7 @@ TEST( Structure, FstPoolAllPairs ) auto sync_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_interval_window_iterator( + auto win_it = make_default_sliding_interval_window_stream( sync_begin, sync_end, window_width ); diff --git a/test/src/population/region_window_iterator.cpp b/test/src/population/region_window_stream.cpp similarity index 99% rename from test/src/population/region_window_iterator.cpp rename to test/src/population/region_window_stream.cpp index 6e7960c8..474a95b5 100644 --- a/test/src/population/region_window_iterator.cpp +++ b/test/src/population/region_window_stream.cpp @@ -32,7 +32,7 @@ #include "genesis/population/variant.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/region_window_iterator.hpp" +#include "genesis/population/window/region_window_stream.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/generic_input_stream.hpp" #include "genesis/utils/math/bitvector.hpp" @@ -182,7 +182,7 @@ void run_region_window_test_( size_t var_total_cnt = 0; // Make the iterator - auto win_it = make_default_region_window_iterator( + auto win_it = make_default_region_window_stream( variants.begin(), variants.end(), region_list ); @@ -519,7 +519,7 @@ std::string test_get_target_representation_( size_t target ) // Main test functions // ------------------------------------------------------------------------- -TEST( WindowIterator, RegionWindowIterator ) +TEST( WindowStream, RegionWindowStream ) { // We want all kinds of combinations: // diff --git a/test/src/population/sliding_entries_window_iterator.cpp b/test/src/population/sliding_entries_window_stream.cpp similarity index 88% rename from test/src/population/sliding_entries_window_iterator.cpp rename to test/src/population/sliding_entries_window_stream.cpp index 038101af..562cdfed 100644 --- a/test/src/population/sliding_entries_window_iterator.cpp +++ b/test/src/population/sliding_entries_window_stream.cpp @@ -34,8 +34,8 @@ #include "genesis/population/formats/simple_pileup_reader.hpp" #include "genesis/population/streams/variant_input_stream.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/sliding_entries_window_iterator.hpp" -#include "genesis/population/window/variant_window_iterator.hpp" +#include "genesis/population/window/sliding_entries_window_stream.hpp" +#include "genesis/population/window/variant_window_stream.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/generic_input_stream.hpp" @@ -44,15 +44,15 @@ using namespace genesis::population; using namespace genesis::utils; -template -void test_sliding_entries_iterator_( WindowIterator& win_it, size_t count ) +template +void test_sliding_entries_stream_( WindowStream& win_it, size_t count ) { bool found_first_win = false; bool found_last_win = false; // Also test that the observer functions get executed once per window. size_t observe_cnt = 0; - using ValueType = typename WindowIterator::InputIteratorType::value_type; + using ValueType = typename WindowStream::InputStreamType::value_type; win_it.add_observer( [&observe_cnt]( Window const& ){ // LOG_DBG << "at " << observe_cnt; ++observe_cnt; @@ -139,7 +139,7 @@ void test_sliding_entries_iterator_( WindowIterator& win_it, size_t count ) EXPECT_TRUE( found_last_win ); } -void test_window_iterator_sliding_entries_direct( size_t count ) +void test_window_stream_sliding_entries_direct( size_t count ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -151,12 +151,12 @@ void test_window_iterator_sliding_entries_direct( size_t count ) auto pileup_end = SimplePileupInputStream<>(); // Set up the window iterator. Rename to `win_it` to use it with the below test code. - auto win_it = make_default_sliding_entries_window_iterator( + auto win_it = make_default_sliding_entries_window_stream( pileup_begin, pileup_end, count ); // Run the tests. - test_sliding_entries_iterator_( win_it, count ); + test_sliding_entries_stream_( win_it, count ); // auto window_range = make_sliding_window_range( // auto win_it = make_sliding_window_iterator( @@ -180,13 +180,13 @@ void test_window_iterator_sliding_entries_direct( size_t count ) // } } -TEST( WindowIterator, SlidingEntriesDirect ) +TEST( WindowStream, SlidingEntriesDirect ) { - test_window_iterator_sliding_entries_direct( 9000 ); - test_window_iterator_sliding_entries_direct( 10000 ); + test_window_stream_sliding_entries_direct( 9000 ); + test_window_stream_sliding_entries_direct( 10000 ); } -void test_window_iterator_sliding_entries_lambda( size_t count ) +void test_window_stream_sliding_entries_lambda( size_t count ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -201,20 +201,20 @@ void test_window_iterator_sliding_entries_lambda( size_t count ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_entries_window_iterator( + auto win_it = make_default_sliding_entries_window_stream( pileup_begin, pileup_end, count ); - test_sliding_entries_iterator_( win_it, count ); + test_sliding_entries_stream_( win_it, count ); } -TEST( WindowIterator, SlidingEntriesLambda ) +TEST( WindowStream, SlidingEntriesLambda ) { - test_window_iterator_sliding_entries_lambda( 9000 ); - test_window_iterator_sliding_entries_lambda( 10000 ); + test_window_stream_sliding_entries_lambda( 9000 ); + test_window_stream_sliding_entries_lambda( 10000 ); } -void run_sliding_entries_window_view_variant_test_( VariantWindowViewIterator& win_it ) +void run_sliding_entries_window_view_variant_test_( VariantWindowViewStream& win_it ) { size_t window_cnt = 0; for( auto it = win_it.begin(); it != win_it.end(); ++it ) { @@ -230,7 +230,7 @@ void run_sliding_entries_window_view_variant_test_( VariantWindowViewIterator& w EXPECT_EQ( 6, window_cnt ); } -TEST( WindowIterator, SlidingEntriesWindowView ) +TEST( WindowStream, SlidingEntriesWindowView ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -245,7 +245,7 @@ TEST( WindowIterator, SlidingEntriesWindowView ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_entries_window_view_iterator( + auto win_it = make_default_sliding_entries_window_view_stream( pileup_begin, pileup_end, 9000 ); @@ -267,7 +267,7 @@ TEST( WindowIterator, SlidingEntriesWindowView ) // EXPECT_EQ( 6, window_cnt ); } -TEST( WindowIterator, SlidingEntriesEmpty ) +TEST( WindowStream, SlidingEntriesEmpty ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -279,7 +279,7 @@ TEST( WindowIterator, SlidingEntriesEmpty ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_entries_window_iterator( + auto win_it = make_default_sliding_entries_window_stream( pileup_begin, pileup_end, 10000 ); diff --git a/test/src/population/sliding_interval_window_iterator.cpp b/test/src/population/sliding_interval_window_stream.cpp similarity index 90% rename from test/src/population/sliding_interval_window_iterator.cpp rename to test/src/population/sliding_interval_window_stream.cpp index a85a0f94..1788e9b8 100644 --- a/test/src/population/sliding_interval_window_iterator.cpp +++ b/test/src/population/sliding_interval_window_stream.cpp @@ -34,8 +34,8 @@ #include "genesis/population/formats/simple_pileup_reader.hpp" #include "genesis/population/streams/variant_input_stream.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/sliding_interval_window_iterator.hpp" -#include "genesis/population/window/variant_window_iterator.hpp" +#include "genesis/population/window/sliding_interval_window_stream.hpp" +#include "genesis/population/window/variant_window_stream.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/generic_input_stream.hpp" @@ -44,8 +44,8 @@ using namespace genesis::population; using namespace genesis::utils; -template -void test_sliding_interval_iterator_( WindowIterator& win_it ) +template +void test_sliding_interval_stream_( WindowStream& win_it ) { bool found_first_win = false; bool found_last_win = false; @@ -71,7 +71,7 @@ void test_sliding_interval_iterator_( WindowIterator& win_it ) // Also test that the observer functions get executed once per window. size_t observe_cnt = 0; - using ValueType = typename WindowIterator::InputIteratorType::value_type; + using ValueType = typename WindowStream::InputStreamType::value_type; win_it.add_observer( [&observe_cnt]( Window const& ){ // LOG_DBG << "at " << observe_cnt; ++observe_cnt; @@ -114,7 +114,7 @@ void test_sliding_interval_iterator_( WindowIterator& win_it ) EXPECT_TRUE( found_last_win ); } -TEST( WindowIterator, SlidingIntervalDirect ) +TEST( WindowStream, SlidingIntervalDirect ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -126,13 +126,13 @@ TEST( WindowIterator, SlidingIntervalDirect ) auto pileup_end = SimplePileupInputStream<>(); // Set up the window iterator. Rename to `win_it` to use it with the below test code. - auto win_it = make_default_sliding_interval_window_iterator( + auto win_it = make_default_sliding_interval_window_stream( pileup_begin, pileup_end, 10000 ); win_it.emit_leading_empty_windows( false ); // Run the tests. - test_sliding_interval_iterator_( win_it ); + test_sliding_interval_stream_( win_it ); // auto window_range = make_sliding_window_range( // auto win_it = make_sliding_window_iterator( @@ -156,7 +156,7 @@ TEST( WindowIterator, SlidingIntervalDirect ) // } } -TEST( WindowIterator, SlidingIntervalLambda ) +TEST( WindowStream, SlidingIntervalLambda ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -171,15 +171,15 @@ TEST( WindowIterator, SlidingIntervalLambda ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_interval_window_iterator( + auto win_it = make_default_sliding_interval_window_stream( pileup_begin, pileup_end, 10000 ); win_it.emit_leading_empty_windows( false ); - test_sliding_interval_iterator_( win_it ); + test_sliding_interval_stream_( win_it ); } -void run_sliding_interval_window_view_variant_test_( VariantWindowViewIterator& win_it ) +void run_sliding_interval_window_view_variant_test_( VariantWindowViewStream& win_it ) { size_t window_cnt = 0; for( auto it = win_it.begin(); it != win_it.end(); ++it ) { @@ -188,7 +188,7 @@ void run_sliding_interval_window_view_variant_test_( VariantWindowViewIterator& EXPECT_EQ( 7, window_cnt ); } -TEST( WindowIterator, SlidingIntervalWindowView ) +TEST( WindowStream, SlidingIntervalWindowView ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -203,7 +203,7 @@ TEST( WindowIterator, SlidingIntervalWindowView ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_interval_window_view_iterator( + auto win_it = make_default_sliding_interval_window_view_stream( pileup_begin, pileup_end, 10000 ); // win_it.emit_leading_empty_windows( false ); @@ -219,7 +219,7 @@ TEST( WindowIterator, SlidingIntervalWindowView ) run_sliding_interval_window_view_variant_test_( win_it ); EXPECT_EQ( 7, observe_cnt ); - // test_sliding_interval_iterator_( win_it ); + // test_sliding_interval_stream_( win_it ); // size_t window_cnt = 0; // for( auto it = win_it.begin(); it != win_it.end(); ++it ) { // ++window_cnt; @@ -227,7 +227,7 @@ TEST( WindowIterator, SlidingIntervalWindowView ) // EXPECT_EQ( 786, window_cnt ); } -TEST( WindowIterator, SlidingIntervalEmpty ) +TEST( WindowStream, SlidingIntervalEmpty ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -239,7 +239,7 @@ TEST( WindowIterator, SlidingIntervalEmpty ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_default_sliding_interval_window_iterator( + auto win_it = make_default_sliding_interval_window_stream( pileup_begin, pileup_end, 10000 ); diff --git a/test/src/population/variant_gapless_input_iterator.cpp b/test/src/population/variant_gapless_input_stream.cpp similarity index 100% rename from test/src/population/variant_gapless_input_iterator.cpp rename to test/src/population/variant_gapless_input_stream.cpp diff --git a/test/src/population/variant_input_iterator.cpp b/test/src/population/variant_input_stream.cpp similarity index 100% rename from test/src/population/variant_input_iterator.cpp rename to test/src/population/variant_input_stream.cpp diff --git a/test/src/population/variant_parallel_input_iterator.cpp b/test/src/population/variant_parallel_input_stream.cpp similarity index 100% rename from test/src/population/variant_parallel_input_iterator.cpp rename to test/src/population/variant_parallel_input_stream.cpp diff --git a/test/src/population/window_view_iterator.cpp b/test/src/population/window_view_stream.cpp similarity index 94% rename from test/src/population/window_view_iterator.cpp rename to test/src/population/window_view_stream.cpp index 29487169..e1fa9c0a 100644 --- a/test/src/population/window_view_iterator.cpp +++ b/test/src/population/window_view_stream.cpp @@ -34,10 +34,10 @@ #include "genesis/population/formats/simple_pileup_reader.hpp" #include "genesis/population/streams/variant_input_stream.hpp" #include "genesis/population/window/base_window.hpp" -#include "genesis/population/window/base_window_iterator.hpp" +#include "genesis/population/window/base_window_stream.hpp" #include "genesis/population/window/functions.hpp" -#include "genesis/population/window/sliding_interval_window_iterator.hpp" -#include "genesis/population/window/window_view_iterator.hpp" +#include "genesis/population/window/sliding_interval_window_stream.hpp" +#include "genesis/population/window/window_view_stream.hpp" #include "genesis/population/window/window_view.hpp" #include "genesis/population/window/window.hpp" #include "genesis/utils/containers/generic_input_stream.hpp" @@ -45,7 +45,7 @@ using namespace genesis::population; using namespace genesis::utils; -TEST( WindowIterator, WindowViewIterator ) +TEST( WindowStream, WindowViewStream ) { // Skip test if no data availabe. NEEDS_TEST_DATA; @@ -60,8 +60,8 @@ TEST( WindowIterator, WindowViewIterator ) auto pileup_end = data_gen.end(); // Create a window iterator based on the Generic Input Stream. - auto win_it = make_window_view_iterator( - make_default_sliding_interval_window_iterator( + auto win_it = make_window_view_stream( + make_default_sliding_interval_window_stream( pileup_begin, pileup_end, 10000 ).emit_leading_empty_windows( false ) );