Ejemplo n.º 1
0
    def buildBox(self):
        """
        Use the template structure to build the full structure by
        replicating it each dimension until it's bigger than the
        target box size, then deleting waters with centroid that fall
        outside the target box.
        The resulting AtomicGroup is self.full_system
        """

        # figure out how many replicas we need in each direction
        num_x = int(self.box.x() / self.template_box.x()) + 1
        num_y = int(self.box.y() / self.template_box.y()) + 1
        num_z = int(self.box.z() / self.template_box.z()) + 1

        # build up the new system by replicating the target box
        # and systematically translating it
        self.full_system = loos.AtomicGroup()
        for x in range(num_x):
            for y in range(num_y):
                for z in range(num_z):
                    new = self.template.copy()

                    trans = loos.GCoord()
                    trans.x(self.template_box.x() * x)
                    trans.y(self.template_box.y() * y)
                    trans.z(self.template_box.z() * z)

                    new.translate(trans)
                    self.full_system.append(new)

        self.full_system.centerAtOrigin()

        # trim the waters outside the target box size
        residues = self.full_system.splitByResidue()
        print len(residues), len(self.full_system)
        half_box = 0.5 * self.box
        to_remove = loos.AtomicGroup()
        for res in residues:
            centroid = res.centroid()
            print centroid, half_box
            if ((abs(centroid.x()) > half_box.x())
                    or (abs(centroid.y()) > half_box.y())
                    or (abs(centroid.z()) > half_box.z())):
                to_remove.append(res)

        print "Need to remove: ", len(to_remove)
        print "before: ", self.full_system.boundingBox(), len(self.full_system)
        self.full_system.remove(to_remove)
        print "after: ", self.full_system.boundingBox(), len(self.full_system)

        self.full_system.periodicBox(self.box)

        # renumber atom ids and resids
        self.full_system.renumber()
        for i in range(len(self.full_system)):
            self.full_system[i].resid(i / 3 + 1)
Ejemplo n.º 2
0
 def __call__(self, atomicgroup):
     ag = loos.AtomicGroup()
     ag.periodicBox(atomicgroup.periodicBox())
     for a in atomicgroup:
         if self.min_z < a.coords().z() < self.max_z:
             ag.append(a)
     return ag
Ejemplo n.º 3
0
    protein = loos.selectAtoms(system, protein_selection)
    all_lipids = loos.selectAtoms(system, all_lipid_selection)
    # NOTE: target_lipids must be a subset of all_lipids
    target_lipids = loos.selectAtoms(all_lipids, target_lipid_selection)

    slicer = ZSliceSelector(zmin, zmax)

    # TODO: this should probably be a command line option
    # Note: normally, this small a padding might be a problem for Voronoi
    #       decomposition with 1 atom/lipid. However, we're not using the areas
    #       (which is what gets screwed up by lack of padding), and 15 ought
    #       to be big enough to make sure we've got 1 layer of lipid around
    #       the protein.
    padding = 15.

    protein_centroid = loos.AtomicGroup()
    protein_centroid.append(loos.Atom())

    # set up space to hold the neigbor time series
    neighbor_timeseries = numpy.zeros(
        [len(target_lipids), len(traj)], numpy.float)

    for frame in traj:
        # Use the centroid of the protein slice to represent the protein
        protein_slice = slicer(protein)
        centroid = protein_slice.centroid()
        protein_centroid[0].coords(centroid)

        # We assume you're using 1 atom/lipid.
        # Applying slice operation here allows you to be sloppy
        # with your selections.
Ejemplo n.º 4
0



# make hb detector object
model_hbs = loos.HBondDetector(args.bondlength, args.angle, model)

# select all nitrogens and oxygens in the model as putative donors/acceptors
putative = loos.selectAtoms(model, 'name =~ "^N" || name =~ "^O"')

# select all hydrogens to test which are DA pairs
hydrogens = loos.selectAtoms(model, 'name =~ "^H"')

# initialize donor and acceptor groups for appending
donors = []
acceptors = loos.AtomicGroup()

# build list of donor and acceptor groups from putative groups.
for i in putative:
    bound_to_hydrogen = False
    for h in hydrogens:
        if i.isBoundTo(h):
            donors.append((h,i)) # Associate donor with its hydrogen
            bound_to_hydrogen = True
    if not bound_to_hydrogen:
        acceptors.append(i)

# list of donor-H-acceptor triples present in reference crds
ref_dhas = []

# fill out the donor-H-acceptor list
Ejemplo n.º 5
0
        raise ValueError, "Too few waters after superposition: %d %d" % (
            len(water.full_system) / 3, total_water_and_salt)

    sys.stderr.write("Finished bump-checking water against lipid\n")
    sys.stderr.write("Current # water molecules: %d\n" %
                     (len(water.full_system) / 3))
    sys.stderr.write("Adding salt\n")

    # regenerate the list of oxygens
    water_oxygens = loos.selectAtoms(water.full_system, 'name =~ "^O"')
    water_residues = water.full_system.splitByResidue()

    # now replace waters with salt
    salts = []
    for salt in config.salt:
        ions = loos.AtomicGroup()
        for i in range(salt.numres):
            a = loos.Atom()
            a.resname(salt.resname)
            a.segid(salt.segname)
            a.name(salt.atomname)
            a.resid(i + 1)

            # pick a water oxygen at random, replace it with salt
            ox = random.choice(water_oxygens)
            a.coords(ox.coords())
            ions.append(a)

            # remove this water
            for w in water_residues:
                if ox in w:
Ejemplo n.º 6
0
            r.print_indices()
            print


if __name__ == '__main__':

    import sys

    structure = loos.createSystem("trj_1.pdb")
    #structure = loos.createSystem("example.pdb")
    #structure = loos.createSystem("b2ar.pdb")

    #box = loos.GCoord(55., 77, 100)
    #box = loos.GCoord(55., 77, 100)
    phos = loos.selectAtoms(structure, 'name == "P"')
    upper = loos.AtomicGroup()
    for p in phos:
        if p.coords().z() > 0:
            upper.append(p)
    upper.periodicBox(structure.periodicBox())
    print upper.isPeriodic()
    """
    slice = loos.AtomicGroup()
    for a in structure:
        if a.coords().z() > 20 and a.coords().z() < 21:
            slice.append(a)
    slice.periodicBox(box)
    """

    v = VoronoiWrapper(upper)
    #v = VoronoiWrapper(slice)
Ejemplo n.º 7
0
protein = loos.selectAtoms(system, args.protein_string)

output_directory = args.directory
if not os.path.exists(output_directory):
    try:
        os.mkdir(output_directory)
    except OSError as inst:
        print 'Error creating output directory %s : ' % output_directory
        print inst
        sys.exit(1)
if not os.access(output_directory, os.W_OK):
    print "Error: no permission to write to output directory ", output_directory
    sys.exit(1)

helices = []
helix_centroids = loos.AtomicGroup()
for h in args.helix_ranges:
    first, last = h.split(":")
    helix_string = '(resid >= ' + first + ') ' + '&& (resid <= ' + last + ')'
    helix = loos.selectAtoms(protein, helix_string)
    helices.append(helix)
    helix_centroids.append(loos.Atom())

target = loos.selectAtoms(system, args.target_string)
target = loos.selectAtoms(target, "!hydrogen")

chains = target.splitByResidue()

if (args.zmin > args.zmax):
    tmp = args.zmax
    args.zmax = args.zmin
Ejemplo n.º 8
0
segments = []
for segment in config.segments:
    s = loos.selectAtoms(system, 'segname == "' + segment.segname + '"')
    if (len(s) == 0):
        sys.stderr.write("Selection failed assembling system: segment %s doesn't exist\n" % (segment.segname))
        sys.stderr.write("Exiting...\n")
        sys.exit(0)

    segments.append(s)


# copy the protein coordinates into the system
if (config.protein is not None):
    # create AtomicGroup containing all protein segments in case
    # we want to rotate it
    to_rot = loos.AtomicGroup()

    for s in config.protein.segments:
        current_seg = s[0].segid()
        # Don't need to trap failed selection here, because we
        # already know this segment exists
        seg = loos.selectAtoms(system, 'segname == "' + current_seg + '"')
        seg.copyMappedCoordinatesFrom(s)
        to_rot.append(seg)

    # if we asked for rotation, rotate all segments together
    # about a random axis
    if config.protrot:
        axis = loos.GCoord()
        axis.random()
        rot = random.uniform(0., 360.)
Ejemplo n.º 9
0
box = loos.GCoord(args.box_size, args.box_size, args.box_size)
half_box = 0.5 * args.box_size
half_z = half_box

if args.zbox:
    box.z(args.zbox)
    half_z = 0.5 * args.zbox

if args.z_exclude:
    args.z_exclude = abs(args.z_exclude)

if args.protein:
    protein = loos.createSystem(args.protein)
else:
    protein = loos.AtomicGroup()

protein.periodicBox(box)

library = LipidLibrary.LipidLibrary(args.library_location)

if not args.no_center:
    protein.centerAtOrigin()

accepts = 0
trials = 0
while accepts < args.num_ligands:
    trials += 1

    new_molecule = library.pick_structure()
    new_molecule.centerAtOrigin()
Ejemplo n.º 10
0
system_filename = sys.argv[1]
traj_filename = sys.argv[2]
out_prefix = sys.argv[3]
selections = sys.argv[4:]


system = loos.createSystem(system_filename)
traj = loos.pyloos.Trajectory(traj_filename, system)


helices = []
for s in selections:
    helices.append(loos.selectAtoms(system, s))

# Make a fake atomicgroup to hold the placeholder atoms
new_group = loos.AtomicGroup()
resnum = 1
for i in range(len(helices)):
    a = loos.Atom()
    b = loos.Atom()
    c = loos.Atom()
    a.resid(resnum)
    b.resid(resnum)
    c.resid(resnum)
    a.name("CENT")
    b.name("PLUS")
    c.name("MIN")

    new_group.append(a)
    new_group.append(b)
    new_group.append(c)
Ejemplo n.º 11
0
parser.add_argument('--selection',
                    nargs=2,
                    action='append',
                    help="segid selection-string")
parser.add_argument('--default',
                    nargs=1,
                    default="OTH",
                    help="default segid to apply to unmatched atoms")
parser.add_argument('--fullhelp',
                    help="Print detailed description of all options",
                    action=FullHelp)
args = parser.parse_args()

system = loos.createSystem(args.system_file)

all_selections = loos.AtomicGroup()
for seg, sel in args.selection:
    selection = loos.selectAtoms(system, sel)
    # SEGIDs are supposed to be 4 characters
    if len(seg) > 4:
        seg = seg[:4]
    for a in selection:
        a.segid(seg)

    all_selections.append(selection)

remaining_atoms = system.clone()
remaining_atoms.remove(all_selections)
print(len(remaining_atoms), " atoms unlabeled, applying default segid ",
      args.default)
for a in remaining_atoms: