Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ pdbTools is a set of command line [python](http://www.python.org) scripts that m

Most of the scripts will run "out of the box" using a python interpreter. The command line parser is designed to be flexible. It will take an arbitrarily long list of pdb files, pdb ids, text files with pdb ids, or some mixture of all three. If the pdb file or id is not in the working directory, scripts will attempt to download the pdb file from [RCSB](http://www.rcsb.org/). Depending on the type of operation being done, a program will either write output files in the working directory or will print to stdout. All structure outputs are written in standard pdb format. All data outputs are in fixed-width column format. They were designed to be read by the statistics package [R](http://cran.r-project.org/); however, they should be easily parsed by other graphing programs.

*Note:* These scripts are only compatible with Python version 2.4-2.7.

## Installation

Install the development version by cloning this repo and running `pip`:
Expand Down
7 changes: 4 additions & 3 deletions pdbtools/addH.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__description__ = "Adds polar hydrogens to a pdb file for a UHBD calculation."
__author__ = "Michael J. Harms"
__date__ = "070727"
Expand Down Expand Up @@ -69,8 +70,8 @@ def convertResidues(pdb,atom_conv={},resid_conv={},atom_skip=[],resid_skip=[]):
states and give every group a charge.
"""

atom_to_convert = atom_conv.keys()
res_to_convert = resid_conv.keys()
atom_to_convert = list(atom_conv.keys())
res_to_convert = list(resid_conv.keys())

new_pdb = []
for line in pdb:
Expand Down Expand Up @@ -181,7 +182,7 @@ def flipAtoms(pdb):

flip = {"ASP":("OD1","OD2"),
"GLU":("OE1","OE2")}
flip_keys = flip.keys()
flip_keys = list(flip.keys())

for index, line in enumerate(pdb):
res = line[17:30]
Expand Down
2 changes: 1 addition & 1 deletion pdbtools/bfactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def pdbBfactor(pdb,data_dict):
for line in pdb:
if line[0:6] == "ATOM ":
resnum = line[23:26].strip()
if resnum in data_dict.keys():
if resnum in list(data_dict.keys()):
out.append("%s%6.2F%s" % (line[:60],data_dict[resnum],
line[66:]))
else:
Expand Down
9 changes: 6 additions & 3 deletions pdbtools/centerasu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from __future__ import print_function
from builtins import map
from builtins import range
__description__ = \
"""
pdb_centerasu.py
Expand All @@ -20,8 +23,8 @@
try:
from numpy import array, linalg, dot, mean, squeeze
except ImportError:
print "numpy package is required for this program!"
print "(http://numpy.scipy.org/)"
print("numpy package is required for this program!")
print("(http://numpy.scipy.org/)")
sys.exit()

class PdbCenterAsuError(Exception):
Expand All @@ -46,7 +49,7 @@ def pdbCenterasu(pdb, write_coord =False):
fmx = []
for line in pdb:
if line.startswith('SCALE'):
data = map(float, line[6:].split()[:-1])
data = list(map(float, line[6:].split()[:-1]))
fmx.append(data)

if len(fmx) == 0:
Expand Down
19 changes: 12 additions & 7 deletions pdbtools/centermass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
from builtins import range
from past.utils import old_div
__description__ = \
"""
pdb_centermass.py
Expand All @@ -17,7 +22,7 @@
__date__ = "061109"

import sys, re
from data import common
from .data import common

def pdbCentermass(pdb,write_coord=False,include_hetatm=False,include_mass=True):
"""
Expand Down Expand Up @@ -73,15 +78,15 @@ def pdbCentermass(pdb,write_coord=False,include_hetatm=False,include_mass=True):
try:
masses.append(common.ATOM_WEIGHTS[atom_type])
except:
print "File contains atoms of unknown type (%s)" % atom_type
print "Will assign them mass of carbon (12.011 g/mol)"
print "To fix, edit ATOM_WEIGHTS dictionary in pdb_data/common.py"
print("File contains atoms of unknown type (%s)" % atom_type)
print("Will assign them mass of carbon (12.011 g/mol)")
print("To fix, edit ATOM_WEIGHTS dictionary in pdb_data/common.py")
masses.append(12.011)

num_atoms = len(coord)

total_mass = sum(masses)
weights = [m/total_mass for m in masses]
weights = [old_div(m,total_mass) for m in masses]
center = [sum([coord[i][j]*weights[i] for i in range(num_atoms)])
for j in range(3)]

Expand All @@ -100,7 +105,7 @@ def pdbCentermass(pdb,write_coord=False,include_hetatm=False,include_mass=True):
center_out = ["%10.4F" % c for c in center]

if warn:
print "Warning. No element entries in file. Attempting to extract"
print "from the atom names. Not always reliable..."
print("Warning. No element entries in file. Attempting to extract")
print("from the atom names. Not always reliable...")

return center_out, out
8 changes: 5 additions & 3 deletions pdbtools/charmm/interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import
# Copyright 2007, Michael J. Harms
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.
Expand All @@ -13,7 +15,7 @@
__date__ = "080418"

import math, os
import gen_input
from . import gen_input

# Set up charmm binary
try:
Expand Down Expand Up @@ -66,7 +68,7 @@ def runCharmm(input):
err = "charmm binary \"%s\" does not exist!" % charmm_bin
raise CharmmInterfaceError(err)

print "Running: %s" % (charmm_bin)
print("Running: %s" % (charmm_bin))

cin, cout = os.popen2(charmm_bin)
cin.write(input)
Expand All @@ -90,7 +92,7 @@ def charmm2pdb(charmm_output):

# Rename oddball residues
rename_dict = {"OCT1":" O ","OCT2":" OXT"}
rename_lines = [l for l in pdb if l[12:16] in rename_dict.keys()]
rename_lines = [l for l in pdb if l[12:16] in list(rename_dict.keys())]
for line in rename_lines:
index = pdb.index(line)
new_atom = rename_dict[line[12:16]]
Expand Down
30 changes: 16 additions & 14 deletions pdbtools/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from __future__ import print_function
__description__ = \
"""
pdb_clean.py
Expand Down Expand Up @@ -56,7 +57,7 @@ def convertModifiedAA(coord,header):
backbone_atoms = ["N ","CA ","C ","O "]
new_coord = []
for line in coord:
if line[17:20] in mod_dict.keys():
if line[17:20] in list(mod_dict.keys()):
new = mod_dict[line[17:20]]
if line[13:16] in backbone_atoms:
new_line = "ATOM %s%s%s" % (line[6:17],new,line[20:])
Expand All @@ -72,7 +73,7 @@ def convertModifiedAA(coord,header):
old_seq = line[19:70].split()
new_seq = []
for aa in old_seq:
if aa in mod_dict.keys():
if aa in list(mod_dict.keys()):
new_seq.append(mod_dict[aa])
else:
new_seq.append(aa)
Expand All @@ -87,7 +88,7 @@ def convertModifiedAA(coord,header):

# Create output remarks
conv = ["REMARK converted %s to %s\n" % (k,mod_dict[k])
for k in mod_dict.keys()]
for k in list(mod_dict.keys())]

return new_coord, new_header, conv

Expand Down Expand Up @@ -120,7 +121,7 @@ def removeLetters(line):

# If the residue is not known, update known_atom_dict and append line
# to coordinate file
if residue not in known_atom_dict.keys():
if residue not in list(known_atom_dict.keys()):
out = removeLetters(c)
coord_out.append(out)
known_atom_dict.update([(residue,[c[13:16]])])
Expand Down Expand Up @@ -197,7 +198,8 @@ def addMissingAtoms(coord,seqres,keep_temp=False,renumber_residues=False,
try:
new_coord = charmm.interface.charmmWash(structure_list,
keep_temp=keep_temp,fix_atoms=fix_atoms,num_steps=num_steps)
except charmm.interface.CharmmInterfaceError, (strerror):
except charmm.interface.CharmmInterfaceError as xxx_todo_changeme:
(strerror) = xxx_todo_changeme
err = "CharmmInterfaceError\n%s\n" % strerror
raise PdbCleanError(err)

Expand Down Expand Up @@ -265,7 +267,7 @@ def pdbClean(pdb,pdb_id="temp",chains="all",renumber_residues=False,
coord, header, converted = convertModifiedAA(coord,header)
if len(converted) != 0:
log.append(log_fmt % "Modified amino acids converted.")
print log[-1],
print(log[-1], end=' ')
log.extend(converted)
if pdbCheck(coord):
err = "Modified amino acid converter removed all atoms! Mangled pdb!"
Expand All @@ -278,13 +280,13 @@ def pdbClean(pdb,pdb_id="temp",chains="all",renumber_residues=False,
raise PdbCleanError(err)
else:
log.append(log_fmt % "HETATM entries removed.")
print log[-1],
print(log[-1], end=' ')

# Grab only the chain we want, if specified
if chains != "all":
coord = [l for l in coord if l[21] in chains]
log.append(log_fmt % ("Took only chain %r." % chains))
print log[-1],
print(log[-1], end=' ')
if pdbCheck(coord):
err = "Chain filter (%r) removed all atoms in pdb file!" % chains
raise PdbCleanError(err)
Expand All @@ -293,7 +295,7 @@ def pdbClean(pdb,pdb_id="temp",chains="all",renumber_residues=False,
coord, skipped = stripACS(coord)
if len(skipped) != 0:
log.append(log_fmt % "Alternate conformations were removed.")
print log[-1],
print(log[-1], end=' ')
log.extend(skipped)
if pdbCheck(coord):
err = "ACS stripper removed all atoms! Mangled pdb file."
Expand All @@ -303,14 +305,14 @@ def pdbClean(pdb,pdb_id="temp",chains="all",renumber_residues=False,
coord, removed = backboneCheck(coord)
if len(removed) != 0:
log.append(log_fmt % "Residues with missing backbone atoms removed.")
print log[-1],
print(log[-1], end=' ')
log.extend(removed)
if pdbCheck(coord):
err = "Backbone checker removed all atoms! Mangled pdb file."
raise PdbCleanError(err)

# Add missing atoms using CHARMM
print log_fmt % "Adding heavy atoms using CHARMM.",
print(log_fmt % "Adding heavy atoms using CHARMM.", end=' ')
seqres = [l for l in header if l[0:6] == "SEQRES"]
coord = addMissingAtoms(coord,seqres,keep_temp,renumber_residues,pdb_id,
fix_atoms,num_steps)
Expand All @@ -319,17 +321,17 @@ def pdbClean(pdb,pdb_id="temp",chains="all",renumber_residues=False,
# Renumber residues if requested
if renumber_residues:
log.append(log_fmt % "Residues renumbered from one.")
print log[-1],
print(log[-1], end=' ')

# Renumber atoms from 1
coord = pdb_atom_renumber.pdbAtomRenumber(coord)
log.append(log_fmt % "Renumbered atoms from 1")
print log[-1],
print(log[-1], end=' ')

# Standardize atom-type on far right pdb column
coord = ["%s %s \n" % (c[:66],c[13]) for c in coord]
log.append(log_fmt % "Atom types were standardized.")
print log[-1],
print(log[-1], end=' ')

# Final check
if pdbCheck(coord):
Expand Down
1 change: 1 addition & 0 deletions pdbtools/closecontacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__description__ = \
"""
pdb_close-contacts.py
Expand Down
3 changes: 2 additions & 1 deletion pdbtools/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__description__ = \
"""
pdb_contacting-residues.py
Expand Down Expand Up @@ -42,7 +43,7 @@ def pdbContacting(pdb,target,cutoff,target_type="resname"):
contacts.append(a[0][5:].strip())

# Grab only unique contacts
contacts = dict([(c,()) for c in contacts]).keys()
contacts = list(dict([(c,()) for c in contacts]).keys())
out.append("%s\t%s\n" % (t[0],("\t".join(contacts))))

return out
1 change: 1 addition & 0 deletions pdbtools/contactplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__description__ = \
"""
pdb_contact.py
Expand Down
11 changes: 7 additions & 4 deletions pdbtools/coulomb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from __future__ import division
from builtins import range
from past.utils import old_div
__description__ = \
"""
pdb_coulomb.py
Expand Down Expand Up @@ -33,7 +36,7 @@ def readPDB(pdb_file):

# Grab only ATOM entries that are titratable
pdb = [l for l in pdb if l[0:4] == "ATOM" and
l[17:20] in TITR_ATOM.keys() and
l[17:20] in list(TITR_ATOM.keys()) and
l[13:16] == TITR_ATOM[l[17:20]]]

# Initalize lists to hold coordinates, pkas, and charge
Expand All @@ -60,7 +63,7 @@ def hendersonHasselbach(pKa,charge,pH):
pH value.
"""

return charge/(1 + 10**(charge*(pH-pKa)))
return old_div(charge,(1 + 10**(charge*(pH-pKa))))


def pdbCoulomb(coord,pKa,charge,dielec_const,ionic_str,pH,temperature):
Expand All @@ -70,10 +73,10 @@ def pdbCoulomb(coord,pKa,charge,dielec_const,ionic_str,pH,temperature):
ionic strength.
"""

ionic_str = ionic_str/1000
ionic_str = old_div(ionic_str,1000)

# Initialize variables
kappa = 50.29*sqrt(ionic_str/(dielec_const*temperature))
kappa = 50.29*sqrt(old_div(ionic_str,(dielec_const*temperature)))
num_groups = len(coord)
energy = 0.

Expand Down
2 changes: 1 addition & 1 deletion pdbtools/data/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _readParam(param_file):
# Fill charge and radii dictionaries keyed to aa, then atom type
charge = dict([(x[0],[]) for x in param])
radii = dict([(x[0],[]) for x in param])
for k in charge.keys():
for k in list(charge.keys()):
charge[k] = dict([(x[1],x[2]) for x in param if x[0] == k])
radii[k] = dict([(x[1],x[3]) for x in param if x[0] == k])

Expand Down
1 change: 1 addition & 0 deletions pdbtools/dist_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__author__ = "Michael J. Harms"
__date__ = "070709"
__description__ = \
Expand Down
1 change: 1 addition & 0 deletions pdbtools/disulfide.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This program is distributed under General Public License v. 3. See the file
# COPYING for a copy of the license.

from builtins import range
__description__ = \
"""
pdb_disulfide.py
Expand Down
Loading