rdkit.VLib.NodeLib.SDSupply

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  from rdkit import Chem
     7  from rdkit import six
     8  from rdkit.VLib.Supply import SupplyNode
     9
    10
    11 -class SDSupplyNode(SupplyNode):
    12    """ SD supplier
    13
    14    Sample Usage:
    15      >>> import os
    16      >>> from rdkit import RDConfig
    17      >>> fileN = os.path.join(RDConfig.RDCodeDir,'VLib','NodeLib',\
    18                               'test_data','NCI_aids.10.sdf')
    19      >>> suppl = SDSupplyNode(fileN)
    20      >>> ms = [x for x in suppl]
    21      >>> len(ms)
    22      10
    23      >>> ms[0].GetProp("_Name")
    24      '48'
    25      >>> ms[1].GetProp("_Name")
    26      '78'
    27      >>> suppl.reset()
    28      >>> suppl.next().GetProp("_Name")
    29      '48'
    30      >>> suppl.next().GetProp("_Name")
    31      '78'
    32
    33    """
    34
    35 -  def __init__(self, fileName, **kwargs):
    36      SupplyNode.__init__(self, **kwargs)
    37      self._fileName = fileName
    38      self._supplier = Chem.SDMolSupplier(self._fileName)
    39
    40 -  def reset(self):
    41      SupplyNode.reset(self)
    42      self._supplier.reset()
    43
    44 -  def next(self):
    45      """
    46
    47      """
    48      return next(self._supplier)
    49
    50
    51  if six.PY3:
    52    SDSupplyNode.__next__ = SDSupplyNode.next
    53
    54
    55  # ------------------------------------
    56  #
    57  #  doctest boilerplate
    58  #
    59 -def _runDoctests(verbose=None):  # pragma: nocover
    60    import sys
    61    import doctest
    62    failed, _ = doctest.testmod(optionflags=doctest.ELLIPSIS, verbose=verbose)
    63    sys.exit(failed)
    64
    65
    66  if __name__ == '__main__':  # pragma: nocover
    67    _runDoctests()
    68