def plotdmat(line): xyzs = np.zeros((len_peptide, 3)) # Unpack parameters _, pdb, chain, species = line[:4] betatype = line[10] # Read coordinates from a PDB file... fl_pdb = f"{pdb}.pdb" pdb_path = os.path.join(drc, fl_pdb) atoms_pdb = pr.atom.read(pdb_path) # Create a lookup table for this pdb... atom_dict = pr.atom.create_lookup_table(atoms_pdb) # Obtain coordinates... xyzs = pr.atom.extract_xyz(peptide, atom_dict, chain, nterm, cterm) # Calculate distance matrix... dmat = pr.distance.calc_dmat(xyzs, xyzs) fl_dmat = os.path.join(drc_dmat, f"{pdb}.{chain}.dmat") plot_dmat(dmat, fl_dmat, lbl = {}, lbl_fontsize = 29, width = 10, height = 12, fontsize = 29, linewidth = 2.0, palette = pal, NaN = 0) return None
def plotdmat(line): # Unpack parameters _, pdb, chain, lb_term, ub_term = line[:5] # Read coordinates from a PDB file... fl_pdb = f"{pdb}.pdb" pdb_path = os.path.join(drc, fl_pdb) atoms_pdb = pr.atom.read(pdb_path) # Create a lookup table for this pdb... atom_dict = pr.atom.create_lookup_table(atoms_pdb) # Obtain the chain to process... chain_dict = atom_dict[chain] # Obtain seq string for the current chain... tar_seq = seq_dict[f"{pdb.lower()}_{chain}"] # Obtain xyzs... entry = f"{pdb}_{chain}" xyzs = pr.atom.extract_xyz_by_seq(backbone, chain_dict, tar_seq, nseqi, cseqi) # Calculate distance matrix... dmat = pr.distance.calc_dmat(xyzs, xyzs) fl_dmat = os.path.join(drc_dmat, f"{pdb}.{chain}.dmat") plot_dmat(dmat, fl_dmat, lbl={}, palette=pal, NaN=0, linewidth=1, intst_max=100) return None
## # Draw the rigid framework... ## fl_fwk = 'fwk.dat' ## fwk = pr.utils.read_file(fl_fwk, numerical = True) ## cmd_fwk = [] ## for i in range(len(fwk)): ## cmd = [] ## b1, e1 = [ k * 4 for k in fwk[i] ] ## cmd.append(f"set object rectangle front from {b1},{e1} to {e1},{b1} fs empty border linecolor rgb 'black'") ## for j in range(i + 1, len(fwk)): ## b2, e2 = [ k * 4 for k in fwk[j] ] ## cmd.append(f"set object rectangle front from {b1},{b2} to {e1},{e2} fs empty linecolor rgb '{color_guideline}'") ## cmd_fwk.extend(cmd) ## cmds_guideline_bottom.extend(cmd_fwk) ## cmds_guideline_top.append(f"set key top left") plot_dmat( dmat_full, fl_rmsd_dmat, lbl={}, width=10, height=12, fontsize=29, lbl_fontsize=29, linewidth=2.0, palette=pal, intst_max="*", ## cmds_top = cmds_guideline_top, ## cmds_bottom = cmds_guideline_bottom, )
chain_dict = atom_dict[chain] # Obtain seq string for the current chain... tar_seq = seq_dict[f"{pdb.lower()}_{chain}"] # Obtain xyzs... entry = f"{pdb}_{chain}" xyzs = pr.atom.extract_xyz_by_seq(backbone, chain_dict, tar_seq, nseqi, cseqi) xyzs[mask_loop == 0] = np.nan # Calculate distance matrix... dmat = pr.distance.calc_dmat(xyzs, xyzs) fl_dmat = os.path.join(drc_dmat, f"{pdb}.{chain}.dmat") plot_dmat(dmat, fl_dmat, lbl={}, palette=pal, NaN=0) if pdb == "7dd5": break if False: def plotdmat(line): # Unpack parameters _, pdb, chain, lb_term, ub_term = line[:5] # Read coordinates from a PDB file... fl_pdb = f"{pdb}.pdb" pdb_path = os.path.join(drc, fl_pdb) atoms_pdb = pr.atom.read(pdb_path) # Create a lookup table for this pdb...
# Find the indices of values that are within the range of (dmin, dmax)... out_range_bool = np.logical_or(dmin > dmat, dmat > dmax) # Form a submatrix by selecting values within the range... dmat[out_range_bool] = np.nan # Apply dmask... dmat *= dmask # Put more resi labels... diaglbl = {} for resi in range(nterm, cterm, 1): seqi = pr.fasta.resi_to_seqi(resi, super_seg, nterm) diaglbl[resi] = [seqi, seqi] fl_dmat = os.path.join(drc_dmat, f"{pdb}.{chain}.dmat") plot_dmat(dmat, fl_dmat, lbl=labels_TM, lbl_fontsize=18, diaglbl=diaglbl, diaglblfontsize=3, intst_min=dmin, intst_max=dmax, palette=pal, temp=False, mode='sparse', showsparselabel=False, NaN=0)
# Define a colorscheme... # Colorscheme is inspired by from this publication (DOI: 10.1093/nar/gkw555) from Zhong Ren pal = "set palette defined ( 0 'seagreen', 0.1 'white', 0.5 'blue', 1 'navy' )" # Create labels... # +1 to make it a right-end closed ## labels = { ## "TM1" : [ 36, 60 + 1], ## "TM2" : [ 69, 97 + 1], ## "TM3" : [104, 136 + 1], ## "TM4" : [146, 171 + 1], ## "TM5" : [189, 221 + 1], ## "TM6" : [369, 397 + 1], ## "TM7" : [406, 427 + 1], ## "H8" : [432, 441 + 1], ## } ## for k, v in labels.items(): labels[k] = [ (i - nterm) * len_res for i in v ] plot_dmat( rmsd_dmat, fl_rmsd_dmat, ## lbl = labels, width=10, height=12, fontsize=29, lbl_fontsize=29, linewidth=1.0, palette=pal, intst_max="*", )