예제 #1
0
def move_models_and_atoms(tf, models, atoms, move_whole_molecules, base_model):

    if move_whole_molecules and atoms is not None and len(atoms) > 0:
        models = list(models) + list(atoms.unique_structures)
        from chimerax.atomic import Atoms
        atoms = Atoms()
    if atoms is None:
        from chimerax.atomic import Atoms
        atoms = Atoms()
    global position_history
    position_history.record_position(models, atoms, base_model)
    for m in models:
        # TODO: Handle case where parent of volume has non-identity position.  tf is in scene coords.
        m.position = tf * m.position
    if len(atoms) > 0:
        atoms.coords = tf * atoms.coords
    position_history.record_position(models, atoms, base_model)
예제 #2
0
def apply_strict_ncs(template_atoms, ncs_map):
    '''
    Copy the transformed coordinates of the template atoms to the given NCS
    atoms.

    Args:

        * template_atoms: a :class:`Atoms` instance
        * ncs_map: a list of (:class:`Place`, :class:`Atoms`) pairs. Each
            array of atoms must have a 1:1 correspondence to the template_atoms.
            Atoms will be sorted according to (chain, residue number, insertion
            code, atom name) before applying the NCS operators.
    '''
    from chimerax.atomic import Atoms
    template_atoms = Atoms(
        sorted(template_atoms,
               key=lambda a: (a.residue.chain_id, a.residue.number, a.residue.
                              insertion_code, a.name)))
    for (place, ncs_atoms) in ncs_map:
        ncs_atoms = Atoms(
            sorted(ncs_atoms,
                   key=lambda a: (a.residue.chain_id, a.residue.number, a.
                                  residue.insertion_code, a.name)))
        ncs_atoms.coords = place * template_atoms.coords