Re: [Rdkit-discuss] atom indexing

2023-06-19 Thread Ling Chan
Great to know, many thanks Greg!
Ling


Greg Landrum  於 2023年6月19日週一 下午9:53寫道:

> Hi Ling,
>
> On Mon, Jun 19, 2023 at 3:03 AM Ling Chan  wrote:
>
>>
>> I got some questions about atom indexing. Just wonder if you could help
>> me?
>>
>>1. In m3=Chem.CombineMols(m1,m2) , is it guaranteed that the atom
>>indices in m3 is equivalent to the indices in m1 followed by the indices 
>> in
>>m2?
>>
>> Yes
>
>>
>>1. If I construct an editable mol from m1, is it that the atomic
>>indices in the editable mol is equivalent to that in m1? And when I 
>> convert
>>the editable mol back, suppose the atom indexing is also preserved?
>>2.
>>
>> Yes
>
>>
>>1. Same as #2, but for an RWMol instead of an editable mol.
>>
>> Yes
>
>>
>>1. If I delete an "F" atom from an editable mol, is there a way to
>>mark the atom in the new mol that was originally bonded to the "F"? I 
>> mean,
>>if I get its atomic index before the deletion, suppose it won't be
>>preserved.
>>
>> You can set a property on the neighboring atom with something like:
> atom.SetProp("F_Neighbor","1")
>
>>
>>1. Similar to #4, but for DeleteSubstructs.
>>
>> Same answer: you can always use SetProp
>
>
>> Alternatively, if there is a way to mark atoms, I don't need the atom
>> indices anyway.
>>
>
> As mentioned, SetProp is great for this. Note that using the property
> interface is slower than just relying on the indexing remaining the same,
> which you can do in the first two cases.
>
> best regards,
> -greg
>
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] atom indexing

2023-06-19 Thread Greg Landrum
Hi Ling,

On Mon, Jun 19, 2023 at 3:03 AM Ling Chan  wrote:

>
> I got some questions about atom indexing. Just wonder if you could help me?
>
>1. In m3=Chem.CombineMols(m1,m2) , is it guaranteed that the atom
>indices in m3 is equivalent to the indices in m1 followed by the indices in
>m2?
>
> Yes

>
>1. If I construct an editable mol from m1, is it that the atomic
>indices in the editable mol is equivalent to that in m1? And when I convert
>the editable mol back, suppose the atom indexing is also preserved?
>2.
>
> Yes

>
>1. Same as #2, but for an RWMol instead of an editable mol.
>
> Yes

>
>1. If I delete an "F" atom from an editable mol, is there a way to
>mark the atom in the new mol that was originally bonded to the "F"? I mean,
>if I get its atomic index before the deletion, suppose it won't be
>preserved.
>
> You can set a property on the neighboring atom with something like:
atom.SetProp("F_Neighbor","1")

>
>1. Similar to #4, but for DeleteSubstructs.
>
> Same answer: you can always use SetProp


> Alternatively, if there is a way to mark atoms, I don't need the atom
> indices anyway.
>

As mentioned, SetProp is great for this. Note that using the property
interface is slower than just relying on the indexing remaining the same,
which you can do in the first two cases.

best regards,
-greg
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] atom indexing

2023-06-18 Thread Ling Chan
Dear colleagues,

I got some questions about atom indexing. Just wonder if you could help me?

   1. In m3=Chem.CombineMols(m1,m2) , is it guaranteed that the atom
   indices in m3 is equivalent to the indices in m1 followed by the indices in
   m2?
   2. If I construct an editable mol from m1, is it that the atomic indices
   in the editable mol is equivalent to that in m1? And when I convert the
   editable mol back, suppose the atom indexing is also preserved?
   3. Same as #2, but for an RWMol instead of an editable mol.
   4. If I delete an "F" atom from an editable mol, is there a way to mark
   the atom in the new mol that was originally bonded to the "F"? I mean, if I
   get its atomic index before the deletion, suppose it won't be preserved.
   5. Similar to #4, but for DeleteSubstructs.

Alternatively, if there is a way to mark atoms, I don't need the atom
indices anyway.

Thank you!

Ling
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Atom indexing with AssignBondOrdersFromTemplate

2022-07-17 Thread He, Amy
Hi Brian,

Thank you for your kind reply. That’s a very good point! The order of atoms in 
the PDB file (which I extracted from RCSB PDB) is not the same as in the 
SMILES. And I find that the indexing in newmol will follow the reference 
molecule.

But I was wrong in thinking that the indexing was different from both. I didn’t 
realize that the indexing is zero-based… Using the codes in the previous 
message, the newmol will receive the bond order from smilemol and the indexing 
from pdbmol, which is exactly what I wanted to do!

Thank you again for your time and kind help!!

Thanks,
Amy

--
Amy He
Chemistry Graduate Teaching Assistant
Hadad Research Group
Ohio State University
he.1...@osu.edu

From: Bennion, Brian 
Date: Sunday, July 17, 2022 at 8:20 PM
To: He, Amy , rdkit-discuss@lists.sourceforge.net 

Subject: Re: [Rdkit-discuss] Atom indexing with AssignBondOrdersFromTemplate
I don’t know if this is the issue but Are the order of atoms the same between 
the pdb file and the smiles string? --- Sent from Workspace ONE Boxer On July 
16, 2022 at 8:14:51 PM PDT, He, Amy  wrote: ‍ ‍ ‍ 
‍ ‍

I don’t know if this is the issue but Are the order of atoms the same between 
the pdb file and the smiles string?


---
Sent from Workspace ONE 
Boxer<https://urldefense.com/v3/__https:/whatisworkspaceone.com/boxer__;!!KGKeukY!ys014tzEXJmNi8IQW56hTW857n_g_PPt2PXLOUBlwv2sRR__E6NIIDJeLXnpF8VrEQlDqMnesvLXIQc-55S-Qekas4gYPes$>
On July 16, 2022 at 8:14:51 PM PDT, He, Amy  wrote:

Dear RDKit experts,



I am new to RDKit and I have a simple question about atom indexing with RDKit. 
I am using RDKit in Python to process a collection of small molecule, for each 
I have the SMILES and a pdb file without explicit hydrogens. To draw the 2D 
images of the molecules, I used AssignBondOrdersFromTemplate to assign the bond 
order.



pdbmol = rdmolfiles.MolFromPDBFile()

smilemol = Chem.MolFromSmiles()



newmol = AllChem.AssignBondOrdersFromTemplate(smilemol, pdbmol)

rdDepictor.Compute2DCoords(newmol)

for atom in newmol.GetAtoms():

atom.SetAtomMapNum(atom.GetIdx())



Using the above lines, I was able to draw the ligand in 2D with Idx of atoms. 
However, I noticed that the Idx of atoms have changed in the newmol… Is there a 
way to keep the original indexing from the PDB file in the newmol (perhaps by 
an alternative way to set bond order)? I wanted to label a couple of atoms in 
the 2D picture, but I only know their Idx in the PDB file, so I really wish to 
keep the original indexing.



Any comments/suggestions would be greatly appreciated. Thank you for your time 
and kind advice in advance!!





Many Thanks,

Amy

--

Amy He

Chemistry Graduate Teaching Assistant

Hadad Research Group

Ohio State University

he.1...@osu.edu<mailto:he.1...@osu.edu>




___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Atom indexing with AssignBondOrdersFromTemplate

2022-07-17 Thread Bennion, Brian via Rdkit-discuss
I don’t know if this is the issue but Are the order of atoms the same between 
the pdb file and the smiles string?


---
Sent from Workspace ONE Boxer

On July 16, 2022 at 8:14:51 PM PDT, He, Amy  wrote:

Dear RDKit experts,



I am new to RDKit and I have a simple question about atom indexing with RDKit. 
I am using RDKit in Python to process a collection of small molecule, for each 
I have the SMILES and a pdb file without explicit hydrogens. To draw the 2D 
images of the molecules, I used AssignBondOrdersFromTemplate to assign the bond 
order.



pdbmol = rdmolfiles.MolFromPDBFile()

smilemol = Chem.MolFromSmiles()



newmol = AllChem.AssignBondOrdersFromTemplate(smilemol, pdbmol)

rdDepictor.Compute2DCoords(newmol)

for atom in newmol.GetAtoms():

atom.SetAtomMapNum(atom.GetIdx())



Using the above lines, I was able to draw the ligand in 2D with Idx of atoms. 
However, I noticed that the Idx of atoms have changed in the newmol… Is there a 
way to keep the original indexing from the PDB file in the newmol (perhaps by 
an alternative way to set bond order)? I wanted to label a couple of atoms in 
the 2D picture, but I only know their Idx in the PDB file, so I really wish to 
keep the original indexing.



Any comments/suggestions would be greatly appreciated. Thank you for your time 
and kind advice in advance!!





Many Thanks,

Amy

--

Amy He

Chemistry Graduate Teaching Assistant

Hadad Research Group

Ohio State University

he.1...@osu.edu





___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Atom indexing with AssignBondOrdersFromTemplate

2022-07-16 Thread He, Amy
Dear RDKit experts,

I am new to RDKit and I have a simple question about atom indexing with RDKit. 
I am using RDKit in Python to process a collection of small molecule, for each 
I have the SMILES and a pdb file without explicit hydrogens. To draw the 2D 
images of the molecules, I used AssignBondOrdersFromTemplate to assign the bond 
order.

pdbmol = rdmolfiles.MolFromPDBFile()
smilemol = Chem.MolFromSmiles()

newmol = AllChem.AssignBondOrdersFromTemplate(smilemol, pdbmol)
rdDepictor.Compute2DCoords(newmol)
for atom in newmol.GetAtoms():
atom.SetAtomMapNum(atom.GetIdx())

Using the above lines, I was able to draw the ligand in 2D with Idx of atoms. 
However, I noticed that the Idx of atoms have changed in the newmol… Is there a 
way to keep the original indexing from the PDB file in the newmol (perhaps by 
an alternative way to set bond order)? I wanted to label a couple of atoms in 
the 2D picture, but I only know their Idx in the PDB file, so I really wish to 
keep the original indexing.

Any comments/suggestions would be greatly appreciated. Thank you for your time 
and kind advice in advance!!


Many Thanks,
Amy
--
Amy He
Chemistry Graduate Teaching Assistant
Hadad Research Group
Ohio State University
he.1...@osu.edu

___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] atom indexing in mol and conformer

2022-06-19 Thread Ling Chan
Good, thank you Sereina!
Ling

Sereina Riniker  於 2022年6月19日週日 上午1:48寫道:

> Dear Ling,
>
> Yes, the atom indexing is the same for all conformers of a molecule.
>
> Best regards,
> Sereina
>
>
>
> > On 19 Jun 2022, at 00:04, Ling Chan  wrote:
> >
> > Dear colleagues,
> >
> > Just wonder if the atom indexing in a conformer is always identical to
> that of the parent molecule? I suspect it is but would like to confirm.
> >
> > Specifically, I would like to confirm that
> >   for conf in mol.GetConformers():
> > conf.GetAtomPosition(idx)
> > always corresponds to the atom
> >   mol.GetAtomWithIdx(idx)
> >
> > Thank you.
> >
> > Ling
> > ___
> > Rdkit-discuss mailing list
> > Rdkit-discuss@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] atom indexing in mol and conformer

2022-06-19 Thread Sereina Riniker
Dear Ling,

Yes, the atom indexing is the same for all conformers of a molecule.

Best regards,
Sereina



> On 19 Jun 2022, at 00:04, Ling Chan  wrote:
> 
> Dear colleagues,
> 
> Just wonder if the atom indexing in a conformer is always identical to that 
> of the parent molecule? I suspect it is but would like to confirm.
> 
> Specifically, I would like to confirm that
>   for conf in mol.GetConformers():
> conf.GetAtomPosition(idx)
> always corresponds to the atom
>   mol.GetAtomWithIdx(idx)
> 
> Thank you.
> 
> Ling
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss



___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] atom indexing in mol and conformer

2022-06-18 Thread Ling Chan
Dear colleagues,

Just wonder if the atom indexing in a conformer is always identical to that
of the parent molecule? I suspect it is but would like to confirm.

Specifically, I would like to confirm that
  for conf in mol.GetConformers():
conf.GetAtomPosition(idx)
always corresponds to the atom
  mol.GetAtomWithIdx(idx)

Thank you.

Ling
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] atom indexing

2013-07-31 Thread Greg Landrum
Hi Ling,

On Thu, Aug 1, 2013 at 2:56 AM, S.L. Chan  wrote:

> Hello folks,
>
> In a way this is a continuation of a previous discussion.
>
> My question is: so is there a simple way to obtain the original
> indexing with all hydrogen atoms included? Do I have to write
> my own function?
>

I guess this means that you want the hydrogens to not be removed from the
molecule?
If so, you just need to tell the RDKit not to remove the Hs.

>From a mol file this is a single extra argument:
In [3]: m = Chem.MolFromMolFile('hmol.mol',removeHs=False)

In [4]: m.Debug()
Atoms:
0 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
1 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
 2 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
3 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
 4 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
5 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
 6 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
7 8 O chg: 0  deg: 2 exp: 2 imp: 0 hyb: 4 arom?: 0 chi: 0
 8 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
 1 0->2 order: 1 conj?: 0 aromatic?: 0
2 0->3 order: 1 conj?: 0 aromatic?: 0
3 0->4 order: 1 conj?: 0 aromatic?: 0
 4 1->5 order: 1 conj?: 0 aromatic?: 0
5 1->6 order: 1 conj?: 0 aromatic?: 0
6 1->7 order: 1 conj?: 0 aromatic?: 0
 7 7->8 order: 1 conj?: 0 aromatic?: 0

but you can also do it from SMILES if you need to:

In [6]: m = Chem.MolFromSmiles('[H]C([H])([H])O[H]',sanitize=False)

In [7]: Chem.SanitizeMol(m)
Out[7]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE

In [8]: m.Debug()
Atoms:
0 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
 1 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
2 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
 3 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
4 8 O chg: 0  deg: 2 exp: 2 imp: 0 hyb: 4 arom?: 0 chi: 0
 5 1 H chg: 0  deg: 1 exp: 1 imp: 0 hyb: 1 arom?: 0 chi: 0
Bonds:
0 0->1 order: 1 conj?: 0 aromatic?: 0
 1 1->2 order: 1 conj?: 0 aromatic?: 0
2 1->3 order: 1 conj?: 0 aromatic?: 0
3 1->4 order: 1 conj?: 0 aromatic?: 0
 4 4->5 order: 1 conj?: 0 aromatic?: 0

Does that help?
-greg
--
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] atom indexing

2013-07-31 Thread S.L. Chan
Hello folks,

In a way this is a continuation of a previous discussion.

My question is: so is there a simple way to obtain the original
indexing with all hydrogen atoms included? Do I have to write
my own function?

Thank you.

Ling




Re: [Rdkit-discuss] SMILES and atom indexing
greg landrum Tue, 19 Mar 2013 13:09:32 -0700
Hi Nick, On Mar 19, 2013, at 5:00 PM, Nicholas Firth  
wrote:
> Hi RDKitters,
> 
> I'm sure this must of been covered somewhere else but I can't find it in the 
> forum or the source.
> 
> I am manipulating SMILES strings and wonder whether I can use RDKit as a 
> shortcut, so my question is does the order of occurrence in a SMILES string 
> of an atom match the atom index that is given by RDKit. It seems to me that 
> it does but I'd like to know for all cases. For example
> 
> >>> from rdkit import Chem
> >>> mol=Chem.MolFromSmiles('CSNOC')
> >>> for atom in mol.GetAtoms(): print atom.GetAtomicNum(),atom.GetIdx()
> ... 
> 6 0
> 16 1
> 7 2
> 8 3
> 6 4
> 
> This is what I would expect, but is there a case when this order might not be 
> conserved? The atom and bond order will be preserved unless the smiles 
> contains hydrogens 
as explicit atoms, i.e. as [H]. In that case, the hydrogens are removed and the 
remaining indices are what your would expect. > If the order isn't always 
conserved, how does the indexing cope with RDKit 
> canonical smiles? I don't understand the question but maybe that doesn't 
> matter since the order 
is preserved? -greg > Thanks in advance.
> 
> Best,
> Nick
> 
> Nicholas C. Firth | PhD Student | Cancer Therapeutics
> The Institute of Cancer Research | 15 Cotswold Road | Belmont | Sutton | 
> Surrey | SM2 5NG
> T 020 8722 4033 | E nicholas.fi...@icr.ac.uk | W www.icr.ac.uk | Twitter 
> @ICRnews
> Facebook www.facebook.com/theinstituteofcancerresearch 
--
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss