Hi Shaozhen,

that parameter can be accessed from Python, it is called maxProducts, and it defaults to 1000 as described in the Python API docs:

http://www.rdkit.org/docs/source/rdkit.Chem.rdChemReactions.html?highlight=runreactants#rdkit.Chem.rdChemReactions.ChemicalReaction.RunReactants

Cheers,
p.

On 11/15/18 16:52, Francis Atkinson wrote:

I don't know how you access that parameter from Pythonn, I'm afraid.

Maybe someone else here can help?

On 15/11/2018 12:47, ?????? wrote:

Dear Atkinson:
From rdkit document, I found there is a parameter named numProducts in RunReactants function, this parameter can limit the products number, and it defaults to 1000. How can I change this parameter??If I change this number to a small one , I may change the run time.
I hope to solve this problem very much.

Thanks a lot.
Kind regards
Shaozhen


------------------?0?2?????????0?2------------------
*??????:*?0?2"Francis Atkinson"<[email protected]>;
*????????:*?0?22018??11??15??(??????) ????7:02
*??????:*?0?2"??????"<[email protected]>;
*????:*?0?2Re: ?????? [Rdkit-discuss] Help: How to set timeout for the function namedRunReactants

Shaozhen,

?0?2?0?2?0?2 OK, this doesn't work for me either on my Mac, but does work as expected on Linux (RHEL7). I'm afraid I really don't know why!

?0?2?0?2?0?2 I also don't know if this is something is to do with the version of MacOS; I tend to do development on a Mac, but run large jobs on Linux, so I might simply not have noticed this failure on the Mac before.

?0?2?0?2?0?2 ?0?2?0?2?0?2 Francis

On 15/11/2018 10:14, ?????? wrote:
Hi?0?2Atkinson:
Thanks so much, and I have taken your?0?2 advice.(I saved the code as timeout.py ,and put it on '/Users/ding/Desktop' )
But?0?2 it cannot resolve my problems.
My operating system is Mac OS.
It works well in the function mytest (in the following code).
But It cannot work in the function reaction_predict_outside (in the following code).
If I don??t stop this function, it always make my computer down.

Could you please help me to solve this trouble?
Kind regards.
Shaozhen

>>import sys
>>sys.path.insert(0,'/Users/ding/Desktop')
>>from timeout import timeout
>>import time
>>import rdkit.Chem as Chem
>>from rdkit.Chem import AllChem
>>from rdkit.Chem import MolFromSmiles

@timeout(1)
def mytest():
print 'start'
try:
for i in range(1,10):
time.sleep(10)
except:
print 'finish'



@timeout(1)
def reaction_predict_outside(rule,rxnrs):
print 'start'
try:
rxn = AllChem.ReactionFromSmarts(rule)
outcomes = rxn.RunReactants(rxnrs)
except:
return []

if __name__ == '__main__':
mytest()
reactants = ['CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCOP(=O)(O)OP(=O)(O)O'] rule = '[O:10][P:11](=[O:12])([O:13])[O:14].[O:40][P:41](=[O:42])([O:43])[O:44].[O:30][P:31](=[O:32])([O:33])[O:34].[O:50][P:51](=[O:52])([O:53])[O:54].[O:20][P:21](=[O:22])([O:23])[O:24].[C:1]([CH3:2])=[C:3][C:4][CH2:5][C:6]([CH3:7])=[C:8][C:9][CH2:25][C:26]([CH3:27])=[C:28][C:29][CH2:35][C:36]([CH3:37])=[C:38][C:39][CH2:45][C:46]([CH3:47])=[C:48][C:49][CH2:55][C:56]([CH3:57])=[C:58][C:59][O:0]>>[C:1]([CH3:2])=[C:3][C:4][O:0].[CH2:5]=[C:6]([CH3:7])[C:8][C:9][O:10][P:11](=[O:12])([O:13])[O:14].[CH2:25]=[C:26]([CH3:27])[C:28][C:29][O:20][P:21](=[O:22])([O:23])[O:24].[CH2:45]=[C:46]([CH3:47])[C:48][C:49][O:40][P:41](=[O:42])([O:43])[O:44].[CH2:35]=[C:36]([CH3:37])[C:38][C:39][O:30][P:31](=[O:32])([O:33])[O:34].[CH2:55]=[C:56]([CH3:57])[C:58][C:59][O:50][P:51](=[O:52])([O:53])[O:54]'
rxnrs = [Chem.MolFromSmiles(reactant) for reactant in reactants]
print reaction_predict_outside(rule,rxnrs)





------------------?0?2?????????0?2------------------
*??????:*?0?2"Francis Atkinson"<[email protected]>;
*????????:*?0?22018??11??15??(??????) ????5:03
*??????:*?0?2"rdkit-discuss"<[email protected]>;
*????:*?0?2Re: [Rdkit-discuss] Help: How to set timeout for the function namedRunReactants

Shaozen,

?0?2?0?2?0?2 I have successfully used the solution outlined in this SO answer 
...

https://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish

?0?2?0?2?0?2 It uses Posix signals so it wouldn't work on older versions of Windows (I don't know about Windows 10, what with this new Linux-compatibility layer). It also doesn't work when running under mod_wsgi.

?0?2?0?2?0?2 ?0?2?0?2?0?2 Francis

On 15/11/2018 04:21, ?????? wrote:
Hi:
I want to set?0?2timeout for the function named RunReactants, because sometimes?0?2I found there needs over 10 minutes when running this function. For example:

>>import rdkit.Chem as Chem
>>from rdkit.Chem import AllChem
>>from rdkit.Chem import MolFromSmiles,MolFromSmarts
>>from rdkit.Chem.Fingerprints import FingerprintMols
>>reactants = ['CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C)=CC=CC=C(C)C=CC=C(C)C=CC1=C(C)C(=O)C(OP(=O)(O)O)CC1(C)C', 'CC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCCC(C)=CCOP(=O)(O)OP(=O)(O)O'] >>rule = '[O:10][P:11](=[O:12])([O:13])[O:14].[O:40][P:41](=[O:42])([O:43])[O:44].[O:30][P:31](=[O:32])([O:33])[O:34].[O:50][P:51](=[O:52])([O:53])[O:54].[O:20][P:21](=[O:22])([O:23])[O:24].[C:1]([CH3:2])=[C:3][C:4][CH2:5][C:6]([CH3:7])=[C:8][C:9][CH2:25][C:26]([CH3:27])=[C:28][C:29][CH2:35][C:36]([CH3:37])=[C:38][C:39][CH2:45][C:46]([CH3:47])=[C:48][C:49][CH2:55][C:56]([CH3:57])=[C:58][C:59][O:0]>>[C:1]([CH3:2])=[C:3][C:4][O:0].[CH2:5]=[C:6]([CH3:7])[C:8][C:9][O:10][P:11](=[O:12])([O:13])[O:14].[CH2:25]=[C:26]([CH3:27])[C:28][C:29][O:20][P:21](=[O:22])([O:23])[O:24].[CH2:45]=[C:46]([CH3:47])[C:48][C:49][O:40][P:41](=[O:42])([O:43])[O:44].[CH2:35]=[C:36]([CH3:37])[C:38][C:39][O:30][P:31](=[O:32])([O:33])[O:34].[CH2:55]=[C:56]([CH3:57])[C:58][C:59][O:50][P:51](=[O:52])([O:53])[O:54]'
>>rxnrs = [Chem.MolFromSmiles(reactant) for reactant in reactants]
>>rxn = AllChem.ReactionFromSmarts(rule)
>>outcomes = rxn.RunReactants(rxnrs)
if this functions cannnot return result within 3s, I will make it return a empty set.
Could you help me deal with this problems?
Thanks a lot.
Yours
Shaozhen



_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
--
Dr Francis L Atkinson

Chemogenomics Group
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom

(01223) 494473
--
Dr Francis L Atkinson

Chemogenomics Group
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom

(01223) 494473
--
Dr Francis L Atkinson

Chemogenomics Group
European Bioinformatics Institute (EMBL-EBI)
European Molecular Biology Laboratory
Wellcome Genome Campus
Hinxton
Cambridge CB10 1SD
United Kingdom

(01223) 494473




_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to