Sanitization error applying reaction to molecule RDKitWhy do backslashes appear twice?Import error: No module name urllib2error: Unable to find vcvarsall.batfatal error: Python.h: No such file or directoryHow to make a python organic chemistry retro-synthesis generator?Installing RDKitError MolFromSmiles - RDkitHow to use RDKit to calculte molecular fingerprint and similarity of a list of SMILE structures?installing rdkit and deepchem on anacondaHot to use RDKit to read and process millions of molecules in parallel?How to protonate a molecule in rdkit?
What is the name of this plot that has rows with two connected dots?
Availability Groups automatic failover is not so automatic
Recommended Breathing Exercises to Play Woodwinds
Why didn't Doc believe Marty was from the future?
Could the UK amend the European Withdrawal Act and revoke the Article 50 invocation?
Why does a sticker slowly peel off, but if it is pulled quickly it tears?
Can someone identify this unusual plane at airport?
Find most "academic" implementation of doubly linked list
How to prevent a hosting company from accessing a VM's encryption keys?
Can I Prove Schröder-Bernstein With Just Definition of Bijection?
Why did Lucius make a deal out of Buckbeak hurting Draco but not about Draco being turned into a ferret?
How to determine algebraically whether an equation has an infinite solutions or not?
Did anybody find out it was Anakin who blew up the command center?
Unlock your Lock
GDPR: What happens to deleted contacts re-entered through imports
Videos of surgery
What to do about my 1-month-old boy peeing through diapers?
Is there a word or phrase that means "use other people's wifi or Internet service without consent"?
Why did James Cameron decide to give Alita big eyes?
Did ancient peoples ever hide their treasure behind puzzles?
The term Feed-forward and its meaning?
Is there any problem with a full installation on a USB drive?
Can I take a boxed bicycle on a German train?
Why is sh (not bash) complaining about functions defined in my .bashrc?
Sanitization error applying reaction to molecule RDKit
Why do backslashes appear twice?Import error: No module name urllib2error: Unable to find vcvarsall.batfatal error: Python.h: No such file or directoryHow to make a python organic chemistry retro-synthesis generator?Installing RDKitError MolFromSmiles - RDkitHow to use RDKit to calculte molecular fingerprint and similarity of a list of SMILE structures?installing rdkit and deepchem on anacondaHot to use RDKit to read and process millions of molecules in parallel?How to protonate a molecule in rdkit?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Sanitization error while applying a reaction to an molecule with wedged bond.
I am getting this error while applying a proton removal reaction to a molecule but I do not see any error in MolBlock information.
This is for a reaction problem in which I am trying to apply a simple reaction (proton removal) to a molecule given its isomeric SMILES.
I create a function to apply reaction using SMARTS and SMILES but I am getting the following error which I could not fixed.
I am using the following code to load my inputs.
smile = rdkit.Chem.rdmolfiles.MolToSmiles(mol,isomericSmiles=True)
which leads to:
C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1
I create the following dictionary to use my SMILES and SMARTS:
reaction_smarts =
# proton removal reaction
reaction_smarts["proton_removal"] = "[Ch:1]-[C+1:2]>>[C:1]=[C+0:2].[H+]"
reactions = name: AllChem.ReactionFromSmarts(reaction_smarts[name]) for name in reaction_smarts
# function to run reactions
def run_reaction(molecule, reaction):
products = []
for product in reaction.RunReactant(molecule, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
return products
# apply reaction
products = run_reaction(cation_to_rdkit_mol["mol_name"], reactions["proton_removal"])
At this step I am getting this error but I cannot fix it.
RDKit ERROR: [10:43:23] Explicit valence for atom # 0 C, 5, is greater than permitted
Expected results should be the the molecule with the double bond and its stereoisomers:
First product: CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1
Second product: C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1
Third product: C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1
I am using Chem.EnumerateStereoisomers.EnumerateStereoisomers()
to get all stereoisomers but I am just getting the first and second product. I also added your initial proposal product[0].GetAtomWithIdx(0).SetNumExplicitHs(0)
which actually fix the Explicit valence error. But now I am trying to figure it out how to get all that three stereoisomers.
Any hint why this is happening?, cause if I check the mol block with all the info about valence it seems to be fine.
python python-3.x rdkit
add a comment |
Sanitization error while applying a reaction to an molecule with wedged bond.
I am getting this error while applying a proton removal reaction to a molecule but I do not see any error in MolBlock information.
This is for a reaction problem in which I am trying to apply a simple reaction (proton removal) to a molecule given its isomeric SMILES.
I create a function to apply reaction using SMARTS and SMILES but I am getting the following error which I could not fixed.
I am using the following code to load my inputs.
smile = rdkit.Chem.rdmolfiles.MolToSmiles(mol,isomericSmiles=True)
which leads to:
C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1
I create the following dictionary to use my SMILES and SMARTS:
reaction_smarts =
# proton removal reaction
reaction_smarts["proton_removal"] = "[Ch:1]-[C+1:2]>>[C:1]=[C+0:2].[H+]"
reactions = name: AllChem.ReactionFromSmarts(reaction_smarts[name]) for name in reaction_smarts
# function to run reactions
def run_reaction(molecule, reaction):
products = []
for product in reaction.RunReactant(molecule, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
return products
# apply reaction
products = run_reaction(cation_to_rdkit_mol["mol_name"], reactions["proton_removal"])
At this step I am getting this error but I cannot fix it.
RDKit ERROR: [10:43:23] Explicit valence for atom # 0 C, 5, is greater than permitted
Expected results should be the the molecule with the double bond and its stereoisomers:
First product: CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1
Second product: C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1
Third product: C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1
I am using Chem.EnumerateStereoisomers.EnumerateStereoisomers()
to get all stereoisomers but I am just getting the first and second product. I also added your initial proposal product[0].GetAtomWithIdx(0).SetNumExplicitHs(0)
which actually fix the Explicit valence error. But now I am trying to figure it out how to get all that three stereoisomers.
Any hint why this is happening?, cause if I check the mol block with all the info about valence it seems to be fine.
python python-3.x rdkit
add a comment |
Sanitization error while applying a reaction to an molecule with wedged bond.
I am getting this error while applying a proton removal reaction to a molecule but I do not see any error in MolBlock information.
This is for a reaction problem in which I am trying to apply a simple reaction (proton removal) to a molecule given its isomeric SMILES.
I create a function to apply reaction using SMARTS and SMILES but I am getting the following error which I could not fixed.
I am using the following code to load my inputs.
smile = rdkit.Chem.rdmolfiles.MolToSmiles(mol,isomericSmiles=True)
which leads to:
C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1
I create the following dictionary to use my SMILES and SMARTS:
reaction_smarts =
# proton removal reaction
reaction_smarts["proton_removal"] = "[Ch:1]-[C+1:2]>>[C:1]=[C+0:2].[H+]"
reactions = name: AllChem.ReactionFromSmarts(reaction_smarts[name]) for name in reaction_smarts
# function to run reactions
def run_reaction(molecule, reaction):
products = []
for product in reaction.RunReactant(molecule, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
return products
# apply reaction
products = run_reaction(cation_to_rdkit_mol["mol_name"], reactions["proton_removal"])
At this step I am getting this error but I cannot fix it.
RDKit ERROR: [10:43:23] Explicit valence for atom # 0 C, 5, is greater than permitted
Expected results should be the the molecule with the double bond and its stereoisomers:
First product: CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1
Second product: C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1
Third product: C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1
I am using Chem.EnumerateStereoisomers.EnumerateStereoisomers()
to get all stereoisomers but I am just getting the first and second product. I also added your initial proposal product[0].GetAtomWithIdx(0).SetNumExplicitHs(0)
which actually fix the Explicit valence error. But now I am trying to figure it out how to get all that three stereoisomers.
Any hint why this is happening?, cause if I check the mol block with all the info about valence it seems to be fine.
python python-3.x rdkit
Sanitization error while applying a reaction to an molecule with wedged bond.
I am getting this error while applying a proton removal reaction to a molecule but I do not see any error in MolBlock information.
This is for a reaction problem in which I am trying to apply a simple reaction (proton removal) to a molecule given its isomeric SMILES.
I create a function to apply reaction using SMARTS and SMILES but I am getting the following error which I could not fixed.
I am using the following code to load my inputs.
smile = rdkit.Chem.rdmolfiles.MolToSmiles(mol,isomericSmiles=True)
which leads to:
C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1
I create the following dictionary to use my SMILES and SMARTS:
reaction_smarts =
# proton removal reaction
reaction_smarts["proton_removal"] = "[Ch:1]-[C+1:2]>>[C:1]=[C+0:2].[H+]"
reactions = name: AllChem.ReactionFromSmarts(reaction_smarts[name]) for name in reaction_smarts
# function to run reactions
def run_reaction(molecule, reaction):
products = []
for product in reaction.RunReactant(molecule, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
return products
# apply reaction
products = run_reaction(cation_to_rdkit_mol["mol_name"], reactions["proton_removal"])
At this step I am getting this error but I cannot fix it.
RDKit ERROR: [10:43:23] Explicit valence for atom # 0 C, 5, is greater than permitted
Expected results should be the the molecule with the double bond and its stereoisomers:
First product: CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1
Second product: C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1
Third product: C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1
I am using Chem.EnumerateStereoisomers.EnumerateStereoisomers()
to get all stereoisomers but I am just getting the first and second product. I also added your initial proposal product[0].GetAtomWithIdx(0).SetNumExplicitHs(0)
which actually fix the Explicit valence error. But now I am trying to figure it out how to get all that three stereoisomers.
Any hint why this is happening?, cause if I check the mol block with all the info about valence it seems to be fine.
python python-3.x rdkit
python python-3.x rdkit
edited Apr 1 at 16:26
Fence
asked Mar 27 at 20:25
FenceFence
669 bronze badges
669 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The Error is stating that the Explicit valence for atom 0 (Carbon) is 5, this would suggest that the explicit hydrogen hasn't been removed although the bond is now a double bond, hence a valence of 5. I am not too familiar with reaction SMARTS although an easy way to fix this manually would be to set the number of explicit hydrogens on atom 0 to 0 before you sanitize:
product.GetAtomWithIdx(0).SetNumExplicitHs(0)
Chem.SanitizeMol(product)
Edit 1:
Scratch that, I did some experimentation, try this reaction:
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
This way in the reaction definition we explicitly state that a hydrogen is lost and the resultant molecule will sanitize. Does this work for you?
Edit 2:
When I run this reaction the product does not seem to contain a cation:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
products = list()
for product in rxn.RunReactant(mol, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
print(Chem.MolToSmiles(products[0]))
Output:
'CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1'
Edit 3:
I think I now understand what you are looking for:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
# Reactant SMARTS
reactant_smarts = '[CH3:1][C+:2][C@@H:3]'
# Product SMARTS
product_smarts = [
'[CH2:1]=[CH0+0:2][CH:3]',
'[CH2:1]=[CH0+0:2][C@H:3]',
'[CH2:1]=[CH0+0:2][C@@H:3]',
]
# Reaction SMARTS
reaction_smarts = str(reactant_smarts + '>>' + '.'.join(product_smarts))
# RDKit Reaction
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
# Get Products
results = list()
for products in rxn.RunReactant(mol, 0):
for product in products:
Chem.SanitizeMol(product)
results.append(product)
print(Chem.MolToSmiles(product))
Output:
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
Note that we get the same products twice, I think this is because the reactant SMARTS matches both CH3 groups, hence the reaction is applied to both. I hope this is what you are looking for.
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385877%2fsanitization-error-applying-reaction-to-molecule-rdkit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The Error is stating that the Explicit valence for atom 0 (Carbon) is 5, this would suggest that the explicit hydrogen hasn't been removed although the bond is now a double bond, hence a valence of 5. I am not too familiar with reaction SMARTS although an easy way to fix this manually would be to set the number of explicit hydrogens on atom 0 to 0 before you sanitize:
product.GetAtomWithIdx(0).SetNumExplicitHs(0)
Chem.SanitizeMol(product)
Edit 1:
Scratch that, I did some experimentation, try this reaction:
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
This way in the reaction definition we explicitly state that a hydrogen is lost and the resultant molecule will sanitize. Does this work for you?
Edit 2:
When I run this reaction the product does not seem to contain a cation:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
products = list()
for product in rxn.RunReactant(mol, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
print(Chem.MolToSmiles(products[0]))
Output:
'CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1'
Edit 3:
I think I now understand what you are looking for:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
# Reactant SMARTS
reactant_smarts = '[CH3:1][C+:2][C@@H:3]'
# Product SMARTS
product_smarts = [
'[CH2:1]=[CH0+0:2][CH:3]',
'[CH2:1]=[CH0+0:2][C@H:3]',
'[CH2:1]=[CH0+0:2][C@@H:3]',
]
# Reaction SMARTS
reaction_smarts = str(reactant_smarts + '>>' + '.'.join(product_smarts))
# RDKit Reaction
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
# Get Products
results = list()
for products in rxn.RunReactant(mol, 0):
for product in products:
Chem.SanitizeMol(product)
results.append(product)
print(Chem.MolToSmiles(product))
Output:
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
Note that we get the same products twice, I think this is because the reactant SMARTS matches both CH3 groups, hence the reaction is applied to both. I hope this is what you are looking for.
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
|
show 2 more comments
The Error is stating that the Explicit valence for atom 0 (Carbon) is 5, this would suggest that the explicit hydrogen hasn't been removed although the bond is now a double bond, hence a valence of 5. I am not too familiar with reaction SMARTS although an easy way to fix this manually would be to set the number of explicit hydrogens on atom 0 to 0 before you sanitize:
product.GetAtomWithIdx(0).SetNumExplicitHs(0)
Chem.SanitizeMol(product)
Edit 1:
Scratch that, I did some experimentation, try this reaction:
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
This way in the reaction definition we explicitly state that a hydrogen is lost and the resultant molecule will sanitize. Does this work for you?
Edit 2:
When I run this reaction the product does not seem to contain a cation:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
products = list()
for product in rxn.RunReactant(mol, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
print(Chem.MolToSmiles(products[0]))
Output:
'CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1'
Edit 3:
I think I now understand what you are looking for:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
# Reactant SMARTS
reactant_smarts = '[CH3:1][C+:2][C@@H:3]'
# Product SMARTS
product_smarts = [
'[CH2:1]=[CH0+0:2][CH:3]',
'[CH2:1]=[CH0+0:2][C@H:3]',
'[CH2:1]=[CH0+0:2][C@@H:3]',
]
# Reaction SMARTS
reaction_smarts = str(reactant_smarts + '>>' + '.'.join(product_smarts))
# RDKit Reaction
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
# Get Products
results = list()
for products in rxn.RunReactant(mol, 0):
for product in products:
Chem.SanitizeMol(product)
results.append(product)
print(Chem.MolToSmiles(product))
Output:
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
Note that we get the same products twice, I think this is because the reactant SMARTS matches both CH3 groups, hence the reaction is applied to both. I hope this is what you are looking for.
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
|
show 2 more comments
The Error is stating that the Explicit valence for atom 0 (Carbon) is 5, this would suggest that the explicit hydrogen hasn't been removed although the bond is now a double bond, hence a valence of 5. I am not too familiar with reaction SMARTS although an easy way to fix this manually would be to set the number of explicit hydrogens on atom 0 to 0 before you sanitize:
product.GetAtomWithIdx(0).SetNumExplicitHs(0)
Chem.SanitizeMol(product)
Edit 1:
Scratch that, I did some experimentation, try this reaction:
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
This way in the reaction definition we explicitly state that a hydrogen is lost and the resultant molecule will sanitize. Does this work for you?
Edit 2:
When I run this reaction the product does not seem to contain a cation:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
products = list()
for product in rxn.RunReactant(mol, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
print(Chem.MolToSmiles(products[0]))
Output:
'CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1'
Edit 3:
I think I now understand what you are looking for:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
# Reactant SMARTS
reactant_smarts = '[CH3:1][C+:2][C@@H:3]'
# Product SMARTS
product_smarts = [
'[CH2:1]=[CH0+0:2][CH:3]',
'[CH2:1]=[CH0+0:2][C@H:3]',
'[CH2:1]=[CH0+0:2][C@@H:3]',
]
# Reaction SMARTS
reaction_smarts = str(reactant_smarts + '>>' + '.'.join(product_smarts))
# RDKit Reaction
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
# Get Products
results = list()
for products in rxn.RunReactant(mol, 0):
for product in products:
Chem.SanitizeMol(product)
results.append(product)
print(Chem.MolToSmiles(product))
Output:
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
Note that we get the same products twice, I think this is because the reactant SMARTS matches both CH3 groups, hence the reaction is applied to both. I hope this is what you are looking for.
The Error is stating that the Explicit valence for atom 0 (Carbon) is 5, this would suggest that the explicit hydrogen hasn't been removed although the bond is now a double bond, hence a valence of 5. I am not too familiar with reaction SMARTS although an easy way to fix this manually would be to set the number of explicit hydrogens on atom 0 to 0 before you sanitize:
product.GetAtomWithIdx(0).SetNumExplicitHs(0)
Chem.SanitizeMol(product)
Edit 1:
Scratch that, I did some experimentation, try this reaction:
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
This way in the reaction definition we explicitly state that a hydrogen is lost and the resultant molecule will sanitize. Does this work for you?
Edit 2:
When I run this reaction the product does not seem to contain a cation:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
rxn = AllChem.ReactionFromSmarts('[#6@@H:1]-[#6+:2] >> [#6H0:1]=[#6+0:2]')
products = list()
for product in rxn.RunReactant(mol, 0):
Chem.SanitizeMol(product[0])
products.append(product[0])
print(Chem.MolToSmiles(products[0]))
Output:
'CC(C)=C1C/C=C(\C)CC/C=C(\C)CC1'
Edit 3:
I think I now understand what you are looking for:
mol = Chem.MolFromSmiles('C/C1=C\C[C@@H]([C+](C)C)CC/C(C)=C/CC1')
# Reactant SMARTS
reactant_smarts = '[CH3:1][C+:2][C@@H:3]'
# Product SMARTS
product_smarts = [
'[CH2:1]=[CH0+0:2][CH:3]',
'[CH2:1]=[CH0+0:2][C@H:3]',
'[CH2:1]=[CH0+0:2][C@@H:3]',
]
# Reaction SMARTS
reaction_smarts = str(reactant_smarts + '>>' + '.'.join(product_smarts))
# RDKit Reaction
rxn = AllChem.ReactionFromSmarts(reaction_smarts)
# Get Products
results = list()
for products in rxn.RunReactant(mol, 0):
for product in products:
Chem.SanitizeMol(product)
results.append(product)
print(Chem.MolToSmiles(product))
Output:
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)C1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@H]1C/C=C(\C)CC/C=C(\C)CC1'
'C=C(C)[C@@H]1C/C=C(\C)CC/C=C(\C)CC1'
Note that we get the same products twice, I think this is because the reactant SMARTS matches both CH3 groups, hence the reaction is applied to both. I hope this is what you are looking for.
edited Apr 2 at 13:27
answered Mar 28 at 11:39
Oliver ScottOliver Scott
5631 silver badge15 bronze badges
5631 silver badge15 bronze badges
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
|
show 2 more comments
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
Thanks for the reply. I just tried the reaction but what I got is the molecule with the double bond but with a cation. Since the idea behind this proton removal reaction is to remove a proton by creating a double bond. I don't get this by using your proposal.
– Fence
Mar 28 at 12:41
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I am not getting the same result as you when I run the reaction, I will edit my post
– Oliver Scott
Mar 28 at 16:17
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
I just try your code and what I get is this smile CC(C)=C1C/C=C(C)CC/C=C(C)CC1. Do note that this smile is different from the one you get. Besides, you do not get all isomers from the bond orientation (@@) in the products list, in products list, you just get one product
– Fence
Apr 1 at 15:04
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
Can you post the results you are expecting?
– Oliver Scott
Apr 1 at 15:22
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
I just edit the question with that info. Basically I am trying to get the product and its stereoisomers
– Fence
Apr 1 at 16:27
|
show 2 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385877%2fsanitization-error-applying-reaction-to-molecule-rdkit%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown