Skip to content

Commit 52c52df

Browse files
committed
Autopep8: E1 Indentions
Signed-off-by: Justin Lecher <[email protected]>
1 parent 4a6537b commit 52c52df

Some content is hidden

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

75 files changed

+11262
-11279
lines changed

Diff for: aaindex.py

+76-76
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
aaindex2b
1010
pmf
1111
'''
12-
12+
1313
import sys, os
14-
14+
1515
_aaindex = dict()
1616
_pymol_auto_arg_update = lambda: None
17-
17+
1818
def search(pattern, searchtitle=True, casesensitive=False):
1919
'''
2020
Search for pattern in description and title (optional) of all records and
@@ -29,15 +29,15 @@ def search(pattern, searchtitle=True, casesensitive=False):
2929
if pattern in whatcase(record.desc) or searchtitle and pattern in whatcase(record.title):
3030
matches.append(record)
3131
return matches
32-
32+
3333
def grep(pattern):
3434
'''
3535
Search for pattern in title and description of all records (case
3636
insensitive) and print results on standard output.
3737
'''
3838
for record in search(pattern):
3939
print record
40-
40+
4141
class Record:
4242
'''
4343
Amino acid index (AAindex) Record
@@ -72,7 +72,7 @@ def median(self):
7272
def __str__(self):
7373
desc = self.desc.replace('\n', ' ').strip()
7474
return '%s(%s: %s)' % (self.__class__.__name__, self.key, desc)
75-
75+
7676
class MatrixRecord(Record):
7777
'''
7878
Matrix record for mutation matrices or pair-wise contact potentials
@@ -107,20 +107,20 @@ def median(self):
107107
if len(x) % 2 == 1:
108108
return x[len(x)/2]
109109
return sum(x[len(x)/2-1:len(x)/2+1])/2.0
110-
110+
111111
def get(key):
112112
'''
113113
Get record for key
114114
'''
115115
if len(_aaindex) == 0:
116116
init()
117117
return _aaindex[key]
118-
118+
119119
def _float_or_None(x):
120120
if x == 'NA' or x == '-':
121121
return None
122122
return float(x)
123-
123+
124124
def init(path=None, index='13'):
125125
'''
126126
Read in the aaindex files. You need to run this (once) before you can
@@ -141,10 +141,10 @@ def init(path=None, index='13'):
141141
if '3' in index:
142142
_parse(path + '/aaindex3', MatrixRecord)
143143
_pymol_auto_arg_update()
144-
144+
145145
def init_from_file(filename, type=Record):
146146
_parse(filename, type)
147-
147+
148148
def _parse(filename, rec, quiet=True):
149149
'''
150150
Parse aaindex input file. `rec` must be `Record` for aaindex1 and
@@ -157,15 +157,15 @@ def _parse(filename, rec, quiet=True):
157157
filename = urllib.urlretrieve(url, filename)[0]
158158
print 'Saved to "%s"' % (filename)
159159
f = open(filename)
160-
160+
161161
current = rec()
162162
lastkey = None
163-
163+
164164
for line in f:
165165
key = line[0:2]
166166
if key[0] == ' ':
167167
key = lastkey
168-
168+
169169
if key == '//':
170170
_aaindex[current.key] = current
171171
current = rec()
@@ -217,63 +217,63 @@ def _parse(filename, rec, quiet=True):
217217
current.extend(map(_float_or_None, a))
218218
elif not quiet:
219219
print 'Warning: line starts with "%s"' % (key)
220-
220+
221221
lastkey = key
222-
222+
223223
########## PYMOL ###########
224-
224+
225225
# from Bio.SCOP.Raf import to_one_letter_code
226226
# See also http://www.pymolwiki.org/index.php/Aa_codes
227227
to_one_letter_code = {'PAQ': 'Y', 'AGM': 'R', 'ILE': 'I', 'PR3': 'C',
228-
'GLN': 'Q', 'DVA': 'V', 'CCS': 'C', 'ACL': 'R', 'GLX': 'Z', 'GLY': 'G',
229-
'GLZ': 'G', 'DTH': 'T', 'OAS': 'S', 'C6C': 'C', 'NEM': 'H', 'DLY': 'K',
230-
'MIS': 'S', 'SMC': 'C', 'GLU': 'E', 'NEP': 'H', 'BCS': 'C', 'ASQ': 'D',
231-
'ASP': 'D', 'SCY': 'C', 'SER': 'S', 'LYS': 'K', 'SAC': 'S', 'PRO': 'P',
232-
'ASX': 'B', 'DGN': 'Q', 'DGL': 'E', 'MHS': 'H', 'ASB': 'D', 'ASA': 'D',
233-
'NLE': 'L', 'DCY': 'C', 'ASK': 'D', 'GGL': 'E', 'STY': 'Y', 'SEL': 'S',
234-
'CGU': 'E', 'ASN': 'N', 'ASL': 'D', 'LTR': 'W', 'DAR': 'R', 'VAL': 'V',
235-
'CHG': 'A', 'TPO': 'T', 'CLE': 'L', 'GMA': 'E', 'HAC': 'A', 'AYA': 'A',
236-
'THR': 'T', 'TIH': 'A', 'SVA': 'S', 'MVA': 'V', 'SAR': 'G', 'LYZ': 'K',
237-
'BNN': 'A', '5HP': 'E', 'IIL': 'I', 'SHR': 'K', 'HAR': 'R', 'FME': 'M',
238-
'PYX': 'C', 'ALO': 'T', 'PHI': 'F', 'ALM': 'A', 'PHL': 'F', 'MEN': 'N',
239-
'TPQ': 'A', 'GSC': 'G', 'PHE': 'F', 'ALA': 'A', 'MAA': 'A', 'MET': 'M',
240-
'UNK': 'X', 'LEU': 'L', 'ALY': 'K', 'SET': 'S', 'GL3': 'G', 'TRG': 'K',
241-
'CXM': 'M', 'TYR': 'Y', 'SCS': 'C', 'DIL': 'I', 'TYQ': 'Y', '3AH': 'H',
242-
'DPR': 'P', 'PRR': 'A', 'CME': 'C', 'IYR': 'Y', 'CY1': 'C', 'TYY': 'Y',
243-
'HYP': 'P', 'DTY': 'Y', '2AS': 'D', 'DTR': 'W', 'FLA': 'A', 'DPN': 'F',
244-
'DIV': 'V', 'PCA': 'E', 'MSE': 'M', 'MSA': 'G', 'AIB': 'A', 'CYS': 'C',
245-
'NLP': 'L', 'CYQ': 'C', 'HIS': 'H', 'DLE': 'L', 'CEA': 'C', 'DAL': 'A',
246-
'LLP': 'K', 'DAH': 'F', 'HMR': 'R', 'TRO': 'W', 'HIC': 'H', 'CYG': 'C',
247-
'BMT': 'T', 'DAS': 'D', 'TYB': 'Y', 'BUC': 'C', 'PEC': 'C', 'BUG': 'L',
248-
'CYM': 'C', 'NLN': 'L', 'CY3': 'C', 'HIP': 'H', 'CSO': 'C', 'TPL': 'W',
249-
'LYM': 'K', 'DHI': 'H', 'MLE': 'L', 'CSD': 'A', 'HPQ': 'F', 'MPQ': 'G',
250-
'LLY': 'K', 'DHA': 'A', 'DSN': 'S', 'SOC': 'C', 'CSX': 'C', 'OMT': 'M',
251-
'DSP': 'D', 'PTR': 'Y', 'TRP': 'W', 'CSW': 'C', 'EFC': 'C', 'CSP': 'C',
252-
'CSS': 'C', 'SCH': 'C', 'OCS': 'C', 'NMC': 'G', 'SEP': 'S', 'BHD': 'D',
253-
'KCX': 'K', 'SHC': 'C', 'C5C': 'C', 'HTR': 'W', 'ARG': 'R', 'TYS': 'Y',
254-
'ARM': 'R', 'DNP': 'A'}
255-
228+
'GLN': 'Q', 'DVA': 'V', 'CCS': 'C', 'ACL': 'R', 'GLX': 'Z', 'GLY': 'G',
229+
'GLZ': 'G', 'DTH': 'T', 'OAS': 'S', 'C6C': 'C', 'NEM': 'H', 'DLY': 'K',
230+
'MIS': 'S', 'SMC': 'C', 'GLU': 'E', 'NEP': 'H', 'BCS': 'C', 'ASQ': 'D',
231+
'ASP': 'D', 'SCY': 'C', 'SER': 'S', 'LYS': 'K', 'SAC': 'S', 'PRO': 'P',
232+
'ASX': 'B', 'DGN': 'Q', 'DGL': 'E', 'MHS': 'H', 'ASB': 'D', 'ASA': 'D',
233+
'NLE': 'L', 'DCY': 'C', 'ASK': 'D', 'GGL': 'E', 'STY': 'Y', 'SEL': 'S',
234+
'CGU': 'E', 'ASN': 'N', 'ASL': 'D', 'LTR': 'W', 'DAR': 'R', 'VAL': 'V',
235+
'CHG': 'A', 'TPO': 'T', 'CLE': 'L', 'GMA': 'E', 'HAC': 'A', 'AYA': 'A',
236+
'THR': 'T', 'TIH': 'A', 'SVA': 'S', 'MVA': 'V', 'SAR': 'G', 'LYZ': 'K',
237+
'BNN': 'A', '5HP': 'E', 'IIL': 'I', 'SHR': 'K', 'HAR': 'R', 'FME': 'M',
238+
'PYX': 'C', 'ALO': 'T', 'PHI': 'F', 'ALM': 'A', 'PHL': 'F', 'MEN': 'N',
239+
'TPQ': 'A', 'GSC': 'G', 'PHE': 'F', 'ALA': 'A', 'MAA': 'A', 'MET': 'M',
240+
'UNK': 'X', 'LEU': 'L', 'ALY': 'K', 'SET': 'S', 'GL3': 'G', 'TRG': 'K',
241+
'CXM': 'M', 'TYR': 'Y', 'SCS': 'C', 'DIL': 'I', 'TYQ': 'Y', '3AH': 'H',
242+
'DPR': 'P', 'PRR': 'A', 'CME': 'C', 'IYR': 'Y', 'CY1': 'C', 'TYY': 'Y',
243+
'HYP': 'P', 'DTY': 'Y', '2AS': 'D', 'DTR': 'W', 'FLA': 'A', 'DPN': 'F',
244+
'DIV': 'V', 'PCA': 'E', 'MSE': 'M', 'MSA': 'G', 'AIB': 'A', 'CYS': 'C',
245+
'NLP': 'L', 'CYQ': 'C', 'HIS': 'H', 'DLE': 'L', 'CEA': 'C', 'DAL': 'A',
246+
'LLP': 'K', 'DAH': 'F', 'HMR': 'R', 'TRO': 'W', 'HIC': 'H', 'CYG': 'C',
247+
'BMT': 'T', 'DAS': 'D', 'TYB': 'Y', 'BUC': 'C', 'PEC': 'C', 'BUG': 'L',
248+
'CYM': 'C', 'NLN': 'L', 'CY3': 'C', 'HIP': 'H', 'CSO': 'C', 'TPL': 'W',
249+
'LYM': 'K', 'DHI': 'H', 'MLE': 'L', 'CSD': 'A', 'HPQ': 'F', 'MPQ': 'G',
250+
'LLY': 'K', 'DHA': 'A', 'DSN': 'S', 'SOC': 'C', 'CSX': 'C', 'OMT': 'M',
251+
'DSP': 'D', 'PTR': 'Y', 'TRP': 'W', 'CSW': 'C', 'EFC': 'C', 'CSP': 'C',
252+
'CSS': 'C', 'SCH': 'C', 'OCS': 'C', 'NMC': 'G', 'SEP': 'S', 'BHD': 'D',
253+
'KCX': 'K', 'SHC': 'C', 'C5C': 'C', 'HTR': 'W', 'ARG': 'R', 'TYS': 'Y',
254+
'ARM': 'R', 'DNP': 'A'}
255+
256256
def aaindex2b(key='KYTJ820101', selection='(all)', quiet=0, var='b'):
257257
'''
258258
DESCRIPTION
259-
259+
260260
"aaindex" looks up the Amino Acid Index from
261261
http://www.genome.jp/aaindex/
262262
for the given key and assignes b-factors to the given selection. Unknown
263263
residues get the average index value assigned.
264-
264+
265265
USAGE
266-
266+
267267
aaindex2b [key [, selection]]
268-
268+
269269
ARGUMENTS
270-
270+
271271
key = string: Key of AAindex entry
272-
272+
273273
selection = string: atoms to assign b-factors {default: (all)}
274-
274+
275275
EXAMPLE
276-
276+
277277
# Hydropathy index by Kyte-Doolittle
278278
aaindex2b KYTJ820101
279279
spectrumany b, white yellow forest
@@ -282,49 +282,49 @@ def aaindex2b(key='KYTJ820101', selection='(all)', quiet=0, var='b'):
282282
from pymol import cmd, stored
283283
entry = get(key)
284284
median = entry.median()
285-
285+
286286
if int(quiet) != 0:
287287
print entry.desc.strip()
288-
288+
289289
def lookup(resn):
290290
one_letter = to_one_letter_code.get(resn, 'X')
291291
value = entry.get(one_letter)
292292
if value is None:
293293
return median
294294
return value
295295
stored.aaindex = lookup
296-
296+
297297
cmd.alter(selection, var + '=stored.aaindex(resn)')
298-
298+
299299
def pmf(key, cutoff=7.0, selection1='(name CB)', selection2='', state=1, quiet=1):
300300
'''
301301
DESCRIPTION
302-
302+
303303
Potential of Mean Force
304-
304+
305305
ARGUMENTS
306-
306+
307307
key = string: aaindex key
308-
308+
309309
cutoff = float: distance cutoff {default: 7.0}
310310
cutoff = (float, float): distance shell
311-
311+
312312
selection1 = string: atom selection {default: (name CB)}
313-
313+
314314
selection2 = string: atom selection {default: selection1}
315-
315+
316316
NOTES
317-
317+
318318
Does also support a list of keys and a list of cutoffs to deal with
319319
multiple distance shells.
320-
320+
321321
EXAMPLES
322-
322+
323323
# distance dependent c-beta contact potentials
324324
pmf SIMK990101, 5, /2x19//A//CB
325325
pmf SIMK990102, [5, 7.5], /2x19//A//CB
326326
pmf [SIMK990101, SIMK990102, SIMK990103], [0, 5, 7.5, 10], /2x19//A//CB
327-
327+
328328
# interface potential
329329
sidechaincenters 2x19_scc, 2x19
330330
pmf KESO980102, 7.0, /2x19_scc//A, /2x19_scc//B
@@ -354,21 +354,21 @@ def pmf(key, cutoff=7.0, selection1='(name CB)', selection2='', state=1, quiet=1
354354
print 'Distance shells:'
355355
for i in range(len(key)):
356356
print '%s %.1f-%.1f' % (key[i], cutoff[i], cutoff[i+1])
357-
357+
358358
idmap = dict()
359359
cmd.iterate_state(state, '(%s) or (%s)' % (selection1, selection2),
360-
'idmap[model,index] = [(resn,name),(x,y,z)]', space={'idmap': idmap})
360+
'idmap[model,index] = [(resn,name),(x,y,z)]', space={'idmap': idmap})
361361
twoN = cmd.count_atoms(selection1) + cmd.count_atoms(selection2)
362362
pairs = cmd.find_pairs(selection1, selection2, cutoff=max(cutoff),
363-
state1=state, state2=state)
363+
state1=state, state2=state)
364364
if len(pairs) == 0:
365365
print 'Empty pair list'
366366
return 0.0
367-
367+
368368
matrix = map(get, key)
369369
for i in matrix:
370370
assert isinstance(i, MatrixRecord)
371-
371+
372372
i_list = range(len(key))
373373
u_sum = 0
374374
count = 0
@@ -385,12 +385,12 @@ def pmf(key, cutoff=7.0, selection1='(name CB)', selection2='', state=1, quiet=1
385385
count += 1
386386
except:
387387
print 'Failed for', a1[0], a2[0]
388-
388+
389389
value = float(u_sum) / twoN
390390
if not quiet:
391391
print 'PMF: %.4f (%d contacts, %d residues)' % (value, count, twoN)
392392
return value
393-
393+
394394
try:
395395
from pymol import cmd
396396
cmd.extend('aaindex2b', aaindex2b)
@@ -413,5 +413,5 @@ def pymol_auto_arg_update():
413413
_pymol_auto_arg_update = pymol_auto_arg_update
414414
except:
415415
pass
416-
416+
417417
# vi: ts=4:sw=4:smarttab:expandtab

0 commit comments

Comments
 (0)