Skip to content

Commit

Permalink
new transform
Browse files Browse the repository at this point in the history
  • Loading branch information
luiswyss committed Oct 4, 2024
1 parent 5e75c26 commit cb7a42d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/rnaglib/transforms/annotate/binding_sites.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from rnaglib.transforms import AnnotationTransform

from networkx import set_node_attributes

class BindingSiteAnnotator(AnnotationTransform):
def forward (self, rna_dict: dict) -> dict:
binding_sites = {
node: self._has_binding_site(nodedata)
for node, nodedata in rna_dict['rna'].nodes(data=True)
}
set_node_attributes(rna_dict['rna'], binding_sites, "binding_site")
return rna_dict

@staticmethod
def _has_binding_site(nodedata: dict) -> bool:
return any(
nodedata.get(binding_type) is not None
for binding_type in ('binding_small-molecule', 'binding_ion')
)

0 comments on commit cb7a42d

Please sign in to comment.