mdtraj icon indicating copy to clipboard operation
mdtraj copied to clipboard

Cannot select residues with names starting with numbers

Open cmwoodley opened this issue 1 year ago • 2 comments

Just something I noticed when processing an example MD trajectory from the gcprmd repository.

The following snippet:

import mdtraj as md

t = md.load('../Example_MD/gpcrmd_97/10932_trj_97.xtc', top='../Example_MD/gpcrmd_97/10936_dyn_97.pdb', stride=50)
topology = t.topology

topology.select('resname 1Q5')

Returns an empty array.

Manually renaming the residue to something else resolves the issue.

Not a big deal, but may cause some confusion. Cheers!

cmwoodley avatar Jan 26 '24 16:01 cmwoodley

you need to use the regex operator for this:

topology.select("resname =~ '^1Q5'")

note - the single quote marks around the expression.

RobertArbon avatar Mar 07 '24 18:03 RobertArbon

Thanks for responding @RobertArbon ! Yes, select allows for regex operators for residues starting with numbers since that's a fairly uncommon use case (never occurring with proteins, and usually only specific ligands)....Did this work? I can close this issue if so!

sukritsingh avatar May 17 '24 16:05 sukritsingh