def generateBuildingBlock(self, numPoints, pointA, pointB, minDist, bondLength, pointsToAvoid=[], envelope="None"): self.numPoints = numPoints self.pointA = pointA self.pointB = pointB self.baseLength = np.linalg.norm(pointA - pointB) self.bondLength = float(bondLength) self.minDist = minDist self.pointA = np.array([-self.baseLength / 2, 0.0, 0.0]) self.pointB = np.array([self.baseLength / 2, 0.0, 0.0]) self.pointsToAvoid = pointsToAvoid self.envelope = envelope.split() # generate the transformation information from building block to pointA and pointB self.labDirector, self.labRefPoint, self.labRotation = self.computeTransform( ) # convert the pointsToAvoid information from the labFrame to the block frame self.pointsToAvoid = self.transformFromLabFrameToBlockFrame( self.labDirector, self.labRefPoint, self.labRotation, pointsToAvoid) fIO.saveXYZ([self.pointA, self.pointB], 'S', 'endPoints.xyz') return BBG.generateBuildingBlock(self, numPoints)
def generateBuildingBlock(self, numPoints, XRange, YRange, ZRange, minDist, visualiseEnvelope=(0, 20), envelopeList=['None'], pointsToAvoid=[]): # XRange, YRange and ZRange are a pair of min and max points. # Note the number of points self.numPoints = numPoints self.minDist = minDist # specify the min and max of X self.XRange = XRange self.YRange = YRange self.ZRange = ZRange self.pointsToAvoid = pointsToAvoid return BBG.generateBuildingBlock( self, numPoints, minDist, visualiseEnvelope=visualiseEnvelope, envelopeList=envelopeList, pointsToAvoid=pointsToAvoid, )
def generateBuildingBlock(self, numStrands, strandLength, inStrandDirector, crossStrandDirector, offset, polarity='NC', parallel=True, loopedEnds=True): self.startPos = np.array([0.0, 0.0, 0.0]) self.numStrands = numStrands self.numPoints = strandLength * 3 # number of points per strand. self.strandLength = strandLength self.inStrandDirectorHat = inStrandDirector / np.linalg.norm( inStrandDirector) self.crossStrandDirectorHat = crossStrandDirector / np.linalg.norm( crossStrandDirector) self.oStrandDirectorHat = np.cross(self.inStrandDirectorHat, self.crossStrandDirectorHat) self.offsetXYZ = offset[2] * self.inStrandDirectorHat + offset[ 0] * self.crossStrandDirectorHat + offset[ 1] * self.oStrandDirectorHat self.polarity = polarity self.parallel = parallel self.loopEnds = loopedEnds return BBG.generateBuildingBlock(self, self.numPoints)
def generateBuildingBlock(self, species, minDist, showBlockDirector=False): self.species = species dummyNumPoints = 0 self.minDist = minDist self.spidroinDirector = np.array([0.0, 0.0, 1.0]) self.spidroinRefPoint = np.array([0.0, 0.0, 0.0]) return BBG.generateBuildingBlock(self, dummyNumPoints, minDist, showBlockDirector=showBlockDirector)
def generateBuildingBlock( self, numPoints, pointA, pointB, minDist, bondLength, pointsToAvoid=[], envelope="None"): self.numPoints = numPoints self.pointA = pointA self.pointB = pointB self.baseLength = np.linalg.norm(pointA - pointB) self.bondLength = float(bondLength) self.minDist = minDist self.pointA = np.array([-self.baseLength/2, 0.0, 0.0]) self.pointB = np.array([self.baseLength/2, 0.0, 0.0]) self.pointsToAvoid = pointsToAvoid self.envelope = envelope.split() # generate the BuildingBlock reference point earlier than usual because # we need the transformation for the pointsToAvoid input. self.blockRefPoint = self.generateBuildingBlockRefPoint() # generate the BuildingBlock director unit vector earlier than usual because # we need the transformation for the pointsToAvoid input. self.blockDirectorHat = self.generateBuildingBlockDirector() # generate the transformation information from building block to pointA and pointB self.labDirector, self.labRefPoint, self.labRotation = self.computeTransform() # convert the pointsToAvoid information from the labFrame to the block frame self.pointsToAvoid = self.transformFromLabFrameToBlockFrame(self.labDirector, self.labRefPoint, self.labRotation, pointsToAvoid) return BBG.generateBuildingBlock(self, numPoints)
def generateBuildingBlock(self, numBetasheets, minDist, longChain=False, showBlockDirector=False, nameByBuildingBlockType=True): # compute number of residues needed in the chain. # Full Short length including termini is 3129 # Full Long length including termini is 3779 # if longChain: self.numResiduesCoil = self.numResiduesLongChain else: self.numResiduesCoil = self.numResiduesShortChain self.numPoints = self.numResiduesCoil * 3 self.numBetasheets = numBetasheets self.inStrandDirectorHat = np.array([0.0, 0.0, 1.0]) self.crossStrandDirectorHat = np.array([1.0, 0.0, 0.0]) self.minDist = minDist self.spidroinDirector = np.array([0.0, 0.0, 1.0]) self.spidroinRefPoint = np.array([0.0, 0.0, 0.0]) self.nameByBuildingBlockType = nameByBuildingBlockType return BBG.generateBuildingBlock(self, self.numPoints, minDist, showBlockDirector=showBlockDirector)
def generateBuildingBlock( self, numPoints, startPoints, endPoints, alpha1, alpha2, beta1, beta2, minDist, bondLength, pointsToAvoid=[]): self.numPoints = numPoints self.startPoints = startPoints self.endPoints = endPoints self.bondLength = bondLength self.minDist = minDist self.pointsToAvoid = pointsToAvoid # use these ranges for the allowed dihedral and bond angles # when it comes to the last point or couple of points at add, # we can relax these contraints for one point, providing the bond length is ok. self.alphaMin = min([alpha1 * np.pi/180, alpha2 * np.pi/180]) self.alphaMax = min([alpha1 * np.pi/180, alpha2 * np.pi/180]) self.betaMin = min([beta1 * np.pi/180, beta2 * np.pi/180]) self.betaMax = max([beta1 * np.pi/180, beta2 * np.pi/180]) # compute the overall polymerCompression that will result self.MaxLength = (self.numPoints + 1) * bondLength self.distAToB = np.linalg.norm(startPoints[-1] - endPoints[-1]) self.polymerCompression= self.compressionScaleFactor * self.distAToB/self.MaxLength return BBG.generateBuildingBlock(self, numPoints)
def generateBuildingBlock(self, numStrands, strandLength, numLoopResidues, minDist, inStrandDirector, crossStrandDirector, offset, parallel=True, nameCA=False): self.startPos = np.array([0.0, 0.0, 0.0]) self.numStrands = numStrands self.numPoints = strandLength * 3 # number of points per strand. self.strandLength = strandLength self.numLoopResidues = numLoopResidues self.minDist = minDist self.inStrandDirectorHat = inStrandDirector / np.linalg.norm( inStrandDirector) self.crossStrandDirectorHat = crossStrandDirector / np.linalg.norm( crossStrandDirector) self.oStrandDirectorHat = np.cross(self.inStrandDirectorHat, self.crossStrandDirectorHat) self.offsetXYZ = offset[2] * self.inStrandDirectorHat + offset[ 0] * self.crossStrandDirectorHat + offset[ 1] * self.oStrandDirectorHat self.parallel = parallel self.nameCA = nameCA return BBG.generateBuildingBlock(self, self.numPoints, minDist)
def generateBuildingBlock(self, numSpidroinSpecies1, numSpidroinSpecies2, numClustersInAggregate): self.numSpidroinSpecies1 = numSpidroinSpecies1 self.numSpidroinSpecies2 = numSpidroinSpecies2 self.numPointsInCluster = numSpidroinSpecies1 + numSpidroinSpecies2 self.numClustersInAggregate = numClustersInAggregate return BBG.generateBuildingBlock(self, self.numPointsInCluster, self.minDist)
def generateBuildingBlock(self, XYZFileName, showBlockDirector=False, visualiseEnvelope=(0, 20, 'envelope.xyz'), envelopeList=['None'], pointsToAvoid=[]): self.atomNameList, self.xyzList = fIO.loadXYZ(XYZFileName) self.numPoints = len(self.atomNameList) minDistDummy = 0.0 return BBG.generateBuildingBlock(self, self.numPoints, minDistDummy, showBlockDirector=showBlockDirector)
def generateBuildingBlock(self, backboneOnly=True, director=None, showBlockDirector=False, nameCA=False): self.backboneOnly = backboneOnly self.backboneIndices = self.extractBackBoneIndices() self.numPoints = len(self.backboneIndices) self.nameCA = nameCA self.director = director self.dumpInterimFiles = 0 minDistDummy = 0.0 return BBG.generateBuildingBlock(self, self.numPoints, minDistDummy, showBlockDirector=showBlockDirector)
def generateBuildingBlock(self, numPoints, pointA, pointB, minDist, bondLength, numCrankMoves, pointsToAvoid=[], visualiseEnvelope=(0, 20), envelopeList=["None"], angularRange=["None"], startDirector=["None"]): self.numPoints = numPoints self.pointA = pointA self.pointB = pointB self.baseLength = np.linalg.norm(pointA - pointB) self.bondLength = float(bondLength) self.minDist = minDist self.numCrankMoves = numCrankMoves self.angularRange = angularRange self.startDirector = startDirector self.blockNames = self.generateBuildingBlockNames() self.allowedList = self.generateAllowedList() blockDirector = self.generateBuildingBlockDirector() self.blockDirectorHat = blockDirector / np.linalg.norm(blockDirector) self.blockRefPoint = self.generateBuildingBlockRefPoint() self.parseEnvelopeList(envelopeList) # from the points to avoid list only remember those that would pass the specified envelope test self.pointsToAvoid = pointsToAvoid # check starting points are legal or it's gonna be a long wait. if not self.checkPointInBounds(self.pointA): print("Error Warning: PointA out of bounds") time.sleep(3) if not self.checkPointInBounds(self.pointB): print("Error Warning: PointB out of bounds") time.sleep(3) return BBG.generateBuildingBlock(self, numPoints, minDist, envelopeList=envelopeList, visualiseEnvelope=visualiseEnvelope, pointsToAvoid=pointsToAvoid)
def generateBuildingBlock(self, species, minDist, showBlockDirector=False, sheared=False, envelopeList=['None']): self.species = species self.sheared = sheared dummyNumPoints = 0 self.minDist = minDist self.spidroinDirector = np.array([0.0, 0.0, 1.0]) self.spidroinRefPoint = np.array([0.0, 0.0, 0.0]) return BBG.generateBuildingBlock(self, dummyNumPoints, minDist, showBlockDirector=showBlockDirector, envelopeList=envelopeList)
def generateBuildingBlock( self, numPoints, x1, x2, y1, y2, z1, z2, networkMinDist, neighborRadius, monomerMinDist, bondLength, curlyFactor, coneAngle, minAngle, threshold, maxNeighbours, angularRange=['None'], pointsToAvoid=[], visualiseEnvelope=(0,20), envelopeList=["None"]): self.numPoints = numPoints self.bondLength = float(bondLength) self.networkMinDist = networkMinDist self.neighborRadius = neighborRadius self.monomerMinDist = monomerMinDist self.x1 = x1 self.x2 = x2 self.y1 = y1 self.y2 = y2 self.z1 = z1 self.z2 = z2 self.coneAngle = coneAngle self.minAngle = minAngle self.threshold = threshold self.maxNeighbours = maxNeighbours self.curlyFactor = curlyFactor self.pointsToAvoid = pointsToAvoid self.visualiseEnvelope = visualiseEnvelope self.envelopeList = envelopeList self.angularRange = angularRange return BBG.generateBuildingBlock(self, numPoints, networkMinDist, envelopeList=envelopeList, visualiseEnvelope=visualiseEnvelope, pointsToAvoid=pointsToAvoid)
def generateBuildingBlock(self, startPos, direction, rotation, alignDirectors=True, showDirector=False, nameByBuildingBlockType=True): self.numPoints = 0 self.spidroinDirector = np.array([0.0, 0.0, 1.0]) self.spidroindRefPoint = np.array([0.0, 0.0, 0.0]) self.nameByBuildingBlockType = nameByBuildingBlockType return BBG.generateBuildingBlock(self, self.numPoints, startPos, direction, rotation, alignDirectors=alignDirectors, showDirector=showDirector)
def generateBuildingBlock(self, numPoints, minDist, envelopeList='[None]', pointsToAvoid=[], visualiseEnvelope=(0, 200, 'envelope.xyz'), showBlockDirector=False, defaultBlockRefPoint=None): self.numPoints = numPoints self.minDist = minDist return BBG.generateBuildingBlock( self, numPoints, minDist, envelopeList=envelopeList, pointsToAvoid=pointsToAvoid, visualiseEnvelope=visualiseEnvelope, showBlockDirector=showBlockDirector, defaultBlockRefPoint=defaultBlockRefPoint)
def generateBuildingBlock(self, numPoints, pointA, alpha1, alpha2, beta1, beta2, minDist, bondLength, pointsToAvoid=[], visualiseEnvelope=(0, 20, 'envelope.xyz'), envelopeList=["None"], showBlockDirector=False, SpaceCurveTransform=True): self.numPoints = numPoints self.pointA = pointA self.bondLength = float(bondLength) self.minDist = minDist self.blockDirectorHat = np.array([0.0, 0.0, 1.0]) self.allowedList = self.generateAllowedList() self.blockNames = self.generateBuildingBlockNames() self.parseEnvelopeList(envelopeList) self.alpha1 = min(alpha1 * np.pi / 180, alpha2 * np.pi / 180) self.alpha2 = max(alpha1 * np.pi / 180, alpha2 * np.pi / 180) self.beta1 = min(beta1 * np.pi / 180, beta2 * np.pi / 180) self.beta2 = max(beta1 * np.pi / 180, beta2 * np.pi / 180) self.pointsToAvoid = pointsToAvoid self.SpaceCurveTransform = SpaceCurveTransform # check starting points are legal or it's gonna be a long wait. if not self.checkPointInBounds(self.pointA): print("Error Warning: PointA out of bounds") time.sleep(3) return BBG.generateBuildingBlock(self, numPoints, minDist, envelopeList=envelopeList, visualiseEnvelope=visualiseEnvelope, showBlockDirector=showBlockDirector, pointsToAvoid=pointsToAvoid)
def generateBuildingBlock(self, minDist, species='SP1', showBlockDirector=False): self.species = species self.minDist = minDist if species == 'SP1': self.numGUnits = self.SP1NumGUnits self.numPQUnits = self.SP1NumGUnits else: self.numGUnits = self.SP2NumGUnits self.numPQUnits = self.SP2NumGUnits + 1 self.numPoints = self.numGUnits * 3 + self.numPQUnits * 3 self.directorHat = np.array([0.0, 0.0, 1.0]) return BBG.generateBuildingBlock(self, self.numPoints, minDist, showBlockDirector=showBlockDirector)
def generateBuildingBlock(self, numResidues, seedResidue=None, showBlockDirector=False, nameCA=False): self.numResidues = numResidues self.numPoints = numResidues * 3 self.directorHat = np.array([0.0, 0.0, 1.0]) self.nameCA = nameCA self.seedResidue = seedResidue if not seedResidue == None: if not len(seedResidue) == 3: print( "Warning: Seed residue in peptide backbone generator is not 3 atoms long" ) minDistDummy = 1.0 return BBG.generateBuildingBlock(self, self.numPoints, minDistDummy, showBlockDirector=showBlockDirector)
def generateBuildingBlock(self, numGen1Unimers, x1, x2, y1, y2, z1, z2, networkMinDist, alpha1, alpha2, beta1, beta2, monomerMinDist, bondLength, minNumPointsUnimer, maxNumAttempts, selfAvoid, coneAngle, directorMaxPitch, globalDirector, numBranchGenerations, branchDensity, minBranchAngle, angularRange=['None'], pointsToAvoid=[], visualiseEnvelope=(0, 20), envelopeList=["None"], SpaceCurveTransform=True): numPoints = 0 # computed on the fly in this case self.networkGraph = nx.Graph() self.numGen1Unimers = numGen1Unimers self.x1 = x1 self.x2 = x2 self.y1 = y1 self.y2 = y2 self.z1 = z1 self.z2 = z2 self.networkMinDist = networkMinDist self.monomerMinDist = monomerMinDist self.alpha1 = alpha1 self.alpha2 = alpha2 self.beta1 = beta1 self.beta2 = beta2 self.bondLength = bondLength self.minNumPointsUnimer = minNumPointsUnimer self.maxNumAttempts = maxNumAttempts self.selfAvoid = selfAvoid self.coneAngle = coneAngle * np.pi / 180.0 self.directorMaxPitch = directorMaxPitch * np.pi / 180.0 self.globalDirector = globalDirector self.numBranchGenerations = numBranchGenerations self.branchDensity = branchDensity self.minBranchAngle = minBranchAngle * np.pi / 180.0 self.pointsToAvoid = pointsToAvoid self.visualiseEnvelope = visualiseEnvelope self.envelopeList = envelopeList + [ 'cuboid ' + str(x1) + ' ' + str(x2) + ' ' + str(y1) + ' ' + str(y2) + ' ' + str(z1) + ' ' + str(z2) ] self.angularRange = angularRange self.blockRefPoint = self.generateBuildingBlockRefPoint() self.SpaceCurveTransform = SpaceCurveTransform return BBG.generateBuildingBlock(self, numPoints, networkMinDist, envelopeList=self.envelopeList, visualiseEnvelope=visualiseEnvelope, pointsToAvoid=pointsToAvoid)
import numpy as np from Builder.BuildingBlockGenerator import BuildingBlockGenerator BBG = BuildingBlockGenerator('MWEParameters.txt') numAtoms = 30 startPosition = np.array([0.0, 0.0, 0.0]) orientationVector = np.array([0.0, 0.0, 1.0]) rotation = 45 * np.pi / 180 minDist = 1.0 testBuildBlock = BBG.generateBuildingBlock(numAtoms, minDist) testBuildBlock.transformBBToLabFrame(orientationVector, startPosition, rotation) testBuildBlock.exportBBK('example') print "example done"
def generateBuildingBlock(self, numPoints, pointA, pointB, minDist, bondLength, numCrankMoves, pointsToAvoid=[], envelopeList=["None"]): self.numPoints = numPoints self.labPointA = pointA self.labPointB = pointB self.baseLength = np.linalg.norm(pointA - pointB) self.bondLength = float(bondLength) self.minDist = minDist self.blockPointA = np.array([-self.baseLength / 2, 0.0, 0.0]) self.blockPointB = np.array([self.baseLength / 2, 0.0, 0.0]) self.numCrankMoves = numCrankMoves self.allowedList = self.generateAllowedList() if self.dumpInterimFiles: fIO.saveXYZList([self.blockPointA, self.blockPointB], ['Ca', 'O'], 'blockPoints.xyz') # generate the BuildingBlock reference point earlier than usual because # we need the transformation for the pointsToAvoid input. self.blockRefPoint = self.generateBuildingBlockRefPoint() # generate the BuildingBlock director unit vector earlier than usual because # we need the transformation for the pointsToAvoid input. self.blockDirectorHat = self.generateBuildingBlockDirector() # generate the transformation information from building block to labPointA and labPointB self.labDirector, self.labRefPoint, self.labRotation = self.computeTransform( ) # convert the pointsToAvoid information from the labFrame to the block frame blockPointsToAvoid = coords.transformFromLabFrameToBlockFrame( self.labDirector, self.labRefPoint, self.labRotation, self.blockDirectorHat, self.blockRefPoint, pointsToAvoid) if self.dumpInterimFiles == 1: # these are debugging tests to make sure the transform is correct blockPointATrans = coords.transformFromLabFrameToBlockFrame( self.labDirector, self.labRefPoint, self.labRotation, self.blockDirectorHat, self.blockRefPoint, [pointA])[0] blockPointBTrans = coords.transformFromLabFrameToBlockFrame( self.labDirector, self.labRefPoint, self.labRotation, self.blockDirectorHat, self.blockRefPoint, [pointB])[0] fIO.saveXYZList([blockPointATrans, blockPointBTrans], ['Ca', 'O'], "blockPointsTransFromLab.xyz") fIO.saveXYZ(blockPointsToAvoid, 'Li', "blockPointsToAvoid.xyz") labPointsToAvoidTrans = coords.transformFromBlockFrameToLabFrame( self.labDirector, self.labRefPoint, self.labRotation, self.blockDirectorHat, self.blockRefPoint, blockPointsToAvoid) fIO.saveXYZ(labPointsToAvoidTrans, 'Be', "labPointsToAvoidTrans.xyz") # parse the envelope list now to check pointA and point B self.parseEnvelopeList(envelopeList) # store points to avoid to check pointA and point B self.pointsToAvoid = blockPointsToAvoid # check starting points are legal or it's gonna be a long wait. if not self.checkPointInBounds(self.blockPointA): print "Error Warning: PointA out of bounds" time.sleep(3) if not self.checkPointInBounds(self.blockPointB): print "Error Warning: PointB out of bounds" time.sleep(3) return BBG.generateBuildingBlock(self, numPoints, minDist, envelopeList=envelopeList, pointsToAvoid=blockPointsToAvoid)