1 #define RANGELESS_FN_ENABLE_PARALLEL 1 51 using seq_id_t = std::pair<accession_t, version_t>;
97 using fn::operators::operator%;
113 return [key_fn = std::move(key_fn)](
auto inputs)
115 return std::move(inputs)
125 return [key_fn = std::move(key_fn)](
auto inputs)
127 return std::move(inputs)
137 return [key_fn = std::move(key_fn)](
auto inputs)
140 return std::move(inputs)
160 size_t max_queue_size = std::thread::hardware_concurrency())
162 assert(max_queue_size >= 1);
164 return [max_queue_size,
fn](
auto inputs)
166 return std::move(inputs)
173 return std::async( std::launch::async,
174 [inp = std::move(inp),
fn]()
mutable 176 return fn(std::move(inp));
187 using fn_out_t = decltype(
fn( std::move( *inputs.begin())));
188 return i++ < max_queue_size ? std::future<fn_out_t>() :
fn::end_seq();
199 return view.begin()->get();
208 size_t max_queue_size = std::thread::hardware_concurrency(),
209 size_t batch_size = 2)
211 return [=](
auto inputs)
213 return std::move(inputs)
217 return std::move(inputs_batch)
236 ret.push_back(std::move(a));
240 #define LAMBDA(expr) ([&](const auto& _){ return expr; }) 248 return std::move(alns_for_gene)
268 std::make_tuple( _.chr_id.first.find(
"NC_") != 0,
269 std::cref( _.chr_id ),
270 _.chr_cds_start_pos))
278 std::cref( _.mrna_id) ))
280 #else // alternatively, e.g if you want to use your own sort 285 alns.begin(), alns.end(),
288 return std::make_pair(
292 return std::move(alns);
306 return std::move(alns_seq)
314 return std::move(alns_for_gene)
336 return std::move(alns_for_mrna)
339 std::tie( _.mrna_id, _.chr_id, _.chr_start, _.chr_stop ));
365 alns.push_back(
aln_t{ 101, 2, {
"NM_000001", 2}, {
"NC_000001", 1}, 1000000, 1001000, 100100, 100});
366 alns.push_back(
aln_t{ 102, 2, {
"NM_000001", 2}, {
"NC_000001", 1}, 1000000, 1001000, 100100, 100});
367 alns.push_back(
aln_t{ 103, 2, {
"NM_000001", 2}, {
"NC_000001", 1}, 1000001, 1001000, 100100, 50 });
368 alns.push_back(
aln_t{ 104, 2, {
"NM_000001", 1}, {
"NC_000001", 1}, 1000000, 1001000, 100100, 100});
369 alns.push_back(
aln_t{ 201, 2, {
"NM_000002", 1}, {
"NC_000001", 1}, 1000000, 1001000, 0, 100});
370 alns.push_back(
aln_t{ 301, 2, {
"NM_000003", 1}, {
"NC_000001", 1}, 1000000, 1001000, 0, 100});
371 alns.push_back(
aln_t{ 401, 2, {
"NM_000004", 1}, {
"NC_000001", 1}, 1000000, 1001000, 0, 100});
372 alns.push_back(
aln_t{ 501, 2, {
"NM_000005", 1}, {
"NC_000001", 1}, 1000000, 1001000, 100100, 110});
373 alns.push_back(
aln_t{ 801, 2, {
"NM_000008", 1}, {
"NC_000001", 1}, 1000000, 1001000, 100200, 100});
376 alns.push_back(
aln_t{ 601, 3, {
"NM_000005", 1}, {
"NC_000001", 1}, 1000000, 1001000, 100100, 100});
377 alns.push_back(
aln_t{ 701, 3, {
"NM_000007", 1}, {
"NT_000001", 1}, 1000000, 1001000, 100100, 100});
380 using fn::operators::operator%;
382 std::vector<int64_t> kept_ids{};
388 return i < alns.size() ? std::move(alns[i++]) :
fn::end_seq();
396 kept_ids.push_back(a.
aln_id);
399 assert((kept_ids == std::vector<int64_t>{{ 501, 101, 601 }} ));
impl::group_adjacent_by< F > group_adjacent_by(F key_fn)
Group adjacent elements.
static auto unique_all_by
impl::where< P > where(P pred)
Filter elements.
static auto filter_to_unique_cds_for_gene(alns_t alns_for_gene) -> alns_t
impl::group_adjacent_by< impl::chunker > in_groups_of(size_t n)
Group adjacent elements into chunks of specified size.
static auto lazy_transform_in_parallel
static auto batched_lazy_transform_in_parallel
impl::concat concat()
Flatten the result of group_all_by or group_adjacent_by.
impl::sliding_window sliding_window(size_t win_size)
impl::sort_by< F, impl::stable_sort_tag > sort_by(F key_fn)
stable-sort and return the input.
impl::take_while< impl::call_count_lt > take_first(size_t n=1)
Yield first n elements.
LINQ -like library of higher-order functions for data manipulation.
impl::gt< T > decreasing(T x)
Wraps the passed value and exposes inverted operator<.
std::pair< accession_t, version_t > seq_id_t
Return fn::end_seq() from input-range generator function to signal end-of-inputs.
impl::seq< impl::catch_end< NullaryInvokable > > seq(NullaryInvokable gen_fn)
Adapt a generator function as InputRange.
static constexpr pos_t invalid_pos
impl::to_vector to_vector()
Move elements of an Iterable to std::vector.
impl::append< Iterable > append(Iterable next)
Yield elements of next after elements of arg.
impl::comp< F > make_comp(F key_fn)
Make binary comparison predicate from a key-function.
std::vector< aln_t > alns_t
impl::unique_adjacent_by< F > unique_adjacent_by(F key_fn)
Keep first element from every adjacently-equal run of elements.
aln_t & operator=(const aln_t &)=delete
impl::for_each< F > for_each(F fn)
static alns_t realign(aln_t a)