nclist-cpp
C++ implementation of nested containment lists
|
Header-only library for nested containment lists. More...
Typedefs | |
template<class Array_ > | |
using | ArrayElement = typename std::remove_const<typename std::remove_reference<decltype(std::declval<Array_>()[0])>::type>::type |
Functions | |
template<typename Index_ , class StartArray_ , class EndArray_ > | |
Nclist< Index_, ArrayElement< StartArray_ > > | build_custom (Index_ num_subset, const Index_ *subset, const StartArray_ &starts, const EndArray_ &ends) |
template<typename Index_ , class StartArray_ , class EndArray_ > | |
Nclist< Index_, ArrayElement< StartArray_ > > | build_custom (Index_ num_intervals, const StartArray_ &starts, const EndArray_ &ends) |
template<typename Index_ , typename Position_ > | |
Nclist< Index_, Position_ > | build (Index_ num_subset, const Index_ *subset, const Position_ *starts, const Position_ *ends) |
template<typename Index_ , typename Position_ > | |
Nclist< Index_, Position_ > | build (Index_ num_intervals, const Position_ *starts, const Position_ *ends) |
template<typename Index_ , typename Position_ > | |
void | nearest (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const NearestParameters< Position_ > ¶ms, NearestWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_any (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const OverlapsAnyParameters< Position_ > ¶ms, OverlapsAnyWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_end (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const OverlapsEndParameters< Position_ > ¶ms, OverlapsEndWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_equal (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const OverlapsEqualParameters< Position_ > ¶ms, OverlapsEqualWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_extend (const Nclist< Index_, Position_ > &subject, Position_ query_start, Position_ query_end, const OverlapsExtendParameters< Position_ > ¶ms, OverlapsExtendWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_start (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const OverlapsStartParameters< Position_ > ¶ms, OverlapsStartWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
template<typename Index_ , typename Position_ > | |
void | overlaps_within (const Nclist< Index_, Position_ > &subject, const Position_ query_start, const Position_ query_end, const OverlapsWithinParameters< Position_ > ¶ms, OverlapsWithinWorkspace< Index_ > &workspace, std::vector< Index_ > &matches) |
Header-only library for nested containment lists.
using nclist::ArrayElement = typename std::remove_const<typename std::remove_reference<decltype(std::declval<Array_>()[0])>::type>::type |
Convenient shorthand to get the type of element in an array or array-like object.
Array_ | Class with a [ method that accepts an Index_ and returns a value or reference. |
Nclist< Index_, Position_ > nclist::build | ( | Index_ | num_intervals, |
const Position_ * | starts, | ||
const Position_ * | ends ) |
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end position of each interval. |
num_intervals | Number of subject intervals to include in the NCList. | |
[in] | starts | Pointer to an array of length num_intervals , containing the start positions of all subject intervals. |
[in] | ends | Pointer to an array of length num_intervals , containing the end positions of all subject intervals. The i -th subject interval is defined as [starts[i], ends[i]) . Note the non-inclusive nature of the end positions. |
Nclist
containing all subject intervals. Nclist< Index_, Position_ > nclist::build | ( | Index_ | num_subset, |
const Index_ * | subset, | ||
const Position_ * | starts, | ||
const Position_ * | ends ) |
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end positions of each interval. |
num_subset | Number of subject intervals in the subset to include in the Nclist . | |
[in] | subset | Pointer to an array of length equal to num_subset , containing the subset of subject intervals to include in the NCList. |
[in] | starts | Pointer to an array containing the start positions of all subject intervals. This should be long enough to be addressable by any element in [subset, subset + num_subset) . |
[in] | ends | Pointer to an array containing the end positions of all subject intervals. This should be long enough to be addressable by any element in [subset, subset + num_subset) , where the i -th subject interval is defined as [starts[i], ends[i]) . Note the non-inclusive nature of the end positions. |
Nclist
containing the specified subset of subject intervals. Nclist< Index_, ArrayElement< StartArray_ > > nclist::build_custom | ( | Index_ | num_intervals, |
const StartArray_ & | starts, | ||
const EndArray_ & | ends ) |
Index_ | Integer type of the subject interval index. |
StartArray_ | Class with a [ method that accepts an Index_ and returns the start position of the associated interval. |
EndArray_ | Class with a [ method that accepts an Index_ and returns the end position of the associated interval. The type of position (after removing references and const -ness) should be the same as that returned by StartArray 's [ method`. |
Position_ | Numeric type for the start/end position of each interval. |
num_intervals | Number of subject intervals to include in the NCList. | |
[in] | starts | Array-like object containing the start positions of all subject intervals. This should be addressable by any element in [0, num_intervals) . |
[in] | ends | Array-like object containing the end positions of all subject intervals. This should be addressable by any element in [0, num_intervals) , where the i -th subject interval is defined as [starts[i], ends[i]) . Note the non-inclusive nature of the end positions. |
Nclist
containing the specified subset of subject intervals. Nclist< Index_, ArrayElement< StartArray_ > > nclist::build_custom | ( | Index_ | num_subset, |
const Index_ * | subset, | ||
const StartArray_ & | starts, | ||
const EndArray_ & | ends ) |
Index_ | Integer type of the subject interval index. |
StartArray_ | Class with a [ method that accepts an Index_ and returns the start position of the associated interval. |
EndArray_ | Class with a [ method that accepts an Index_ and returns the end position of the associated interval. The type of position (after removing references) should be the same as that returned by StartArray 's [ method`. |
num_subset | Number of subject intervals in the subset to include in the Nclist . | |
[in] | subset | Pointer to an array of length equal to num_subset , containing the subset of subject intervals to include in the NCList. |
[in] | starts | Array-like object containing the start positions of all subject intervals. This should be addressable by any element in [subset, subset + num_subset) . |
[in] | ends | Array-like object containing the end positions of all subject intervals. This should be addressable by any element in [subset, subset + num_subset) , where the i -th subject interval is defined as [starts[i], ends[i]) . Note the non-inclusive nature of the end positions. |
Nclist
containing the specified subset of subject intervals. void nclist::nearest | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const NearestParameters< Position_ > & | params, | ||
NearestWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject intervals that are nearest to the query interval. If any overlaps are present, all overlapping intervals are reported. If no overlaps are present, the subject interval with the smallest gap to the query is reported. A gap is defined as the distance between the query start and subject end (for queries after the subject) or the subject start and the query end (otherwise). If multiple subjects have the same gap, all ties are reported.
This function is based on its counterpart of the same name in the IRanges R/Bioconductor package. Users should set NearestParameters::adjacent_equals_overlap = true
to obtain the same results as the R package,
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end positions of each interval. |
subject | An Nclist of subject intervals, typically built with build() . | |
query_start | Start of the query interval. | |
query_end | Non-inclusive end of the query interval. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across nearest() calls. | |
[out] | matches | On output, vector of indices of the nearest subject intervals to the query interval. Indices are reported in arbitrary order. |
void nclist::overlaps_any | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const OverlapsAnyParameters< Position_ > & | params, | ||
OverlapsAnyWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject intervals that exhibit any overlap with the query interval.
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end positions of each interval. |
subject | An Nclist of subject intervals, typically built with build() . | |
query_start | Start of the query interval. | |
query_end | Non-inclusive end of the query interval. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_any() calls. | |
[out] | matches | On output, vector of subject interval indices that overlap with the query interval. Indices are reported in arbitrary order. |
void nclist::overlaps_end | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const OverlapsEndParameters< Position_ > & | params, | ||
OverlapsEndWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject intervals with the same end position as the query interval.
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end positions of each interval. |
subject | An Nclist of subject intervals, typically built with build() . | |
query_start | Start of the query interval. | |
query_end | Non-inclusive end of the query interval. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_end() calls. | |
[out] | matches | On output, vector of subject interval indices that overlap with the query interval. Indices are reported in arbitrary order. |
void nclist::overlaps_equal | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const OverlapsEqualParameters< Position_ > & | params, | ||
OverlapsEqualWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject intervals with the same start and end positions as the query interval. By default, given a subject interval [subject_start, subject_end)
, an overlap is considered if subject_start == query_end
and query_start == subject_end
. This behavior can be tuned with parameters in params
.
Index_ | Integer type of the subject interval index. |
Position_ | Numeric type for the start/end positions of each interval. |
subject | An Nclist of subject intervals, typically built with build() . | |
query_start | Start of the query interval. | |
query_end | Non-inclusive end of the query interval. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_equal() calls. | |
[out] | matches | On output, vector of subject interval indices that overlap with the query interval. Indices are reported in arbitrary order. |
void nclist::overlaps_extend | ( | const Nclist< Index_, Position_ > & | subject, |
Position_ | query_start, | ||
Position_ | query_end, | ||
const OverlapsExtendParameters< Position_ > & | params, | ||
OverlapsExtendWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject ranges that are extended by the query range, i.e., each subject range is a subrange of the query.
Index_ | Integer type of the subject range index. |
Position_ | Numeric type for the start/end positions of each range. |
subject | An Nclist of subject ranges, typically built with build() . | |
query_start | Start of the query range. | |
query_end | Non-inclusive end of the query range. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_extend() calls. | |
[out] | matches | On output, vector of subject range indices that overlap with the query range. Indices are reported in arbitrary order. |
void nclist::overlaps_start | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const OverlapsStartParameters< Position_ > & | params, | ||
OverlapsStartWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject ranges that have the same start position as the query.
Index_ | Integer type of the subject range index. |
Position_ | Numeric type for the start/end positions of each range. |
subject | An Nclist of subject ranges, typically built with build() . | |
query_start | Start of the query range. | |
query_end | Non-inclusive end of the query range. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_end() calls. | |
[out] | matches | On output, vector of subject range indices that overlap with the query range. Indices are reported in arbitrary order. |
void nclist::overlaps_within | ( | const Nclist< Index_, Position_ > & | subject, |
const Position_ | query_start, | ||
const Position_ | query_end, | ||
const OverlapsWithinParameters< Position_ > & | params, | ||
OverlapsWithinWorkspace< Index_ > & | workspace, | ||
std::vector< Index_ > & | matches ) |
Find subject ranges where the query range lies within them, i.e., the query is a subrange of each subject range.
Index_ | Integer type of the subject range index. |
Position_ | Numeric type for the start/end positions of each range. |
subject | An Nclist of subject ranges, typically built with build() . | |
query_start | Start of the query range. | |
query_end | Non-inclusive end of the query range. | |
params | Parameters for the search. | |
workspace | Workspace for intermediate data structures. This can be default-constructed and re-used across overlaps_within() calls. | |
[out] | matches | On output, vector of subject range indices that overlap with the query range. Indices are reported in arbitrary order. |