Пример #1
0
def test_center_in_box_bad_ag(translate_universes):
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    # what happens if something other than an AtomGroup is given?
    bad_ag = 1
    with pytest.raises(ValueError):
        center_in_box(bad_ag)(ts)
Пример #2
0
def test_center_in_box_bad_ag(translate_universes):
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    # what happens if something other than an AtomGroup is given?
    bad_ag = 1
    with pytest.raises(ValueError): 
        center_in_box(bad_ag)(ts)
Пример #3
0
def test_center_in_box_bad_pbc(translate_universes):
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # is pbc passed to the center methods?
    # if yes it should raise an exception for boxes that are zero in size
    with pytest.raises(ValueError):
        center_in_box(ag, wrap=True)(ts)
Пример #4
0
def test_center_in_box_no_masses(translate_universes):   
    # this universe has no masses
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # if the universe has no masses and `mass` is passed as the center arg
    bad_center = "mass"
    with pytest.raises(AttributeError): 
        center_in_box(ag, center=bad_center)(ts)
Пример #5
0
def test_center_in_box_bad_center(translate_universes):
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # what if a wrong center type name is passed?
    bad_center = " "
    with pytest.raises(ValueError): 
        center_in_box(ag, center=bad_center)(ts)
Пример #6
0
def test_center_in_box_bad_pbc(translate_universes):    
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # is pbc passed to the center methods?
    # if yes it should raise an exception for boxes that are zero in size
    with pytest.raises(ValueError): 
        center_in_box(ag, wrap=True)(ts)
Пример #7
0
def test_center_in_box_bad_center(translate_universes):
    # this universe has a box size zero
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # what if a wrong center type name is passed?
    bad_center = " "
    with pytest.raises(ValueError):
        center_in_box(ag, center=bad_center)(ts)
Пример #8
0
def test_center_in_box_no_masses(translate_universes):
    # this universe has no masses
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # if the universe has no masses and `mass` is passed as the center arg
    bad_center = "mass"
    with pytest.raises(AttributeError):
        center_in_box(ag, center=bad_center)(ts)
Пример #9
0
def centre_protein_gh(dict_of_systs, wrap=False, cent="geometry"):

    # The GroupHug class was created by Richard Gowers (https://github.com/richardjgowers)
    # in response to this question on the MDAnalysis forum:
    # https://groups.google.com/forum/#!topic/mdnalysis-discussion/umDpvbCmQiE

    class GroupHug:
        def __init__(self, center, *others):
            self.c = center
            self.o = others

        @staticmethod
        def calc_restoring_vec(ag1, ag2):
            box = ag1.dimensions[:3]
            dist = ag1.center_of_mass() - ag2.center_of_mass()

            return box * np.rint(dist / box)

        def __call__(self, ts):
            # loop over other atomgroups and shunt them into nearest image to center
            for i in self.o:
                rvec = self.calc_restoring_vec(self.c, i)

                i.translate(+rvec)

            return ts

    # Centre the protein in the box using MDAnalysis
    for ligand_name, syst in dict_of_systs.items():
        u = dict_of_systs[ligand_name]
        ligand_resname = ligand_name[:3]
        print(ligand_resname)

        if ligand_resname == "lar":
            print("WARNING: This script should only be used for the NTRK3 6KZD system!")

        # hard code the protein chains for now -> only for 6KZD model
        chainA = u.select_atoms("resid 527-627")
        chainB = u.select_atoms("resid 648-713")
        chainC = u.select_atoms("resid 728-838")
        lig = u.select_atoms("resname " + ligand_resname)
        ions = u.select_atoms("resname NA CL")

        protein = u.select_atoms("protein or resname ACE NME")
        reference = u.copy().select_atoms("protein or resname ACE NME")
        not_protein = u.select_atoms("not protein and not resname ACE NME")
        protein_and_lig = u.select_atoms("protein or resname ACE NME " + ligand_resname)

        transforms = [
            trans.unwrap(protein),
            trans.unwrap(lig),
            GroupHug(chainA, chainB, chainC, lig),
            trans.center_in_box(protein_and_lig, wrap=wrap, center="geometry"),
            trans.wrap(ions),
            trans.fit_rot_trans(protein, reference),
        ]

        dict_of_systs[ligand_name].trajectory.add_transformations(*transforms)

    return dict_of_systs
Пример #10
0
def test_center_in_box_coords_no_options(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ref_center = np.float32([6, 7, 8])
    box_center = np.float32([186., 186.5, 187.])
    ref.positions += box_center - ref_center
    ag = trans_u.residues[0].atoms
    trans = center_in_box(ag)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #11
0
def test_center_in_box_coords_no_options(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ref_center = np.float32([6, 7, 8])
    box_center = np.float32([186., 186.5, 187.])
    ref.positions += box_center - ref_center
    ag = trans_u.residues[0].atoms
    trans = center_in_box(ag)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #12
0
def test_center_in_box_coords_with_mass(translate_universes):   
    # using masses for calculating the center of the atomgroup
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[24].atoms
    box_center = np.float32([186., 186.5, 187.])
    ref_center = ag.center_of_mass()
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, center="mass")(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #13
0
def test_center_in_box_coords_with_mass(translate_universes):
    # using masses for calculating the center of the atomgroup
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[24].atoms
    box_center = np.float32([186., 186.5, 187.])
    ref_center = ag.center_of_mass()
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, center="mass")(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #14
0
def test_center_transformations_api(translate_universes):
    # test if the translate transformation works when using the 
    # on-the-fly transformations API
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ref_center = np.float32([6, 7, 8])
    box_center = np.float32([186., 186.5, 187.])
    ref.positions += box_center - ref_center
    ag = trans_u.residues[0].atoms
    trans_u.trajectory.add_transformations(center_in_box(ag))
    assert_array_almost_equal(trans_u.trajectory.ts.positions, ref.positions, decimal=6)
Пример #15
0
def test_center_in_box_coords_with_box(translate_universes):
    # using masses for calculating the center of the atomgroup
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[0].atoms
    newpoint = [1000, 1000, 1000]
    box_center = np.float32(newpoint)
    ref_center = np.float32([6, 7, 8])
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, point=newpoint)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #16
0
def test_center_in_box_coords_with_box(translate_universes):   
    # using masses for calculating the center of the atomgroup
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[0].atoms
    newpoint = [1000, 1000, 1000]
    box_center = np.float32(newpoint)
    ref_center = np.float32([6, 7, 8])
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, point=newpoint)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #17
0
def test_center_in_box_coords_with_pbc(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    # using pbc into account for center of geometry calculation
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    trans_u.dimensions = [363., 364., 365., 90., 90., 90.]
    ag = trans_u.residues[24].atoms
    box_center = np.float32([181.5, 182., 182.5])
    ref_center = np.float32([75.6, 75.8, 76.])
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, wrap=True)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #18
0
def test_center_in_box_coords_with_pbc(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    # using pbc into account for center of geometry calculation
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    trans_u.dimensions = [363., 364., 365., 90., 90., 90.]
    ag = trans_u.residues[24].atoms
    box_center = np.float32([181.5, 182., 182.5])
    ref_center = np.float32([75.6, 75.8, 76.])
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, wrap=True)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #19
0
def test_center_in_box_coords_all_options(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    # using pbc into account for center of geometry calculation
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[24].atoms
    newpoint = [1000, 1000, 1000]
    box_center = np.float32(newpoint)
    ref_center = ag.center_of_mass(pbc=True)
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, center='mass', wrap=True, point=newpoint)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #20
0
def test_center_transformations_api(translate_universes):
    # test if the translate transformation works when using the
    # on-the-fly transformations API
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ref_center = np.float32([6, 7, 8])
    box_center = np.float32([186., 186.5, 187.])
    ref.positions += box_center - ref_center
    ag = trans_u.residues[0].atoms
    trans_u.trajectory.add_transformations(center_in_box(ag))
    assert_array_almost_equal(trans_u.trajectory.ts.positions,
                              ref.positions,
                              decimal=6)
Пример #21
0
def test_center_in_box_coords_all_options(translate_universes):
    # what happens when we center the coordinates arround the center of geometry of a residue?
    # using pbc into account for center of geometry calculation
    ref_u, trans_u = translate_universes
    ref = ref_u.trajectory.ts
    ag = trans_u.residues[24].atoms
    newpoint = [1000, 1000, 1000]
    box_center = np.float32(newpoint)
    ref_center = ag.center_of_mass(pbc=True)
    ref.positions += box_center - ref_center
    trans = center_in_box(ag, center='mass', wrap=True,
                          point=newpoint)(trans_u.trajectory.ts)
    assert_array_almost_equal(trans.positions, ref.positions, decimal=6)
Пример #22
0
def centre_protein(dict_of_systs, wrap=False, cent="geometry"):

    # Centre the protein in the box using MDAnalysis
    for syst in dict_of_systs:
        u = dict_of_systs[syst]
        reference = u.copy().select_atoms("protein or resname ACE NME")

        protein = u.select_atoms("protein or resname ACE NME")
        not_protein = u.select_atoms("not protein")

        transforms = [
            trans.center_in_box(protein, wrap=wrap, center=cent),
            trans.wrap(not_protein),
            trans.fit_rot_trans(protein, reference),
        ]

        dict_of_systs[syst].trajectory.add_transformations(*transforms)

    return dict_of_systs
Пример #23
0
    atom2 = i.atoms.ids[1]

    distance = np.linalg.norm(u.trajectory[random_frame][atom1] -
                              u.trajectory[random_frame][atom2])

    if distance > allowed_max_distance:

        print("unusually long bond between " + str(atom1) + " " + str(atom2) +
              " with length " + str(distance / 10) + " nm")
        center_trigger = True

# the below selections must be adjusted when integrating into the AddData.py
membrane_string = 'resname POPC'  #( resname POPC or resname DPPC .... )
not_membrane_string = 'not resname POPC'

if center_trigger:

    u = mda.Universe(topol, traj)

    membrane = u.select_atoms(membrane_string)
    not_membrane = u.select_atoms(not_membrane_string)
    everything = u.select_atoms(everything_string)

    transforms = [
        trans.unwrap(membrane),
        trans.center_in_box(membrane, wrap=True),
        trans.wrap(not_membrane)
    ]

    u.trajectory.add_transformations(*transforms)
Пример #24
0
def test_center_in_box_bad_point(translate_universes, point):
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # what if the box is in the wrong format?
    with pytest.raises(ValueError):
        center_in_box(ag, point=point)(ts)
Пример #25
0
        nodrudes = u.select_atoms("not type DP_")
        core = nodrudes.select_atoms("resname na1*")
        ils = nodrudes.select_atoms("not group core", core=core)

        with mda.Writer(pdbfile, multiframe=True, bonds=None) as f:
            for ts in u.trajectory:
                f.write(nodrudes)

        u = mda.Universe(psffile, dcdfile, in_memory=True)

        core = u.select_atoms("resname na1* and not type DP_")
        notcore = u.select_atoms("not group core and not type DP_", core=core)

        workflow = [
            transformations.unwrap(core),
            transformations.center_in_box(core, center='mass'),
            transformations.wrap(notcore)
        ]

        u.trajectory.add_transformations(*workflow)

        with mda.Writer(ilfile, multiframe=True) as f:
            with mda.Writer(corefile, multiframe=True) as g:
                counter = 0
                for ts in u.trajectory:
                    if counter == 100:
                        cations, anions = order_ions(ionpairs)
                        resids = ""
                        for i in range(0, ionpairs):
                            if resids == "":
                                resids = resids + " resid {} or resid {}".format(
Пример #26
0
def runextract(ionpairs, dcdfile):
    def order_ions(ionpairs, u):
        cations = []
        anions = []
        for i in range(10, 150, 2):
            atoms = u.select_atoms(
                "sphlayer {} {} group core and not type DP_".format(
                    i / 10, (i + 2) / 10),
                core=core)
            for j in list(atoms):
                fields = str(j).split()
                if fields[8] == "c4c1pyrr,":
                    if fields[10] not in cations:
                        cations += [fields[10]]
                if fields[8] == "otf," or fields[8] == "tcm," or fields[
                        8] == "mso4,":
                    if fields[10] not in anions:
                        anions += [fields[10]]
        return (cations[0:ionpairs], anions[0:ionpairs])

    filepath = "/".join(dcdfile.split("/")[:-1])
    pdbname = dcdfile.split("/")[-1].split(".")[0]
    if filepath == "":
        filepath = "."
    psffile = filepath + f"/topol.psf"

    u = mda.Universe(psffile, dcdfile, in_memory=True)

    core = u.select_atoms("resname na1* and not type DP_")
    notcore = u.select_atoms("not group core and not type DP_", core=core)

    workflow = [
        transformations.unwrap(core),
        transformations.center_in_box(core, center='mass'),
        transformations.wrap(notcore)
    ]

    u.trajectory.add_transformations(*workflow)

    cations, anions = order_ions(ionpairs, u)
    counter = 1
    resids = ""
    filelist = []

    for j in range(1, ionpairs + 1):
        if resids == "":
            resids = resids + " resid {} or resid {}".format(
                cations[j - 1], anions[j - 1])
        else:
            resids = resids + " or resid {} or resid {}".format(
                cations[j - 1], anions[j - 1])

        with mda.Writer(f"{pdbname}-il-{j}.xyz") as f:
            filelist += [f"{pdbname}-il-{j}.xyz"]
            aroundcore = u.select_atoms("not type DP_ and ({})".format(resids))
            f.write(aroundcore)

        with mda.Writer(f"{pdbname}-core.xyz") as g:
            filelist += [f"{pdbname}-core.xyz"]
            g.write(core)
        counter += 1

    for xyzfile in filelist:
        geoms = readXYZ(xyzfile)
        count = 0

        with open(xyzfile, "w") as f:
            for i in geoms:
                for j in i:
                    f.write(str(j) + "\n")
Пример #27
0
protein = mda.Universe('selex.00.pdb').select_atoms('protein')

""" Crteate the solvent box """
num,rho = pkm.tools.molecules_for_target_density(
    {protein:1, ligand:1}, water, SOLVENT_BOX_RHO, SOLVENT_BOX_DIM)
solvent = pkm.packmol([
    pkm.PackmolStructure(water, num, [SOLVENT_BOX_CMD])])

""" Center components """
complejo = mda.Merge(ligand, protein)
protein = complejo.select_atoms('protein')
ligand = complejo.select_atoms('resname UNL')

point = [d/2 for d in SOLVENT_BOX_DIM]
complejo.trajectory.add_transformations(
    mtx.center_in_box(complejo.atoms, point=point, wrap=False))

""" Dissolve complex """
uni_selex00 = mda.Merge(complejo.atoms, solvent.atoms)

""" Construct mutation strings by chain for PDBFixer """
wtgroup_A = uni_selex00.select_atoms('segid A and (around 3.0 resname UNL)')
mutations_A = [f'{r.resname}-{r.resid}-GLY' for r in wtgroup_A.residues]

wtgroup_B = uni_selex00.select_atoms('segid B and (around 3.0 resname UNL)')
mutations_B = [f'{r.resname}-{r.resid}-GLY' for r in wtgroup_B.residues]
    
""" Apply mutations and save """
fixer = PDBFixer('selex.00.pdb')
fixer.applyMutations(mutations_A, 'A')
fixer.applyMutations(mutations_B, 'B')
Пример #28
0
def test_center_in_box_bad_point(translate_universes, point):
    ts = translate_universes[0].trajectory.ts
    ag = translate_universes[0].residues[0].atoms
    # what if the box is in the wrong format?
    with pytest.raises(ValueError): 
        center_in_box(ag, point=point)(ts)
Пример #29
0
    print("Running production simulation ...")
    simulation.step(production_steps)

if production_steps / production_trajectory_frequency >= 1:

    print("Transforming trajectory ...")
    u = mda.Universe(
        str(output_directory / "equilibration/out_state.pdb"),
        str(output_directory / "trajectory.xtc"),
    )
    backbone = u.select_atoms("backbone")
    not_protein = u.select_atoms("not protein")
    workflow = (
        transformations.unwrap(backbone),
        transformations.center_in_box(backbone),
        transformations.wrap(not_protein, compound="fragments"),
        transformations.fit_rot_trans(backbone, backbone),
    )
    u.trajectory.add_transformations(*workflow)

    print("Saving transformed topology and trajectory ...")
    u.atoms.write(str(output_directory / "topology_wrapped.pdb"))
    with mda.Writer(
        str(output_directory / "trajectory_wrapped.xtc"), u.atoms.n_atoms
    ) as W:
        for ts in u.trajectory:
            W.write(u.atoms)

print("Finished")
Пример #30
0
import MDAnalysis as mda
from MDAnalysis import transformations
import sys

#error handling
if len(sys.argv) != 4:
    raise Exception('wrong number of arguments. Need 3')
u = mda.Universe(sys.argv[1], sys.argv[2])
prot = u.select_atoms("segid A")
# we load another universe to define the reference
# it uses the same input files, but this doesn't have to be always the case
ref_u = u.copy()
reference = ref_u.select_atoms("segid A")
ag = u.atoms
workflow = (transformations.unwrap(ag), transformations.center_in_box(prot, center='mass'), transformations.wrap(ag, compound='fragments'))
u.trajectory.add_transformations(*workflow)

all_as=u.select_atoms('all')
with mda.Writer(sys.argv[3], all_as.n_atoms) as W:
    for ts in u.trajectory:
        W.write(all_as)
Пример #31
0
def populate_dict(chunk, dictionary, pdb_file, mutant_sel, project_code,
                  frames_to_stride):

    interface_selection_strings = {
        "rbd":
        "segid A and (backbone and (resid 403 or resid 417 or resid 439 or resid 445-447 or resid 449 or resid 453 or resid 455 or resid 456 or resid 473-477 or resid 484-487 or resid 489 or resid 490 or resid 493-503 or resid 505 or resid 506))",
        "ace2":
        "segid C and (backbone and (resid 18 or resid 21 or resid 23-32 or resid 33-39 or resid 41 or resid 42 or resid 45 or resid 75 or resid 76 or resid 78-84))",
        "rbd_and_ace2":
        "(segid A and (backbone and (resid 403 or resid 417 or resid 439 or resid 445-447 or resid 449 or resid 453 or resid 455 or resid 456 or resid 473-477 or resid 484-487 or resid 489 or resid 490 or resid 493-503 or resid 505 or resid 506))) or (segid C and (backbone and (resid 18 or resid 21 or resid 23-32 or resid 33-39 or resid 41 or resid 42 or resid 45 or resid 75 or resid 76 or resid 78-84)))",
    }

    # Create a dictionary containing selection strings for MDAnalysis
    # residues 417 and 439 are not named since these are mutated across systems
    # segid C = ACE2, segid A = RBD

    # TODO remove project keys, not sure they are needed
    proj_mutant_dict = {
        "17311": {
            "WT": {
                "D30": "segid C and (resid 30 and name OD1 OD2)",
                "res417": "segid A and (resid 417 and name NZ)",
                "E329": "segid C and (resid 329 and name OE1 OE2)",
                "res439": "segid A and (resid 439 and name ND2)",
                "K31": "segid C and (resid 31 and name NZ)",
                "E484": "segid A and (resid 484 and name OE1 OE2)",
                "E35": "segid C and (resid 35 and name OE1 OE2)",
                "K31": "segid C and (resid 31 and name NZ)",
                "Q493": "segid A and (resid 493 and name NE2 OE1)",
                "K353": "segid C and (resid 353 and name NZ)",
                "G496bb": "segid A and (resid 496 and name O C CA N)",
                "D38": "segid C and (resid 38 and name OD1 OD2)",
                "Y449":
                "segid A and (resid 449 and name CG CD1 CE1 CZ CE2 CD2 OH)",
                "Q42": "segid C and (resid 42 and name NE2 OE1)",
                "K353bb": "segid C and (resid 353 and name O C CA N)",
                "G502bb": "segid A and (resid 502 and name O C CA N)",
            },
        },
    }

    # set the reference to be the equilibrated structure
    ref = mda.Universe(pdb_file)
    ref.trajectory[0]  # there is only one frame anyway, but just to be sure
    ref_bb = ref.select_atoms("backbone")  # the ref for RMSD calcs later

    # set reference interfaces
    ref_rbd_interface_bb = ref.select_atoms(interface_selection_strings["rbd"])

    ref_ace2_interface_bb = ref.select_atoms(
        interface_selection_strings["ace2"])

    ref_whole_interface_bb = ref.select_atoms(
        interface_selection_strings["rbd_and_ace2"])

    reference = ref.select_atoms(
        "not resname Na+ Cl- HOH")  # the ref for transforms later

    for traj in chunk:
        print("--> Analysing trajectory: ", traj)

        mobile = mda.Universe(pdb_file, traj)
        # centre the two protein chains in the box
        # this stops chains jumping across PBC
        chainA = mobile.select_atoms("segid A or segid B")  # RBD + glycans
        chainB = mobile.select_atoms("segid C or segid D")  # ACE2 + glycans
        ions = mobile.select_atoms("resname Na+ Cl- HOH")
        protein = mobile.select_atoms("not resname Na+ Cl- HOH")

        transforms = [
            trans.unwrap(protein),
            GroupHug(chainA, chainB),
            trans.center_in_box(protein, wrap=False, center="geometry"),
            trans.wrap(ions),
            trans.fit_rot_trans(protein, reference),
        ]

        print("--> Centring protein chains in the box")
        mobile.trajectory.add_transformations(*transforms)

        # loop over each frame in the current trajectory, with a defined stride
        for ts in mobile.trajectory[::frames_to_stride]:

            print(f"--> Current frame: {ts.frame}")

            # calculate the key interactions
            # RBD --- ACE2

            # D30 --- K417
            D30 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["D30"])
            res417 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["res417"])

            D30_res417_dist_mindist = np.min(
                distances.distance_array(D30.positions, res417.positions))

            # E329 --- N439
            E329 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["E329"])
            res439 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["res439"])

            E329_res439_dist_mindist = np.min(
                distances.distance_array(E329.positions, res439.positions))

            # E484 --- K31
            K31 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["K31"])
            E484 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["E484"])

            E484_K31_dist_mindist = np.min(
                distances.distance_array(E484.positions, K31.positions))

            # E35 --- K31
            E35 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["E35"])

            E35_K31_dist_mindist = np.min(
                distances.distance_array(E35.positions, K31.positions))

            # E35 --- Q493
            Q493 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["Q493"])

            E35_Q493_dist_mindist = np.min(
                distances.distance_array(E35.positions, Q493.positions))

            # Additional interactions
            K31_Q493_dist_mindist = np.min(
                distances.distance_array(K31.positions, Q493.positions))

            # K353 --- G496 (K353 to G496 backbone)
            K353 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["K353"])
            G496bb = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["G496bb"])

            K353_G496bb_dist_mindist = np.min(
                distances.distance_array(K353.positions, G496bb.positions))

            # D38 --- Y449
            D38 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["D38"])
            Y449 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["Y449"])

            D38_Y449_dist_mindist = np.min(
                distances.distance_array(D38.positions, Y449.positions))

            # Q42 --- Y449
            Q42 = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["Q42"])

            Q42_Y449_dist_mindist = np.min(
                distances.distance_array(Q42.positions, Y449.positions))

            # K353bb --- G502bb (Backbone to backbone)
            K353bb = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["K353bb"])
            G502bb = mobile.select_atoms(
                proj_mutant_dict[project_code][mutant]["G502bb"])

            K353bb_G502bb_dist_mindist = np.min(
                distances.distance_array(K353bb.positions, G502bb.positions))

            # sort out names for the dict
            traj_split = traj.split("/")
            key_name = f"{traj_split[6]}/{traj_split[7]}/{traj_split[8]}_{ts.frame}"

            # populate the dict - with placeholder keys for now
            dictionary[key_name] = {
                "d30_res417_mindist": D30_res417_dist_mindist,
                "e329_res439_mindist": E329_res439_dist_mindist,
                "e484_k31_mindist": E484_K31_dist_mindist,
                "e35_k31_mindist": E35_K31_dist_mindist,
                "e35_q493_mindist": E35_Q493_dist_mindist,
                "q493_k31_mindist": K31_Q493_dist_mindist,
                "k353_g496bb_mindist": K353_G496bb_dist_mindist,
                "d38_y449_dist_mindist": D38_Y449_dist_mindist,
                "q42_y449_dist_mindist": Q42_Y449_dist_mindist,
                "k353bb_g502bb_dist_mindist": K353bb_G502bb_dist_mindist,
            }