def test_residue_iter(array): centroid = [ struc.centroid(res).tolist() for res in struc.residue_iter(array) ] ref_centroid = struc.apply_residue_wise(array, array.coord, np.average, axis=0) assert centroid == ref_centroid.tolist()
def test_coarse_grained(pdb_id): # Multi atom SASA (ProtOr), compare with single atom SASA # on residue level file = mmtf.MMTFFile.read(join(data_dir("structure"), pdb_id + ".mmtf")) array = mmtf.get_structure(file, model=1) array = array[struc.filter_amino_acids(array)] sasa = struc.apply_residue_wise(array, struc.sasa(array, vdw_radii="ProtOr"), np.nansum) sasa_exp = struc.apply_residue_wise(array, struc.sasa(array, vdw_radii="Single"), np.nansum) # Assert that more than 90% of atoms # have less than 10% SASA difference assert np.count_nonzero(np.isclose(sasa, sasa_exp, rtol=1e-1, atol=1)) / len(sasa) > 0.9 # Assert that more than 98% of atoms # have less than 40% SASA difference assert np.count_nonzero(np.isclose(sasa, sasa_exp, rtol=4e-1, atol=1)) / len(sasa) > 0.98
def test_apply_residue_wise(array): data = struc.apply_residue_wise(array, np.ones(len(array)), np.sum) assert data.tolist() == [ len(array[array.res_id == i]) for i in range(1, 21) ]
# Besides other parameters, you can choose between different # Van-der-Waals radii sets: # *Prot0r*, the default set, is a set that defines radii for # non-hydrogen atoms, but determines the radius of an atom based on the # assumed amount of hydrogen atoms connected to it. # Therefore, *ProtOr* is suitable for structures with missing hydrogen # atoms, like crystal structures. # Since the structure of *TC5b* was elucidated via NMR, we can assign a # radius to every single atom (including hydrogens), hence we use the # *Single* set. array = strucio.load_structure(file_path)[0] # The following line calculates the atom-wise SASA of the atom array atom_sasa = struc.sasa(array, vdw_radii="Single") # Sum up SASA for each residue in atom array res_sasa = struc.apply_residue_wise(array, atom_sasa, np.sum) # Again plotting stuff plt.plot(np.arange(1, 21), res_sasa) plt.xlim(0, 20) plt.xticks(np.arange(1, 21)) plt.xlabel("Residue") plt.ylabel("SASA") plt.show() ######################################################################## # Secondary structure determination # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # # *Biotite* can also be used to assign # *secondary structure elements* (SSE) to a structure with the # :func:`annotate_sse()` function.