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 :type value_checker: Optional[Callable] :param value_checker: function with accepts the value of the desired attribute and returns True/False :type aggfunc: Optional[Callable] :param aggfunc: function to aggregate the residue labels at the RNA level (only if aggregarion_mode is “aggfunc”) :type min_valid: int :param min_valid: minium 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.data_loading 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