Beispiel #1
0
def buildMassTable(model_name, psf_name, subset_selection):
    model = loos.createSystem(model_name)
    psf = loos.createSystem(psf_name)

    # First, fix masses...
    mass_table = {}
    for atom in psf:
        name = atom.name()
        mass = atom.mass()
        if name in mass_table:
            if mass != mass_table[name]:
                print('Error- multiple masses found for {} ({} vs {})'.format(
                    name, mass, mass_table[name]))
                sys.exit(-10)
        else:
            mass_table[name] = mass

    protein = loos.selectAtoms(model, subset_selection)
    masses = []
    for atom in protein:
        name = atom.name()
        if name not in mass_table:
            print('Error- could not find {} in mass table'.format(name))
            sys.exit(-11)
        atom.mass(mass_table[name])
        masses.append(mass_table[name])

    return masses
Beispiel #2
0
    def pick_structure(self):
        # pick a structure file at random, and build up the filename 
        filename = os.path.join(self.path, random.choice(self.structures))

        # read the file
        lipid = loos.createSystem(filename)

        # return the AtomicGroup
        return lipid
Beispiel #3
0
    def pick_structure(self):
        # pick a structure file at random, and build up the filename
        filename = os.path.join(self.path, random.choice(self.structures))

        # read the file
        lipid = loos.createSystem(filename)

        # return the AtomicGroup
        return lipid
Beispiel #4
0
    def __init__(self, filename, template_box, target_box, segname):
        self.filename = filename
        self.box = target_box
        self.template_box = template_box
        self.segname = segname

        self.template = loos.createSystem(filename)
        for i in range(len(self.template)):
            self.template[i].segid(segname)

        self.buildBox()
Beispiel #5
0
    def __init__(self, filename, template_box, target_box, segname):
        self.filename = filename
        self.box = target_box
        self.template_box = template_box
        self.segname = segname

        self.template = loos.createSystem(filename)
        for i in range(len(self.template)):
            self.template[i].segid(segname)

        self.buildBox()
Beispiel #6
0
    def __init__(self, line):
        (tag, model_file, psf_file, water_seg, scale_by_molecule) = line.split()
        self.model_file = os.path.abspath(model_file)
        self.psf_file = os.path.abspath(psf_file)
        self.water_segname = water_seg.upper()
        self.scale = int(scale_by_molecule)

        self.model = loos.createSystem(self.model_file)
        self.segments = self.model.splitByUniqueSegid()

        self.has_water = False
        for s in self.segments:
            if s[0].segid() == self.water_segname:
                self.has_water = True
                break
Beispiel #7
0
    def __init__(self, line):
        (tag, model_file, psf_file, water_seg, scale_by_molecule) = line.split()
        self.model_file = os.path.abspath(model_file)
        self.psf_file = os.path.abspath(psf_file)
        self.water_segname = water_seg.upper()
        self.scale = int(scale_by_molecule)

        self.model = loos.createSystem(self.model_file)
        self.segments = self.model.splitByUniqueSegid()

        self.has_water = False
        for s in self.segments:
            if s[0].segid() == self.water_segname:
                self.has_water = True
                break
Beispiel #8
0
def createWaterBox():

    os.mkdir('water')
    os.symlink('../water.inp', 'water.inp')
    os.symlink('../water_small.pdb', 'water_small.pdb')
    os.symlink('../water_small.psf', 'water_small.psf')

    water_log = open('water.log', 'w')
    water_err = open('water.err', 'w')
    ok = subprocess.call(['/home/tromo/local/bin/namd2', '+p2', 'water.inp'], stdout = water_log, stderr = water_err)
    if ok != 0:
        print 'Water box processing failed with error code ', ok
        sys.exit(-2)

    subprocess.call(['fixdcd', 'water/water.dcd'])

    # Get traj size...
    water_model = loos.createSystem('water_small.psf')
    water_traj = loos.pyloos.Trajectory('water/water.dcd', water_model)
    last_water = water_traj[len(water_traj)-1]
    savePDB('water_randomized.pdb', last_water)
        sys.stderr.write("Will attempt to change permissions\n")
        try:
            os.chmod(config.directory,
                     stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
        except OSError:
            sys.stderr.write(" Unable to change permissions on directory\n")
            os.exit(-1)

    # We need a model containing just the protein and lipid, so we'll
    # make a psfgen script, run it, use the psf to make the AtomicGroup,
    temporary_psfname = os.path.join(config.directory, config.psfname)
    psfgen_script = config.generate_psf(True, False, True, True,
                                        temporary_psfname)
    psfgen = PSFGen.PSFGen(psfgen_script, config.psfgen_binary)
    psfgen.run()
    system = loos.createSystem(temporary_psfname)

    # If the "protein" is actually a bunch of independent molecules (e.g. a bunch of peptides),
    # we'll want to scale them in x & y to match the expanded box.
    if config.protein is not None and config.protein.scale:
        protein_molecules = config.protein.model.splitByMolecule()
        for m in protein_molecules:
            centroid = m.centroid()
            scaled = box_scaling * centroid
            diff = scaled - centroid
            diff.z(0.0)  # we only want to translate in the xy plane
            m.translate(diff)

    molecules = system.splitByMolecule()

    segments = []
Beispiel #10
0
            for r2 in other.regions:
                if r.is_neighbor(r2):
                    return True
        return False

    def print_indices(self):
        for r in self.regions:
            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:
header = " ".join(sys.argv)
print "# ", header

system_file = sys.argv[1]
traj_file = sys.argv[2]
centering_selection_string = sys.argv[3]
target_selection_string = sys.argv[4]
zmin = float(sys.argv[5])
zmax = float(sys.argv[6])
znum_bins = int(sys.argv[7])
rmin = float(sys.argv[8])
rmax = float(sys.argv[9])
rnum_bins = int(sys.argv[10])

system = loos.createSystem(system_file)
traj = loos.pyloos.Trajectory(traj_file, system)

centering = loos.selectAtoms(system, centering_selection_string)
target = loos.selectAtoms(system, target_selection_string)


zbin_width = (zmax - zmin) / znum_bins

rbin_width = (rmax - rmin) / rnum_bins
rmin2 = rmin*rmin
rmax2 = rmax*rmax

hist = numpy.zeros( [rnum_bins, znum_bins])

for frame in traj:
Beispiel #12
0
    sys.stderr.write("Will attempt to change permissions\n")
    try:
        os.chmod(config.directory,
                 stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC)
    except OSError:
        sys.stderr.write(" Unable to change permissions on directory\n")
        os.exit(-1)


# We need a model containing just the protein and lipid, so we'll
# make a psfgen script, run it, use the psf to make the AtomicGroup,
temporary_psfname = os.path.join(config.directory, config.psfname)
psfgen_script = config.generate_psf(True, False, True, True, temporary_psfname)
psfgen = PSFGen.PSFGen(psfgen_script, config.psfgen_binary)
psfgen.run()
system = loos.createSystem(temporary_psfname)

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
Beispiel #13
0
  This package is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import loos
import sys

filename = sys.argv[1]

system = loos.createSystem(filename)

system.centerAtOrigin()
# loop over atoms and reverse the sign of the x coordinate
for i in range(system.size()):
    # 2 different ways to assign to coordinates
    # SWIG won't let us do: coords.x() = new_x
    # so we can do this:
    #system[i].coords().x(-system[i].coords().x())
    # or this:
    system[i].coords()[0] *= -1.0

system.centerAtOrigin()

# convert to PDB and print out
pdb = loos.PDB_fromAtomicGroup(system)
Beispiel #14
0
  This package is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import loos
import sys

filename = sys.argv[1]

system = loos.createSystem(filename)

system.centerAtOrigin()
# loop over atoms and reverse the sign of the x coordinate
for i in range(system.size()):
    # 2 different ways to assign to coordinates
    # SWIG won't let us do: coords.x() = new_x
    # so we can do this:
    #system[i].coords().x(-system[i].coords().x())
    # or this:
    system[i].coords()[0] *= -1.0

system.centerAtOrigin()

# convert to PDB and print out
pdb = loos.PDB_fromAtomicGroup(system)
Beispiel #15
0
def alignWithBackbone(target, fiducial):
    tbb = loos.selectAtoms(target, 'backbone')
    fbb = loos.selectAtoms(fiducial, 'backbone')

    M = tbb.superposition(fbb)
    X = loos.XForm()
    X.load(M)
    target.applyTransform(X)


if len(sys.argv) != 6:
    print('Usage- extract.py PSF model traj fiducial frameno')
    sys.exit(-1)

hdr = ' '.join(sys.argv)

source_model = loos.createSystem(sys.argv[1])
model = loos.createSystem(sys.argv[2])
traj = loos.pyloos.Trajectory(sys.argv[3], model)
fiducial = loos.createSystem(sys.argv[4])
frameno = int(sys.argv[5])

frame = traj[frameno]
alignWithBackbone(frame, fiducial)
matchMetadata(frame, source_model)
pdb = loos.PDB.fromAtomicGroup(frame)
pdb.remarks().add(hdr)
print(str(pdb))

sys.exit(0)
Beispiel #16
0
)
args = parser.parse_args()
cmd_string = sys.argv[0]
for i in range(1, len(sys.argv)):
    arg = sys.argv[i].replace('\n', '\\n')
    cmd_string += " '" + arg + "'"
print('# ', cmd_string)
if args.tsne:
    print("# Warning: tSNE is experimental, and the resulting distances")
    print("#          aren't meaningful.")

if args.perplexity and not args.tsne:
    print("# Warning: perplexity option is ignored without --tsne")

# Create the model & read in the trajectories
model = loos.createSystem(args.model)
allTrajs = loos.pyloos.VirtualTrajectory(skip=args.skip, stride=args.stride)
if args.align:
    allTrajs = loos.pyloos.AlignedVirtualTrajectory(alignwith=args.align,
                                                    skip=args.skip,
                                                    stride=args.stride)
for trajname in args.traj:
    allTrajs.append(
        loos.pyloos.Trajectory(trajname,
                               model,
                               subset=args.selection,
                               skip=args.allskip,
                               stride=args.allstride))

# Set up lists to hold the coordinates...
Beispiel #17
0
        sys.exit(0)

    system_filename = sys.argv[1]
    traj_filename = sys.argv[2]
    skip = int(sys.argv[3])
    zmin = float(sys.argv[4])
    zmax = float(sys.argv[5])
    padding = float(sys.argv[6])
    selection_strings = sys.argv[
        7:]  # first selection gives the all atoms to use
    # in area calculations, all others tell you
    # how to group the areas

    print("# ", " ".join(sys.argv))

    system = loos.createSystem(system_filename)
    traj = loos.createTrajectory(traj_filename, system)

    traj.readFrame(skip)
    traj.updateGroupCoords(system)

    slicer = ZSliceSelector(zmin, zmax)

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

    frame = skip
    string = ""
    for i in range(len(selections)):
Beispiel #18
0
                     ((side <= 0) and (prev_side <= 0)))
            if not match:
                return False
            prev_side = side

        # test the closing line segment
        side = test_side(p, self.coords(self.vertices[-1]),
                         self.coords(self.vertices[0]))
        match = (((side >= 0) and (prev_side >= 0)) or
                 ((side <= 0) and (prev_side <= 0)))
        return match


if __name__ == '__main__':

    ag = loos.createSystem("rhod_only.pdb")
    slicer = ZSliceSelector(-3.0, 3.0)

    ag = loos.selectAtoms(ag, 'name == "CA"')
    ag_slice = slicer(ag)

    hull = ConvexHull(ag_slice)
    hull.generate_hull()
    hull.generate_vertices()

    i = 0
    for v in hull.vertices:
        c = hull.coords(v)
        print(i, v, c.x(), c.y(), c.z())
        i += 1
Beispiel #19
0
            if not match: return False
            prev_side = side

        # test the closing line segment
        side = test_side(p, self.coords(self.vertices[-1]),
                            self.coords(self.vertices[0]))
        match = ( ((side >= 0) and (prev_side >=0) ) or
                  ((side <= 0) and (prev_side <=0) ) )
        return match



if __name__ == '__main__':

    from numpy import random
    ag = loos.createSystem("rhod_only.pdb")

    slicer = ZSliceSelector(-3.0,3.0)

    ag = loos.selectAtoms(ag, 'name == "CA"')
    ag_slice = slicer(ag)

    hull = ConvexHull(ag_slice)
    hull.generate_hull()
    #print hull.hull.simplices
    #print hull.hull.neighbors
    hull.generate_vertices()

    #print hull.vertices
    #print hull.num_atoms()
    i = 0
Beispiel #20
0
    try:
        os.chmod(config.directory, 
                 stat.S_IREAD|stat.S_IWRITE|stat.S_IEXEC)
    except OSError:
        sys.stderr.write(" Unable to change permissions on directory\n")
        os.exit(-1)



# We need a model containing just the protein and lipid, so we'll
# make a psfgen script, run it, use the psf to make the AtomicGroup,
temporary_psfname = os.path.join(config.directory, config.psfname) 
psfgen_script = config.generate_psf(True, False, True, True, temporary_psfname)
psfgen = PSFGen.PSFGen(psfgen_script, config.psfgen_binary)
psfgen.run()
system = loos.createSystem(temporary_psfname)

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
Beispiel #21
0
                    type=float)
args = parser.parse_args()

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
#!/usr/bin/env python

import sys
import loos
import numpy as np

left = loos.createSystem(sys.argv[2])
right = loos.createSystem(sys.argv[3])

left_bb = loos.selectAtoms(left, 'backbone && resid < 129')
right_bb = loos.selectAtoms(right, 'backbone && resid < 129')

nl = len(left_bb)
nr = len(right_bb)

if nl != nr:
    print('***ERROR: systems have wrong size')
    print("Left has size {}, but right has size {}".format(nl, nr))
    print("Left:")
    print(str(loos.PDB.fromAtomicGroup(left_bb)))
    print("Right:")
    print(str(loos.PDB.fromAtomicGroup(right_bb)))
    
    sys.exit(-1)

D = np.zeros( (nl*3, 1) )

k = 0
for i in range(nl):
    d = left_bb[i].coords() - right_bb[i].coords()
    D[k, 0] = d[0]
Beispiel #23
0
                    help="Step size for striding through trajectories",
                    type=int,
                    default=1)
parser.add_argument('--no_h',
                    help="Exclude hydrogens from calculation",
                    action='store_true')
parser.add_argument('--pca',
                    help="Perform PCA on the per-residue profiles",
                    action='store_true')
parser.add_argument('--fullhelp',
                    help="Print detailed description of all options",
                    action=FullHelp)

args = parser.parse_args()

system = loos.createSystem(args.system_file)

protein = loos.selectAtoms(system, args.protein_selection)
probe = loos.selectAtoms(system, args.probe_selection)
if args.no_h:
    protein = loos.selectAtoms(protein, '!hydrogen')
    probe = loos.selectAtoms(probe, '!hydrogen')

residues = protein.splitByResidue()
probes = probe.splitByMolecule()

frame_index = 0
traj = loos.pyloos.Trajectory(args.traj[0],
                              system,
                              skip=args.skip,
                              stride=args.stride)
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""



from math import *
import sys
import loos
import loos.pyloos

## Command line arguments
model_name = sys.argv[1]
traj_name = sys.argv[2]
selection = sys.argv[3]

# Define the system first
mol = loos.createSystem(model_name)
traj = loos.pyloos.Trajectory(traj_name, mol, subset=selection)

for frame in traj:

    # Compute the principal axes for the subset of atoms given above
    axes = frame.principalAxes()

    # Print out time, and the dot-product between
    # The Z-axis (i.e. membrane normal) and the first principal axes
    # of the subset of atoms
    print traj.index(), "\t", axes[0].z()


Beispiel #25
0
parser.add_argument('-x', '--traj', help='Filename of trajectory or trajectories', nargs='+')
parser.add_argument('-k', '--skip', help='Skip this amount from the start of the trajectory', type=int, default=0)
parser.add_argument('-i', '--stride', help='Step through the trajectory by this many frames', type=int, default=1)
parser.add_argument('-s', '--selection', help='Use this selection for computing the native hbonds', default='all')
parser.add_argument('-n', '--nativeHBs', help='a filename to write PDB with just the native HBs used', type=str, default='')
parser.add_argument('-b', '--bondlength', help='maximum length for HB.', type=float, default = 3.0)
parser.add_argument('-o', '--outfile', help='file to write timeseries to.', type=str, default='')
parser.add_argument('-a', '--angle', help='maximum valid D-H-A angle.', type=float, default = 30.0)
args = parser.parse_args()


# define the model, subset to selection at this point
if args.coords:
    model = loos.selectAtoms(loos.loadStructureWithCoords(args.model, args.coords), args.selection)
else:
    model = loos.selectAtoms(loos.createSystem(args.model), args.selection) 

# add connectivity, anything within 1.65 A (loos default) is assumed covalently bound
if model.hasCoords():
    if not model.hasBonds():
        model.findBonds()
else: # if model doesn't have any coordinates, this analysis is nonsensical; exit with error.
    print('Error: You must supply a model structure with coordinates.')
    exit(-1)





# make hb detector object
model_hbs = loos.HBondDetector(args.bondlength, args.angle, model)
Beispiel #26
0
parser.add_argument("helix_ranges", 
                    nargs="+",
                    help="list of colon-delimited residue number ranges specifying where the helices are")
parser.add_argument("-d", "--directory", 
                    help="Directory to create output files", 
                    default=".")
parser.add_argument("-t", "--threshold",
                    default=7,
                    type=int,
                    help="Number of atoms inside for the chain to be considered inside")

args = parser.parse_args()

    

system = loos.createSystem(args.system_file)
traj = loos.createTrajectory(args.traj_file, system)

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)
                        % config.directory)
        sys.stderr.write("Will attempt to change permissions\n")
        try:
            os.chmod(config.directory, 
                     stat.S_IREAD|stat.S_IWRITE|stat.S_IEXEC)
        except OSError:
            sys.stderr.write(" Unable to change permissions on directory\n")
            os.exit(-1)

    # We need a model containing just the protein and lipid, so we'll
    # make a psfgen script, run it, use the psf to make the AtomicGroup,
    temporary_psfname = os.path.join(config.directory, config.psfname) 
    psfgen_script = config.generate_psf(True, False, True, True, temporary_psfname)
    psfgen = PSFGen.PSFGen(psfgen_script, config.psfgen_binary)
    psfgen.run()
    system = loos.createSystem(temporary_psfname)

    # If the "protein" is actually a bunch of independent molecules (e.g. a bunch of peptides),
    # we'll want to scale them in x & y to match the expanded box.
    if config.protein is not None and config.protein.scale:
        protein_molecules = config.protein.model.splitByMolecule()
        for m in protein_molecules:
            centroid = m.centroid()
            scaled = box_scaling*centroid
            diff = scaled - centroid
            diff.z(0.0)   # we only want to translate in the xy plane
            m.translate(diff) 

    molecules = system.splitByMolecule()

    segments = []
Beispiel #28
0
    "A": ["N1", "N3", "N7", "O2'", "O3'", "O4'", "O5'", "OP1", "OP2"],
    "C": ["N3", "O2", "O2'", "O3'", "O4'", "O5'", "OP1", "OP2"],
    "G": ["N3", "N7", "O6", "O2'", "O3'", "O4'", "O5'", "OP1", "OP2"],
    "U": ["O2", "O4", "O2'", "O3'", "O4'", "O5'", "OP1", "OP2"]
}
N_acceptor = {s: len(rna_acceptors[s]) for s in rna_acceptors}

# Compare to square of distance and angle cutoffs because sqrt() is expensive
# Compare to sin of angle cutoff because planar groups can have normal
# vectors that are close to parallel or close to anti-parallel
dist_cutoff_sq = numpy.square(args.distance_cutoff)
stack_cutoff_sq = numpy.square(args.stack_cutoff)
angle_cutoff_sq = numpy.square(numpy.sin(args.angle_cutoff / rad2deg))

# Create system model
system = loos.createSystem(args.input_pdb)

# Get arginine residues
arg_atoms = loos.selectAtoms(system, args.protein)
all_arg_residues = arg_atoms.splitByResidue()
arg_residues = [res for res in all_arg_residues if is_valid_arg_residue(res)]
N_arg = len(arg_residues)

# If there are no arginines, then exit
if N_arg == 0:
    quit()

# Get RNA residues
rna_atoms = loos.selectAtoms(system, args.rna)
all_rna_residues = rna_atoms.splitByResidue()
rna_residues = [res for res in all_rna_residues if is_valid_rna_residue(res)]
Beispiel #29
0
"""
simple_model_calc.py : simple skeleton of a program that reads in a
    structure, makes a selection, then loops over the atoms.

Alan Grossfield
University of Rochester Medical Center
"""

import loos
import sys

header = " ".join(sys.argv)
print("#", header)

# parse the command line arguments -- in a more complex example,
# you'd use the argparse module
model_filename = sys.argv[1]
selection_string = sys.argv[2]

# Create the system
model = loos.createSystem(model_filename)

# Select a subset of the system
subset = loos.selectAtoms(model, selection_string)


# Iterate over atoms and calculate something#
for atom in subset:
    # do something
    continue
Beispiel #30
0
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

from math import *
import sys
import loos
import loos.pyloos

## Command line arguments
model_name = sys.argv[1]
traj_name = sys.argv[2]
selection = sys.argv[3]

# Define the system first
mol = loos.createSystem(model_name)
traj = loos.pyloos.Trajectory(traj_name, mol, subset=selection)

for frame in traj:

    # Compute the principal axes for the subset of atoms given above
    axes = frame.principalAxes()

    # Print out time, and the dot-product between
    # The Z-axis (i.e. membrane normal) and the first principal axes
    # of the subset of atoms
    print(traj.index(), "\t", axes[0].z())
Beispiel #31
0
import loos.pyloos
import argparse
import sys


parser = argparse.ArgumentParser()
parser.add_argument('model', help='Structure to use')
parser.add_argument('traj', help='Trajectory')
parser.add_argument('align', help='Selection to use for aligning')
parser.add_argument('--skip', help='Skip this amount from the start of the trajectory', type=int, default=0)
parser.add_argument('--stride', help='Step through the trajectory by this many frames', type=int, default=1)
parser.add_argument('--rmsd', help='Use this selection for computing the RMSD', default='all')
args = parser.parse_args()

# Create the model & read in the trajectory
model = loos.createSystem(args.model)
traj = loos.pyloos.Trajectory(args.traj, model, skip = args.skip, stride = args.stride)

patraj = loos.pyloos.AlignedVirtualTrajectory(traj, alignwith = args.align)
patraj.setSubset(args.rmsd)
average = loos.pyloos.averageStructure(traj)


avg_rmsd = 0
for structure in patraj:
   rmsd = average.rmsd(structure)
   avg_rmsd = avg_rmsd + rmsd
   print "%d\t%f" % (patraj.index(), rmsd)

print "# Average rmsd = %f" % (avg_rmsd/len(patraj))
Beispiel #32
0
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""

import loos
import sys


if len(sys.argv) == 1 or sys.argv[1] == '-h':
    print 'Usage- renum-by-mol.py model [selection]'
    sys.exit(0)
    

model = loos.createSystem(sys.argv[1])

if len(sys.argv) > 2:
    model = loos.selectAtoms(model, sys.argv[2])
    model.pruneBonds()

if model.hasBonds():
    molecules = model.splitByMolecule()
else:
    molecules = model.splitByUniqSegid()

for molecule in molecules:
    residues = molecule.splitByResidue()
    resid = 1
    for residue in residues:
        for atom in residue:
Beispiel #33
0
        for r in self.regions:
            for r2 in other.regions:
                if r.is_neighbor(r2):
                    return True
        return False

    def print_indices(self):
        for r in self.regions:
            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()
Beispiel #34
0
#!/bin/env python

import loos
import sys

model = loos.createSystem(sys.argv[1])
for atom in model:
    atom.bfactor(0.0)
subset = loos.selectAtoms(model, sys.argv[2])
for atom in subset:
    atom.bfactor(1.0)

pdb = loos.PDB.fromAtomicGroup(model)
print str(pdb)