Re: [Rdkit-discuss] Highlighting atoms with different colors in a molecule

2019-06-04 Thread Greg Landrum
On Tue, Jun 4, 2019 at 4:32 PM Omar H94  wrote:

> I wonder if it is possible to highlight different atoms with different
> colors in a one molecule. For example, to highlight atom 1 in red and atom
> 3 in blue in the same image of the molecule. If there’s a way to do this, I
> would like to know how.
>

Yep, there are some examples here:
http://rdkit.blogspot.com/2015/02/new-drawing-code.html

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


[Rdkit-discuss] Highlighting atoms with different colors in a molecule

2019-06-04 Thread Omar H94
Dear RDKit users,
I wonder if it is possible to highlight different atoms with different
colors in a one molecule. For example, to highlight atom 1 in red and atom
3 in blue in the same image of the molecule. If there’s a way to do this, I
would like to know how.

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


Re: [Rdkit-discuss] Catching errors in SMILES files

2019-06-04 Thread Paolo Tosco

Hi David,

I think I already have a fix for this bug, I'll submit a PR later. If 
you can create a ?GitHub issue it would be great so I can link my PR to 
the bug.


Thanks, cheers
p.


On 06/04/19 12:10, David Cosgrove wrote:

Hi Paolo,
Many thanks for the speedy reply.  I'll do as you suggest for now.  Do 
you want me to file an issue on github, or even, maybe, see if I can 
fix it myself?

Cheers,
Dave


On Mon, Jun 3, 2019 at 5:32 PM Paolo Tosco > wrote:


Hi David,

a workaround could be adding a final check after the for loop:

#!/usr/bin/env python

from rdkit import Chem

suppl1 = Chem.SmilesMolSupplier('test1.smi', titleLine=False,
nameColumn=1)
rec_num = 0
print("len(suppl1) = {0:d}".format(len(suppl1)))
for mol in suppl1:
    rec_num += 1
    if not mol:
    print('Record {} not read.'.format(rec_num))
    else:
    print('Record {} read ok.'.format(rec_num))
if (rec_num == len(suppl1) - 1):
    rec_num += 1
    print('Record {} not read.'.format(rec_num))


suppl2 = Chem.SmilesMolSupplier('test2.smi', titleLine=False,
nameColumn=1)
rec_num = 0
print("len(suppl2) = {0:d}".format(len(suppl2)))
for mol in suppl2:
    rec_num += 1
    if not mol:
    print('Record {} not read.'.format(rec_num))
    else:
    print('Record {} read ok.'.format(rec_num))
if (rec_num == len(suppl2) - 1):
    rec_num += 1
    print('Record {} not read.'.format(rec_num))

This should work until what seems to be an issue in the
SmilesSupplier is fixed.

Cheers,
p.

On 06/03/19 16:49, David Cosgrove wrote:

Hi,

I'm trying to catch the line numbers of lines in a SMILES file
that aren't parsed by the SmilesMolSupplier.  Example code is
attached, along with 2 SMILES files.  When there is a bad SMILES
string on the last line, the error is not reported, as in
test2.smi.  I've tried iterating through the file in a loop using
next(suppl1) and catching the StopIteration exception, but I have
the same issue. Is there a way to spot a last bad record in a file?

Thanks,
Dave

-- 
David Cosgrove

Freelance computational chemistry and chemoinformatics developer
http://cozchemix.co.uk





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

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




--
David Cosgrove
Freelance computational chemistry and chemoinformatics developer
http://cozchemix.co.uk



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


Re: [Rdkit-discuss] Catching errors in SMILES files

2019-06-04 Thread David Cosgrove
Hi Paolo,
Many thanks for the speedy reply.  I'll do as you suggest for now.  Do you
want me to file an issue on github, or even, maybe, see if I can fix it
myself?
Cheers,
Dave


On Mon, Jun 3, 2019 at 5:32 PM Paolo Tosco 
wrote:

> Hi David,
>
> a workaround could be adding a final check after the for loop:
>
> #!/usr/bin/env python
>
> from rdkit import Chem
>
> suppl1 = Chem.SmilesMolSupplier('test1.smi', titleLine=False, nameColumn=1)
> rec_num = 0
> print("len(suppl1) = {0:d}".format(len(suppl1)))
> for mol in suppl1:
> rec_num += 1
> if not mol:
> print('Record {} not read.'.format(rec_num))
> else:
> print('Record {} read ok.'.format(rec_num))
> if (rec_num == len(suppl1) - 1):
> rec_num += 1
> print('Record {} not read.'.format(rec_num))
>
>
> suppl2 = Chem.SmilesMolSupplier('test2.smi', titleLine=False, nameColumn=1)
> rec_num = 0
> print("len(suppl2) = {0:d}".format(len(suppl2)))
> for mol in suppl2:
> rec_num += 1
> if not mol:
> print('Record {} not read.'.format(rec_num))
> else:
> print('Record {} read ok.'.format(rec_num))
> if (rec_num == len(suppl2) - 1):
> rec_num += 1
> print('Record {} not read.'.format(rec_num))
>
> This should work until what seems to be an issue in the SmilesSupplier is
> fixed.
>
> Cheers,
> p.
>
> On 06/03/19 16:49, David Cosgrove wrote:
>
> Hi,
>
> I'm trying to catch the line numbers of lines in a SMILES file that aren't
> parsed by the SmilesMolSupplier.  Example code is attached, along with 2
> SMILES files.  When there is a bad SMILES string on the last line, the
> error is not reported, as in test2.smi.  I've tried iterating through the
> file in a loop using next(suppl1) and catching the StopIteration exception,
> but I have the same issue.  Is there a way to spot a last bad record in a
> file?
>
> Thanks,
> Dave
>
> --
> David Cosgrove
> Freelance computational chemistry and chemoinformatics developer
> http://cozchemix.co.uk
>
>
>
>
>
> ___
> Rdkit-discuss mailing 
> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
>

-- 
David Cosgrove
Freelance computational chemistry and chemoinformatics developer
http://cozchemix.co.uk
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss