Пример #1
0
def parse_tinker_arc(molecule_file, parameter_file=None):
	if parameter_file:
		elements, atom_types, bond_types, angle_types, dihedral_types = lammps.parse_opls_parameters(parameter_file)

	atoms = []
	for line in open(molecule_file):
		columns = line.split()
		if len(columns)>3:
			atoms.append( utils.Struct(index=int(columns[0]), element=columns[1], x=float(columns[2]), y=float(columns[3]), z=float(columns[4]), bonded=[int(s) for s in columns[6:]], type=([t for t in atom_types if t.index==int(columns[5][-3:])][0] if parameter_file else None), charge=None) )
			if len(columns[5])>3:
				atom_types.append( copy.deepcopy(atoms[-1].type) )
				atoms[-1].type.index = int(columns[5])
	bond_set = {}
	for a in atoms:
		a.bonded = [atoms[i-1] for i in a.bonded]
		for b in a.bonded:
			if (b,a) not in bond_set:
				bond_set[(a,b)] = True
	bonds = [utils.Struct(atoms=b, d=utils.dist_squared(b[0],b[1])**0.5, e=None, type=None) for b in bond_set.keys()]
	angles, dihedrals = get_angles_and_dihedrals(atoms, bonds)
	
	return atoms, bonds, angles, dihedrals
Пример #2
0
	def set_params(param_file):
		Molecule.elements, Molecule.atom_types, Molecule.bond_types, Molecule.angle_types, Molecule.dihedral_types = lammps.parse_opls_parameters(param_file)