Package rdkit :: Package VLib :: Package NodeLib :: Module SDSupply

[hide private]
[frames] | no frames]

# Source Code for Module rdkit.VLib.NodeLib.SDSupply

     1  #  $Id$
     2  #
     3  #  Copyright (C) 2003 Rational Discovery LLC
     4  #     All Rights Reserved
     5  #
     6  import sys,os.path
     7  from rdkit import six
     8  from rdkit import RDConfig
     9  from rdkit.VLib.Supply import SupplyNode
    10  from rdkit import Chem
    11
    12 -class SDSupplyNode(SupplyNode):
    13    """ SD supplier
    14
    15    Sample Usage:
    16      >>> fileN = os.path.join(RDConfig.RDCodeDir,'VLib','NodeLib',\
    17                               'test_data','NCI_aids.10.sdf')
    18      >>> suppl = SDSupplyNode(fileN)
    19      >>> ms = [x for x in suppl]
    20      >>> len(ms)
    21      10
    22      >>> ms[0].GetProp("_Name")
    23      '48'
    24      >>> ms[1].GetProp("_Name")
    25      '78'
    26      >>> suppl.reset()
    27      >>> suppl.next().GetProp("_Name")
    28      '48'
    29      >>> suppl.next().GetProp("_Name")
    30      '78'
    31
    32
    33    """
    34 -  def __init__(self,fileName,**kwargs):
    35      SupplyNode.__init__(self,**kwargs)
    36      self._fileName = fileName
    37      self._supplier = Chem.SDMolSupplier(self._fileName)
    38
    39 -  def reset(self):
    40      SupplyNode.reset(self)
    41      self._supplier.reset()
    42 -  def next(self):
    43      """
    44
    45      """
    46      return next(self._supplier)
    47
    48  if six.PY3:
    49      SDSupplyNode.__next__ = SDSupplyNode.next
    50
    51
    52  #------------------------------------
    53  #
    54  #  doctest boilerplate
    55  #
    56 -def _test():
    57    import doctest,sys
    58    return doctest.testmod(sys.modules["__main__"])
    59
    60
    61  if __name__ == '__main__':
    62    import sys
    63    failed,tried = _test()
    64    sys.exit(failed)
    65