Exemple #1
0
	def __init__(self):
		Molecule.__init__(self, "H2O2")

		# print NANOCAD_PDB_DIR + "/Solvents/WATER.pdb" , NANOCAD_PDB_DIR + "/Solvents/WATER.psf" 
		#self.load(NANOCAD_PDB_DIR + "/Solvents/WATER.pdb" , NANOCAD_PDB_DIR + "/Solvents/WATER.psf")

		# build water H2O2
		atr = AtomAttributes("OT1", "O", "OT", [ -0.077,   0.000,   0.730 ], 0.834, 15.9994, 0.0, 1.0, ' ', "OT  ", "XXX", "A", 1)
		#print "----------------------->", str(atr)
		self.add_node(1, attrs=[atr])

		atr = AtomAttributes("OT2", "O", "OT", [  0.077,   0.000,  -0.730], 0.834, 15.9994, 0.0, 1.0, ' ', "OT  ", "XXX", "A", 1)
		#print "----------------------->", str(atr)
		self.add_node(2, attrs=[atr])

		atr = AtomAttributes("HT1", "H", "HT", [  -1.077,   0.000,   1.730], 0.417, 1.00794, 0.0, 1.0, ' ', "HT ", "XXX", "A", 1)
		#print "----------------------->", str(atr)
		self.add_node(3, attrs=[atr])

		atr = AtomAttributes("HT2", "H", "HT", [   1.077,   0.000,  -1.730], 0.417, 1.00794, 0.0, 1.0, ' ', "HT ", "XXX", "A", 1)
		#print "----------------------->", str(atr)
		self.add_node(4, attrs=[atr])

		self.addBond(1, 2)
		self.addBond(1, 3)
		self.addBond(2, 4)

		#self.add_angle(3,1,2)
		#self.add_angle(1,2,4)

		#self.add_dihedral(1,2,3,4)

		
		self.setForceField(_FORCE_FIELD )
		self.copyChargesToForceField()
Exemple #2
0
    def __init__(self):
        Molecule.__init__(self, "WATER")

        # print NANOCAD_PDB_DIR + "/Solvents/WATER.pdb" , NANOCAD_PDB_DIR + "/Solvents/WATER.psf"
        #self.load(NANOCAD_PDB_DIR + "/Solvents/WATER.pdb" , NANOCAD_PDB_DIR + "/Solvents/WATER.psf")

        # build water molecule
        atr = AtomAttributes(WATER.otObj,
                             [4.01300001, 0.83099997, -9.08300018])
        #print "----------------------->", str(atr)
        self.add_atom(atr, [])

        atr = AtomAttributes(WATER.htObj,
                             [4.94099998, 0.84399998, -8.83699989])
        #print "----------------------->", str(atr)
        self.add_atom(atr, [1])

        atr = AtomAttributes(WATER.htObj, [3.75, -0.068, -9.29300022])
        #print "----------------------->", str(atr)
        self.add_atom(atr, [1])

        if WATER._FORCE_FIELD == None:
            print("WATER generating FF")
            WATER._FORCE_FIELD = ForceField(
                self, NANOCAD_FORCE_FIELDS + "/WATER.prm")
        #print "WATER1", WATER._FORCE_FIELD._BONDS
        self.setForceField(WATER._FORCE_FIELD)
        #print "WATER2", self.getForceField()._BONDS
        self.copyChargesToForceField()
Exemple #3
0
    def __init__(self):
        Molecule.__init__(self, "CLF4")

        atr = AtomAttributes(CLF4.ai1, [0., 0., 0.])
        self.add_atom(atr, [])
        atr = AtomAttributes(CLF4.ai2, [0.58099997, -1.07599998, -1.27499998])
        self.add_atom(atr, [1])
        atr = AtomAttributes(CLF4.ai3, [1.29900002, 0.29100001, 1.16199994])
        self.add_atom(atr, [1])
        atr = AtomAttributes(CLF4.ai4, [-0.509, 1.53499997, -0.71100003])
        self.add_atom(atr, [1])

        if CLF4._FORCE_FIELD == None:
            CLF4._FORCE_FIELD = ForceField(self,
                                           NANOCAD_FORCE_FIELDS + "/CLF4.prm")
        self.setForceField(CLF4._FORCE_FIELD)
        self.copyChargesToForceField()
Exemple #4
0
    def __init__(self):
        Molecule.__init__(self, "Argon")

        atr = AtomAttributes("AR", "AR", "AR", [0.0, 0.0, 0.0], 0.0, 39.9500,
                             0.0, 1.0, ' ', "OT  ", "WAT", "A", 1)
        #print "----------------------->", str(atr)
        self.add_node(1, attrs=[atr])

        self.setForceField(self._FORCE_FIELD)
        self.copyChargesToForceField()
Exemple #5
0
    def __init__(self):
        Molecule.__init__(self, "Na")

        atr = AtomAttributes(Na.ai, [0.0, 0.0, 0.0])
        self.add_atom(atr, [])

        #print NANOCAD_PDB_DIR + "/Solvents/THF.pdb" , NANOCAD_PDB_DIR + "/Solvents/THF.psf"
        self.load(NANOCAD_PDB_DIR + "/Ions/Na.pdb",
                  NANOCAD_PDB_DIR + "/Ions/Na.psf")

        if Na._FORCE_FIELD == None:
            Na._FORCE_FIELD = ForceField(self)
            Na._FORCE_FIELD.setNonBond("Na", -0.1153, NonBond._EPSILON)
            Na._FORCE_FIELD.setNonBond("Na", 2.275, NonBond._SIGMA)
            Na._FORCE_FIELD.setNonBond("Na", 1., NonBond._CHARGE)
        self.setForceField(Na._FORCE_FIELD)
        self.copyChargesToForceField()
Exemple #6
0
	def generateZigZag(self):
		unitVectLength = self._bondLength * math.sqrt(2.-2.*math.cos(2.*math.pi/3.))
		by             = math.sqrt(self._bondLength * self._bondLength - unitVectLength*unitVectLength/4)
		bondsArray     = list()
		Cx             = self._m * unitVectLength + math.cos(math.pi/3.) * self._n * unitVectLength
		Cy             = math.sin(math.pi/3.) * self._n * unitVectLength
		Cangle         = math.atan2(Cy, Cx)

		xMin           = -self._length * math.cos(Cangle)
		xMax           = Cx 
		zMax           = self._length + Cx 
		xsteps         = int((xMax - xMin) / unitVectLength) + 1
		zsteps         = int(zMax / unitVectLength) + 1

		# determine gap widths
		 
		# generate coordinates
		z = 0.
		for zi in range(zsteps):
			row1 = list()
			if zi % 2 == 0:
				x = xMin
			else:
				x = xMin + unitVectLength / 2.
			for xi in range(xsteps):
				row1.append([x,0.,z])
				x += unitVectLength

			row2 = list()
 			if zi % 2 == 0:
				x = xMin + unitVectLength / 2.
			else:
				x = xMin
			z += by
			for xi in range(xsteps):
				row2.append([x,0.,z])
				x += unitVectLength
			bondsArray.append([row1,row2])
			z += self._bondLength

		n = 1
		# first two rows
		for row in range(len(bondsArray)):
			coords = bondsArray[row][0]
			rowLength = xsteps
			for coord in coords:
				atr = AtomAttributes(self.ai, coord, 0., [])
				self.add_node(n, attrs=[atr])
				if row > 0:
					self.add_bond([n,n-rowLength])
				n += 1

			coords = bondsArray[row][1]
			rowLength = xsteps

			
			atr = AtomAttributes(self.ai, coords[0], 0., [])
			self.add_node(n, attrs=[atr])
			self.add_bond([n,n-rowLength])
			if row % 2 == 0:
				self.add_bond([n,n-rowLength+1])
			n += 1
			for coord in coords[1:-1]:
				atr = AtomAttributes(self.ai, coord, [])
				self.add_node(n, attrs=[atr])
				self.add_bond([n,n-rowLength])
				if row % 2 == 0:
					self.add_bond([n,n-rowLength+1])
				else:
					self.add_bond([n,n-rowLength-1])
				n += 1
			atr = AtomAttributes(self.ai, coords[-1], 0., [])
			self.add_node(n, attrs=[atr])
			self.add_bond([n,n-rowLength])
			if row % 2 == 1:
				self.add_bond([n,n-rowLength-1])
			n += 1
Exemple #7
0
class Element(Molecule):
    _FORCE_FIELD_PARAMETERS = {  # reference
        "H": [-0.03, 1.3582],
        "B": [-.0100, 2.085],  # (1)
        "HE": [-.0100, 2.495],  # (1)
        "KR": [-.0100, 3.599],  # (1)
        "RN": [-.0100, 4.009],  # (1)
        "SE": [-.0430, 3.510],  # (1)
        "AT": [-.3200, 3.884],  # (1)
        "BR": [-.3200, 3.884],  # (1)
        "XE": [-.0100, 3.849],  # (1)
        "I": [-.8000, 3.635],  # (1)
        "AL": [-.2500, 4.740],  # (1)
        "AS": [-.0600, 3.564],  # (1)
        "BA": [-.1600, 3.385],  # (1)
        "BE": [-.0030, 1.960],  # (1)
        "CA": [-.0600, 3.107],  # (1)
        "CS": [-.0045, 5.183],  # (1)
        "CU": [-.0600, 2.459],  # (1)
        "FE": [-.0200, 2.610],  # (1)
        "GE": [-.0450, 3.029],  # (1)
        "K": [-.0100, 4.187],  # (1)
        "LI": [-.0070, 2.202],  # (1)
        "MG": [-.0450, 2.564],  # (1)
        "MN": [-.7000, 2.851],  # (1)
        "NI": [-.0500, 1.782],  # (1)
        "PD": [-.0100, 2.388],  # (1)
        "PT": [-.0100, 2.370],  # (1)
        "RB": [-.0065, 4.741],  # (1)
        "RH": [-.0250, 2.797],  # (1)
        "RU": [-.0250, 2.940],  # (1)
        "SI": [-.3100, 4.455],  # (1)
        "SN": [-.0450, 3.385],  # (1)
        "SR": [-.1719, 3.523],  # (1)
        "YB": [-.0600, 3.127],  # (1)
        "ZN": [-.2500, 1.942],  # (1)
        "ZR": [-.0100, 3.617],  # (1)
        "C": [-0.032, 2.0],
        "N": [-0.18, 1.79],
        "O": [-0.12, 1.7],
        "F": [-.1000, 2.029],  # (1)
        "NA": [-0.1153, 2.275],
        "P": [-0.585, 2.15],
        "S": [-0.565, 2.05],
        "CL": [-0.3002, 1.735],
        "AR": [-.01, 3.35],
        "AU": [-0.53537, 3.2]
    }

    _ATTRIBUTES = {
        "H":
        AtomAttributes(
            AtomInfo("H", "H", "H", 0.417, 1.00794, 0.0, 1.0, ' ', "H", "ELT",
                     "A", 1), [0., 0., 0.]),
        "O":
        AtomAttributes(
            AtomInfo("O", "O", "O", -0.834, 15.9994, 0.0, 1.0, ' ', "O", "ELT",
                     "A", 1), [0., 0., 0.]),
        "C":
        AtomAttributes(
            AtomInfo("C", "C", "C", 0.147156, 12.0107, 1.0, 1.0, ' ', "C",
                     "ELT", "A", 1), [0., 0., 0.]),
        "F":
        AtomAttributes(
            AtomInfo("F", "F", "F", -1, 18.9984032, 1.0, 1.0, ' ', "F", "ELT",
                     "A", 1), [0., 0., 0.]),
        "N":
        AtomAttributes(
            AtomInfo("N", "N", "N", -0.341313, 14.0067, 1.0, 1.0, ' ', "N",
                     "ELT", "A", 1), [0., 0., 0.]),
        "NA":
        AtomAttributes(
            AtomInfo("NA", "NA", "NA", 1.0, 22.98977, 1.0, 1.0, ' ', "NA",
                     "ELT", "A", 1), [0., 0., 0.]),
        "P":
        AtomAttributes(
            AtomInfo("P", "P", "P", 0.39354, 30.9738, 1.0, 1.0, ' ', "P",
                     "ELT", "A", 1), [0., 0., 0.]),
        "S":
        AtomAttributes(
            AtomInfo("S", "S", "S", 0.0, 32.065, 1.0, 1.0, ' ', "S", "ELT",
                     "A", 1), [0., 0., 0.]),
        "CL":
        AtomAttributes(
            AtomInfo("CL", "CL", "CL", -0.14, 35.453, 0.0, 1.0, ' ', "CL",
                     "ELT", "A", 1), [0., 0., 0.]),
        "AR":
        AtomAttributes(
            AtomInfo("AR", "AR", "AR", 0.0, 39.9500, 0.0, 1.0, ' ', "O", "ELT",
                     "A", 1), [0., 0., 0.]),
        "AU":
        AtomAttributes(
            AtomInfo("AU", "AU", "AU", 0.0, 96.96657, 0.0, 1.0, ' ', "AU",
                     "ELT", "A", 1), [0., 0., 0.])
    }
    _ENAME_TO_SYMBOL = {
        "Argon": "AR",
        "Carbon": "C",
        "Chlorine": "CL",
        "Hydrogen": "H",
        "Fluorine": "F",
        "Gold": "AU",
        "Nitrogen": "N",
        "Oxygen": "O",
        "Phosphorous": "P",
        "Sodium": "NA",
        "Sulfur": "S"
    }

    def __init__(self, symbol):
        try:
            symbol = symbol.upper()
            nbParameters = Element._FORCE_FIELD_PARAMETERS[symbol]
        except:
            import logging
            logger = logging.getLogger(self.__class__.__name__)
            logger.error("Invalid element symbol \"" + str(symbol) + "\"")
            print("Invalid element symbol \"" + str(symbol) + "\"")
            return

        Molecule.__init__(self, symbol)

        self.add_node(1, attrs=[copy.deepcopy(Element._ATTRIBUTES[symbol])])

        ff = ForceField(self)
        ff.setNonBond(symbol, nbParameters[NonBond._EPSILON], NonBond._EPSILON)
        ff.setNonBond(symbol, nbParameters[NonBond._SIGMA] / 2.,
                      NonBond._SIGMA)  # VDw DISTANCE DIVIDED BY 2!!!!!

        self.setForceField(ff)
        #self.copyChargesToForceField()

    @staticmethod
    def nameToSymbol(ename):
        return Element._ENAME_TO_SYMBOL[ename]
Exemple #8
0
	def _processFirstFrame(self):
		"""
		Gets the first pybel Molecule and puts its Wolffia equivalent Mixture in self.currentMolecule.
		Returns the first frame.
		Raises whichever exception that pybel throws (probably StopIteration).
		"""
		
		mol = next(self.molIterator)
		chemicalGraphMixed = ChemicalGraph()
		etable			 = openbabel.OBElementTable()

		
		n = 0
		for atom in mol.atoms:
			atomType = atom.OBAtom.GetResidue().GetAtomID(atom.OBAtom)
			symbol = etable.GetSymbol(atom.atomicnum)
			coords = list(atom.coords)
			name	 = etable.GetName(atom.atomicnum) 
			residue = atom.OBAtom.GetResidue().GetName()
			psfType = atom.OBAtom.GetResidue().GetAtomID(atom.OBAtom).strip()
			#print "_processFirstFrame: '" + psfType + "'"
			charge = atom.partialcharge
			mass	 = atom.atomicmass	
			if self.psf != None:
				psfType = self.psf.getType(n)
				charge = self.psf.getCharge(n)
				mass	 = self.psf.getMass(n)
				print("CoordinateFile _processFirstFrame charge  ", charge)
		
		
			ai  = AtomInfo(atomType, symbol, psfType, charge, mass, 1, 1, 1, name, residue)
			atr = AtomAttributes(ai, coords, [])
			chemicalGraphMixed.add_node(n + 1, attrs=[atr])
			n += 1
		
		# add edges
		print('_processFirstFrame add edges')
		if self.psf != None:
			for b in self.psf.bonds:
				try:  # avoids adding an edge twice
					chemicalGraphMixed.add_edge(b)
				except AdditionError:
					pass			
			if len(mol.atoms) != len(self.psf.atoms):
				raise MixtureError("Amount of atoms in " + self.fileName + " and psf File files are different (" + str(len(self.atoms)) + " vs " + str(len(self.psf.atoms)) + ").")
		else:			
			for bond in openbabel.OBMolBondIter(mol.OBMol):   
				chemicalGraphMixed.add_edge([bond.GetBeginAtom().GetIdx(), bond.GetEndAtom().GetIdx()])	   
					
		molecules = list(chemicalGraphMixed.connectedComponents())
		self.currentMolecule = Mixture()
		
		#print '_processFirstFrame Añadir'+  str(list(molecules)) + ' moléculas a mezcla:  ', 
		if len(molecules) == 1:
			self.currentMolecule.add(Molecule(self.mixtureName, molecule=molecules[0]))
		else:
			n = 0
			for m in molecules:
				self.currentMolecule.add(
							Molecule(self.mixtureName + "(" + str(n) + ")", molecule=m),
							checkForInconsistentNames=False)
				n += 1

		return self.currentMolecule
Exemple #9
0
    def __init__(self):
        Molecule.__init__(self, "DMF")

        #print NANOCAD_PDB_DIR + "/Solvents/DMF.pdb" , NANOCAD_PDB_DIR + "/Solvents/DMF.psf"
        #self.load(NANOCAD_PDB_DIR + "/Solvents/DMF.pdb" , NANOCAD_PDB_DIR + "/Solvents/DMF.psf")

        atr = AtomAttributes(DMF.ai1, [0.045, -0.12800001, 0.038])
        self.add_atom(atr, [])
        atr = AtomAttributes(DMF.ai2, [-0.38, 1.09099996, -0.31900001])
        self.add_atom(atr, [1])
        atr = AtomAttributes(DMF.ai3, [0.45500001, 2.171, -0.19499999])
        self.add_atom(atr, [2])
        atr = AtomAttributes(DMF.ai4, [1.38699996, -0.30599999, 0.55500001])
        self.add_atom(atr, [1])
        atr = AtomAttributes(DMF.ai5, [-0.838, -1.26999998, -0.094])
        self.add_atom(atr, [1])
        atr = AtomAttributes(DMF.ai6, [-1.38, 1.22399998, -0.70499998])
        self.add_atom(atr, [2])
        atr = AtomAttributes(DMF.ai7, [1.37600005, -0.192, 1.63900006])
        self.add_atom(atr, [4])
        atr = AtomAttributes(DMF.ai8, [2.04699993, 0.442, 0.117])
        self.add_atom(atr, [4])
        atr = AtomAttributes(DMF.ai9, [1.74600005, -1.30299997, 0.29800001])
        self.add_atom(atr, [4])
        atr = AtomAttributes(DMF.ai10, [-1.12800002, -1.38699996, -1.13800001])
        self.add_atom(atr, [5])
        atr = AtomAttributes(DMF.ai11, [-1.72899997, -1.11199999, 0.51499999])
        self.add_atom(atr, [5])
        atr = AtomAttributes(DMF.ai12, [-0.322, -2.16899991, 0.243])
        self.add_atom(atr, [5])

        if DMF._FORCE_FIELD == None:
            DMF._FORCE_FIELD = ForceField(self,
                                          NANOCAD_FORCE_FIELDS + "/DMF.prm")
        self.setForceField(DMF._FORCE_FIELD)
        self.copyChargesToForceField()
Exemple #10
0
    def __init__(self):
        Molecule.__init__(self, "THF")

        #print NANOCAD_PDB_DIR + "/Solvents/THF.pdb" , NANOCAD_PDB_DIR + "/Solvents/THF.psf"
        #self.load(NANOCAD_PDB_DIR + "/Solvents/THF.pdb" , NANOCAD_PDB_DIR + "/Solvents/THF.psf")

        atr = AtomAttributes(THF.atr1, [0.180, 0.300, -2.690])
        self.add_atom(atr, [])
        atr = AtomAttributes(THF.atr2, [1.084, 0.909, -2.675])
        self.add_atom(atr, [1])
        atr = AtomAttributes(THF.atr3, [-0.637, 0.671, -3.309])
        self.add_atom(atr, [1])
        atr = AtomAttributes(THF.atr4, [-0.350, 0.030, -1.310])
        self.add_atom(atr, [1])
        atr = AtomAttributes(THF.atr5, [-1.282, -0.535, -1.328])
        self.add_atom(atr, [4])
        atr = AtomAttributes(THF.atr6, [-0.371, 0.969, -0.757])
        self.add_atom(atr, [4])
        atr = AtomAttributes(THF.atr7, [0.820, -0.800, -0.800])
        self.add_atom(atr, [4])
        atr = AtomAttributes(THF.atr8, [0.539, -1.361, 0.091])
        self.add_atom(atr, [7])
        atr = AtomAttributes(THF.atr9, [1.667, -0.126, -0.669])
        self.add_atom(atr, [7])
        atr = AtomAttributes(THF.atr10, [1.110, -1.690, -1.900])
        self.add_atom(atr, [7])
        atr = AtomAttributes(THF.atr11, [0.460, -1.140, -3.080])
        self.add_atom(atr, [1, 10])
        atr = AtomAttributes(THF.atr12, [-0.501, -1.639, -3.207])
        self.add_atom(atr, [11])
        atr = AtomAttributes(THF.atr13, [1.120, -1.188, -3.946])
        self.add_atom(atr, [11])
        '''
		self.addBond(1,2)
		self.addBond(1,3)
		self.addBond(1,4)
		self.addBond(1,11)
		self.addBond(4,5)
		self.addBond(4,6)
		self.addBond(4,7)
		self.addBond(7,8)
		self.addBond(7,9)
		self.addBond(7,10)
		self.addBond(10,11)
		self.addBond(11,12)
		self.addBond(11,13)
		'''

        #self.add_angle()
        #self.add_angle()
        #self.add_angle()
        #self.add_angle()

        #self.add_dihedrals ()
        #self.add_dihedrals ()

        if THF._FORCE_FIELD == None:
            THF._FORCE_FIELD = ForceField(self,
                                          NANOCAD_FORCE_FIELDS + "/THF.prm")
        self.setForceField(THF._FORCE_FIELD)
        self.copyChargesToForceField()