def __init__(self): mix = Mixture() mix.loadWFM(WOLFFIA_WFY_DIR + "/PABApentane.wfm") print(mix.molecules()) Molecule.__init__(self, "PABA-Pentane", molecule=mix.getMolecule("PABA-Pentane_1")) self.changeResidues("PAB")
def __init__(self, m, n, q): diamondMix = Mixture() diamondMix.loadWFM(WOLFFIA_WFY_DIR + "/diamond.wfm") diamondCell = diamondMix.getMolecule('Diamond_1') sal = Element("NA") sal.moveBy([-1, -1, -1]) # put it out of the way #'Crece' el diamante tempMixture = Mixture() for dm in range(m): for dn in range(n): for dq in range(q): newCell = diamondCell.copy() newCell.moveby([dm * 5.43, dn * 5.43, dq * 5.43]) tempMixture.add(newCell) tempMixture.add(sal) G = tempMixture.copy() H = tempMixture.copy() Coord = [] overlapAtoms = [] atomNeighbors = [] toEliminate = [] #Hace que las moleculas se conecten al atomo de Na y hace de la mezcla una molecula for p, mol in enumerate(G): molecule = G.getMolecule(mol) for idx, atom1 in enumerate(molecule): if molecule.getAttributes( atom1).getInfo().getElement() == "NA": molSal = mol numMolecule = p atomSal = molecule.atom(idx) for p, mol in enumerate(G): molecule = G.getMolecule(mol) if p != numMolecule: molC = mol atomC = molecule.atom(1) H.addBond([molSal, atomSal], [molC, atomC]) #Pone las coordenadas de la mezcla en una lista for p, mol in enumerate(H): molecule = H.getMolecule(mol) for atom in molecule: coordinates = molecule.getAttributes(atom).getCoord() Coord.append(coordinates) #Te da los atomos que estan en la misma posicion for a, coord1 in enumerate(Coord): #print a,coord1 for x, coord2 in enumerate(Coord): if a < x and math.fabs( coord1[0] - coord2[0]) < TOLERANCE and math.fabs( coord1[1] - coord2[1]) < TOLERANCE and math.fabs( coord1[2] - coord2[2]) < TOLERANCE: overlapAtoms.append(a) overlapAtoms.append(x) toEliminate.append(x) #Te dice los vecinos de los atomos for mol in H: molecule = H.getMolecule(mol) for i in range(len(overlapAtoms) / 2): vecinos = molecule.neighbors(overlapAtoms[2 * i + 1] + 1) #atomNeighbors.append(overlapAtoms[2*i+1]+1) atomNeighbors.append(vecinos) G = H.copy() for p, mol in enumerate(G): molecule = G.getMolecule(mol) for i, j in enumerate(atomNeighbors): #print i, len(j), j[0] mol1 = mol atom1 = molecule.atom(overlapAtoms[2 * i]) #print atom1, "atomo 1", i if len(j) == 1: atom2 = molecule.atom(j[0] - 1) #print j[0] #print atom2, atom1 H.addBond([mol1, atom1], [mol1, atom2]) elif len(j) == 2: atom2A = molecule.atom(j[0] - 1) atom2B = molecule.atom(j[1] - 1) H.addBond([mol1, atom1], [mol1, atom2A]) H.addBond([mol1, atom1], [mol1, atom2B]) #toEliminate.sort() G = H.copy() #print "a Eliminarse", toEliminate toEliminate = sorted(set(toEliminate)) #Busca el indice del atomo Na for p, mol in enumerate(G): molecule = G.getMolecule(mol) for idx, atom1 in enumerate(molecule): if molecule.getAttributes( atom1).getInfo().getElement() == "NA": idxNa = idx + 1 #Elimina los atomos 'repetidos' y el atomo de Na for p, mol in enumerate(G): molecule = G.getMolecule(mol) for i in reversed(toEliminate): #print i+1 molecule.removeAtom(i + 1) molecule.removeAtom(idxNa) Molecule.__init__(self, "Diamond", next(G.moleculeGenerator())) # Fix atom types for atom in self: N = len(self.neighbors(atom)) if N == 4: self.getAtomAttributes(atom).getInfo().setType("C") if N == 1: self.getAtomAttributes(atom).getInfo().setType("C2") if N == 2: self.getAtomAttributes(atom).getInfo().setType("C3") self.getForceField().setBond(('C', 'C'), 222., NonBond._EPSILON) self.getForceField().setBond(('C', 'C'), 1.512, NonBond._SIGMA)