def convert_topology(src_filename, set_backbone=True, in_place=False, split_dir=None): """ Converts the D.E.Shaw topology to Charm-usable force field with TIP4P water molecules. THis re-sorts the atoms in the water solvent chains (C2,C3) to group all 4 atoms as one contiguous residue. It also aliases the ion charges 'pseu' atom to 'OM' for use with the standard tip4p.par parameter file. The set_backbone option is to set constraint during initial minimzation""" # Grab unit cell description (should be on first few lines: cryst = None with open(src_filename) as src: for line in src.readlines(): if line.startswith('CRYST1'): cryst = line break # Read in source PDB (DEShaw original format) src_pdb = PdbStructure(open(src_filename)) atoms = list(src_pdb.iter_atoms()) topo = md.load(src_filename).top # Break into 4 segments segment_list = ['C1', 'C2', 'C3', 'C4'] segment = {l:[] for l in segment_list} for i in atoms: segment[i.segment_id].append(i) # Set temperature factor (for gradual heating) if set_backbone: backbone = topo.select("backbone") for i in range(0, len(segment['C1'])): if i in backbone: segment['C1'][i].location.temperature_factor = 1.0 # Resort water segements and alias "pseu" to OM (tip4p forcefield) for wat in ['C2', 'C3']: segment[wat] = sorted(segment[wat], key = lambda i: i.residue_number) start_serial_num = min(segment[wat], key= lambda i: i.serial_number) for i in range(0, len(segment[wat])): newsn = i + start_serial_num.serial_number segment[wat][i].serial_number = newsn if segment[wat][i].get_name == 'pseu': segment[wat][i].set_name_with_spaces(' OM ') # FOR RE-RUNNING THE PSFGEN if split_dir is not None: for s in segment_list: with open(split_dir + '/%s.pdb' % s, 'w') as dest: for atom in segment[s]: _=dest.write(str(atom) + '\n') # Writeout new file if in_place: dest = open(src_filename, 'w') if cryst is not None: dest.write(cryst) for s in segment_list: for atom in segment[s]: _=dest.write(str(atom) + '\n') _=dest.write('END') dest.close()
def reset_pdb(src_filename): """ Updates PDB file with crytalline unit cell data and backbone temp control to enable gradual heating""" # Standard unit cell description (first lines) cryst= 'CRYST1 51.263 51.263 51.263 90.00 90.00 90.00 P 1 1\n' # Read in source PDB (DEShaw original format) src_pdb = PdbStructure(open(src_filename)) atoms = list(src_pdb.iter_atoms()) topo = md.load(src_filename).top # Set temperature factor (for gradual heating) backbone = topo.select("backbone") for i in range(0, len(atoms)): if i in backbone: atoms[i].location.temperature_factor = 1.0 # Write out to file dest = open(src_filename, 'w') if cryst is not None: dest.write(cryst) dest.write('REMARK Dynamically Generated from data driven controller (DDC)\n') for atom in atoms: _=dest.write(str(atom) + '\n') _=dest.write('END') dest.close()
def reset_pdb(src_filename): """ Updates PDB file with crytalline unit cell data and backbone temp control to enable gradual heating""" # Standard unit cell description (first lines) cryst = 'CRYST1 51.263 51.263 51.263 90.00 90.00 90.00 P 1 1\n' # Read in source PDB (DEShaw original format) src_pdb = PdbStructure(open(src_filename)) atoms = list(src_pdb.iter_atoms()) topo = md.load(src_filename).top # Set temperature factor (for gradual heating) backbone = topo.select("backbone") for i in range(0, len(atoms)): if i in backbone: atoms[i].location.temperature_factor = 1.0 # Write out to file dest = open(src_filename, 'w') if cryst is not None: dest.write(cryst) dest.write( 'REMARK Dynamically Generated from data driven controller (DDC)\n') for atom in atoms: _ = dest.write(str(atom) + '\n') _ = dest.write('END') dest.close()
def convert_topology(src_filename, set_backbone=True, in_place=False, split_dir=None): """ Converts the D.E.Shaw topology to Charm-usable force field with TIP4P water molecules. THis re-sorts the atoms in the water solvent chains (C2,C3) to group all 4 atoms as one contiguous residue. It also aliases the ion charges 'pseu' atom to 'OM' for use with the standard tip4p.par parameter file. The set_backbone option is to set constraint during initial minimzation""" # Grab unit cell description (should be on first few lines: cryst = None with open(src_filename) as src: for line in src.readlines(): if line.startswith('CRYST1'): cryst = line break # Read in source PDB (DEShaw original format) src_pdb = PdbStructure(open(src_filename)) atoms = list(src_pdb.iter_atoms()) topo = md.load(src_filename).top # Break into 4 segments segment_list = ['C1', 'C2', 'C3', 'C4'] segment = {l: [] for l in segment_list} for i in atoms: segment[i.segment_id].append(i) # Set temperature factor (for gradual heating) if set_backbone: backbone = topo.select("backbone") for i in range(0, len(segment['C1'])): if i in backbone: segment['C1'][i].location.temperature_factor = 1.0 # Resort water segements and alias "pseu" to OM (tip4p forcefield) for wat in ['C2', 'C3']: segment[wat] = sorted(segment[wat], key=lambda i: i.residue_number) start_serial_num = min(segment[wat], key=lambda i: i.serial_number) for i in range(0, len(segment[wat])): newsn = i + start_serial_num.serial_number segment[wat][i].serial_number = newsn if segment[wat][i].get_name == 'pseu': segment[wat][i].set_name_with_spaces(' OM ') # FOR RE-RUNNING THE PSFGEN if split_dir is not None: for s in segment_list: with open(split_dir + '/%s.pdb' % s, 'w') as dest: for atom in segment[s]: _ = dest.write(str(atom) + '\n') # Writeout new file if in_place: dest = open(src_filename, 'w') if cryst is not None: dest.write(cryst) for s in segment_list: for atom in segment[s]: _ = dest.write(str(atom) + '\n') _ = dest.write('END') dest.close()