VLib.NodeLib.SDSupply

Package VLib :: Package NodeLib :: Module SDSupply |
[hide private]
[frames] | no frames]

# Source Code for Module VLib.NodeLib.SDSupply

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