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 f_log.close() pdb_out = PdbFile(sys.argv[3]) pdb_out.open_to_write() pdb_out.write_all(chains) pdb_out.close()
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]) bf = [] for line in f_bf_in: if line.find('#') != -1: continue bf.append(float(line.split()[1]))
if len(sys.argv) != 4: print(' Usage: % SCRIPT [input DCD] [input PDB] [output PDB] ') sys.exit(2) dcd = DcdFile(sys.argv[1]) dcd.open_to_read() dcd.read_header() nmp = dcd.get_header().nmp_real f_pdb = PdbFile(sys.argv[2]) f_pdb.open_to_read() chains = f_pdb.read_all() f_pdb.close() f_out = PdbFile(sys.argv[3]) f_out.open_to_write() ave = [] for i in range(nmp): xyz = [0.0, 0.0, 0.0] ave.append(xyz) nframe = 0 while dcd.has_more_data(): data = dcd.read_onestep() nframe += 1 print(nframe) for i in range(nmp): ave[i][0] += data[i][0] ave[i][1] += data[i][1] ave[i][2] += data[i][2]
from cafysis.file_io.ts import TsFile from cafysis.file_io.pdb import PdbFile if len(sys.argv) != 5: print('Usage: % SCRIPT [input DCD] [ts file] [reference PDB] [output movie]') sys.exit(2) # Read the reference PDB pdb = PdbFile(sys.argv[-2]) pdb.open_to_read() chains = pdb.read_all() pdb.close() # Output PDB pdb = PdbFile(sys.argv[-1]) pdb.open_to_write() # Open DCD and read the header dcd_filename = sys.argv[1] dcd = DcdFile(dcd_filename) dcd.open_to_read() dcd.read_header() # Open TS and read the header ts = TsFile(sys.argv[2]) ts.open_to_read() ts.read_header() # read and write imodel = 0 i_org = 0
# matrices[mtx_id].show() #sys.exit(1) filename_pdb = sys.argv[1] ''' Read inpout PDB ''' pdb = PdbFile(filename_pdb) pdb.open_to_read() chains = pdb.read_all() pdb.close() _, ext = os.path.splitext(filename_pdb) filename_base = os.path.basename(filename_pdb)[:-len(ext)] ''' Rotate and output each assembly unit ''' for mtx_id in assembly_units: newchains = copy.deepcopy(chains) for c in newchains: for r in c.residues: for a in r.atoms: #print ('###') #print (a.xyz.x, a.xyz.y, a.xyz.z) a.xyz.put_as_list(matrices[mtx_id].do_to_1darray( a.xyz.get_as_ndarray())) #print (a.xyz.x, a.xyz.y, a.xyz.z) outpdb = PdbFile('%s_%s%s' % (filename_base, mtx_id, ext)) outpdb.open_to_write() outpdb.write_all(newchains) outpdb.close()
a.serial = atom_id a.name = ' S ' a.res_name = 'D%s ' % nt[SEQ_POSITION:SEQ_POSITION + 1] #a.chain_id = 'A' a.chain_id = '%s' % nchain a.res_seq = res_id a.xyz = xyz_S / float(nS) r_cg.push_atom(a) atom_id += 1 a = Atom() a.serial = atom_id #a.name = ' %sb ' % nt a.name = ' %sb ' % nt[SEQ_POSITION:SEQ_POSITION + 1] #a.res_name = 'R%s ' % nt a.res_name = 'D%s ' % nt[SEQ_POSITION:SEQ_POSITION + 1] #a.chain_id = 'A' a.chain_id = '%s' % nchain a.res_seq = res_id a.xyz = xyz_B / float(nB) r_cg.push_atom(a) c_cg.push_residue(r_cg) cg_chains.append(c_cg) cg = PdbFile(sys.argv[-1]) cg.open_to_write() cg.write_all(cg_chains) cg.close()
print('Error: Beginning frame must be > 0') sys.exit(2) if args.frame_stride <= 0: print('Error: Frame stride must be > 0') sys.exit(2) # Read the reference PDB pdb = PdbFile(args.pdb) pdb.open_to_read() chains = pdb.read_all() pdb.close() # Output PDB movie = PdbFile(args.out) movie.open_to_write() # Open DCD and read the header dcd = DcdFile(args.dcd) dcd.open_to_read() dcd.read_header() num_dcd_frames = dcd.count_frame() if args.frame_end == -1: frame_end = num_dcd_frames - 1 elif args.frame_end > num_dcd_frames - 1: print('Warning: There are only %i frames found in the dcd while you specified --to %i' % (num_dcd_frames, args.frame_end)) print(' Output only %i frames.' % (num_dcd_frames)) frame_end = num_dcd_frames - 1