Skip to content

Commit

Permalink
PEP8 makeover.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrueffer committed Dec 6, 2012
1 parent fd82a0a commit 514eb8f
Showing 1 changed file with 63 additions and 64 deletions.
127 changes: 63 additions & 64 deletions Scripts/Structure/hsexpo
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ from optparse import OptionParser
from Bio.PDB import * from Bio.PDB import *
import sys import sys


__doc__=""" __doc__ = """
This program calculates solvent exposure for all amino This program calculates solvent exposure for all amino
acids in a PDB file using 5 different methods: acids in a PDB file using 5 different methods:
Expand All @@ -24,116 +24,115 @@ A PDB file can be written out with the exposure in the B factor field.
See --help for all options. See --help for all options.
""" """


if len(sys.argv)==1: if len(sys.argv) == 1:
print __doc__ print __doc__
sys.exit() sys.exit()


# Get the user's options # Get the user's options
parser=OptionParser(usage="usage: %prog [options] <PDB file>") parser = OptionParser(usage="usage: %prog [options] <PDB file>")


parser.add_option("-t", "--type", dest="exp", parser.add_option("-t", "--type", dest="exp",
help="exposure type (HSEAU, HSEAD, HSEBU, HSEBD, CN, DSSPr, DSSPa, RD, RDa)", help="exposure type (HSEAU, HSEAD, HSEBU, HSEBD,\
default="HSEb") CN, DSSPr, DSSPa, RD, RDa)", default="HSEb")


parser.add_option("-o", "--out", dest="outfile", parser.add_option("-o", "--out", dest="outfile",
help="output to PDB file (B factor=exposure)") help="output to PDB file (B factor=exposure)")


parser.add_option("-r", "--radius", dest="radius", type="float", parser.add_option("-r", "--radius", dest="radius", type="float",
help="sphere radius (default 13.0 A)", help="sphere radius (default 13.0 A)",
default=13.0) default=13.0)


parser.add_option("-m", "--model", dest="model", type="int", parser.add_option("-m", "--model", dest="model", type="int",
help="model number (default 0)", help="model number (default 0)",
default=0) default=0)


(options, args)=parser.parse_args() (options, args) = parser.parse_args()


pdbfile=args[0] pdbfile = args[0]


# Get the structure # Get the structure
p=PDBParser() p = PDBParser()
s=p.get_structure('X', pdbfile) s = p.get_structure('X', pdbfile)


# First model by default # First model by default
m=s[options.model] m = s[options.model]


RADIUS=options.radius RADIUS = options.radius


# d=dictionary of exposures # d=dictionary of exposures
# k=position in ntuple containing the desired exposure # k=position in ntuple containing the desired exposure


format="%4i" format = "%4i"


options.exp=options.exp.upper() options.exp = options.exp.upper()


if options.exp[0]=="H" and options.exp[3]=="A": if options.exp[0] == "H" and options.exp[3] == "A":
hse=HSExposureCA(m, RADIUS) hse = HSExposureCA(m, RADIUS)
if options.exp[-1]=="D": if options.exp[-1] == "D":
k='EXP_HSE_A_D' k = 'EXP_HSE_A_D'
else: else:
k='EXP_HSE_A_U' k = 'EXP_HSE_A_U'
elif options.exp[0]=="H" and options.exp[3]=="B": elif options.exp[0] == "H" and options.exp[3] == "B":
hse=HSExposureCB(m, RADIUS) hse = HSExposureCB(m, RADIUS)
#hse.write_pymol_script() #hse.write_pymol_script()
if options.exp[-1]=="D": if options.exp[-1] == "D":
k='EXP_HSE_B_U' k = 'EXP_HSE_B_U'
else: else:
k='EXP_HSE_B_D' k = 'EXP_HSE_B_D'
elif options.exp=="CN": elif options.exp == "CN":
hse=ExposureCN(m, RADIUS) hse = ExposureCN(m, RADIUS)
k='EXP_CN' k = 'EXP_CN'
elif options.exp=="ANGLE": elif options.exp == "ANGLE":
hse=HSExposureCA(m, RADIUS) hse = HSExposureCA(m, RADIUS)
k='EXP_CB_PCB_ANGLE' k = 'EXP_CB_PCB_ANGLE'
format="%4.1f" format = "%4.1f"
elif options.exp=="DSSPR": elif options.exp == "DSSPR":
d=DSSP(m, pdbfile) d = DSSP(m, pdbfile)
k='EXP_DSSP_RASA' k = 'EXP_DSSP_RASA'
format="%.4f" format = "%.4f"
elif options.exp=="DSSPA": elif options.exp == "DSSPA":
d=DSSP(m, pdbfile) d = DSSP(m, pdbfile)
k='EXP_DSSP_ASA' k = 'EXP_DSSP_ASA'
elif options.exp=="RD": elif options.exp == "RD":
d=ResidueDepth(m, pdbfile) d = ResidueDepth(m, pdbfile)
k='EXP_RD' k = 'EXP_RD'
format="%4.1f" format = "%4.1f"
elif options.exp=="RDA": elif options.exp == "RDA":
d=ResidueDepth(m, pdbfile) d = ResidueDepth(m, pdbfile)
k='EXP_RD_CA' k = 'EXP_RD_CA'
format="%4.1f" format = "%4.1f"
else: else:
print "ERROR: Unknown option." print "ERROR: Unknown option."
sys.exit() sys.exit()


residue_list=Selection.unfold_entities(m, 'R') residue_list = Selection.unfold_entities(m, 'R')


for r in residue_list: for r in residue_list:


if r.xtra.has_key(k): if k in r.xtra:


exposure=r.xtra[k] exposure = r.xtra[k]


if options.exp=="DSSPR": if options.exp == "DSSPR":
# to 0=exposed, 1=buried # to 0=exposed, 1=buried
exposure=1-exposure exposure = 1 - exposure


# Print info # Print info
hetflag, resseq, icode=r.get_id() hetflag, resseq, icode = r.get_id()


if icode==' ': if icode == ' ':
icode='_' icode = '_'


resname=r.get_resname() resname = r.get_resname()


print (("%s %4i %c\t"+format) % (resname, resseq, icode, exposure)) print (("%s %4i %c\t" + format) % (resname, resseq, icode, exposure))
else: else:
exposure=0.0 exposure = 0.0


for atom in r.get_iterator(): for atom in r.get_iterator():
atom.set_bfactor(exposure) atom.set_bfactor(exposure)


if options.outfile: if options.outfile:
io=PDBIO() io = PDBIO()
io.set_structure(s) io.set_structure(s)
io.save(options.outfile) io.save(options.outfile)

0 comments on commit 514eb8f

Please sign in to comment.