예제 #1
0
In this test, an SDS molecule is loaded
several records manipulations, translation, rotation, orientation, ... are tested
"""
# standard distribution imports
import os

# pdbParser imports
from pdbParser.Utilities.Collection import get_path
from pdbParser.log import Logger
from pdbParser.pdbParser import pdbParser
from pdbParser.Utilities.Geometry import *

pdbRESULT = pdbParser()

Logger.info("loading sds molecule ...")
pdbSDS = pdbParser(os.path.join(get_path("pdbparser"), "Data", "SDS.pdb"))
INDEXES = range(len(pdbSDS.records))
# get molecule axis
sdsAxis = get_axis(INDEXES, pdbSDS)
## translate to positive quadrant
atomToOriginIndex = get_closest_to_origin(INDEXES, pdbSDS)
atom = pdbSDS.records[atomToOriginIndex]
[minX, minY,
 minZ] = [atom['coordinates_x'], atom['coordinates_y'], atom['coordinates_z']]
translate(INDEXES, pdbSDS, [-1.1 * minX, -1.1 * minY, -1.1 * minZ])

Logger.info("orient molecule along [1,0,0] ...")
orient(axis=[1, 0, 0], indexes=INDEXES, pdb=pdbSDS, records_axis=sdsAxis)
sdsAxis = [1, 0, 0]
pdbRESULT.concatenate(pdbSDS)
import os
import tempfile

import numpy as np

from pdbParser.log import Logger
from pdbParser.Utilities.Collection import get_path
from pdbParser import pdbParser
from pdbParser.Utilities.Simulate import Simulation

# import molecule
pdb = pdbParser(os.path.join(get_path("pdbparser"), "Data/WATER.pdb"))

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

# initial parameters
Logger.info("minimizing 100 step with H-O-H angle %s and O-H bond %s" %
            (sim.__ANGLE__['h o h']['theta0'], sim.__BOND__['h o']['b0']))
sim.minimize_steepest_descent()

# change parameters to 120
sim.__ANGLE__['h o h']['theta0'] = 120
sim.set_angles_parameters()
sim.set_bonds_parameters()
Logger.info("minimizing 100 step with H-O-H angle %s and O-H bond %s" %
예제 #3
0
import os
from pdbParser.pdbParser import pdbParser
from pdbParser.Utilities.Collection import get_path
from pdbParser.Utilities.Construct import AmorphousSystem
from pdbParser.Utilities.Geometry import get_satisfactory_records_indexes, translate, get_geometric_center
from pdbParser.Utilities.Modify import delete_records_and_models_records, reset_records_serial_number, reset_sequence_number_per_residue
from pdbParser.Utilities.Database import __WATER__

# read thf molecule and translate to the center
thfNAGMA = pdbParser(os.path.join(get_path("pdbparser"), "Data/NAGMA.pdb"))
center = get_geometric_center(thfNAGMA.indexes, thfNAGMA)
translate(thfNAGMA.indexes, thfNAGMA, -center)

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

# create amorphous
pdbWATER = AmorphousSystem(pdbWATER, boxSize=[40, 40, 40],
                           density=0.75).construct().get_pdb()
center = get_geometric_center(pdbWATER.indexes, pdbWATER)
translate(pdbWATER.indexes, pdbWATER, -center)

# make hollow
hollowIndexes = get_satisfactory_records_indexes(
    pdbWATER.indexes, pdbWATER, "np.sqrt(x**2 + y**2 + z**2) <= 10")
delete_records_and_models_records(hollowIndexes, pdbWATER)

# concatenate
thfNAGMA.concatenate(pdbWATER, pdbWATER.boundaryConditions)
예제 #4
0
import os

from pdbParser.Utilities.Collection import get_path
from pdbParser import pdbParser
from pdbParser.Utilities.Construct import Micelle

# load molecules pdbs from pdbParser database
pdbSDS = pdbParser(os.path.join(get_path("pdbparser"), "Data/SDS.pdb"))
pdbCTAB = pdbParser(os.path.join(get_path("pdbparser"), "Data/CTAB.pdb"))

# constuct hybrid micelle
pdbMICELLE = Micelle([pdbCTAB, pdbSDS],
                     flipPdbs=[True, True],
                     positionsGeneration="symmetric").construct().solvate(
                         density=0.25,
                         restrictions="np.sqrt(x**2+y**2+z**2)<25")

# solvate micelle with density = 0.5
#pdbMICELLE.solvate(density = 0.5)

# visualize solvate micelle
pdbMICELLE.get_pdb().visualize()
예제 #5
0
import os
from pdbParser.pdbParser import pdbParser
from pdbParser.Utilities.Construct import AmorphousSystem
from pdbParser.Utilities.Collection import get_path

# create thf amorphous box
pdb = pdbParser(os.path.join(get_path("pdbparser"),
                             "Data/Tetrahydrofuran.pdb"))
#pdb.visualize()
#exit()
pdb = AmorphousSystem(pdb,
                      boxSize=[48, 48, 48],
                      recursionLimit=1000000,
                      insertionNumber=700,
                      density=0.7,
                      priorities={
                          "boxSize": True,
                          "insertionNumber": False,
                          "density": True
                      }).construct().get_pdb()
pdb.export_pdb("thf.pdb")
예제 #6
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()
예제 #7
0
"""
Construct a graphene sheet in two orientations
"""
import os

from pdbParser.Utilities.Collection import get_path
from pdbParser.log import Logger
from pdbParser import pdbParser
from pdbParser.Utilities.Connectivity import Connectivity
from pdbParser.Utilities.Modify import reset_atom_name

Logger.info("reading SDBS molecule")
pdb = pdbParser(
    os.path.join(get_path("pdbparser"), "Data/connectivityTestMolecule.pdb"))

connectivity = Connectivity(pdb)

# bonds
Logger.info("calculating bonds")
connectivity.calculate_bonds()
bonds = connectivity.get_bonds(key="atom_name")
print "BONDS:"
print "======"
for idx in range(len(bonds[0])):
    print "%6s" % bonds[0][idx], ' = ', bonds[1][idx]
#connectivity.export_bonds('lol.psf')

# angles
Logger.info("calculating angles")
connectivity.calculate_angles()
angles = connectivity.get_angles(key="atom_name")
예제 #8
0
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
indexes = get_models_records_indexes_by_records_indexes(