Ejemplo n.º 1
0
 def importBBK(self, fileroot):
     # replaces the core representation of the building block with the data stored in a BBK file.
     xyzVals, self.blockAtomNames = fIO.loadXYZ(fileroot + '.xyz')
     self.blockXYZVals = np.array([xyzVals])
     inputVals = fIO.readTextFile(fileroot+'.bbk')
     self.blockRefPoint = np.array([float(refVal) for refVal in inputVals[0].split()[2:]])
     director = np.array([float(refVal) for refVal in inputVals[1].split()[2:]])
     self.blockDirectorHat = director/np.linalg.norm(director)
     self.blockConnectors = np.array([int(val) for val in inputVals[2].split()[2:]])
     self.blockConnectors = np.reshape(self.blockConnectors, (self.blockConnectors/3, 3))
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    def generateBuildingBlockXYZ(self):

        print "load spidroin coil information"
        spidroinCoilSpecies1Names, spidroinCoilSpecies1XYZ = fIO.loadXYZ(
            self.spidroinSpecies1FName)
        spidroinCoilSpecies2Names, spidroinCoilSpecies2XYZ = fIO.loadXYZ(
            self.spidroinSpecies2FName)

        print "Generating spidroin sites within cluster"
        spidroinPositionBB = self.SPEBBG.generateBuildingBlock(
            self.numPointsInCluster, self.clusterRX, self.clusterRY,
            self.clusterRZ, -90.0, 90.0, -180.0, 180.0, self.SpidroinRadius)

        # compute the positions and orientations of each individual spidroin within it's cluster
        spidroinPositions = spidroinPositionBB.blockXYZVals
        spidroinDirectors = [spidPos for spidPos in spidroinPositions]
        spidroinDirectorsHat = [
            spidDir / np.linalg.norm(spidDir) for spidDir in spidroinDirectors
        ]
        spidroinRots = [
            rnd.uniform(0, 360) for _ in range(0, self.numPointsInCluster)
        ]

        print "Generating cluster positions within the larger aggregate"
        clusterPositionBB = self.VPEBBG.generateBuildingBlock(
            self.numClustersInAggregate, self.aggregateRX, self.aggregateRY,
            self.aggregateRZ, -90.0, 90.0, -180.0, 180.0,
            (max(self.clusterRX, self.clusterRY, self.clusterRZ) +
             self.species2AltitudeBoost + self.TerminalExtension))
        clusterPositions = clusterPositionBB.blockXYZVals
        clusterDirectors = [clustPos for clustPos in clusterPositions]
        clusterDirectorsHat = [
            clustDir / np.linalg.norm(clustDir)
            for clustDir in clusterDirectors
        ]
        clusterRots = [
            rnd.uniform(0, 360) for _ in range(0, self.numClustersInAggregate)
        ]

        fIO.saveXYZ(clusterPositions, 'Ne', 'aggClusterPoints.xyz')

        print "Producing Cluster"
        # sety up output arrays
        clusterXYZ = []
        clusterNames = []
        spidroinNum = 0
        # loop through the right number of times for the species1 data
        for rotation, director, position in zip(
                spidroinRots[0:self.numSpidroinSpecies1],
                spidroinDirectorsHat[0:self.numSpidroinSpecies1],
                spidroinPositions[0:self.numSpidroinSpecies1]):
            print spidroinNum
            if len(clusterXYZ) == 0:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                clusterXYZ = xyzVals[:]
                clusterNames = spidroinCoilSpecies1Names
            else:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                clusterXYZ = np.concatenate((clusterXYZ, xyzVals[:]), 0)
                clusterNames = np.concatenate(
                    (clusterNames[:], spidroinCoilSpecies1Names), 0)
            spidroinNum += 1

        # loop throught the species2 data and add the species two data at a slightly higher altitude.
        for rotation, director, position in zip(
                spidroinRots[self.numSpidroinSpecies1:],
                spidroinDirectorsHat[self.numSpidroinSpecies1:],
                spidroinPositions[self.numSpidroinSpecies1:]):
            print spidroinNum
            xyzVals = coords.transformFromBlockFrameToLabFrame(
                director, position + director * self.species2AltitudeBoost,
                rotation, np.array([0.0, 0.0, 1.0]), np.array([0.0, 0.0, 0.0]),
                spidroinCoilSpecies2XYZ[:])
            clusterXYZ = np.concatenate((clusterXYZ, xyzVals[:]), 0)
            clusterNames = np.concatenate(
                (clusterNames[:], spidroinCoilSpecies2Names), 0)
            spidroinNum += 1

        fIO.saveXYZList(clusterXYZ, clusterNames, "cluster.xyz")

        print "Producing aggregate"
        # sety up output arrays
        aggregateXYZ = []
        aggregateNames = []
        clusterNum = 0
        # loop through the right number of times for the species1 data
        for rotation, director, position in zip(clusterRots,
                                                clusterDirectorsHat,
                                                clusterPositions):
            print clusterNum
            if len(aggregateXYZ) == 0:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), clusterXYZ)
                aggregateXYZ = xyzVals[:]
                aggregateNames = clusterNames
            else:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), clusterXYZ)
                aggregateXYZ = np.concatenate((aggregateXYZ, xyzVals[:]), 0)
                aggregateNames = np.concatenate((aggregateNames, clusterNames),
                                                0)
            clusterNum += 1

        fIO.saveXYZList(aggregateXYZ, aggregateNames, "spidroinAggregate.xyz")

        self.namesTemp = aggregateNames
        return aggregateXYZ
Ejemplo n.º 4
0
import Utilities.fileIO as fIO
import Utilities.coordSystems as coords

blockNames, xyzVals = fIO.loadXYZ('species2Spidroin.hPin.xyz')
eAtomNames, ePositions, eSizes, eRs, eRotVecs = coords.convertTriplesToEllipsoids(blockNames, xyzVals, 1.0, 1.0)
fIO.saveEllipsoidXYZList(eAtomNames, ePositions, eSizes, eRs, eRotVecs, 'species2Spidroin.e.xyz')

print "example done"
Ejemplo n.º 5
0
    def generateBuildingBlockXYZ(self):

        print "load spidroin coil information"
        spidroinCoilSpecies1Names, spidroinCoilSpecies1XYZ = fIO.loadXYZ(
            self.spidroinSpecies1FName)
        spidroinCoilSpecies2Names, spidroinCoilSpecies2XYZ = fIO.loadXYZ(
            self.spidroinSpecies2FName)

        print "Generating spidroin sites within cluster"
        spidroinPositionBB = self.VPESCPBBG.generateBuildingBlock(
            self.numPointsInCluster, self.clusterRX, self.clusterRY,
            self.clusterRZ, -90.0, 90.0, -180.0, 180.0, -10.0, 10.0, -10.0,
            10.0, self.monomerRadius, self.terminalSeparation, 2)

        # compute the positions and orientations of each individual spidroin within it's cluster
        spidroinPositionInfo = spidroinPositionBB.blockXYZVals
        spidroinPositions = [
            (pos + spidroinPositionInfo[2 * i + 1]) / 2.0
            for i, pos in enumerate(spidroinPositionInfo[0:-1:2])
        ]
        spidroinDirectors = [
            (2.0 * float(rnd.randint(0, 1)) - 1.0) *
            (spidroinPositionInfo[2 * i + 1] - pos)
            for i, pos in enumerate(spidroinPositionInfo[0:-1:2])
        ]
        spidroinDirectorsHat = [
            director / np.linalg.norm(director)
            for director in spidroinDirectors
        ]
        spidroinRots = [
            rnd.uniform(0.0, 360.0) for _ in range(0, self.numPointsInCluster)
        ]

        print "Generating cluster positions within the larger aggregate"
        clusterPositionBB = self.VPESCPBBG.generateBuildingBlock(
            self.numClustersInAggregate, self.aggregateRX, self.aggregateRY,
            self.aggregateRZ, -90.0, 90.0, -180.0, 180.0, -90.0, 90.0, -180.0,
            180.0, self.clusterRY, self.clusterRX, 2)
        clusterPositionInfo = clusterPositionBB.blockXYZVals
        clusterPositions = [
            (pos + clusterPositionInfo[2 * i + 1]) / 2.0
            for i, pos in enumerate(clusterPositionInfo[0:-1:2])
        ]
        clusterDirectors = [
            (clusterPositionInfo[2 * i + 1] - pos)
            for i, pos in enumerate(clusterPositionInfo[0:-1:2])
        ]
        clusterDirectorsHat = [
            clustDir / np.linalg.norm(clustDir)
            for clustDir in clusterDirectors
        ]
        clusterRots = [0.0 for _ in range(0, self.numClustersInAggregate)]

        fIO.saveXYZList(spidroinPositions,
                        ['Ca', 'O'] * self.numPointsInCluster,
                        'aggClusterPoints.xyz')

        print "Producing Cluster"
        # sety up output arrays
        clusterXYZ = []
        clusterNames = []
        spidroinNum = 0
        # loop through the right number of times for the species1 data
        for rotation, director, position in zip(
                spidroinRots[0:self.numSpidroinSpecies1],
                spidroinDirectorsHat[0:self.numSpidroinSpecies1],
                spidroinPositions[0:self.numSpidroinSpecies1]):
            print spidroinNum
            if len(clusterXYZ) == 0:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([1.0, 0.0, 0.0]),
                    np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                clusterXYZ = xyzVals[:]
                clusterNames = spidroinCoilSpecies1Names
            else:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([1.0, 0.0, 0.0]),
                    np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                clusterXYZ = np.concatenate((clusterXYZ, xyzVals[:]), 0)
                clusterNames = np.concatenate(
                    (clusterNames[:], spidroinCoilSpecies1Names), 0)
            spidroinNum += 1

        # loop throught the species2 data and add the species two data at a slightly higher altitude.
        for rotation, director, position in zip(
                spidroinRots[self.numSpidroinSpecies1:],
                spidroinDirectorsHat[self.numSpidroinSpecies1:],
                spidroinPositions[self.numSpidroinSpecies1:]):
            print spidroinNum
            xyzVals = coords.transformFromBlockFrameToLabFrame(
                director, position, rotation, np.array([1.0, 0.0, 0.0]),
                np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies2XYZ[:])
            clusterXYZ = np.concatenate((clusterXYZ, xyzVals[:]), 0)
            clusterNames = np.concatenate(
                (clusterNames[:], spidroinCoilSpecies2Names), 0)
            spidroinNum += 1

        fIO.saveXYZList(clusterXYZ, clusterNames, "cluster.xyz")

        print "Producing aggregate"
        # sety up output arrays
        aggregateXYZ = []
        aggregateNames = []
        clusterNum = 0
        # loop through the right number of times for the species1 data
        for rotation, director, position in zip(clusterRots,
                                                clusterDirectorsHat,
                                                clusterPositions):
            print clusterNum
            if len(aggregateXYZ) == 0:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), clusterXYZ)
                aggregateXYZ = xyzVals[:]
                aggregateNames = clusterNames
            else:
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position, rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), clusterXYZ)
                aggregateXYZ = np.concatenate((aggregateXYZ, xyzVals[:]), 0)
                aggregateNames = np.concatenate((aggregateNames, clusterNames),
                                                0)
            clusterNum += 1

        fIO.saveXYZList(aggregateXYZ, aggregateNames, "spidroinAggregate.xyz")

        self.namesTemp = aggregateNames
        return aggregateXYZ
Ejemplo n.º 6
0
from Projects.chainOfChains import chainOfChainsGenerator as CCGen
import Utilities.fileIO as fIO

filename = "chainOfChains.txt"
nameList, xyzVals = fIO.loadXYZ("species1SpidroinHPin.xyz")

# create the backbone generator object using static file parameters
chainOfChainsGen = CCGen(filename)

# generate backbone realtime parameters
minDist = 1.0
residues = [19, 15] * 93
radii = [minDist * 6] * 186
nameType = ['G', 'PQ'] * 186

pointsA = [xyzVal for xyzVal, name in zip(xyzVals, nameList) if name == 'N']
pointsB = [xyzVal for xyzVal, name in zip(xyzVals, nameList) if name == 'C']

fIO.saveXYZList(pointsA + pointsB,
                ['Ca'] * len(pointsA) + ['O'] * len(pointsB), "labPoints.xyz")

cOfChainsBB = chainOfChainsGen.generateBuildingBlock(
    residues,
    pointsA,
    pointsB,
    radii,
    nameType,
    minDist,
    visualiseEnvelope=(0, 50, 'envelope.xyz'))
cOfChainsBB.exportBBK("species1Chain")
Ejemplo n.º 7
0
    def generateBuildingBlockXYZ(self):

        print "Computing standard CTerminus for export as PDB"
        refPosCTerm = np.array([
            -self.spidroinTerminusSeparation / 2.0, 0.0, -2.7
        ])  # this last 2.7 is a total hack to get pointB in the envelope
        self.CTerminusAll = self.CTerminusGen.generateBuildingBlock(
            backboneOnly=False,
            director=self.CTermDirectorHat,
            showBlockDirector=False)
        self.CTerminusBackbone = self.CTerminusGen.generateBuildingBlock(
            backboneOnly=True,
            director=self.CTermDirectorHat,
            showBlockDirector=False)
        self.CTerminusAll.transformBBToLabFrame(self.spidroinDirector,
                                                refPosCTerm, self.CTermRot)
        self.CTerminusBackbone.transformBBToLabFrame(self.spidroinDirector,
                                                     refPosCTerm,
                                                     self.CTermRot)

        print "Computing standard NTerminus for export as PDB"
        refPosNTerm = np.array(
            [self.spidroinTerminusSeparation / 2.0, 0.0, 0.0])
        self.NTerminusAll = self.NTerminusGen.generateBuildingBlock(
            backboneOnly=False,
            director=self.NTermDirectorHat,
            showBlockDirector=False)
        self.NTerminusBackbone = self.NTerminusGen.generateBuildingBlock(
            backboneOnly=True,
            director=self.NTermDirectorHat,
            showBlockDirector=False)
        self.NTerminusAll.transformBBToLabFrame(self.spidroinDirector,
                                                refPosNTerm, self.NTermRot)
        self.NTerminusBackbone.transformBBToLabFrame(self.spidroinDirector,
                                                     refPosNTerm,
                                                     self.NTermRot)

        print "Generating spidroin sites within cluster"
        spidroinPositionBB = SPEBBG.generateBuildingBlock(
            self, self.numPointsInCluster, self.clusterRX, self.clusterRY,
            self.clusterRZ, -90, 90, -180, 180, self.SpidroinRadius)
        # compute the positions and orientations of each individual spidroin within it's cluster
        spidroinPositions = spidroinPositionBB.xyzVals
        spidroinDirectors = [spidPos for spidPos in spidroinPositions]
        spidroinDirectorsHat = [
            spidDir / np.linalg.norm(spidDir) for spidDir in spidroinDirectors
        ]
        spidroinRots = [
            rnd.uniform(0, 360) for _ in range(0, self.numSpidroins)
        ]

        print "Generating cluster positions with in the aggregate"
        clusterPositionBB = SPEBBG.generateBuildingBlock(
            self, self.numClustersInAggregate, self.aggregateRX,
            self.aggregateRY, self.aggregateRZ, -90, 90, -180, 180,
            max(self.clusterRX, self.clusterRY, self.clusterRZ) +
            self.species2AltitudeBoost + self.TerminalExtension)
        clusterPositions = clusterPositionBB.xyzVals
        clusterDirectors = [clustPos for clustPos in clusterPositions]
        clusterDirectorsHat = [
            clustDir / np.linalg.norm(clustDir)
            for clustDir in clusterDirectors
        ]
        clusterRots = [
            rnd.uniform(0, 360) for _ in range(0, self.numClustersInAggregate)
        ]

        print "load spidroin coil information"
        spidroinCoilSpecies1XYZ, spidroinCoilSpecies1Names = fIO.loadXYZ(
            self.spidroinSpecies1FName)
        spidroinCoilSpecies2XYZ, spidroinCoilSpecies2Names = fIO.loadXYZ(
            self.spidroinSpecies2FName)

        print "Producing Cluster of clusters"
        # sety up output arrays
        NTermPoints = []
        CTermPoints = []
        xyzValCoils = []
        names = []

        for clustDirector, clustPosition, clustRotation in zip(
                clusterDirectorsHat, clusterPositions, clusterRots):

            # loop through the right number of times for the species1 data
            for rotation, director, position in zip(
                    spidroinRots[0:self.numSpidroinSpecies1],
                    spidroinDirectorsHat[0:self.numSpidroinSpecies1],
                    spidroinPositions[0:self.numSpidroinSpecies1]):
                if len(NTermPoints) == 0:
                    xyzVals = coords.transformFromBlockFrameToLabFrame(
                        director, position, rotation, np.array([0.0, 0.0,
                                                                1.0]),
                        np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                    xyzVals = coords.transformFromBlockFrameToLabFrame(
                        clustDirector, clustPosition, clustRotation, director,
                        position, xyzVals)
                    NTermPoints = xyzVals[0]
                    NTermPoints = xyzVals[-1]
                    xyzValCoils = xyzVals
                    names = spidroinCoilSpecies1Names
                else:
                    xyzVals = coords.transformFromBlockFrameToLabFrame(
                        director, position, rotation, np.array([0.0, 0.0,
                                                                1.0]),
                        np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies1XYZ[:])
                    xyzVals = coords.transformFromBlockFrameToLabFrame(
                        clustDirector, clustPosition, clustRotation, director,
                        position, xyzVals)
                    NTermPoints = np.concatenate((NTermPoints, xyzVals[0]), 0)
                    CTermPoints = np.concatenate((CTermPoints, xyzVals[0]), 0)
                    xyzValCoils = np.concatenate((xyzValCoils, xyzVals), 0)
                    names = np.concatenate((names, spidroinCoilSpecies1Names),
                                           0)

            # loop throught the species2 data and add the species two data at a slightly higher altitude.
            for rotation, director, position in zip(
                    spidroinRots[self.numSpidroinSpecies1:],
                    spidroinDirectorsHat[self.numSpidroinSpecies1:],
                    spidroinPositions[self.numSpidroinSpecies1:]):
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    director, position + director * self.species2AltitudeBoost,
                    rotation, np.array([0.0, 0.0, 1.0]),
                    np.array([0.0, 0.0, 0.0]), spidroinCoilSpecies2XYZ[:])
                xyzVals = coords.transformFromBlockFrameToLabFrame(
                    clustDirector, clustPosition, clustRotation, director,
                    position, xyzVals)
                NTermPoints = np.concatenate((NTermPoints, xyzVals[0]), 0)
                CTermPoints = np.concatenate((CTermPoints, xyzVals[0]), 0)
                xyzValCoils = np.concatenate((xyzValCoils, xyzVals), 0)
                names = np.concatenate((names, spidroinCoilSpecies2Names), 0)
        self.namesTemp = names

        return xyzValCoils