Beispiel #1
0
    def setUp(self):
        # get data
        import pdbparser
        from Utilities.Collection import get_path

        pdbparserPath = get_path("pdbparser_path")
        self.__pdb = pdbparser.pdbparser(
            os.path.join(pdbparserPath, 'Data',
                         'connectivityTestMolecule.pdb'))
        # get method
        self.__method = __import__("Utilities.Connectivity",
                                   fromlist=["Connectivity"]).Connectivity

        # results
        self.__bonds = [[1], [2], [3, 9], [5], [5, 7], [6], [], [8], [], [10],
                        [11, 12], [], [13, 14, 15], [], [], []]
        self.__angles = [[0, 1, 2], [1, 2, 3], [1, 2, 9], [3, 2, 9], [2, 3, 5],
                         [2, 9, 10], [3, 5, 6],
                         [5, 4, 7], [4, 5, 6], [4, 7, 8], [9, 10, 11],
                         [9, 10, 12], [11, 10, 12], [10, 12, 13], [10, 12, 14],
                         [10, 12, 15], [13, 12, 14], [13, 12,
                                                      15], [14, 12, 15]]
        self.__dihedrals = [[0, 1, 2, 3], [0, 1, 2, 9], [1, 2, 3, 5],
                            [1, 2, 9, 10], [5, 3, 2, 9], [3, 2, 9, 10],
                            [2, 3, 5, 6], [2, 9, 10, 11], [2, 9, 10, 12],
                            [6, 5, 4, 7], [5, 4, 7, 8], [9, 10, 12, 13],
                            [9, 10, 12, 14], [9, 10, 12, 15], [11, 10, 12, 13],
                            [11, 10, 12, 14], [11, 10, 12, 15]]
Beispiel #2
0
 def setUp(self):
     # get data
     import pdbparser
     self.__pdbData = pdbparser.pdbparser()
     self.__pdbData.records = __import__("Utilities.Database",
                                         fromlist=["__WATER__"]).__WATER__
     # get method
     self.__method = __import__("Utilities.Geometry",
                                fromlist=["translate"]).translate
Beispiel #3
0
 def __initialize_input_files_variables__(self, input_files):
     # simulation box size
     self.simulationBox = SimulationBox.PeriodicSimulationBox()
     self.simulationBox.setVectors(self.parameters["box_size"])
     # initial coordinates
     pdb = pdbparser.pdbparser(input_files["pdb"])
     self.coordinates = Array(pdb.get_coordinates())
     # number of atoms
     self.numberOfAtoms = self.coordinates.shape[0]
     # structure information
     self.structure = StructureFileParser(input_files["sf"])
     # initialize velocities
     self.velocities = Array(
         randomVelocity(self.parameters["temperature"],
                        self.structure.atomMass / 6.023e23))
Beispiel #4
0
 def initialize_default_attributes(self):
     # self.pdb
     if not hasattr(self, "pdb"):
         object.__setattr__(self, "pdb", pdbparser())
     else:
         assert isinstance(self.pdb, pdbparser)
     # self.indexes
     if not hasattr(self, "indexes"):
         self.indexes = self.pdb.indexes
     elif self.indexes is None:
         self.indexes = self.pdb.indexes
     else:
         assert isinstance(self.indexes, (list, tuple))
         self.indexes = list(self.indexes)
         self.indexes = sorted(self.indexes)
         assert self.indexes[0] >= 0
         assert self.indexes[-1] < len(self.pdb)
Beispiel #5
0
 def initialize_default_attributes(self):
     # self.pdb
     if not hasattr(self, "pdb"):
         object.__setattr__(self, "pdb", pdbparser())
     else:
         assert isinstance(
             self.pdb,
             pdbparser), Logger.error("pdb must a pdbparser instance")
     # self.filePath
     if not hasattr(self, "filePath"):
         object.__setattr__(self, "filePath", self.__defaults__["filePath"])
     elif self.filePath is not None:
         try:
             fd = open(self.filePath, 'r')
         except:
             Logger.error("Cannot open %r for reading." % self.filePath)
             raise
         else:
             fd.close()
     # info
     self.info = {}
at4['coordinates_x'] =  3.920020
at5['coordinates_x'] =  5.033480
at6['coordinates_x'] =  6.146940
at7['coordinates_x'] =  7.260400
at8['coordinates_x'] =  8.373860
at1['coordinates_y'] =  0.368530
at2['coordinates_y'] = -0.368280
at3['coordinates_y'] =  0.368280
at4['coordinates_y'] = -0.368530
at5['coordinates_y'] =  0.368530
at6['coordinates_y'] = -0.368280
at7['coordinates_y'] =  0.368280
at8['coordinates_y'] = -0.368530

# create molecule molecule
pdb = pdbparser()
pdb.records = [at1, at2, at3, at4]#, at5, at6, at7, at8]
#pdb.visualize()

# create simulation
sim = Simulation(pdb, logStatus = True, logExport = False,
                 numberOfSteps = 100, outputFrequency = 1,
                 exportInitialConfiguration = True, outputPath = tempfile.mktemp(".xyz"))


# remove all bonded and non bonded interactions except dihedrals
sim.bonds_indexes = []
sim.angles_indexes = []
sim.lennardJones_eps *= 0
sim.atomsCharge *= 0
Beispiel #7
0
# standard libraries imports
from __future__ import print_function
import os, copy
from collections import Counter

# external libraries imports
import numpy as np

# pdbparser library imports
from pdbparser import pdbparser
from pdbparser.Utilities.Collection import get_path
from pdbparser.Utilities.Database import __ATOM__
from pdbparser.Utilities.Construct import Micelle, Sheet, Nanotube
from pdbparser.Analysis.Structure.SolventAccessibleSurfaceArea import SolventAccessibleSurfaceArea

pdbSDS = pdbparser(os.path.join(get_path("pdbparser"), "Data/SDS.pdb"))
pdbCTAB = pdbparser(os.path.join(get_path("pdbparser"), "Data/CTAB.pdb"))

PDB = Nanotube().construct().get_pdb()
PDB = Sheet().construct().get_pdb()
PDB = Micelle([pdbSDS], flipPdbs=[True, True],
              positionsGeneration="symmetric").construct().get_pdb()

SASA = SolventAccessibleSurfaceArea(trajectory=PDB,
                                    configurationsIndexes=[0],
                                    targetAtomsIndexes=PDB.indexes,
                                    atomsRadius='vdwRadius',
                                    makeContiguous=False,
                                    probeRadius=0,
                                    resolution=0.5,
                                    storeSurfacePoints=True,
Beispiel #8
0
from pdbparser import pdbparser
from pdbparser.log import Logger
from pdbparser.Utilities.Database import __ATOM__
from pdbparser.Utilities.Construct import AmorphousSystem
from pdbparser.Utilities.Collection import get_path
from pdbparser.Utilities.Simulate import Simulation

Ar1 = copy.deepcopy(__ATOM__)
Ar1['atom_name'] = "Ar1"
Ar1['residue_name'] = "Ar"
Ar1['element_symbol'] = "Ar"
Ar2 = copy.deepcopy(Ar1)
Ar2['atom_name'] = "Ar2"
Ar2["coordinates_x"] = 1
pdbAr = pdbparser()
pdbAr.records = [Ar1]

boxSize = np.array([20, 20, 20])
pdb = AmorphousSystem([pdbAr],
                      boxSize=boxSize,
                      interMolecularMinimumDistance=2.5,
                      periodicBoundaries=True).construct().get_pdb()

# create simulation
sim = Simulation(pdb,
                 logStatus=True,
                 logExport=False,
                 numberOfSteps=100,
                 outputFrequency=100,
                 boxVectors=boxSize,
from pdbparser.Utilities.Collection import get_path
from pdbparser.Utilities.Simulate import Simulation

at1 = copy.deepcopy(__ATOM__)
at2 = copy.deepcopy(__ATOM__)
at1['atom_name'] = "h1"
at2['atom_name'] = "h2"
at1['residue_name'] = "h2"
at2['residue_name'] = "h2"
at1['element_symbol'] = "h"
at2['element_symbol'] = "h"
at1['coordinates_x'] = -0.125
at2['coordinates_x'] =  0.125

# import molecule
pdb1 = pdbparser()
pdb1.records = [at1, at2]

# create simulation
sim = Simulation(pdb1, logStatus = False, logExport = False,
                 stepTime = 0.2, numberOfSteps = 10, outputFrequency = 1,
                 exportInitialConfiguration = True, outputPath = tempfile.mktemp(".xyz"))
# remove all bonded interactions
sim.bonds_indexes = []
sim.angles_indexes = []
sim.dihedrals_indexes = []
sim.nBondsThreshold = [[],[]]
# setting charges to 0
sim.atomsCharge = [0,0]

# initial parameters
Beispiel #10
0
# standard distribution imports
from __future__ import print_function
import os

# pdbparser imports
from pdbparser.Utilities.Collection import get_path
from pdbparser import pdbparser
from pdbparser.log import Logger
from pdbparser.Utilities.Construct import AmorphousSystem, Micelle
from pdbparser.Utilities.Geometry import get_satisfactory_records_indexes, translate
from pdbparser.Utilities.Modify import delete_records_and_models_records

from pdbparser.Utilities.Database import __WATER__

# create pdbWATER
pdbWATER = pdbparser()
pdbWATER.records = __WATER__
pdbWATER.set_name("water")

Logger.info("Create water box")
pdbWATER = AmorphousSystem(pdbWATER, density = 0.5).construct().get_pdb()
pdbWATERhollow = pdbWATER.get_copy()

# make sphere
Logger.info("Create a water sphere of 15A radius")
sphereIndexes = get_satisfactory_records_indexes(pdbWATER.indexes, pdbWATER, "np.sqrt(x**2 + y**2 + z**2) >= 15")
delete_records_and_models_records(sphereIndexes, pdbWATER)

# make hollow
Logger.info("Remove a water sphere of 15A radius")
hollowIndexes = get_satisfactory_records_indexes(pdbWATERhollow.indexes, pdbWATERhollow, "np.sqrt(x**2 + y**2 + z**2) <= 15")
Beispiel #11
0
from __future__ import print_function
import os

from pdbparser.Utilities.Collection import get_path
from pdbparser import pdbparser
from pdbparser.Utilities.Construct import Liposome
from pdbparser.Utilities.Modify import reset_sequence_identifier_per_model

# read SDS molecule from pdbparser database
pdbSDS = pdbparser(os.path.join(get_path("pdbparser"), "Data/SDS.pdb"))

# create liposome
pdbLIPOSOME = Liposome(pdbSDS,
                       innerInsertionNumber=1000,
                       positionsGeneration="symmetric").construct()

# visualize liposome
pdbLIPOSOME.get_pdb().visualize()
Beispiel #12
0
import random, math
import numpy as np
import matplotlib.pyplot as plt
from pdbparser import pdbparser
from pdbparser.Utilities import Geometry, Information, Modify

## read pdb file
PDB = pdbparser("SiOx.pdb")

## translate to origin
COM = Geometry.get_center(PDB.indexes, PDB)
Geometry.translate(PDB.indexes, PDB, -COM)

## get radius
minX,maxX, minY,maxY, minZ,maxZ = Geometry.get_min_max(PDB.indexes, PDB)
radiusX = (maxX-minX)/2.
radiusY = (maxY-minY)/2.
radiusZ = (maxZ-minZ)/2.
radius  = max(radiusX,radiusY,radiusZ)

# get oxygen/silicon ratio vs depth
oIdxs   = Information.get_records_indexes_by_attribute_value(PDB.indexes, PDB, 'element_symbol', 'O')
siIdxs  = Information.get_records_indexes_by_attribute_value(PDB.indexes, PDB, 'element_symbol', 'Si')
oDist   = np.sqrt(np.sum(PDB.coordinates[oIdxs]**2,1))
siDist  = np.sqrt(np.sum(PDB.coordinates[siIdxs]**2,1))
depth   = math.ceil(max(oDist) - min(oDist))
# get histogram of oxygen/silicon distribution ratio
ho,  e = np.histogram(oDist,  bins=range(math.ceil(radius) - depth, math.ceil(radius)))
hsi, e = np.histogram(siDist, bins=range(math.ceil(radius) - depth, math.ceil(radius)))
ratios = (ho.astype(float)/(ho.astype(float)+hsi.astype(float)))[::-1]
# get ratios slope
Beispiel #13
0
        y = y.reshape((histogram_shape[1], 1))
        z = z.reshape((histogram_shape[2], 1))
        distances = x[indexes[:, 0]] * basisVectors[0] + y[
            indexes[:, 1]] * basisVectors[1] + z[indexes[:,
                                                         2]] * basisVectors[2]
        # return good indexes
        return indexes[np.where(np.add.reduce(distances**2, 1) <= radius**2)]


if __name__ == "__main__":
    import sys
    sys.path.insert(0, "/Users/AOUN/Desktop/pdbparser")
    import pdbparser
    from Utilities import Array

    pdb = pdbparser.pdbparser("examples/Argon.pdb")

    sb = PeriodicSimulationBox()
    sb.setVectors(np.array([[77.395, 0, 0], [0, 77.395, 0], [0, 0, 77.395]]))

    realArray = Array(pdb.get_coordinates())
    boxArray = sb.wrapBoxArray(sb.realToBoxArray(realArray))

    #minDist = []
    #for idx in range(len(pdb)-1):
    #    dist = realArray[idx+1:,:]-realArray[idx]
    #    dist = np.sqrt(np.add.reduce(dist**2,1))
    #    minDist.append(np.min(dist))
    #print np.min(minDist)

    #print realArray
Beispiel #14
0
from __future__ import print_function
import os
import numpy as np

from pdbparser.log import Logger
from pdbparser import pdbparser
from pdbparser.Utilities.Collection import get_path
from pdbparser.Utilities.Selection import NanotubeSelection
from pdbparser.Utilities.Information import get_models_records_indexes_by_records_indexes, get_records_indexes_in_attribute_values
from pdbparser.Utilities.Modify import *
from pdbparser.Utilities.Geometry import get_principal_axis, translate, orient

# read pdb
pdbCNT = pdbparser(
    os.path.join(get_path("pdbparser"), "Data/nanotubeWaterNAGMA.pdb"))

Logger.info("Define models")
# define models
define_models_by_records_attribute_value(pdbCNT.indexes, pdbCNT)

Logger.info("Getting nanotube indexes")
# get CNT indexes
cntIndexes = get_records_indexes_in_attribute_values(pdbCNT.indexes, pdbCNT,
                                                     "residue_name", "CNT")

Logger.info("Create selection")
# create selection
sel = NanotubeSelection(pdbCNT, nanotubeIndexes=cntIndexes).select()

Logger.info("Get models inside nanotube")
# construct models out of residues
Beispiel #15
0
# standard distribution imports
import os

# pdbparser imports
from pdbparser.Utilities.Collection import get_path
from pdbparser import pdbparser
from pdbparser.Utilities.Construct import AmorphousSystem
from pdbparser.Utilities.Database import __WATER__

# create pdbWATER
pdbWATER = pdbparser()
pdbWATER.records = __WATER__
pdbWATER.set_name("water")

# get pdb molecules
pdbDMPC = pdbparser(os.path.join(get_path("pdbparser"), "Data", "DMPC.pdb"))
pdbNAGMA = pdbparser(os.path.join(get_path("pdbparser"), "Data", "NAGMA.pdb"))
pdbNALMA = pdbparser(os.path.join(get_path("pdbparser"), "Data", "NALMA.pdb"))

# construct amorphous system, adding restrictions and existing micelle in universe
pdbAMORPH = AmorphousSystem(
    [pdbWATER, pdbDMPC, pdbNAGMA, pdbNALMA],
    boxSize=[150, 150, 150],
    density=0.25,
    restrictions="np.sqrt(x**2+y**2+z**2)<25").construct()

# visualize amorphous system
pdbAMORPH.get_pdb().visualize()