filter_first_altloc
#
- biotite.structure.filter_first_altloc(atoms, altloc_ids)[source]#
Filter all atoms, that have the first altloc ID appearing in a residue.
Structure files (PDB, PDBx) allow for duplicate atom records, in case a residue is found in multiple alternate locations (altloc). This function is used to remove such duplicate atoms by choosing a single altloc ID for an atom with other altlocs being removed.
- Parameters:
- atomsAtomArray, shape=(n,) or AtomArrayStack, shape=(m,n)
The unfiltered structure to be filtered.
- altloc_idsndarray, shape=(n,), dtype=’U1’
An array containing the alternate location IDs for each atom in atoms. Can contain ‘.’, ‘?’, ‘ ‘, ‘’ or a letter at each position.
- Returns:
- filterndarray, dtype=bool
For each residue, this array is True in the following cases:
The atom has no altloc ID (‘.’, ‘?’, ‘ ‘, ‘’).
The atom has the same altloc ID (e.g. ‘A’, ‘B’, etc.) as the first atom in the residue that has an altloc ID.
Notes
The function will be rarely used by the end user, since this kind of filtering is usually automatically performed, when the structure is loaded from a file. The exception are structures that were read with altloc set to True.
Examples
>>> atoms = array([ ... Atom(coord=[1, 2, 3], res_id=1, atom_name="CA"), ... Atom(coord=[4, 5, 6], res_id=1, atom_name="CB"), ... Atom(coord=[6, 5, 4], res_id=1, atom_name="CB") ... ]) >>> altloc_ids = np.array([".", "A", "B"]) >>> filtered = atoms[filter_first_altloc(atoms, altloc_ids)] >>> print(filtered) 1 CA 1.000 2.000 3.000 1 CB 4.000 5.000 6.000