@@ -421,13 +421,20 @@ def min_hierarchy(self):
421421 """int : Return the smallest hierarchy level"""
422422 return min (self .get_hierarchy_sizes ())
423423
424- def get_scaffolds_in_hierarchy (self , hierarchy ):
424+ def get_scaffolds_in_hierarchy (self , hierarchy , data = False , default = None ):
425425 """Return a generator of all scaffolds within a specified hierarchy.
426426
427427 Parameters
428428 ----------
429429 hierarchy : int
430430 The hierarchy level to retrieve.
431+ data : str, bool, optional
432+ The scaffold node attribute returned in 2-tuple (n, ddict[data]).
433+ If True, return entire node attribute dict as (n, ddict).
434+ If False, return just the nodes n. The default is False.
435+ default : value, bool, optional
436+ Value used for nodes that don't have the requested attribute.
437+ Only relevant if data is not True or False.
431438
432439 Returns
433440 -------
@@ -438,7 +445,12 @@ def get_scaffolds_in_hierarchy(self, hierarchy):
438445 """
439446 for s , d in self .get_scaffold_nodes (data = True ):
440447 if d ['hierarchy' ] == int (hierarchy ):
441- yield s
448+ if data is False :
449+ yield s
450+ elif data is True :
451+ yield (s , d )
452+ else :
453+ yield (s , d .get (data , default ))
442454
443455 def scaffold_in_graph (self , scaffold_smiles ):
444456 """Returns True if the specified scaffold SMILES is in the scaffold graph.
0 commit comments