mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
fix NodeLib
This commit is contained in:
Binary file not shown.
@@ -4,6 +4,7 @@
|
||||
# All Rights Reserved
|
||||
#
|
||||
import sys,os.path
|
||||
from rdkit import six
|
||||
from rdkit import RDConfig
|
||||
from rdkit.VLib.Supply import SupplyNode
|
||||
from rdkit import Chem
|
||||
@@ -42,7 +43,10 @@ class SDSupplyNode(SupplyNode):
|
||||
"""
|
||||
|
||||
"""
|
||||
return self._supplier.next()
|
||||
return next(self._supplier)
|
||||
|
||||
if six.PY3:
|
||||
SDSupplyNode.__next__ = SDSupplyNode.next
|
||||
|
||||
|
||||
#------------------------------------
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# All Rights Reserved
|
||||
#
|
||||
from rdkit import RDConfig
|
||||
from rdkit import six
|
||||
import sys,os,types
|
||||
from rdkit import Chem
|
||||
from rdkit.VLib.Filter import FilterNode
|
||||
@@ -69,7 +70,7 @@ class SmartsFilter(FilterNode):
|
||||
for i in range(nPatts):
|
||||
p = patterns[i]
|
||||
c = counts[i]
|
||||
if type(p) in types.StringTypes:
|
||||
if type(p) in (str,bytes):
|
||||
m = Chem.MolFromSmarts(p)
|
||||
if not m:
|
||||
raise ValueError('bad smarts: %s'%(p))
|
||||
@@ -89,6 +90,8 @@ class SmartsFilter(FilterNode):
|
||||
res = 1
|
||||
break
|
||||
return res
|
||||
if six.PY3:
|
||||
SmartsFilter.__next__ = SmartsFilter.next
|
||||
|
||||
#------------------------------------
|
||||
#
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# All Rights Reserved
|
||||
#
|
||||
from rdkit import RDConfig
|
||||
from rdkit import six
|
||||
import sys,os,types
|
||||
from rdkit import Chem
|
||||
from rdkit.VLib.Transform import TransformNode
|
||||
@@ -84,7 +85,7 @@ class SmartsRemover(TransformNode):
|
||||
targets = [None]*nPatts
|
||||
for i in range(nPatts):
|
||||
p = patterns[i]
|
||||
if type(p) in types.StringTypes:
|
||||
if type(p) in (str,bytes):
|
||||
m = Chem.MolFromSmarts(p)
|
||||
if not m:
|
||||
raise ValueError('bad smarts: %s'%(p))
|
||||
@@ -99,6 +100,10 @@ class SmartsRemover(TransformNode):
|
||||
#sys.stderr.write('\t\tAfter %s: %s\n'%(Chem.MolToSmiles(patt),Chem.MolToSmiles(cmpd)))
|
||||
|
||||
return cmpd
|
||||
|
||||
if six.PY3:
|
||||
SmartsRemover.__next__ = SmartsRemover.next
|
||||
|
||||
|
||||
biggerTest="""
|
||||
>>> smis = ['CCOC','CCO.Cl','CC(=O)[O-].[Na+]','OCC','C[N+](C)(C)C.[Cl-]']
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# All Rights Reserved
|
||||
#
|
||||
from rdkit import RDConfig
|
||||
from rdkit import six
|
||||
import sys,os
|
||||
from rdkit import Chem
|
||||
from rdkit.VLib.Filter import FilterNode
|
||||
@@ -52,6 +53,8 @@ class DupeFilter(FilterNode):
|
||||
else:
|
||||
return 0
|
||||
|
||||
if six.PY3:
|
||||
DupeFilter.__next__ = DupeFilter.next
|
||||
#------------------------------------
|
||||
#
|
||||
# doctest boilerplate
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#
|
||||
import sys,types
|
||||
from rdkit import Chem
|
||||
from rdkit import six
|
||||
|
||||
|
||||
from rdkit.VLib.Output import OutputNode as BaseOutputNode
|
||||
|
||||
@@ -23,14 +25,14 @@ class OutputNode(BaseOutputNode):
|
||||
>>> mols = [Chem.MolFromSmiles(x) for x in smis]
|
||||
>>> from rdkit.VLib.Supply import SupplyNode
|
||||
>>> suppl = SupplyNode(contents=mols)
|
||||
>>> import StringIO
|
||||
>>> io = StringIO.StringIO()
|
||||
>>> node = OutputNode(dest=io,delim=', ')
|
||||
>>> from io import StringIO
|
||||
>>> sio = StringIO()
|
||||
>>> node = OutputNode(dest=sio,delim=', ')
|
||||
>>> node.AddParent(suppl)
|
||||
>>> ms = [x for x in node]
|
||||
>>> len(ms)
|
||||
4
|
||||
>>> txt = io.getvalue()
|
||||
>>> txt = sio.getvalue()
|
||||
>>> repr(txt)
|
||||
"'1, C1CCC1\\\\n2, C1CC1\\\\n3, C=O\\\\n4, CCN\\\\n'"
|
||||
|
||||
@@ -48,7 +50,7 @@ class OutputNode(BaseOutputNode):
|
||||
|
||||
def smilesOut(self,mol):
|
||||
self._nDumped += 1
|
||||
if type(mol) in [types.TupleType,types.ListType]:
|
||||
if type(mol) in (tuple,list):
|
||||
args = mol
|
||||
mol = args[0]
|
||||
if len(args)>1:
|
||||
@@ -66,6 +68,8 @@ class OutputNode(BaseOutputNode):
|
||||
outp = [label,smi]+args
|
||||
return '%s\n'%(self._delim.join(outp))
|
||||
|
||||
if six.PY3:
|
||||
OutputNode.__next__ = OutputNode.next
|
||||
|
||||
#------------------------------------
|
||||
#
|
||||
|
||||
@@ -7,6 +7,8 @@ import sys,os.path
|
||||
from rdkit import RDConfig
|
||||
from rdkit.VLib.Supply import SupplyNode
|
||||
from rdkit import Chem
|
||||
from rdkit import six
|
||||
|
||||
|
||||
class SmilesSupplyNode(SupplyNode):
|
||||
""" Smiles supplier
|
||||
@@ -52,9 +54,11 @@ class SmilesSupplyNode(SupplyNode):
|
||||
"""
|
||||
r = None
|
||||
while not r:
|
||||
r = self._supplier.next()
|
||||
r = next(self._supplier)
|
||||
return r
|
||||
|
||||
if six.PY3:
|
||||
SmilesSupplyNode.__next__ = SmilesSupplyNode.next
|
||||
|
||||
#------------------------------------
|
||||
#
|
||||
|
||||
@@ -13,3 +13,9 @@ tests=[
|
||||
longTests=[
|
||||
|
||||
]
|
||||
|
||||
if __name__=='__main__':
|
||||
import sys
|
||||
from rdkit import TestRunner
|
||||
failed,tests = TestRunner.RunScript('test_list.py',0,1)
|
||||
sys.exit(len(failed))
|
||||
|
||||
Reference in New Issue
Block a user