Trees | Indices | Help |
|
---|
|
object --+ | ??.instance --+ | rdchem.Mol --+ | PropertyMol
allows rdkit molecules to be pickled with their properties saved. >>> from rdkit.six.moves import cPickle >>> m = Chem.MolFromMolFile('test_data/benzene.mol') >>> m.GetProp('_Name') 'benzene.mol' by default pickling removes properties: >>> m2 = cPickle.loads(cPickle.dumps(m)) >>> m2.HasProp('_Name') 0 Property mols solve this: >>> pm = PropertyMol(m) >>> pm.GetProp('_Name') 'benzene.mol' >>> pm.SetProp('MyProp','foo') >>> pm.HasProp('MyProp') 1 >>> pm2 = cPickle.loads(cPickle.dumps(pm)) >>> Chem.MolToSmiles(pm2) 'c1ccccc1' >>> pm2.GetProp('_Name') 'benzene.mol' >>> pm2.HasProp('MyProp') 1 >>> pm2.GetProp('MyProp') 'foo' >>> pm2.HasProp('MissingProp') 0 Property mols are a bit more permissive about the types of property values: >>> pm.SetProp('IntVal',1) That wouldn't work with a standard mol but the Property mols still convert all values to strings before storing: >>> pm.GetProp('IntVal') '1' This is a test for sf.net issue 2880943: make sure properties end up in SD files: >>> import tempfile,os >>> fn = tempfile.mktemp('.sdf') >>> w = Chem.SDWriter(fn) >>> w.write(pm) >>> w=None >>> txt = open(fn,'r').read() >>> '<IntVal>' in txt True >>> try: ... os.unlink(fn) ... except Exception: ... pass The next level of that bug: does writing a *depickled* propertymol to an SD file include properties: >>> fn = tempfile.mktemp('.sdf') >>> w = Chem.SDWriter(fn) >>> pm = cPickle.loads(cPickle.dumps(pm)) >>> w.write(pm) >>> w=None >>> txt = open(fn,'r').read() >>> '<IntVal>' in txt True >>> try: ... os.unlink(fn) ... except Exception: ... pass
|
|||
__getstate_manages_dict__ = True
|
|||
Inherited from |
|
|||
Inherited from |
|
__init__( (object)arg1) -> None : Constructor, takes no arguments C++ signature : void __init__(_object*) __init__( (object)arg1, (str)arg2) -> None : C++ signature : void __init__(_object*,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) __init__( (object)arg1, (Mol)arg2) -> None : C++ signature : void __init__(_object*,RDKit::ROMol) __init__( (object)arg1, (Mol)arg2, (bool)arg3) -> None : C++ signature : void __init__(_object*,RDKit::ROMol,bool) __init__( (object)arg1, (Mol)arg2, (bool)arg3, (int)arg4) -> None : C++ signature : void __init__(_object*,RDKit::ROMol,bool,int)
|
SetProp( (Mol)self, (str)key, (str)val [, (bool)computed=False]) -> None : Sets a molecular property ARGUMENTS: - key: the name of the property to be set (a string). - value: the property value (a string). - computed: (optional) marks the property as being computed. Defaults to False. C++ signature : void SetProp(RDKit::ROMol,char const*,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > [,bool=False])
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Aug 25 09:14:52 2016 | http://epydoc.sourceforge.net |