예제 #1
0
def test_single(pdb_id):
    file_name = join(data_dir, pdb_id + ".pdb")

    # Single atom SASA, compare with MDTraj
    file = pdb.PDBFile()
    file.read(file_name)
    array = file.get_structure(model=1)
    sasa = struc.sasa(array, vdw_radii="Single", point_number=5000)

    from biotite.structure.info.radii import _SINGLE_RADII as radii
    import mdtraj
    # Use the same atom radii
    radii = {
        element.capitalize(): radius / 10
        for element, radius in radii.items()
    }
    traj = mdtraj.load(file_name)
    # Conversion from nm^2 to A^2
    sasa_exp = mdtraj.shrake_rupley(
        traj, change_radii=radii, n_sphere_points=5000)[0] * 100

    # 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=1e-1)) / len(sasa) > 0.9
    # Assert that more than 98% of atoms
    # have less than 1% SASA difference
    assert np.count_nonzero(np.isclose(sasa, sasa_exp, rtol=1e-2,
                                       atol=1e-1)) / len(sasa) > 0.98
예제 #2
0
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
예제 #3
0
# residue-wise SASA.
#
# 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