def writepdbfile(atoms, filename): with open(filename, 'w') as f: for atom in atoms: if atom == 'TER\n': f.write('TER\n') else: f.write(iolines.atom2pdb(atom))
print 'Writ:oniom_line7-', new_line7 # 8 check_oniom8(oniom_line8, 'read') atom8 = iolines.zmat2atom(oniom_line8) new_line8 = iolines.atom2zmat(atom8) check_oniom8(new_line8, 'write') print 'Read:oniom_line8-', oniom_line8 print 'Writ:oniom_line8-', new_line8 #xyzpdb_line check_xyzpdb(xyzpdb_line, 'read') atom_xyzpdb = iolines.zmat2atom(xyzpdb_line) new_linexyzpdb = iolines.atom2zmat(atom_xyzpdb) check_xyzpdb(xyzpdb_line, 'write') print 'Read:xyzpdb_line-', xyzpdb_line print 'Writ:xyzpdb_line-', new_linexyzpdb # mm check_mm(mm_line, 'read') atom_mm = iolines.zmat2atom(mm_line) new_line_mm = iolines.atom2zmat(atom_mm) check_mm(new_line_mm, 'write') # print pdb oniom8 atom8 = iolines.zmat2atom(oniom_line8) p = atoms.PDBinfo('HETATM', 27) atom8.set_pdbinfo(p) print(iolines.atom2pdb(atom8))
if str(scan_step) == 'all': print(len(gaussianlog.grep_bytes['orientation:'])) #falta meter aqui a opcao opt_step =='all' , mas neste caso nao faz muito sentido #if opt_step == 'all': opt_step = int(opt_step) print(len(gaussianlog.grep_bytes['orientation:'])) for i in range(len(gaussianlog.grep_bytes['orientation:'])): atoms_structure = gaussianlog.read_geometry(opt_step, i) for j,atom in enumerate(atoms_structure): pdb_obj = atoms.PDBinfo('ATOM', j+1 ) #res_obj = atoms.RESinfo(atom.element,'',0,'') #quando nao ha info pdb #atom.set_resinfo(res_obj) atom.set_pdbinfo(pdb_obj) atom.pdbinfo.altloc = atom.oniom.layer open_output.write(iolines.atom2pdb(atom)) open_output.write("END\n") #casos em que so extraio de um scan else: scan_step = int(scan_step) #todos os opt if opt_step == 'all': for i in range(len(gaussianlog.grep_bytes['orientation:'][scan_step])): atoms_structure = gaussianlog.read_geometry(i, scan_step) for j,atom in enumerate(atoms_structure): pdb_obj = atoms.PDBinfo('ATOM', j+1) atom.set_pdbinfo(pdb_obj) atom.pdbinfo.altloc = atom.oniom.layer open_output.write(iolines.atom2pdb(atom)) open_output.write("END\n")