def dcd_fit(filename_dcd, filename_dcd_out, natom_total, serials, filename_rmsd): f_out = open(filename_rmsd, 'w') # Coord1 pdb = PdbFile('16SCD.cg.pdb') pdb.open_to_read() ref_chains = pdb.read_all() pdb.close() #num_atom = 0 #for chain in ref_chains : # for residue in chain.residues : # num_atom += len(residue.atoms) ref = zeros((natom_total, 3), dtype=float64, order='C') i = 0 for chain in ref_chains: for residue in chain.residues: for atom in residue.atoms: (ref[i][0], ref[i][1], ref[i][2]) = atom.xyz.get_as_tuple() i += 1 mask = [] for i in range(natom_total): # the serial ID starts from 1, thus i+1 is the serial ID if i + 1 in serials: mask.append(1) else: mask.append(0) dcd = DcdFile(filename_dcd) dcd.open_to_read() dcd.read_header() out_dcd = DcdFile(filename_dcd_out) out_dcd.open_to_write() out_dcd.set_header(dcd.get_header()) out_dcd.write_header() #dcd.show_header() k = 0 while dcd.has_more_data(): k += 1 coords_dcd = dcd.read_onestep_np() rmsd = superimpose(ref.T, coords_dcd.T, mask) f_out.write('{:8d} {:6.2f}\n'.format(k, rmsd)) out_dcd.write_onestep(coords_dcd) dcd.close() out_dcd.close()
# -*- coding: utf-8 -*- ''' @author: Naoto Hori ''' import sys from cafysis.file_io.pdb import PdbFile if len(sys.argv) != 6: print( '\n Usage: SCRIPT [bfactor file] [PDB file] [scale] [Upper] [output PDB file]\n' ) sys.exit(2) f_bf_in = open(sys.argv[1], 'r') f_pdb = PdbFile(sys.argv[2]) f_pdb.open_to_read() chains = f_pdb.read_all() f_pdb.close() f_pdb_out = PdbFile(sys.argv[-1]) f_pdb_out.open_to_write() f_pdb_out._file.write('RECORD # SCRIPT: bfactor_write_to_pdb.py\n') f_pdb_out._file.write('RECORD # argv[1]: ' + sys.argv[1] + '\n') f_pdb_out._file.write('RECORD # argv[2]: ' + sys.argv[2] + '\n') f_pdb_out._file.write('RECORD # argv[3]: ' + sys.argv[3] + '\n') f_pdb_out._file.write('RECORD # argv[4]: ' + sys.argv[4] + '\n') f_pdb_out._file.write('RECORD # argv[5]: ' + sys.argv[5] + '\n') scale = float(sys.argv[3]) upper = float(sys.argv[4])
@author: Naoto Hori ''' import sys from cafysis.file_io.pdb import PdbFile if len(sys.argv) != 5: print('') print( ' Usage: SCRIPT [input PDB] [The residue number of the first a.a.] [output PDB] [log file]' ) print('') sys.exit(2) pdb_in = PdbFile(sys.argv[1]) pdb_in.open_to_read() chains = pdb_in.read_all() pdb_in.close() res_id = int(sys.argv[2]) f_log = open(sys.argv[4], 'w') f_log.write('#original -> new\n') for c in chains: print(sys.argv[1], '#residues', len(c.residues)) for r in c.residues: f_log.write('%i %s -> %i\n' % (r.atoms[0].res_seq, r.atoms[0].ins_code, res_id)) for a in r.atoms: a.res_seq = res_id a.ins_code = ' ' res_id += 1
ID_DOM_INI = int(sys.argv[3]) - 1 # 重心を求める際に必要 ID_DOM_END = int(sys.argv[4]) - 1 ID_DOM_INI_FIT = int(sys.argv[5]) - 1 # 重心を求める際に必要 ID_DOM_END_FIT = int(sys.argv[6]) - 1 BOXSIZE = float(sys.argv[7]) BOXMAX = 0.5 * BOXSIZE BOXMIN = -0.5 * BOXSIZE ### Files dcd = DcdFile(sys.argv[1]) dcd.open_to_read() pdb = PdbFile(sys.argv[2]) pdb.open_to_read() dcd_out = DcdFile(sys.argv[-1]) dcd_out.open_to_write() ### Read the reference pdb ref_chains = pdb.read_all() num_atom = 0 for chain in ref_chains : num_atom += chain.num_atom() ref = zeros((3, num_atom), dtype=float64, order='F') i = 0 for chain in ref_chains :
import sys import math from cafysis.file_io.pdb import PdbFile from cafysis.file_io.ninfo import NinfoFile from cafysis.para.rnaAform import ARNA from cafysis.para.rnaDT13 import DT13 from cafysis.elements.ninfo import NinfoSet, BondLength, BondAngle, BaseStackDT, HBondDT if len(sys.argv) != 4: print('Usage: SCRIPT [cg pdb] [hb list file] [output ninfo]') sys.exit(2) f_in = PdbFile(sys.argv[1]) f_in.open_to_read() chains = f_in.read_all() f_in.close() if len(chains) > 1: print('%i chains' % len(chains)) n_nt = [] for ic, c in enumerate(chains): n_nt.append(c.num_res()) print('#nt (chain %i): ', ic + 1, n_nt) seq = [] for ic, c in enumerate(chains): s = [] for r in c.residues:
import math from cafysis.file_io.pdb import PdbFile from cafysis.elements.coord import Coord if len(sys.argv) not in (2, 3): print('Usage: SCRIPT [PDB] (score cutoff = 0.5)') print(' or : SCRIPT [PDB] [score cutoff]') sys.exit(2) SCORE_CUT = 0.5 if len(sys.argv) > 2: SCORE_CUT = float(sys.argv[2]) pf = PdbFile(sys.argv[1]) pf.open_to_read() chains = pf.read_all() pf.close() coms = [] normals = [] locations = [] ## Suppose all residues have a base nres = 0 for ic, c in enumerate(chains): for ir, r in enumerate(c.residues): nres += 1
from cafysis.file_io.ninfo import NinfoFile from cafysis.file_io.pdb import PdbFile if len(sys.argv) != 4: print ("Usage: SCRIPT [ninfo file] [pdb file] [output file]") sys.exit(2) file_ninfo = NinfoFile(sys.argv[1]) file_ninfo.open_to_read() ns = NinfoSet() file_ninfo.read_all(ns) ns.update_info() file_ninfo.close() file_pdb = PdbFile(sys.argv[2]) file_pdb.open_to_read() chains = file_pdb.read_all() xyz = [] for c in chains: for i in range(c.num_atom()): xyz.append(c.get_atom(i).xyz) print(("## Confirmation: number of atoms = %i" % len(xyz))) f_out = open(sys.argv[-1],'w') f_out.write('#Contacts\n') for con in ns.contacts: conid = con.id imp1 = con.imp1
imp2_offset += c2.num_res() imp1_offset += c1.num_res() return if __name__ == '__main__': import sys if len(sys.argv) != 3: print ('Usage: %SCRIPT [input PDB] [output ninfo]') sys.exit(2) from cafysis.file_io.pdb import PdbFile from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet f = PdbFile(sys.argv[1]) f.open_to_read() chains = f.read_all() f.close() ns = NinfoSet() generate_FENEs(chains, ns) generate_LJs(chains, ns) f_ninfo = NinfoFile(sys.argv[-1]) f_ninfo.open_to_write() f_ninfo.write_all(ns) f_ninfo.close()
SEP_B_B = 3 # residue (i) and residue (i+3) SEP_B_S = 2 # residue (i) and residue (i+2) SEP_S_S = 2 # residue (i) and residue (i+2) import sys from cafysis.file_io.pdb import PdbFile from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet, Fene, LJ from cafysis.para.BetancourtThirumalai import BTmatrix if len(sys.argv) != 3: print('Usage: SCRIPT [input PDB] [output ninfo]') sys.exit(2) p = PdbFile(sys.argv[1]) p.open_to_read() chains = p.read_all() ns = NinfoSet() a_BB_pre = None for ic, c in enumerate(chains): for r in c.residues: num_a = len(r.atoms) a_BB = None a_SC = None for a in r.atoms:
# DT5, DA, DC ...., then SEQ_POSITION = 1 # T5, A, C ...., then #SEQ_POSITION = 0 ATOMS_P = ('P', 'OP1', 'OP2', "O5'") # "O3'" from the previous nucleotide ATOMS_P_AMBER = ("P", "O1P", "O2P", "O5*") ATOMS_S = ("C5'", "C4'", "C3'", "C2'", "C1'", "O4'") ATOMS_S_AMBER = ("C5*", "C4*", "C3*", "C2*", "C1*", "O4*") ATOMS_A = ("N9", "C8", "N7", "C5", "C6", "N6", "N1", "C2", "N3", "C4") ATOMS_G = ("N9", "C8", "N7", "C5", "C6", "O6", "N1", "C2", "N2", "N3", "C4") ATOMS_C = ("N1", "C2", "O2", "N3", "C4", "N4", "C5", "C6") ATOMS_T = ("N1", "C2", "O2", "N3", "C4", "O4", "C5", "C7", "C6") aa = PdbFile(sys.argv[1]) aa.open_to_read() chains = aa.read_all() cg_chains = [] atom_id = 0 for c in chains: c_cg = Chain() xyz_O3 = None res_id = 0 for ir, r in enumerate(c.residues): xyz_P = Coord() nP = 0