예제 #1
0
def _make_solutepdb(atoms, masses, ligand):
    """
    Make a solute PDB file
    """
    mass2elem = {
        1.0080000: "H",
        12.0100000: "C",
        14.0100000: "N",
        16.0000000: "O",
        32.0600000: "S",
        35.4500000: "Cl",
        19.0000000: "F",
        79.9000000: "Br"
    }

    pdbout = pdb.PDBFile()
    res = pdb.Residue()
    res.resname = ligand
    res.serial = 1
    for i, (a, m) in enumerate(zip(atoms, masses), 1):
        atom = pdb.Atom()
        atom.serial = i
        atom.hetatm = False
        atom.name = "%s%d" % (mass2elem[m], i
                              )  # Atom names from masses and serial number
        atom.resname = ligand
        atom.residue = 1
        atom.set_xyz(a.xyz)
        res.atoms.append(atom)
        pdbout.atoms.append(atom)
    pdbout.residues.append(res)
    pdbout.write(ligand + ".pdb")
예제 #2
0
def write_singlepdb(filename, resname, atomname):
    struct = pdb.PDBFile()
    res = pdb.Residue()
    atm = pdb.Atom()
    atm.serial = 1
    atm.name = atomname
    atm.resname = resname
    atm.residue = 1
    res.append(atm)
    struct.residues.append(res)
    struct.write(filename)
예제 #3
0
    def __init__(self, d, converter):
        ran, nam = d.split(":")

        # Parse the range
        if ran.find("-") > -1:
            first, last = ran.split("-")
        else:
            first = ran
            last = ran
        self.first = int(first)
        self.last = int(last)

        # Parse the name
        internal_res = {
            res.name.strip().lower(): res.cg_names
            for res in converter.residues
        }
        internal_bonds = {
            res.name.strip().lower() + "_bonds": res.bonds
            for res in converter.residues
        }
        if nam.strip().lower() in internal_res:
            self.resname = nam
            self.atom_names = internal_res[nam.strip().lower()]
            self.bonds = [
                (b[1], b[2])
                for b in internal_bonds[nam.strip().lower() + "_bonds"]
            ]
        elif os.path.isfile(nam):
            pdbfile = pdb.PDBFile(filename=nam)
            if len(pdbfile.residues) > 1:
                self.resname = "FILE!"
                self.atom_names = []
                self.bonds = []
                self.pdbfile = pdbfile
            else:
                self.resname = pdbfile.residues[0].resname
                self.atom_names = [
                    atom.name for atom in pdbfile.residues[0].atoms
                ]
                self.bonds = []
        else:
            raise Exception(
                "Could not find %s in the converter dictionary and it is not a file"
                % nam)
예제 #4
0
def load_xray(mol, loadsigma=False, loadaa=False) :
  """
  Load an XrayDensity object from a standard location
  """
  template = load_template(mol)
  filename = os.path.join(PROT_INFO_PATH,"xray_%s.gro"%mol)
  if os.path.isfile(filename) :
    sigmafile = None
    # Optionally give the sigma file
    if loadsigma :
      sigmafile = os.path.join(PROT_INFO_PATH,"sigmas_%s"%mol)
      if not os.path.isfile(sigmafile) : sigmafile = None

    if loadaa :
      filename2 = os.path.join(PROT_INFO_PATH,"xray_%s-aa.gro"%mol)
      return XrayDensity(filename,template,sigmafile), pdb.PDBFile(filename2)
    else:
      return XrayDensity(filename,template,sigmafile)
  else :
    raise Exception("File is missing (%s)"%filename)
예제 #5
0
    def __init__(self, filename, template, sigmafile=None):

        # Read in a structure from file
        cholxyz = []
        protxyz = []
        protflag = []
        self.pdbfile = pdb.PDBFile(filename)
        flag = {"BB": 1, "SC": -1}
        for atom in self.pdbfile.atoms:
            if atom.resname[0:3] == "CHO":
                cholxyz.append(atom.xyz)
            elif atom.name.strip()[:2] in ["BB", "SC"]:
                protflag.append(flag[atom.name.strip()[:2]])
                protxyz.append(atom.xyz)
        self.box = self.pdbfile.box
        self.cholxyz = np.array(cholxyz)
        self.protxyz = np.array(protxyz)
        self.protflag = np.array(protflag, dtype=int)
        self.helices = template.helices
        self.template = template

        self.cholleaf = ""
        if self.cholxyz.shape[0] > 0:
            if self.cholxyz.mean(axis=0)[2] < self.protxyz.mean(axis=0)[2]:
                self.cholleaf = "low"
            else:
                self.cholleaf = "upp"

        # Optionally, read a file of Lennard-Jones sigma parameters
        if sigmafile is None:
            self.sigmas = np.ones(self.protxyz.shape[0]) * 2.3
        else:
            self.sigmas = []
            with open(sigmafile, 'r') as f:
                line = f.readline()
                while line:
                    self.sigmas.append(float(line.strip()))
                    line = f.readline()
            self.sigmas = np.array(self.sigmas)
예제 #6
0
    def make(self, bd=3.0):

        struct = pdb.PDBFile()
        res = pdb.Residue()

        for i, bead in enumerate(self.beads):
            atom = pdb.Atom()
            atom.idx = i
            atom.serial = i + 1
            atom.name = bead.name
            atom.resname = self.name
            atom.residue = 1
            atom.set_xyz(bead.xyz * bd)
            res.atoms.append(atom)
            struct.atoms.append(atom)
        struct.residues.append(res)

        allcoord = np.asarray([a.xyz for a in struct.atoms])
        offset = allcoord.mean(axis=0) + 50.0
        for a in struct.atoms:
            a.set_xyz(a.xyz + offset)
        struct.box = np.asarray([100, 100, 100])

        return struct
예제 #7
0
                        type=float,
                        help="the insertion radius from the liposome center")
    parser.add_argument('-p',
                        '--patom',
                        help="the name of the phosphate atom",
                        default="PO4")
    parser.add_argument('-n',
                        '--nvec',
                        type=int,
                        help="the index of a previously employed vector")
    args = parser.parse_args()

    rads_rev = args.radii[::-1]
    rads_pack = zip(args.radii, rads_rev)

    boxfile = pdb.PDBFile(filename=args.box)

    solutefile1 = pdb.PDBFile(filename=args.file)
    solutefile2 = pdb.PDBFile(filename=args.file)
    solxyz = np.array(solutefile1.xyz, copy=True)
    solcent = solxyz.mean(axis=0)

    # Add the atoms of the two solutes to the membrane structure
    # the coordinates of the atoms will be subsequently changed
    for i, atom in enumerate(solutefile1.atoms, 1):
        atom.serial = len(boxfile.atoms) + i
        atom.residue = len(boxfile.residues) + 1
    boxfile.extend(solutefile1)

    for i, atom in enumerate(solutefile2.atoms, 1):
        atom.serial = len(boxfile.atoms) + i
예제 #8
0
                        default="cg")
    #parser.add_argument('-p','--pairfunc',help="the pair function for the AA",default="lj/charmm/coul/long")
    args = parser.parse_args()

    # Load a converter
    converter = lammps.Aa2Cg()
    if args.converter is None:
        converter.read(lammps.get_filename("aa2cg.dat"))  # The default
    else:
        converter.read(args.converter)

    # Load the force field file
    include = lammps.Includefile(args.include)

    # Create a Datafile and PDBFile
    pdbfile = pdb.PDBFile(args.file)  # Input PDB
    takeres = [True for res in pdbfile.residues]
    data = lammps.Datafile()

    # Convert residues
    all_coords = []
    nwat = 0
    moli = 0
    for i, (res, takethis) in enumerate(zip(pdbfile.residues, takeres)):
        if not takethis: continue
        moli += 1
        res2 = res.resname.strip().lower()
        found = False
        for residue in converter.residues:
            if residue.name == res2:
                coord = residue.generate_cg(res, moli + 1, data, mapping=False)
예제 #9
0
    elif atom.mass == 32.06 :
        return 1.85
    else :
        return 2.0

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description="Program make a PQR file")
    parser.add_argument('-f','--file',help="the input gro-file")
    parser.add_argument('-p','--topol',help="the topology file")
    parser.add_argument('-o','--out',help="the output pqr-file",default="conv.pqr")
    parser.add_argument('-m','--mol',nargs="+",help="the molecule to write out",default=["protein"])
    args = parser.parse_args()

    ref = gmx.TopFile(args.topol)
    pdbfile = pdb.PDBFile(args.file)

    mols = []
    for topol_mol in ref.moleculetypes :
        for argmol in args.mol :
            if topol_mol.name.lower() == argmol.lower() :
                mols.append(topol_mol)
                break

    natom = sum([len(mol.atoms) for mol in mols])
    pdbfile.residues = [res for res in pdbfile.residues if res.atoms[0].serial <= natom]
    pdbfile.atoms = pdbfile.atoms[:natom]

    start = 0
    for mol in mols  :
        patoms = pdbfile.atoms[start:start+len(mol.atoms)]
예제 #10
0
        if atom.name.strip() == atomnam and atom.resname.strip() == resname :
            return i
    return None

if __name__ == '__main__':

    argparser = argparse.ArgumentParser(description="Script to LAMMPS restraints for APR")
    argparser.add_argument('-i','--input',help="the apr.in file",default="apr.in")
    argparser.add_argument('-s','--structure',help="a structure file",default="align_z.pdb")
    argparser.add_argument('-p','--pull',type=int,help="the number of pull windows")
    argparser.add_argument('-d','--displ',type=float,nargs="+",help="the displacement vector")
    argparser.add_argument('-f','--force',type=float,nargs=2,help="the bond and angle force respectively",default=[5, 100])
    argparser.add_argument('-l','--label',help="a label for the output files",default="restraints")
    args = argparser.parse_args()

    struct = pdb.PDBFile(args.structure)

    h1 = ""
    h2 = ""
    h3 = ""
    g1 = ""
    g2 = ""
    with open(args.input, "r") as f :
        for line in f.readlines() :
            if line.strip().startswith("H1") :
                h1 = line.strip().split("=")[1].strip()
            elif line.strip().startswith("H2") :
                h2 = line.strip().split("=")[1].strip()
            elif line.strip().startswith("H3") :
                h3 = line.strip().split("=")[1].strip()
            elif line.strip().startswith("G1") :
예제 #11
0
    parser.add_argument('-o',
                        '--out',
                        help="the output file",
                        default="splitted.gro")
    parser.add_argument('-p',
                        '--patom',
                        help="the name of the phosphate atom",
                        default="P")
    parser.add_argument('-d',
                        '--displacement',
                        type=float,
                        help="the displacement length",
                        default="10.0")
    args = parser.parse_args()

    boxfile = pdb.PDBFile(filename=args.box)

    # Calculate the center of membrane
    memz = []
    for atom in boxfile.atoms:
        if atom.name.strip() == args.patom:
            memz.append(atom.z)
    memcent = np.asarray(memz).mean()
    print "Membrane center = %.3f" % memcent

    for residue in boxfile.residues:
        com = residue.collect("centerofmass")
        if com[2] > memcent:
            for atom in residue.atoms:
                new_xyz = atom.xyz + [0, 0, args.displacement]
                atom.set_xyz(new_xyz)
예제 #12
0
    parser.add_argument('--nwater',
                        type=int,
                        help="the number of water per lipids",
                        default=40)
    args = parser.parse_args()

    lipidbook = build_lipid.LipidCollection()
    if args.xml is None:
        thispath = os.path.dirname(os.path.abspath(__file__))
        args.xml = os.path.join(thispath, "lipid_templates.xml")
    lipidbook.load(args.xml)

    structs = []
    lipids = []
    for l in args.lipids:
        structs.append(pdb.PDBFile())
        structs[-1].read(l)
        lipids.append(lipidbook.lipids[structs[-1].residues[0].resname])

        newfilename = os.path.splitext(l)[0] + ".pdb"
        if not os.path.exists(newfilename):
            structs[-1].write(newfilename)

    zlen = np.max([l.head[0].xyz - l.tail[0].xyz for l in lipids], axis=0)[2]

    # Parse the number of lipids of each kind in each leaflet
    if len(args.nlipid) == 1:
        args.nlipid.append(args.nlipid[0])
    nlipid = [map(int, nspec.split(":")) for nspec in args.nlipid]
    # Calculate the side of the box in x and y, assuming 60 A2 area per lipid
    xylen = np.sqrt(np.max([args.area * np.sum(n) for n in nlipid]))
예제 #13
0
    parser.add_argument('-w',
                        '--watom',
                        help="the name of the water atom",
                        default="OH2")
    parser.add_argument('-n',
                        '--n',
                        type=int,
                        nargs=2,
                        help="the number of water to remove in each monolayer")
    parser.add_argument('--nobox',
                        action="store_true",
                        help="do not modify the box",
                        default=False)
    args = parser.parse_args()

    struct = pdb.PDBFile(filename=args.file)

    # Calculate the center of membrane
    memz = []
    for atom in struct.atoms:
        if atom.name.strip() == args.patom:
            memz.append(atom.z)
    memcent = np.asarray(memz).mean()
    print "Membrane center = %.3f" % memcent

    water_z = []
    water_resid = []
    for i, residue in enumerate(struct.residues):
        if residue.atoms[0].name.strip() == args.watom:
            water_z.append(residue.atoms[0].z)
            water_resid.append(i)
예제 #14
0
    parser.add_argument('-s',
                        '--shift',
                        type=float,
                        nargs=3,
                        help="the amount to shift in each direction")
    parser.add_argument(
        '--fromedge',
        action="store_true",
        help="if the shift should be from the edge of the mobile structure",
        default=False)
    parser.add_argument('-o',
                        '--out',
                        help="the output filename, default=[overwrite]")
    args = parser.parse_args()

    pdbref = pdb.PDBFile(args.reference)
    pdbmob = pdb.PDBFile(args.mobile)

    # Calculate the delta that will make the centroid of the two structures to overlap
    avref = np.average(pdbref.xyz, axis=0)
    avmob = np.average(pdbmob.xyz, axis=0)
    delta = avref - avmob

    # By command line arguments we can shift the overlay
    if args.shift is None:
        pdbmob.update_xyz(pdbmob.xyz + delta)
    else:
        # If we should place the mobile next to the edge of the reference structure
        if args.fromedge:
            delta2 = pdbref.xyz[:, 0].max() - avref
            args.shift = [
예제 #15
0
    parser = argparse.ArgumentParser(
        description="Program to convert a POPI membrane to a membrane with IPC"
    )
    parser.add_argument('-f', '--file', help="the input gro-file")
    parser.add_argument('-t', '--template', help="a template IPC pdb-file")
    parser.add_argument('-z', '--zmat', help="the IPC z-matrix")
    parser.add_argument('-i', '--itp', help="the IPC itp-file")
    parser.add_argument('-n',
                        '--nreplace',
                        type=int,
                        help="how many POPI molecules to replace")
    args = parser.parse_args()

    # Read in a gro-file
    popimem = pdb.PDBFile()
    popimem.read(args.file, gro=True)
    # Read in a template IPC-file
    ipc_pdb = pdb.PDBFile(filename=args.template)
    # Read in the z-matrix of the IPC molecule
    ipc_zmat = [
        line.strip().split() for line in open(args.zmat, "r").readlines()
    ]
    # Read in the atom order of the IPC itp-file
    ipctop = gmx.TopFile(args.itp)
    ipc_atomlist = [atom.name for atom in ipctop.moleculetypes[0].atoms]
    nreplace = args.nreplace

    # Check where the middle of the membrane is
    midz = popimem.xyz[:, 2].mean()
예제 #16
0
        default=[])
    args = parser.parse_args()

    if len(args.files) == 0:
        print "Nothing to do. Exiting."
        quit()

    prot_con = None
    if args.pbonds == "":
        print "No connectivity information will be added for the protein"
    else:
        prot_con = make_con(args.pbonds)

    het_con = None
    if len(args.hbonds) == 0:
        print "No connectivity information will be added for the hetero residues"
    else:
        het_con = {}
        for filename in args.hbonds:
            filebase, fileext = os.path.splitext(filename)
            het_con[filebase.upper()] = make_con(filename)

    print het_con

    for filename in args.files:
        filebase, fileext = os.path.splitext(filename)
        pdbfile = pdb.PDBFile()
        pdbfile.read(filename, gro=True)
        print len(pdbfile.chains)
        pdbfile.write(filebase + ".pdb", ter=True, add_extra=add_con)
예제 #17
0
    parser.add_argument('-reference',
                        '--reference',
                        help="the reference PDB file")
    parser.add_argument('-mobile', '--mobile', help="the mobile PDB file")
    parser.add_argument('-ranges',
                        '--ranges',
                        nargs="+",
                        help="list of residues ranges to match")
    parser.add_argument('-offset',
                        '--offset',
                        default=0,
                        type=int,
                        help="reference offset")
    args = parser.parse_args()

    pdb1 = pdb.PDBFile(args.reference, renumber=False)
    pdb2 = pdb.PDBFile(args.mobile, renumber=False)

    naa1 = sum([1 for r in pdb1.residues if r.resname in pdb.std_aa_names])
    naa2 = sum([1 for r in pdb2.residues if r.resname in pdb.std_aa_names])
    if naa1 != naa2:
        raise Exception(
            "The two PDB files does not have the same number of residues (%d, %d)."
            % (naa1, naa2))

    if args.offset != 0:
        for res in pdb1.residues:
            res.serial += args.offset

    print "[Residue match]"
    print "Command= " + " ".join(sys.argv)
예제 #18
0
if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="Program to place a protein next to a membrane")
    parser.add_argument('-prot', '--protein', help="the protein PDB file")
    parser.add_argument('-mem', '--membrane', help="the membrane PDB file")
    parser.add_argument('--lipidref',
                        help="the name of the lipid reference atom",
                        default="P")
    parser.add_argument('-o',
                        '--out',
                        help="the output filename",
                        default="placed.gro")
    args = parser.parse_args()

    prot = pdb.PDBFile(args.protein)
    mem = pdb.PDBFile(args.membrane)

    # Calculate the delta that will make the centroid of the two structures to overlap
    avmem = np.average(
        [atom.xyz for atom in mem.atoms if atom.name.strip() == args.lipidref],
        axis=0)
    avprot = np.average(prot.xyz, axis=0)
    delta = avmem - avprot

    # Calculate how much from the edge of the membrane to shift the protein
    minprot = np.min(prot.xyz, axis=0)
    minatmx = np.argmin(prot.xyz, axis=0)[0]
    prot_lenx = (avprot - minprot)[0]
    mem_lenx = mem.xyz[:, 0].max() - avmem[0]
    shift = np.array([prot_lenx + mem_lenx, 0, 0])
예제 #19
0
from sgenlib import pdb
from sgenlib import groups

if __name__ == "__main__":

    # Setup a parser of the command-line arguments
    parser = argparse.ArgumentParser(description="Program make S2 group files")
    parser.add_argument('-f', '--file', help="the input gro-file")
    parser.add_argument('-g', '--groups', help="the group definitions")
    parser.add_argument('-o', '--out', help="the output prefix", default="")
    args = parser.parse_args()

    residue_groups = groups.read_groups(args.groups)

    # Loop over all residues in the input pdb-file
    for residue in pdb.PDBFile(filename=args.file).residues:
        if residue.resname not in residue_groups: continue
        for atom in residue.atoms:
            for group in residue_groups[residue.resname].groups:
                if not group.has_atom(atom.name.strip()): continue
                group.add_serial(atom.name.strip(), atom.serial)

    # Check for consistency
    for residue in residue_groups:
        residue_groups[residue].check_consistency()
        print "[%s]" % residue
        for g in residue_groups[residue].groups:
            if g.expressed:
                print "\t%s = %d" % (g.name, len(g.serials[g.atoms[0]]))

    # Write output file
예제 #20
0
                        help="the dihedral function for the solute")
    parser.add_argument('--dihfunc_box',
                        help="the dihedral function for the box")
    parser.add_argument('--pairmix',
                        nargs="+",
                        help="pair functions to use when mixing pairs")
    parser.add_argument('--noff',
                        action="store_true",
                        help="turns off the creating of force field file",
                        default=False)
    args = parser.parse_args()

    # Read solute data file
    solute_data = lammps.Datafile(filename=args.solute)
    if args.pdb is not None:
        pdbfile = pdb.PDBFile(filename=args.pdb)
        for datom, patom in zip(solute_data.atoms, pdbfile.atoms):
            datom.set_xyz(patom.xyz)

    # Read box data file and force field
    box_data = lammps.Datafile(filename=args.box)
    for atom in box_data.atoms:
        atom.ix = None
        atom.iy = None
        atom.iz = None
    box_ff = lammps.Includefile(filename=args.ff)

    if args.dihfunc_box is not None:
        for dih in box_ff.dihedralparams:
            if dih.func == "": dih.func = args.dihfunc_box
예제 #21
0
    parser = argparse.ArgumentParser(
        description="Calculate ligand-protein interaction energies")
    parser.add_argument('files', nargs="+", help="the Gromacs xvg-files")
    parser.add_argument('-o', '--out', help="the output file")
    parser.add_argument('-p', '--pdb', help="the protein", default=[])
    parser.add_argument('-r',
                        '--repeats',
                        help="repeat replacement",
                        default=[
                            "r1_", "r2_", "r3_", "r4_", "r5_", "r6_", "r8_",
                            "r9_", "r10_"
                        ])
    args = parser.parse_args()

residues = ["CU", "CL"]
for res in pdb.PDBFile(args.pdb).residues[:235]:
    residues.append("%s%d" % (res.resname.capitalize(), res.serial))

all_data = None
for ri, replacement in enumerate(args.repeats):
    r_data = []
    if ri == 0:
        outname = args.out
    else:
        outname = args.out.replace(args.repeats[0], replacement)
    with open(outname, "w") as f:
        if ri == 0:
            files = args.files
        else:
            files = [
                file.replace(args.repeats[0], replacement)
예제 #22
0
import sys
import os

from sgenlib import pdb


def atom_by_name(residue, atom):
    atom = atom.strip()
    if atom[0] in ["1", "2", "3"]:
        atom = atom[1:] + atom[0]
    if residue.resname == "ILE" and atom == "CD":
        atom = "CD1"
    return residue.atom_by_name(atom)


converted_pdb = pdb.PDBFile(sys.argv[1])
crystal_pdb = pdb.PDBFile(sys.argv[2])

nprotres = len(crystal_pdb.residues)

for conv_res, crys_res in zip(converted_pdb.residues[:nprotres],
                              crystal_pdb.residues):
    for conv_atom in conv_res.atoms:
        crys_atom = atom_by_name(crys_res, conv_atom.name)
        if crys_atom is None:
            print "Could not find %s in %s%d" % (
                conv_atom.name, conv_atom.resname, conv_atom.residue)
        else:
            conv_atom.set_xyz(crys_atom.xyz)

name, ext = os.path.splitext(sys.argv[1])
예제 #23
0
                           '--checkpoint',
                           help="the format checkpoint file")
    argparser.add_argument(
        '-s',
        '--struct',
        help="a gro or pdb file with atom/residue information")
    argparser.add_argument('-b', '--bonds', nargs="+", help="the bonds")
    argparser.add_argument('--scaling',
                           type=float,
                           help="the frequency scaling factor",
                           default=0.963)
    args = argparser.parse_args()

    crds, hess = _parse_fchk(args.checkpoint)

    struct_orig = pdb.PDBFile(args.struct)
    struct = pdb.PDBFile(args.struct)
    for i, atom in enumerate(struct.atoms, 1):
        # 0.529177249 is Bohr to A
        atom.set_xyz(crds[3 * i - 3:3 * i] * 0.529177249)
    base, ext = os.path.splitext(args.struct)
    struct.write(base + "_opt" + ext)

    print "Bond\tr(x-ray)\tr(opt) [nm]\tk [kJ/mol/nm2]"
    for bond in args.bonds:
        atm1, atm2 = _find_pair(struct, bond)
        dist = np.sqrt(atm1.distance2(atm2))

        atm1_orig = struct_orig.atoms[atm1.idx]
        atm2_orig = struct_orig.atoms[atm2.idx]
        dist_orig = np.sqrt(atm1_orig.distance2(atm2_orig))
예제 #24
0
파일: aa2cg.py 프로젝트: syn2018/Scripts
                        default="lj/charmm/coul/long")
    parser.add_argument('-w',
                        '--watrad',
                        type=float,
                        help="the water radius to keep atomistic")
    args = parser.parse_args()

    # Load a converter
    converter = lammps.Aa2Cg()
    if args.converter is None:
        converter.read(lammps.get_filename("aa2cg.dat"))  # The default
    else:
        converter.read(args.converter)

    # Create a Datafile and PDBFile
    pdbfile = pdb.PDBFile(args.file)  # Input PDB
    takeres = [True for res in pdbfile.residues]
    data = lammps.Datafile()
    pdbout = pdb.PDBFile()  # Output PDB

    # Load the force field file
    include = lammps.Includefile(args.include)

    if args.atomistic:
        # At the moment, multiple AA solutes are not supported with atomistic water radius
        if len(args.atomistic) > 1:
            args.watrad = None
        natomtypes = _ntypes(include.masses)
        contypes = [
            _ntypes(include.bondparams),
            _ntypes(include.angleparams),
예제 #25
0
"""
Program to flip the z-coordinate

Examples
--------

"""

import argparse

import numpy as np

from sgenlib import pdb

if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="Program to rename atoms and residue")
    parser.add_argument('file', help="the PDB file")
    parser.add_argument('-o', '--out', help="the output filename")
    args = parser.parse_args()

    pdbin = pdb.PDBFile(args.file)
    pdbin.box[2] *= 2
    for atom in pdbin.atoms:
        new = np.array(atom.xyz, copy=True)
        new[2] = pdbin.box[2] - new[2]
        atom.set_xyz(new)

    pdbin.write(args.out)
예제 #26
0
                        '--charge',
                        type=float,
                        help="The net charge of the molecule(s)",
                        default=0)
    parser.add_argument('-p',
                        '--processors',
                        type=int,
                        help="The number of processors to use",
                        default=1)
    args = parser.parse_args()

    method = {"ff94": "HF/6-31G* SCF", "ff03": "B3LYP/cc-pVTZ SCRF"}

    for filename in args.file:
        h, t = os.path.splitext(filename)
        pdbfile = pdb.PDBFile(filename=filename)
        with open("%s_mk.com" % h, "w") as fout:
            fout.write("%Mem=256MB\n")
            fout.write("%snproc=%d\n" % ('%', args.processors))
            fout.write("\n")
            fout.write(
                "#P %s Pop=(Minimal,MK) IOp(6/33=2,6/41=10,6/42=17)\n\n" %
                method[args.version])
            fout.write("MK ESP on %s, at %s\n" %
                       (filename, time.strftime("%d/%m/%Y")))
            fout.write("\n")
            fout.write("%d 1\n" % args.charge)
            for atom in pdbfile.atoms:
                fout.write("%s %8.3f %8.3f %8.3f\n" %
                           (atom.element(), atom.x, atom.y, atom.z))
            fout.write("\n")
예제 #27
0
if __name__ == '__main__':

    argparser = argparse.ArgumentParser(
        description="Script to displace a small solute")
    argparser.add_argument('-f',
                           '--file',
                           help="the input structure",
                           default="align_z.pdb")
    argparser.add_argument('-o',
                           '--output',
                           help="the output structure file",
                           default="align_z.pdb")
    argparser.add_argument('-r',
                           '--resname',
                           help="the residue name",
                           default="MOL")
    argparser.add_argument('-d',
                           '--displace',
                           type=float,
                           nargs=+3,
                           help="the displace vector",
                           default=[0.0, 0.0, 0.0])
    args = argparser.parse_args()

    struct = pdb.PDBFile(args.file)
    for atom in struct.atoms:
        if atom.resname.strip() == args.resname:
            atom.set_xyz(atom.xyz + args.displace)
    struct.write(args.output)
예제 #28
0
import numpy as np

from sgenlib import pdb

if __name__ == '__main__':

    # Setup a parser of the command-line arguments
    parser = argparse.ArgumentParser(
        description="Program to make a box size for a structure")
    parser.add_argument('file', help="the PDB file")
    parser.add_argument('-p',
                        '--padding',
                        type=float,
                        nargs=3,
                        help="the padding of each axis",
                        default=[10, 10, 10])
    args = parser.parse_args()

    coord = pdb.PDBFile(filename=args.file).xyz
    av = np.average(coord, axis=0)
    mina = np.min(coord, axis=0)
    maxa = np.max(coord, axis=0)

    lo = mina - args.padding
    hi = maxa + args.padding
    len = hi - lo
    print "Low: %.3f %.3f %.3f" % tuple(lo)
    print "High: %.3f %.3f %.3f" % tuple(hi)
    print "Length: %.3f %.3f %.3f" % tuple(len)
예제 #29
0
# Author: Samuel Genheden [email protected]
"""
Program to calculate the extent of PDB structure
"""

import sys

import numpy as np

from sgenlib import pdb

if __name__ == '__main__':

    coord = pdb.PDBFile(filename=sys.argv[1]).xyz
    av = np.average(coord, axis=0)
    mina = np.min(coord, axis=0)
    maxa = np.max(coord, axis=0)
    print "Mean: %.3f %.3f %.3f" % (av[0], av[1], av[2])
    print "Min:  %.3f %.3f %.3f" % (mina[0], mina[1], mina[2])
    print "Max:  %.3f %.3f %.3f" % (maxa[0], maxa[1], maxa[2])
    print "Len:  %.3f %.3f %.3f" % (maxa[0] - mina[0], maxa[1] - mina[1],
                                    maxa[2] - mina[2])
예제 #30
0
파일: pdb_cat.py 프로젝트: fdwonder/Scripts
# Author: Samuel Genheden [email protected]
"""
Program to concatenate structure in PDB or GRO format

Example:
  pdb_cat.py pdb1.pdb pdb2.pdb pdb3.pdb -o pdb_all.pdb
"""

import argparse
import os

from sgenlib import pdb

if __name__ == "__main__":

    # Setup a parser of the command-line arguments
    parser = argparse.ArgumentParser(
        description="Program to concatenate structures")
    parser.add_argument('file', nargs="+", help="the PDB file")
    parser.add_argument('-o', '--out', help="the output filename")
    args = parser.parse_args()

    pdbfile = pdb.PDBFile(filename=args.file[0], renumber=False)
    for filename in args.file[1:]:
        pdbfile2 = pdb.PDBFile(filename, renumber=False)
        pdbfile.extend_residues(pdbfile2.residues)
    pdbfile.write(args.out)