def test_dssp(path): sec_struct_codes = { 0: "I", 1: "S", 2: "H", 3: "E", 4: "G", 5: "B", 6: "T", 7: "C" } mmtf_file = mmtf.MMTFFile.read(path) array = mmtf.get_structure(mmtf_file, model=1) array = array[array.hetero == False] first_chain_id = array.chain_id[0] chain = array[array.chain_id == first_chain_id] n_residues = struc.get_residue_count(chain) # Secondary structure annotation in PDB use also DSSP # -> compare PDB and local DSSP sse = mmtf_file["secStructList"] sse = sse[:n_residues] if (sse == -1).all(): # First chain is not a polypeptide chain (presumably DNA/RNA) # DSSP not applicable -> return return sse = np.array([sec_struct_codes[code] for code in sse], dtype="U1") chain = array[array.chain_id == first_chain_id] sse_from_app = DsspApp.annotate_sse(chain) np.set_printoptions(threshold=10000) # PDB uses different DSSP version -> slight differences possible # -> only 90% must be identical assert np.count_nonzero(sse_from_app == sse) / len(sse) > 0.9
def test_invalid_structure(): array = strucio.load_structure(join(data_dir("structure"), "5ugo.mmtf")) # Get DNA chain -> Invalid for DSSP chain = array[array.chain_id == "T"] with pytest.raises(SubprocessError): DsspApp.annotate_sse(chain)
import biotite.structure.io.xtc as xtc from biotite.application.dssp import DsspApp # Put here the path of the downloaded files templ_file_path = "../../download/lysozyme_md.pdb" traj_file_path = "../../download/lysozyme_md.xtc" xtc_file = xtc.XTCFile.read(traj_file_path) traj = xtc_file.get_structure(template=strucio.load_structure(templ_file_path)) time = xtc_file.get_time() traj = traj[:, struc.filter_amino_acids(traj)] # DSSP does not assign an SSE to the last residue -> -1 sse = np.empty((traj.shape[0], struc.get_residue_count(traj) - 1), dtype='U1') for idx, frame in enumerate(traj): app = DsspApp(traj[idx]) app.start() app.join() sse[idx] = app.get_sse() # Matplotlib needs numbers to assign colors correctly def sse_to_num(sse): num = np.empty(sse.shape, dtype=int) num[sse == 'C'] = 0 num[sse == 'E'] = 1 num[sse == 'B'] = 2 num[sse == 'S'] = 3 num[sse == 'T'] = 4 num[sse == 'H'] = 5 num[sse == 'G'] = 6