# Single chainchain_a = system.select("chain A")chain_b = system.select("chain B")# Combine with other selectorsca_chain_a = system.select("name CA and chain A")
Select all protein atoms (standard amino acid residues).
# All protein atomsprotein = system.select("protein")# Protein in specific chainprotein_a = system.select("protein and chain A")# Everything except proteinnot_protein = system.select("not protein")
Recognized protein residues:
ALA, ARG, ASN, ASP, CYS, GLN, GLU, GLY, HIS, ILE, LEU, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL, MSE, HSD, HSE, HSP
# All backbone atomsbackbone = system.select("backbone")# Backbone in specific regionbackbone_100_120 = system.select("backbone and resid 100:120")# Backbone in chain Abackbone_a = system.select("backbone and chain A")
# CA atoms in chain Aca_chain_a = system.select("name CA and chain A")# Protein backbone atoms in specific residuesbackbone_region = system.select("backbone and resid 50:100")# Multiple conditionsspecific = system.select("name CA and chain A and resid 1:50")
Logical OR - atoms match if they satisfy either condition.
# CA or N atomsca_or_n = system.select("name CA or name N")# Two different residue typesala_or_gly = system.select("resname ALA or resname GLY")# Multiple chainschains_ab = system.select("chain A or chain B")
# Everything except waterno_water = system.select("not resname SOL")# Non-backbone protein atoms (sidechains)sidechains = system.select("protein and not backbone")# Complex negationnot_chain_a_ca = system.select("not (chain A and name CA)")
Parentheses for grouping and controlling operator precedence.
# Group conditionscomplex = system.select("(name CA or name N) and chain A")# Precedence controlselection = system.select("(protein or resname SOL) and not chain B")# Nested groupingnested = system.select("((resid 1:50 or resid 100:150) and backbone) or name CA")
# Protein backbone excluding chain Bbackbone_no_b = system.select("backbone and not chain B")# All CA atoms in proteinsca_protein = system.select("protein and name CA")# Sidechains in active sitesidechain_active = system.select( "protein and not backbone and resid 100:120")
Selections are cached internally by the System object. Repeated calls to system.select() with the same expression return instantly without re-parsing or re-evaluating.
# First call: parses and evaluatesbackbone1 = system.select("backbone") # ~1ms# Subsequent calls: instant return from cachebackbone2 = system.select("backbone") # ~0.001msbackbone3 = system.select("backbone") # ~0.001ms# Different expression: new evaluationca = system.select("name CA") # ~1ms
# Unknown keywordtry: sel = system.select("unknown_keyword value")except Exception as e: print(e) # "unknown predicate 'unknown_keyword'"# Syntax errortry: sel = system.select("name CA and")except Exception as e: print(e) # "unexpected tokens at end of selection"# Invalid operatortry: sel = system.select("name CA & chain A")except Exception as e: print(e) # "unexpected character '&'"