Re: [Rdkit-discuss] Does AddConformer function lose SDF properties of conformers when adding them?

2018-05-24 Thread Udvarhelyi, Aniko
Dear Paolo,

thank you very much! Now it is working as I hoped it would.
My error was that I was using suppl[0] when writing out, instead of defining a 
new variable mol=suppl[0] and doing the copy_coords with that mol variable, as 
you did.

Many thanks for your help!
best regards,
Anikó

From: Paolo Tosco [mailto:paolo.tosco.m...@gmail.com]
Sent: Mittwoch, 23. Mai 2018 17:02
To: Udvarhelyi, Aniko; Greg Landrum
Cc: rdkit-discuss@lists.sourceforge.net
Subject: Re: [Rdkit-discuss] Does AddConformer function lose SDF properties of 
conformers when adding them?


Dear Aniko,
Here is a Jupyter notebook that does what you need:

https://gist.github.com/ptosco/28bc22acbb6d000812c12699b6711be6
Cheers,
p.
On 05/23/18 14:11, Udvarhelyi, Aniko wrote:
Dear Paolo,

thank you very much for your quick reply! So does this mean that Conformer 
Objects cannot have properties themselves, i.e. specific to the conformer 
itself and independent of the properties of the parent Mol Object? So there is 
no way to directly handle conformer properties by reading/writing to/from SDFs?

I implemented your suggested round-about solution as follows.

# reading in confs as written below, calling AlignMolConformers --> allconfs 
object stores aligned confs
def copy_coords(source, to):
for i in range(source.GetNumAtoms()):
to.SetAtomPosition(i, source.GetAtomPosition(i))

i = 0
for conf in confs:  # looping again over original confs to update their 
coordinates from aligned allconfs
suppl = Chem.SDMolSupplier(conf, removeHs = False)
copy_coords(allconfs.GetConformer(i), suppl[0].GetConformer())
wname = conf.split(“.sdf”,1)[0] + “_aligned.sdf”
w = Chem.SDWriter(wname)
w.write(suppl[0])
i += 1
w.close()

Unfortunately it did not work. The original coordinates were kept in the 
_aligned.SDF files and were not updated with the coordinates after alignment. 
What am I doing wrong here?

I would highly appreciate any hints and help on this!

Many thanks and best regards,
Anikó


From: Paolo Tosco [mailto:paolo.tosco.m...@gmail.com]
Sent: Mittwoch, 23. Mai 2018 11:41
To: Udvarhelyi, Aniko; Greg Landrum
Cc: 
rdkit-discuss@lists.sourceforge.net
Subject: Re: [Rdkit-discuss] Does AddConformer function lose SDF properties of 
conformers when adding them?


Dear Aniko,

properties are associated to the Mol object, not to the Conformer object. If 
you wish to retain the original properties associated with each Mol you may 
copy the aligned coordinates to the original Mol object and write that instead. 
This will allow you to retain the original properties. Please note that I 
haven't tried to run my own sample code below, so please bear with me if it 
does not quite work as is, but it was just to give you an idea how to achieve 
your goal:

def copy_coords(from, to):
for i in range(from.GetNumAtoms()):
to.SetAtomPosition(i, from.GetAtomPosition(i))

w = Chem.SDWriter(“aligned.sdf”)
nconfs = len(allconfs.GetConformers())
i = 0
for conf in confs:   # loop over my sdf files
suppl = Chem.SDMolSupplier(conf, removeHs = False)
if “_c0.sdf” in conf:
copy_coords(allconfs.GetConformer(0), suppl[0].GetConformer())
w.write(suppl[0])
else:
for mol in suppl:
i += 1
if (i == nconfs):
raise RuntimeError('Something went wrong, i = nconfs = 
{0:d}'.format(nconfs))
copy_coords(allconfs.GetConformer(i), mol.GetConformer())
w.write(mol)
w.close()
HTH, Cheers,
p.

On 05/23/18 09:11, Udvarhelyi, Aniko wrote:
Dear Greg,

I have separate SDF files of conformers of the same molecule (they are called 
_c0.sdf, _c1.sdf, _c2.sdf and so on), with a few properties for 
each conformer. I am using the following code to read them into RDKit and align 
them:

for conf in confs:   # loop over my sdf files
suppl = Chem.SDMolSupplier(conf, removeHs = False)
if “_c0.sdf” in conf:
allconfs = suppl[0]
else:
for i,mol in enumerate(suppl):
allconfs.AddConformer(mol.GetConformer(), assignId = True)

And then I am using AllChem.AlignMolConformers(allconfs) to align the 
conformers. It all works fine BUT: when I save the aligned conformers with the 
SDWriter, all the conformers have the properties of the very first conformer. 
What should I do to keep the original SDF properties of the conformers from 
before the alignment? Does AddConformer lose the properties or is something 
wrong with how I write them out? I am using the following to save the aligned 
conformers into one sdf:

w = Chem.SDWriter(“aligned.sdf”)
for conf_id in range(len(allconf.GetConformers)):
w.write(allc

[Rdkit-discuss] Molecule does not have substructure match with its fragments

2018-05-24 Thread Larissa Pusch
Hello,

 

I am running rdkit version 2017.09.3.

I read an sdf with

 

supplier = SDMolSupplier('try/try.sdf')

 

I then took the first mol from supplier and named it mol. I then performed

 

fragmented = Recap.RecapDecompose(mol, minFragmentSize=3). I looped through its children with:

fragmented_children_smiles = []
for key in list(fragmented_children):
    fragmented_children_smiles.append(fragmented.GetAllChildren()[key].smiles)
smile = fragmented_children_smiles[0]

 

Now, smile is '[*]Nc1ccc(OC)cc1C([*])=O' . Theoretically, smile should of course be a substructure of mol. But if I check this like this:


smile  = MolFromSmiles(smile)
if mol.HasSubstructMatch(smile):
    print('match smile')
 

nothing gets printed. Apparently, this is because of the [*], if I delete them, there is a match. But why are they there in the first place? Why does HasSubstructMatch not work when they are included? And, most importantly, can I solve this problem, without going trough the code and deleting all '[*]'? First of all, I do not know if the smiles would still make sense if I did that and also, there are some structures like '([*])' and '()' is of course not valid, so deleting them for a large number of smiles would be really bothersome...

 

Thank you for your help!

Regards,

Larissa Pusch

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] convert a smiles file to a xyz file

2018-05-24 Thread Chenyang Shi
Thank you Prof. Jensen. I will study the module.

Best,
Chenyang

On Thu, May 24, 2018 at 1:30 AM, Jan Halborg Jensen 
wrote:

> Have a look at write_xtb_input_file in this module: https://github.com/
> jensengroup/take_elementary_step/blob/master/write_input_files.py
>
> The xtb input is simple an xyz file with some additional lines below if
> the molecule is charged. You can simply those lines in the code.
>
> Best regards, Jan
>
> On 23 May 2018, at 17:23, Chenyang Shi  wrote:
>
> Hi Everyone,
>
> I am seeking helps about how to convert a SMILES file to a series of
> coordinates for the molecule, in the format of xyz.
> I saw some online service that can do the job (e.g.
> http://www.cheminfo.org/Chemistry/Cheminformatics/
> FormatConverter/index.html), but it is not convenient to use.
>
> I am wondering how can we do this by writing RDKit code. A separate
> question is that is the converted molecular structure from SMILES the same
> as that taken from a crystal structure?
>
> Many thanks!
> Chenyang
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org !
> http://sdm.link/slashdot___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] RDKit postgres cartridge building

2018-05-24 Thread Alfredo Quevedo

Good morning,

I am trying to build RDKit from source, and succeed with that following 
the instructions provided in the documentation. Howvere, I am trying to 
use the postgres cartridge, which as far as I understand is built during 
the main building process.


but after trying to create the extension for a database with:

psql -c  'create extension rdkit'  molecules

I am getting the following error

ERROR:  could not open extension control file 
"/usr/share/postgresql/10/extension/rdkit.control": No such file or 
directory


It seems that the building of the cartridge is not being applyed to my 
local postgres installation?


Any hint is highly appreacited,

thanks in advance



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] RDKit postgres cartridge building

2018-05-24 Thread Markus Sitzmann
Hi Alfredo,

My first guess would be you have another, older Postgres version on your 
computer and you have build against this version. Take a look at the 
/use/share/postgresql directory and take a look if there is another directory 
instead of 10/

Markus

-
|  Markus Sitzmann
|  markus.sitzm...@gmail.com

> On 24. May 2018, at 18:24, Alfredo Quevedo  wrote:
> 
> Good morning,
> 
> I am trying to build RDKit from source, and succeed with that following the 
> instructions provided in the documentation. Howvere, I am trying to use the 
> postgres cartridge, which as far as I understand is built during the main 
> building process.
> 
> but after trying to create the extension for a database with:
> 
> psql -c  'create extension rdkit'  molecules
> 
> I am getting the following error
> 
> ERROR:  could not open extension control file 
> "/usr/share/postgresql/10/extension/rdkit.control": No such file or directory
> 
> It seems that the building of the cartridge is not being applyed to my local 
> postgres installation?
> 
> Any hint is highly appreacited,
> 
> thanks in advance
> 
> 
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] RDKit postgres cartridge building

2018-05-24 Thread Alfredo Quevedo

thank you Markus for the reply,

listing the /user/share/postgresql directory I can see several folder 
apart from 10 (9.2, 9.3, etc),


I uninstalled the current postgres instalation and deleted all the 
folder under ´/user/share/postgresql. Afterwards I reinstalled postgres, 
and only  user/share/postgresql/10 is now present.


Afterwards I recompiled the RDKit souurce with:

cmake -DRDK_BUILD_INCHI_SUPPORT=ON -DRDK_BUILD_AVALON_SUPPORT=ON 
-DRDK_BUILD_CAIRO_SUPPORT=ON ..


Is this enough to automatically build the RDKit postgres package or I 
need some extra building flags (such as DRDK_BUILD_PGSQL=ON)?


regards

Alfredo





El 24/05/2018 a las 15:36, Markus Sitzmann escribió:

Hi Alfredo,

My first guess would be you have another, older Postgres version on 
your computer and you have build against this version. Take a look at 
the /use/share/postgresql directory and take a look if there is 
another directory instead of 10/


Markus

-
|  Markus Sitzmann
| markus.sitzm...@gmail.com 

On 24. May 2018, at 18:24, Alfredo Quevedo > wrote:



Good morning,

I am trying to build RDKit from source, and succeed with that 
following the instructions provided in the documentation. Howvere, I 
am trying to use the postgres cartridge, which as far as I understand 
is built during the main building process.


but after trying to create the extension for a database with:

psql -c  'create extension rdkit'  molecules

I am getting the following error

ERROR:  could not open extension control file 
"/usr/share/postgresql/10/extension/rdkit.control": No such file or 
directory


It seems that the building of the cartridge is not being applyed to 
my local postgres installation?


Any hint is highly appreacited,

thanks in advance



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org ! 
http://sdm.link/slashdot

___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net 


https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] RDKit postgres cartridge building

2018-05-24 Thread Paolo Tosco

Dear Alfredo,

this file contains pretty comprehensive instructions how to build and 
install the cartridge:


https://github.com/rdkit/rdkit/blob/master/Code/PgSQL/rdkit/README

Please get back to me off-list if you still have issues in getting it to 
work for you.


Cheers,
p.


On 05/24/18 19:57, Alfredo Quevedo wrote:


thank you Markus for the reply,

listing the /user/share/postgresql directory I can see several folder 
apart from 10 (9.2, 9.3, etc),


I uninstalled the current postgres instalation and deleted all the 
folder under ´/user/share/postgresql. Afterwards I reinstalled 
postgres, and only  user/share/postgresql/10 is now present.


Afterwards I recompiled the RDKit souurce with:

cmake -DRDK_BUILD_INCHI_SUPPORT=ON -DRDK_BUILD_AVALON_SUPPORT=ON 
-DRDK_BUILD_CAIRO_SUPPORT=ON ..


Is this enough to automatically build the RDKit postgres package or I 
need some extra building flags (such as DRDK_BUILD_PGSQL=ON)?


regards

Alfredo





El 24/05/2018 a las 15:36, Markus Sitzmann escribió:

Hi Alfredo,

My first guess would be you have another, older Postgres version on 
your computer and you have build against this version. Take a look at 
the /use/share/postgresql directory and take a look if there is 
another directory instead of 10/


Markus

-
|  Markus Sitzmann
| markus.sitzm...@gmail.com 

On 24. May 2018, at 18:24, Alfredo Quevedo > wrote:



Good morning,

I am trying to build RDKit from source, and succeed with that 
following the instructions provided in the documentation. Howvere, I 
am trying to use the postgres cartridge, which as far as I 
understand is built during the main building process.


but after trying to create the extension for a database with:

psql -c  'create extension rdkit'  molecules

I am getting the following error

ERROR:  could not open extension control file 
"/usr/share/postgresql/10/extension/rdkit.control": No such file or 
directory


It seems that the building of the cartridge is not being applyed to 
my local postgres installation?


Any hint is highly appreacited,

thanks in advance



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org ! 
http://sdm.link/slashdot

___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net 


https://lists.sourceforge.net/lists/listinfo/rdkit-discuss




--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


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


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss