[chimerax-users] Generating surfaces from a specific selection
Eric Pettersen
pett at cgl.ucsf.edu
Tue Jun 29 13:58:55 PDT 2021
Hi Diego,
It's impossible to be 100% certain without knowing exactly which line it crashed in, but my strong suspicion is that the long atom spec you generate overran some limit in the atom spec or command parser and resulted in a crash. I will be investigating in more detail later, but working off that assumption I would change your script to directly select the atoms in Python rather than via a command. I'm going to assume the atoms in your PDB files are always in the same order, and that the structure is the only model open. If so, change these lines in the 'if' block:
cur_sel = selected_atoms(session).unique_structures[0].atoms.serial_numbers
for a in cur_sel:
list_atoms.append('@@serial_number='+str(a))
sel_atoms = ' | '.join(list_atoms)
to:
selected = session.models[0].atoms.selecteds
and these lines in the 'else' block:
rc(session, 'sel {}'.format(sel_atoms))
rc(session, 'surface {} enclose #1'.format(sel_atoms))
to:
session.models[0].atoms.selecteds = selected
rc(session, 'surface sel enclose #1')
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On Jun 29, 2021, at 10:00 AM, Diego Amaya via ChimeraX-users <chimerax-users at cgl.ucsf.edu> wrote:
>
> Hello,
>
> I have a pdb trajectory of 50 frames (in separated pdb files). I want to generate only the solvent accessible surface around amino acid 31 within a radius of 15 A. I want to use the same set of atoms when generating each surface with respect to the first frame of the trajectory. I'm using the python script here below but it doesn't work, I get a segmentation error in the else block. It works if I use "rc(session, 'surface zone #1.1 nearAtoms :{} distance {}'.format(resid, radius))" in the else block but in that way I don't use exactly the same atoms each time. Any suggestions?
>
> Thanks in advance.
>
> Here the code :
>
> ###########################################################
> from chimerax.core.commands import run as rc
>
> def get_surfaces(resid, radius):
> from chimerax.core.commands import run as rc
> from chimerax.atomic import selected_atoms
>
> with open('list_pdbs.txt', 'r') as list_pdbs:
> flag = 0
> for pdb_file in list_pdbs:
> if flag == 0:
> list_atoms = []
> rc(session, 'open ' + pdb_file.strip())
> rc(session, 'sel :{} @<{}'.format(resid, radius))
> cur_sel = selected_atoms(session).unique_structures[0].atoms.serial_numbers
> for a in cur_sel:
> list_atoms.append('@@serial_number='+str(a))
> sel_atoms = ' | '.join(list_atoms)
> rc(session, 'surface #1 enclose #1')
> rc(session, 'surface zone #1.1 nearAtoms :{} distance {}'.format(resid, radius))
> rc(session, '~ribbon')
> rc(session, '~disp')
> rc(session, "save {}_resid_{}_radius_{}.stl format stl".format(pdb_file.strip()[:-4], resid, radius))
> rc(session, 'surface close')
> rc(session, '~sel')
> rc(session, "close all")
> flag = 1
> else:
> rc(session, 'open ' + pdb_file.strip())
> rc(session, 'sel {}'.format(sel_atoms))
> rc(session, 'surface {} enclose #1'.format(sel_atoms))
> rc(session, '~ribbon')
> rc(session, '~disp')
> rc(session, "save {}_resid_{}_radius_{}.stl format stl".format(pdb_file.strip()[:-4], resid, radius))
> rc(session, '~sel')
> rc(session, 'surface close')
> rc(session, "close all")
>
> resid = 31
> radius = 15
>
> get_surfaces(resid, radius)
> rc(session, "quit")
> #############################################################
>
>
> --
> Diego A. Amaya Ramírez
>
> Aviso legal: El contenido de este mensaje y los archivos adjuntos son confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. Se encuentran dirigidos sólo para el uso del destinatario al cual van enviados. La reproducción, lectura y/o copia se encuentran prohibidas a cualquier persona diferente a este y puede ser ilegal. Si usted lo ha recibido por error, infórmenos y elimínelo de su correo. Los Datos Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra Política de Datos Personales que podrá consultar en la página web www.unal.edu.co <http://www.unal.edu.co/>. Las opiniones, informaciones, conclusiones y cualquier otro tipo de dato contenido en este correo electrónico, no relacionados con la actividad de la Universidad Nacional de Colombia, se entenderá como personales y de ninguna manera son avaladas por la Universidad.
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210629/5ef3efe6/attachment-0001.html>
More information about the ChimeraX-users
mailing list