Skip to content

Commit 5229367

Browse files
committed
Autopep8: E3 Blank lines
Signed-off-by: Justin Lecher <[email protected]>
1 parent 52c52df commit 5229367

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+565
-385
lines changed

Diff for: aaindex.py

+26
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
_aaindex = dict()
1616
_pymol_auto_arg_update = lambda: None
1717

18+
1819
def search(pattern, searchtitle=True, casesensitive=False):
1920
'''
2021
Search for pattern in description and title (optional) of all records and
@@ -30,6 +31,7 @@ def search(pattern, searchtitle=True, casesensitive=False):
3031
matches.append(record)
3132
return matches
3233

34+
3335
def grep(pattern):
3436
'''
3537
Search for pattern in title and description of all records (case
@@ -38,11 +40,14 @@ def grep(pattern):
3840
for record in search(pattern):
3941
print record
4042

43+
4144
class Record:
45+
4246
'''
4347
Amino acid index (AAindex) Record
4448
'''
4549
aakeys = 'ARNDCQEGHILKMFPSTWYV'
50+
4651
def __init__(self):
4752
self.key = None
4853
self.desc = ''
@@ -53,41 +58,52 @@ def __init__(self):
5358
self.correlated = dict()
5459
self.index = dict()
5560
self.comment = ''
61+
5662
def extend(self, row):
5763
i = len(self.index)
5864
for x in row:
5965
self.index[self.aakeys[i]] = x
6066
i += 1
67+
6168
def get(self, aai, aaj=None, d=None):
6269
assert aaj is None
6370
return self.index.get(aai, d)
71+
6472
def __getitem__(self, aai):
6573
return self.get(aai)
74+
6675
def median(self):
6776
x = sorted(filter(None, self.index.values()))
6877
half = len(x)/2
6978
if len(x) % 2 == 1:
7079
return x[half]
7180
return (x[half-1] + x[half])/2.0
81+
7282
def __str__(self):
7383
desc = self.desc.replace('\n', ' ').strip()
7484
return '%s(%s: %s)' % (self.__class__.__name__, self.key, desc)
7585

86+
7687
class MatrixRecord(Record):
88+
7789
'''
7890
Matrix record for mutation matrices or pair-wise contact potentials
7991
'''
92+
8093
def __init__(self):
8194
Record.__init__(self)
8295
self.index = []
8396
self.rows = dict()
8497
self.cols = dict()
98+
8599
def extend(self, row):
86100
self.index.append(row)
101+
87102
def _get(self, aai, aaj):
88103
i = self.rows[aai]
89104
j = self.cols[aaj]
90105
return self.index[i][j]
106+
91107
def get(self, aai, aaj, d=None):
92108
try:
93109
return self._get(aai, aaj)
@@ -97,8 +113,10 @@ def get(self, aai, aaj, d=None):
97113
return self._get(aaj, aai)
98114
except:
99115
return d
116+
100117
def __getitem__(self, aaij):
101118
return self.get(aaij[0], aaij[1])
119+
102120
def median(self):
103121
x = []
104122
for y in self.index:
@@ -108,6 +126,7 @@ def median(self):
108126
return x[len(x)/2]
109127
return sum(x[len(x)/2-1:len(x)/2+1])/2.0
110128

129+
111130
def get(key):
112131
'''
113132
Get record for key
@@ -116,11 +135,13 @@ def get(key):
116135
init()
117136
return _aaindex[key]
118137

138+
119139
def _float_or_None(x):
120140
if x == 'NA' or x == '-':
121141
return None
122142
return float(x)
123143

144+
124145
def init(path=None, index='13'):
125146
'''
126147
Read in the aaindex files. You need to run this (once) before you can
@@ -142,9 +163,11 @@ def init(path=None, index='13'):
142163
_parse(path + '/aaindex3', MatrixRecord)
143164
_pymol_auto_arg_update()
144165

166+
145167
def init_from_file(filename, type=Record):
146168
_parse(filename, type)
147169

170+
148171
def _parse(filename, rec, quiet=True):
149172
'''
150173
Parse aaindex input file. `rec` must be `Record` for aaindex1 and
@@ -253,6 +276,7 @@ def _parse(filename, rec, quiet=True):
253276
'KCX': 'K', 'SHC': 'C', 'C5C': 'C', 'HTR': 'W', 'ARG': 'R', 'TYS': 'Y',
254277
'ARM': 'R', 'DNP': 'A'}
255278

279+
256280
def aaindex2b(key='KYTJ820101', selection='(all)', quiet=0, var='b'):
257281
'''
258282
DESCRIPTION
@@ -296,6 +320,7 @@ def lookup(resn):
296320

297321
cmd.alter(selection, var + '=stored.aaindex(resn)')
298322

323+
299324
def pmf(key, cutoff=7.0, selection1='(name CB)', selection2='', state=1, quiet=1):
300325
'''
301326
DESCRIPTION
@@ -395,6 +420,7 @@ def pmf(key, cutoff=7.0, selection1='(name CB)', selection2='', state=1, quiet=1
395420
from pymol import cmd
396421
cmd.extend('aaindex2b', aaindex2b)
397422
cmd.extend('pmf', pmf)
423+
398424
def pymol_auto_arg_update():
399425
aaindexkey_sc = cmd.Shortcut(_aaindex.keys())
400426
cmd.auto_arg[0].update({

Diff for: anglebetweenhelices.py

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def get_unused_name(name):
1515
from pymol.cmd import get_unused_name
1616
STATE = -1
1717

18+
1819
def _vec_sum(vec_list):
1920
# this is the same as
2021
# return numpy.array(vec_list).sum(0).tolist()
@@ -23,6 +24,7 @@ def _vec_sum(vec_list):
2324
vec = cpv.add(vec, x)
2425
return vec
2526

27+
2628
def _mean_and_std(x):
2729
# this is the same as
2830
# return (numpy.mean(x), numpy.std(x, ddof=1))
@@ -33,6 +35,7 @@ def _mean_and_std(x):
3335
var = sum([(i - mu)**2 for i in x]) / float(N - 1)
3436
return (mu, var**0.5)
3537

38+
3639
def _common_orientation(selection, vec, visualize=1, quiet=0):
3740
'''
3841
Common part of different helix orientation functions. Does calculate
@@ -53,6 +56,7 @@ def _common_orientation(selection, vec, visualize=1, quiet=0):
5356
print 'Center: (%.2f, %.2f, %.2f) Direction: (%.2f, %.2f, %.2f)' % tuple(center + vec)
5457
return center, vec
5558

59+
5660
def visualize_orientation(direction, center=[0,0,0], scale=1.0, symmetric=False, color='green', color2='red'):
5761
'''
5862
Draw an arrow. Helper function for "helix_orientation" etc.
@@ -97,6 +101,7 @@ def visualize_orientation(direction, center=[0,0,0], scale=1.0, symmetric=False,
97101
])
98102
cmd.load_cgo(obj, get_unused_name('oriVec'), zoom=0)
99103

104+
100105
def cafit_orientation(selection, visualize=1, quiet=0):
101106
'''
102107
DESCRIPTION
@@ -128,6 +133,7 @@ def cafit_orientation(selection, visualize=1, quiet=0):
128133
vec = cpv.negate(vec)
129134
return _common_orientation(selection, vec, visualize, quiet)
130135

136+
131137
def loop_orientation(selection, visualize=1, quiet=0):
132138
'''
133139
DESCRIPTION
@@ -160,6 +166,7 @@ def loop_orientation(selection, visualize=1, quiet=0):
160166
vec = cpv.normalize(vec)
161167
return _common_orientation(selection, vec, visualize, quiet)
162168

169+
163170
def helix_orientation(selection, visualize=1, sigma_cutoff=1.5, quiet=0):
164171
'''
165172
DESCRIPTION
@@ -210,6 +217,7 @@ def helix_orientation(selection, visualize=1, sigma_cutoff=1.5, quiet=0):
210217
vec = cpv.normalize(vec)
211218
return _common_orientation(selection, vec, visualize, quiet)
212219

220+
213221
def helix_orientation_hbond(selection, visualize=1, cutoff=3.5, quiet=0):
214222
'''
215223
DESCRIPTION
@@ -249,6 +257,7 @@ def helix_orientation_hbond(selection, visualize=1, cutoff=3.5, quiet=0):
249257
vec = cpv.normalize(vec)
250258
return _common_orientation(selection, vec, visualize, quiet)
251259

260+
252261
def angle_between_helices(selection1, selection2, method='helix_orientation', visualize=1, quiet=0):
253262
'''
254263
DESCRIPTION

Diff for: b2transparency.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pymol import cmd, CmdException
1010

11+
1112
def b2transparency(selection='all', setting='transparency', minimum=None,
1213
maximum=None, var='b', quiet=1):
1314
'''

Diff for: bbPlane.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from pymol import cmd
1616

17+
1718
def bbPlane(selection='(all)', color='gray', transp=0.3, state=-1, name=None, quiet=1):
1819
"""
1920
DESCRIPTION

Diff for: ccp4_contact.py

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pymol import cmd
2727
import re
2828

29+
2930
def parseCONTACTContacts( f ):
3031
# Lys 24A ca Asp 263D CG ... 4.94 [ -1B ] 3: -X, Y+1/2, -Z+1/2
3132
conParser = re.compile("(\S*)\s*(\d+)([A-Z])\s*(\w+)")
@@ -43,6 +44,7 @@ def parseCONTACTContacts( f ):
4344

4445
return (s1, s2)
4546

47+
4648
def ccp4_contact( contactsfile, selName1 = "source", selName2 = "target" ):
4749
# read and parse contacts file into two lists of contact atoms and contact pair list
4850
s1, s2 = parseCONTACTContacts(open(contactsfile))

Diff for: ccp4_ncont.py

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pymol import cmd
2828
import re
2929

30+
3031
def parseNCONTContacts( f ):
3132
# /1/B/ 282(PHE). / CE1[ C]: /1/E/ 706(GLN). / O [ O]: 3.32
3233
# * in the second group is needed when chain code is blank
@@ -54,6 +55,7 @@ def parseNCONTContacts( f ):
5455
else:
5556
print "Unknown mode", mode
5657

58+
5759
def ccp4_ncont( contactsfile, selName1 = "source", selName2 = "target" ):
5860
# read and parse contacts file into two lists of contact atoms and contact pair list
5961
s1, s2, pairs = parseNCONTContacts(open(contactsfile))

Diff for: ccp4_pisa.py

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from pymol import cmd
3232
from xml.etree import ElementTree
3333

34+
3435
def parseElement( element ):
3536
""" creates a dict for the sub elements of the element"""
3637
result = { }
@@ -39,10 +40,12 @@ def parseElement( element ):
3940
result[element[l].tag.strip()] = element[l].text.strip()
4041
return result;
4142

43+
4244
def parseBond( elementDir ):
4345
""" puts bond information into tuples"""
4446
return ((elementDir['chain-1'], elementDir['seqnum-1'], elementDir['atname-1']), (elementDir['chain-2'], elementDir['seqnum-2'], elementDir['atname-2']))
4547

48+
4649
def parseInterface( interface, bondname ):
4750
""" parses a single interface into the interface id, the two chain names connected
4851
and two lists of atoms for each chain"""
@@ -62,11 +65,13 @@ def parseInterface( interface, bondname ):
6265
return id, (right_chain, left_chain), right, left
6366
return id, (left_chain, right_chain), left, right
6467

68+
6569
def createSelectionList( atomlist ):
6670
"""creates a PYMOL selection string for a list of atoms"""
6771
atomnames = [chain+'/'+res+'/'+atom for chain, res, atom in atomlist]
6872
return " or ".join(atomnames)
6973

74+
7075
def createInterfaceSelection( interface, prefix ):
7176
"""creates two selections for an interfaces"""
7277
id, e, l, r = interface
@@ -85,6 +90,7 @@ def createInterfaceSelection( interface, prefix ):
8590
print rightname, '\t', rightlist
8691
return leftname, rightname
8792

93+
8894
def ccp4_pisa( filename ):
8995
bond_types = [
9096
('h-bonds', 'h-bonds/bond', 'hb'),

Diff for: center_of_mass.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from pymol import cmd
1919

20+
2021
def com(selection,state=None,mass=None,object=None, quiet=1, **kwargs):
2122
quiet = int(quiet)
2223
if (object == None):
@@ -43,6 +44,7 @@ def com(selection,state=None,mass=None,object=None, quiet=1, **kwargs):
4344

4445
cmd.extend("com",com)
4546

47+
4648
def get_com(selection,state=1,mass=None, quiet=1):
4749
"""
4850
DESCRIPTION

Diff for: cgo_arrow.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pymol import cmd, cgo, CmdException
1010

11+
1112
def cgo_arrow(atom1='pk1', atom2='pk2', radius=0.5, gap=0.0, hlength=-1, hradius=-1,
1213
color='blue red', name=''):
1314
'''

Diff for: color_by_conservation.py

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
'''
1818

1919
from pymol import cmd
20+
21+
2022
def color_by_conservation(aln, names=(), color="rainbow", as_putty=0, _self=cmd):
2123
# PyMOL doesn't yet know about object:alignment
2224
# but we need to check that this exists or we might crash

Diff for: colorbydisplacement.py

+3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
from pymol import cmd
4444
from pymol import stored
4545

46+
4647
def strTrue(p):
4748
return p[0].upper() == "T"
4849

50+
4951
def displacementUpdateBAll(objA, alnAri, objB, alnBri):
5052
print "This will take a while to go through the for loops. Give me around 3-5 minutes..."
5153
### If residue is unassigned in one of the pdb files, we reset its value
@@ -67,6 +69,7 @@ def displacementUpdateBAll(objA, alnAri, objB, alnBri):
6769
cmd.delete(tempObject)
6870
cmd.sort(objA); cmd.sort(objB)
6971

72+
7073
def ColorByDisplacementAll(objSel1, objSel2, super1='all', super2='all', doColor="True", doAlign="True", AlignedWhite='yes'):
7174
### First create backup copies; names starting with __ (underscores) are normally hidden by PyMOL
7275
tObj1, tObj2, aln = "__tempObj1", "__tempObj2", "__aln"

Diff for: colorbyrmsd.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from pymol import cmd, CmdException
1111

12+
1213
def colorbyrmsd(mobile, target, doAlign=1, doPretty=1, guide=1, method='super', quiet=1):
1314
'''
1415
DESCRIPTION

Diff for: com.py

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from pymol import stored
4242
from chempy import cpv
4343

44+
4445
def COM(selection='all', center=0, quiet=1):
4546

4647
model = cmd.get_model(selection)

0 commit comments

Comments
 (0)