mdtraj
mdtraj copied to clipboard
Cannot select residues with names starting with numbers
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!
you need to use the regex operator for this:
topology.select("resname =~ '^1Q5'")
note - the single quote marks around the expression.
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!