Hi Thomas,

In general, the PyMOL API should raise pymol.CmdException if things go wrong. 
But in case of cmd.pair_fit() this wasn't happening (see my fix that I pushed 
few minutes ago: 
https://github.com/schrodinger/pymol-open-source/commit/b26d91c40d20344fef511ea9d6bb664a93f1bb4a
 )

cmd.select() correctly raises an exception, so if you want to make a script 
more robust against selection failures, you could always create a named 
selection first to check if it's valid.

tmpsele1 = cmd.get_unused_name('_sele1')
try:
    cmd.select(tmpsele1, someexpression, 0)
except pymol.CmdException:
    print('invalid selection')
finally:
    cmd.delete(tmpsele1)


Cheers,
  Thomas

> On Feb 22, 2019, at 12:11 PM, Thomas Evangelidis <teva...@gmail.com> wrote:
> 
> Hi Thomas,
> 
> This is great! I can even include more atom types in the selection.
> Just for the record, is it possible to catch PyMOL exceptions like 
> "Selector-Error" from within a Python script? Is there any general strategy 
> to select which exception type to look for? In the past, I was catching 
> exceptions from 'tmalign' with "except AssertionError:" which doesn't work 
> for "Selector-Error".
> 
> Best,
> Thomas
> 
> 
> -- 
> ======================================================================
> Dr Thomas Evangelidis
> Research Scientist
> IOCB - Institute of Organic Chemistry and Biochemistry of the Czech Academy 
> of Sciences
> Prague, Czech Republic
>   & 
> CEITEC - Central European Institute of Technology
> Brno, Czech Republic 
> 
> email: teva...@gmail.com
> website: https://sites.google.com/site/thomasevangelidishomepage/

--
Thomas Holder
PyMOL Principal Developer
Schrödinger, Inc.



_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Unsubscribe: 
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe

Reply via email to