rnaglib.transforms.ResidueAttributeFilter¶
- class rnaglib.transforms.ResidueAttributeFilter(attribute, aggregation_mode='min_valid', value_checker=None, min_valid=1, aggfunc=None, **kwargs)[source]¶
Reject RNAs that lack a certain annotation at the whole residue-level.
- Parameters:
attribute (
str) – Which node-level attribute to look for.aggregation_mode (
str) – str (either “aggfunc” or “min_valid”); if set to “aggfunc”, keeps an RNA if the output of the aggregation function of the residue attribute at the RNA level passes the value_checker; if set to “min_valid”, keeps an RNA if more than min_valid nodes pass the value_checker.value_checker (
Optional[Callable]) – Function that accepts the value of the desired attribute and returns True/False.aggfunc (
Optional[Callable]) – Function to aggregate the residue labels at the RNA level (only if aggregation_mode is “aggfunc”).min_valid (
int) – Minimum number of valid nodes that pass the filter for keeping the RNA (only if aggregation_mode is “min_valid”).
Example
Keep RNAs with at least 1 chemically modified residue:
>>> from rnaglib.dataset import RNADataset >>> from rnaglib.transforms import ResidueAttributeFilter >>> dset = RNADataset(debug=True) >>> t = ResidueAttributeFilter(attribute='is_modified', value_checker: lambda val: val == True, min_valid=1) >>> len(dset) >>> rnas = list(t(dset)) >>> len(rnas)
- __init__(attribute, aggregation_mode='min_valid', value_checker=None, min_valid=1, aggfunc=None, **kwargs)[source]¶
Methods
__init__(attribute[, aggregation_mode, ...])forward(data)Returns true/ or false on the given RNA