centrePos = np.array([0, 0, 0]) director = np.array([0, 0, 1]) rotation = 0 xRadius = 100 yRadius = 100 zRadius = 100 minDist = 1 theta1 = -90.0 theta2 = 90.0 phi1 = 45.0 phi2 = 90.0 envelopeList = ['None'] envelopeList = ['innersphere 60', 'outersphere 80'] # generate the building block EllipsoidPackBB = EllipsoidPackBBG.generateBuildingBlock( numPoints, xRadius, yRadius, zRadius, theta1, theta2, phi1, phi2, minDist, envelopeList=envelopeList, defaultBlockRefPoint=centrePos) EllipsoidPackBB.transformBBToLabFrame(director, centrePos, rotation) EllipsoidPackBB.blockAtomNames[0] = 'P' EllipsoidPackBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt'))
names = ['N', 'C', 'C'] * self.numResidues if (self.polarity == "CN"): names = ['C', 'C', 'N'] * self.numResidues return names if __name__ == "__main__": # get the file name from the command line filename = sys.argv[1] # create the backbone generator object. hairPinGen = peptideHairpinGenerator(filename) # generate a backbone numResidues = 5 bondLength = 3.5 pointA = np.array([3, 0, 0]) pointB = np.array([-3, 0, 0]) pointC = pointA + bondLength * np.array([0.77, 0.77, 0.0]) pointD = pointC + bondLength * np.array([0.0, 1.0, 0.0]) pointE = pointD + bondLength * np.array([0.0, 1.0, 1.0]) minDist = 3 polarity = 'NC' fIO.saveXYZ([pointA, pointB, pointC, pointD, pointE], 'Ca', 'externalPoint.xyz') # build building block and dump to file hairpinBuildingBlock = hairPinGen.generateBuildingBlock(numResidues, pointA, pointB, pointC, pointD, pointE, minDist, bondLength, polarity) hairpinBuildingBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print "hairpin done"
# generate backbone realtime parameters numPoints = 100 pointA = 11.0 * np.array( [1.0 / np.sqrt(3.0), 1.0 / np.sqrt(3.0), 1.0 / np.sqrt(3)]) pointB = 11.0 * np.array( [-1.0 / np.sqrt(3.0), -1.0 / np.sqrt(3.0), -1.0 / np.sqrt(3)]) minDist = 1.0 bondLength = 1.5 crankMoves = 20 spherePointGenerator = EPBBG('../../Library/EllipsoidPacking.txt') spherePoints = spherePointGenerator.generateBuildingBlock( 30, 11, 11, 11, -90, 90, -180, 180, 4) pointsToAvoid = spherePoints.getAtomsXYZ() fIO.saveXYZList([pointA, pointB], ['Ca', 'O'], 'labPoints.xyz') fIO.saveXYZ(pointsToAvoid, 'Na', 'labPointsToAvoid.xyz') # generate a curve between the speicifed points ConstrainedPolymerPackBB = ConstrainedPolymerPackGBB.generateBuildingBlock( numPoints, pointA, pointB, minDist, bondLength, crankMoves, envelopeList=["outersphere 12.0", "innersphere 10.0"], pointsToAvoid=pointsToAvoid) ConstrainedPolymerPackGBB.checkBondLengths() ConstrainedPolymerPackBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print "constrainedPolymer Done"
# get the file name from the command line filename = sys.argv[1] # create the NPack object. SpacePackBBG = SpacePackBBG(filename) numPoints = 1000 centrePos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 0 xR = [-20, 20] yR = [-20, 20] zR = [0, 30] minDist = .2 envelopeList = ['endsphere 20.0 10.0'] envelopeList.append('frustum 20.0 10.0 -10.0 0.0') # generate the building block SpacePackBB = SpacePackBBG.generateBuildingBlock(numPoints, xR, yR, zR, minDist, envelopeList=envelopeList, pointsToAvoid=[]) SpacePackBB.transformBBToLabFrame(director, centrePos, rotation) # dump the list of values to file SpacePackBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print "Space Pack Done"
def getParams(self): return self.params if __name__ == '__main__': # get the file name from the command line filename = sys.argv[1] # create the NPack object. CylinderBBG = SurfacePackCylinderBBG(filename) numPoints = 300 centerPos = np.array([-0, -0, 0]) director = np.array([0, 0, 1]) rotation = 0 rx = 15 ry = 10 z1 = 0 z2 = 40 phi1 = -135 phi2 = 135 minDist = 2 # generate the XYZVals in the packed spaced CylinderBB = CylinderBBG.generateBuildingBlock(numPoints, rx, ry, z1, z2, phi1, phi2, minDist) CylinderBB.transformBBToLabFrame(director, centerPos, rotation) CylinderBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt'))
return np.array([0.0, 0.0, 0.0]) def generateBuildingBlockNames(self): spidroinNames = self.NTermMonBB.atomNames spidroinNames += self.CTermMonBB.atomNames return spidroinNames if __name__ == "__main__": noErrors = True filename = sys.argv[1] # generating an individual spidroin spidroinTerminalGenerator = spidroinTerminalGenerator(filename) startPoint = np.array([0.0, -0.0, 0.0]) direction = np.array([-0.0, 0.0, 1.0]) rotation = 0 SpidroinBB = spidroinTerminalGenerator.generateBuildingBlock( startPoint, direction, rotation, alignDirectors=False, showDirector=False, nameByBuildingBlockType=True) SpidroinBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print("Done.")
# create the generator RandomPolymerPackBBG = RandomPolymerPackBBG(filename) # generate backbone realtime parameters numPoints = 70 pointA = np.array([0.0, 0.0, 0.0]) minDist = 1.0 bondLength = 1.5 alpha1 = 45 # 45.0 alpha2 = 65 # 75.0 beta1 = 110.0 beta2 = 140.0 envelopeList = ['frustum 40 15 0 5'] # generate a curve between the specifed points RandomPolymerPackBB = RandomPolymerPackBBG.generateBuildingBlock( numPoints, pointA, alpha1, alpha2, beta1, beta2, minDist, bondLength, envelopeList=envelopeList, visualiseEnvelope=(100000, 100)) RandomPolymerPackBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print("RandomPolymer Done")
for n, pointToTest in enumerate(xyzVals): # perform spatial test pointGood = self.checkPointInBounds(pointToTest) # if the point is bad then add the index to the array of bad points if not pointGood: badPoints.append(n) return badPoints if __name__ == "__main__": # specify filename filename = "buildingBlockGeneratorExample.txt" # create the backbone generator object using static file parameters BBG = BuildingBlockGenerator(filename) # generate building block realtime parameters numPos = 30 startPos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 45 * np.pi / 180 minDist = 1.0 testBuildBlock = BBG.generateBuildingBlock(numPos, minDist) testBuildBlock.transformBBToLabFrame(director, startPos, rotation) testBuildBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print("building block done")
# get the file name from the command line filename = "alphahelix.txt" # create the backbone generator object using static file parameters backboneObject = peptideBackboneGenerator(filename) # generate backbone realtime parameters numResidues = 16 startPos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 0 * np.pi / 180 backBoneBuildingBlock = backboneObject.generateBuildingBlock( numResidues, showBlockDirector=False) backBoneBuildingBlock.transformBBToLabFrame(director, startPos, rotation) backBoneBuildingBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) filename = "betastrand.txt" # create the backbone generator object using static file parameters backboneObject = peptideBackboneGenerator(filename) # generate backbone realtime parameters numResidues = 15 startPos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 0 * np.pi / 180 backBoneBuildingBlock = backboneObject.generateBuildingBlock(numResidues) backBoneBuildingBlock.transformBBToLabFrame(director, startPos, rotation) backBoneBuildingBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt'))
return directorHat def generateBuildingBlockConnectors(self): return [ np.array([2, 1, 0]), np.array( [self.numPoints - 3, self.numPoints - 2, self.numPoints - 1]) ] if __name__ == "__main__": filename = "spidroinBackbone.txt" # create the backbone generator object using static file parameters backboneObject = spidroinBackboneGenerator(filename) # generate backbone realtime parameters startPos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 0 * np.pi / 180 SP1BuildingBlock = backboneObject.generateBuildingBlock('SP1') SP1BuildingBlock.transformBBToLabFrame(director, startPos, rotation) SP1BuildingBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) SP2BuildingBlock = backboneObject.generateBuildingBlock('SP2') SP2BuildingBlock.transformBBToLabFrame(director, startPos, rotation) SP2BuildingBlock.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print "spidroin backbone done"
return def atomsToCOM(self): '''sets an atoms array to its centre of mass. Returns the COM and the new array''' newAtoms = [] COM = np.array([0.0, 0.0, 0.0]) for atom in self.atoms: COM += np.array([atom[7], atom[8], atom[9]]) COM /= len(self.atoms) for atom in self.atoms: newAtom = [item for item in atom] newAtom[7] -= COM[0] newAtom[8] -= COM[1] newAtom[9] -= COM[2] newAtoms.append(newAtom) self.Com = COM return newAtoms if __name__ == "__main__": pdbfilename = 'dargo##' #sys.argv[1] # create instance of PDB object pdbObject = PDB(pdbfilename) infile = fIO.fileRootFromInfile(pdbfilename, "pdb") pdbObject.makeXYZForBlenderFromPDB(infile + ".xyz", backBoneOnly=True) print("Done")
def extractBackBoneIndices(self): # Extracts the index numbers of the backbone atoms return [ atomIndex for atomIndex, atom in enumerate(self.pdb.atoms) if atom[1] in ['N', 'CA', 'C'] ] def exportPDBWithNewCoords(self, newXYZVals, filename): self.pdb.replacePdbAtoms(newXYZVals, filename) if __name__ == "__main__": # get the file name from the command line filename = sys.argv[1] # create the pdb object generator pdbObject = pdbPeptideBackboneGenerator(filename) # generate backbone realtime parameters refPos = np.array([0.0, 0.0, 0.0]) director = np.array([0.0, 0.0, 1.0]) rotation = 0 * np.pi / 180 pdbBuildingBlock = pdbObject.generateBuildingBlock(showBlockDirector=True) pdbBuildingBlock.transformBBToLabFrame(director, refPos, rotation) pdbBuildingBlock.exportBBK(fIO.fileRootFromInfile( filename, 'pdb')) # adds the xyz extension automatically print "pdb building block done"
if __name__ == '__main__': # get the file name from the command line filename = sys.argv[1] # create the NPack object. CuboidPackSCBBG = VolumePackCuboidSCParticlesBBG(filename) numPoints = 80 centrePos = np.array([0, 0, 0]) director = np.array([0, 0, 1]) rotation = 0 xSize = 10.0 ySize = 10.0 zSize = 10.0 thetad1 = -75.0 thetad2 = -65.0 phid1 = -10.0 phid2 = 10.0 minDist = 2.0 pLength = 10.0 numSpheresPerParticle = 30 # generate the building block CuboidPackSCBB = CuboidPackSCBBG.generateBuildingBlock( numPoints, xSize, ySize, zSize, thetad1, thetad2, phid1, phid2, minDist, pLength, numSpheresPerParticle) CuboidPackSCBB.transformBBToLabFrame(director, centrePos, rotation) CuboidPackSCBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt'))
# create the backbone generator object using static file parameters betasheetGenerator = betasheetGen(filename) # generate backbone realtime parameters numStrands = 4 lengthStrand = 7 numLoopResidues = 0 minDist = 1.0 inStrandDirector = np.array([0.0, 0.0, 1.0]) crossStrandDirector = np.array([1.0, 0.0, 0.0]) offset = np.array([0.0, 0.0, 0.0]) betasheetBB = betasheetGenerator.generateBuildingBlock(numStrands, lengthStrand, numLoopResidues, minDist, inStrandDirector, crossStrandDirector, offset, parallel=True) # global positioning startPos = np.array([0.0, 0.0, 0.0]) globalDirector = np.array([0.0, 0.0, 1.0]) rotation = 0 * np.pi / 180 betasheetBB.transformBBToLabFrame(globalDirector, startPos, rotation) betasheetBB.exportBBK(fIO.fileRootFromInfile(filename, 'txt')) print "betasheet done"
startPoint, direction, rotation, rx, ry, rz, theta1, theta2, phi1, phi2, alignDirectors=True, showDirector=False, nameByBuildingBlockType=True) spidAggBBSpherical.exportBBK( fIO.fileRootFromInfile(sphericalFilename, 'txt')) # generating elliptical structures spidroinAggregateGeneratorElliptical = spidroinAggregateGenerator( ellipticalFilename) # changed parameters rx = 135 ry = 180 rz = 70 spidAggBBElliptical = spidroinAggregateGeneratorElliptical.generateBuildingBlock( numSpids, startPoint, direction, rotation,