def rotateHydrogens(self, mol2data): '''runs after findTerminalHydrogens, rotates the rotatable hydrogens to the angles specified by the rules. differs in that it copies everything and makes all combinations of hydrogen rotations''' self._findDihedrals(mol2data) #first call in case reset was not done rotatedMol2data = mol2data.copy() #copy this one, put all new in rotated rotatedMol2data.atomXyz = [] #clear rotatedMol2data.inputEnergy = [] #clear rotatedMol2data.inputHydrogens = [] #clear rotatedMol2data.origXyzCount = mol2data.xyzCount for xyzCount in xrange(mol2data.xyzCount): #iterate over orig conformations indexToCoords = [] #list of lists originals = [] for atomIndex, atomNum in enumerate(mol2data.atomNum): if atomNum in mol2data.dihedrals.keys(): thisCoords = [] curXyz, dihedral1 = self._getCurDihedral(atomNum, xyzCount, mol2data) thisCoords.append(curXyz[3]) #original saved here originals.append(curXyz[3]) #also save orig here for newAngle in mol2data.rotAngles[atomNum]: #want to find a new rotation angle and move to that newTheta = math.radians(newAngle) #convert to radians!! #print dihedral1, newAngle, newTheta, newHxyz = geometry_basic.rotateAboutLine(curXyz[1], curXyz[2], \ curXyz[3], newTheta) thisCoords.append(newHxyz) #save new ones here indexToCoords.append(thisCoords) #have to make all possible combinations combinations = combinatorics.allCombinations(indexToCoords) for aCombo in combinations: if aCombo != originals: #don't need to do anything for the original set #need to copy inputEnergy and atomXyz, then replace atomXyz atomXyzCopy = mol2data.atomXyz[xyzCount][:] #replace hydrogen positions here replaceIndex = 0 for atomIndex, atomNum in enumerate(mol2data.atomNum): if atomNum in mol2data.dihedrals.keys(): atomXyzCopy[atomIndex] = aCombo[replaceIndex] #replace coord replaceIndex += 1 #move this counter forward rotatedMol2data.atomXyz.append(atomXyzCopy) rotatedMol2data.inputEnergy.append(mol2data.inputEnergy[xyzCount]) #copy rotatedMol2data.inputHydrogens.append(2) #means rotate else: #aCombo is the original set atomXyzCopy = mol2data.atomXyz[xyzCount][:] rotatedMol2data.atomXyz.append(atomXyzCopy) rotatedMol2data.inputEnergy.append(mol2data.inputEnergy[xyzCount]) rotatedMol2data.inputHydrogens.append( \ mol2data.inputHydrogens[xyzCount]) rotatedMol2data.xyzCount = len(rotatedMol2data.atomXyz) #finally set this correctly return rotatedMol2data
def resetHydrogens(self, mol2data): '''runs after findTerminalHydrogens, resets the rotatable hydrogens to 0 instead of the potentially bad angle they were set at.''' self._findDihedrals(mol2data) for xyzCount in xrange(mol2data.xyzCount): #iterate over conformations for atomIndex, atomNum in enumerate(mol2data.atomNum): if atomNum in mol2data.dihedrals.keys() and \ 180. in mol2data.rotAngles[atomNum]: #only planar get reset curXyz, dihedral1 = self._getCurDihedral(atomNum, xyzCount, mol2data) #want to find a new rotation angle, 0, and reset newTheta = 0 - dihedral1 #radians!! #print newTheta newHxyz = geometry_basic.rotateAboutLine(curXyz[1], curXyz[2], \ curXyz[3], newTheta) #print curXyz[3], newHxyz mol2data.atomXyz[xyzCount][atomIndex] = newHxyz mol2data.inputHydrogens[xyzCount] = 1 #means reset