Skip to content

Commit d224c00

Browse files
committed
Apply 2026 black style
1 parent 4418eef commit d224c00

21 files changed

+47
-62
lines changed

lib/bx/align/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def slice_by_component(self, component_index, start, end):
143143
start_col = ref.coord_to_col(start)
144144
end_col = ref.coord_to_col(end)
145145
if ref.strand == "-":
146-
(start_col, end_col) = (end_col, start_col)
146+
start_col, end_col = (end_col, start_col)
147147
return self.slice(start_col, end_col)
148148

149149
def column_iter(self):
@@ -355,7 +355,7 @@ def slice_by_coord(self, start, end):
355355
start_col = self.coord_to_col(start)
356356
end_col = self.coord_to_col(end)
357357
if self.strand == "-":
358-
(start_col, end_col) = (end_col, start_col)
358+
start_col, end_col = (end_col, start_col)
359359
return self.slice(start_col, end_col)
360360

361361
def coord_to_col(self, pos):

lib/bx/align/lav.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __next__(self):
7575
self.parse_h_stanza()
7676
continue
7777
if line.startswith("a {"):
78-
(score, pieces) = self.parse_a_stanza()
78+
score, pieces = self.parse_a_stanza()
7979
break
8080
if line.endswith("{"):
8181
self.parse_unknown_stanza()
@@ -120,7 +120,7 @@ def open_seqs(self):
120120
name1 = self.path_to_src_name(self.seq1_filename)
121121
except ValueError:
122122
name1 = "seq1"
123-
(species1, chrom1) = src_split(name1)
123+
species1, chrom1 = src_split(name1)
124124
self.seq1_src = src_merge(species1, chrom1, contig)
125125
if contig is not None:
126126
chrom1 += f"[{contig}]"
@@ -152,7 +152,7 @@ def open_seqs(self):
152152
name2 = self.path_to_src_name(self.seq2_filename)
153153
except ValueError:
154154
name2 = "seq2"
155-
(species2, chrom2) = src_split(name2)
155+
species2, chrom2 = src_split(name2)
156156
self.seq2_src = src_merge(species2, chrom2, contig)
157157
if contig is not None:
158158
chrom2 += f"[{contig}]"
@@ -180,14 +180,10 @@ def close_seqs(self):
180180
def parse_s_stanza(self):
181181
self.close_seqs()
182182
line = self.fetch_line(report=" in s-stanza")
183-
(self.seq1_filename, self.seq1_start, self.seq1_end, self.seq1_strand, self.seq1_contig) = self.parse_s_seq(
184-
line
185-
)
183+
self.seq1_filename, self.seq1_start, self.seq1_end, self.seq1_strand, self.seq1_contig = self.parse_s_seq(line)
186184

187185
line = self.fetch_line(report=" in s-stanza")
188-
(self.seq2_filename, self.seq2_start, self.seq2_end, self.seq2_strand, self.seq2_contig) = self.parse_s_seq(
189-
line
190-
)
186+
self.seq2_filename, self.seq2_start, self.seq2_end, self.seq2_strand, self.seq2_contig = self.parse_s_seq(line)
191187

192188
line = self.fetch_line(report=" in s-stanza")
193189
assert line == "}", f'improper s-stanza terminator (line {self.lineNumber}, "{line}")'
@@ -467,7 +463,7 @@ def close(self):
467463
keys = list(self.blockHash)
468464
keys = sort_keys_by_chrom(keys)
469465
for key in keys:
470-
(src1, strand1, src2, strand2) = key
466+
src1, strand1, src2, strand2 = key
471467
alignment = self.blockHash[key][0]
472468
self.src1 = src1
473469
self.strand1 = strand1
@@ -485,8 +481,8 @@ def close(self):
485481

486482
def write_s_stanza(self):
487483
self.write_lav_marker()
488-
(strand1, flag1) = minus_or_nothing(self.strand1)
489-
(strand2, flag2) = minus_or_nothing(self.strand2)
484+
strand1, flag1 = minus_or_nothing(self.strand1)
485+
strand2, flag2 = minus_or_nothing(self.strand2)
490486
fname1 = build_filename(self.fname1, self.src1)
491487
fname2 = build_filename(self.fname2, self.src2)
492488
print("s {", file=self.file)
@@ -522,7 +518,7 @@ def write_a_stanza(self, alignment):
522518
nonGap = (ch1 != "-") and (ch2 != "-")
523519
if nonGap:
524520
if piece1 is None: # new piece starts
525-
(piece1, piece2, idCount) = (pos1, pos2, 0)
521+
piece1, piece2, idCount = (pos1, pos2, 0)
526522
if ch1 == ch2:
527523
idCount += 1
528524
elif piece1 is not None: # new gap starts
@@ -543,11 +539,11 @@ def write_a_stanza(self, alignment):
543539

544540
# write the block
545541

546-
(start1, start2, size, pctId) = pieces[-1] # get end of final piece
542+
start1, start2, size, pctId = pieces[-1] # get end of final piece
547543
end1 = start1 + size
548544
end2 = start2 + size
549545

550-
(start1, start2, size, pctId) = pieces[0] # get start of first piece
546+
start1, start2, size, pctId = pieces[0] # get start of first piece
551547

552548
score = int(round(alignment.score))
553549

@@ -575,7 +571,7 @@ def sort_keys_by_chrom(keys):
575571

576572

577573
def chrom_key(src):
578-
(species, chrom) = src_split(src)
574+
species, chrom = src_split(src)
579575
if chrom.startswith("chr"):
580576
chrom = chrom[3:]
581577
try:
@@ -591,7 +587,7 @@ def build_filename(fmt, src):
591587
num = fmt.count("%s")
592588
if num == 0:
593589
return fmt
594-
(species, chrom) = src_split(src)
590+
species, chrom = src_split(src)
595591
if num == 1:
596592
return fmt % chrom
597593
return fmt % (species, chrom)

lib/bx/align/maf_tests.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,12 @@ def test_writer():
120120

121121
writer.write(a)
122122

123-
assert (
124-
val.getvalue()
125-
== """##maf version=1 scoring=foobar
123+
assert val.getvalue() == """##maf version=1 scoring=foobar
126124
a score=7009
127125
s human_hoxa 100 9 + 1000257 ACA-TTACT
128126
s horse_hoxa 120 10 - 98892 ACAATTGCT
129127
130128
""" # noqa: W291
131-
)
132129

133130

134131
def test_slice():

lib/bx/align/score.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ def __init__(
4848
# implement a different underlying table object
4949

5050
def _set_score(self, a_b_pair, val):
51-
(a, b) = a_b_pair
51+
a, b = a_b_pair
5252
self.table[a, b] = val
5353

5454
def _get_score(self, a_b_pair):
55-
(a, b) = a_b_pair
55+
a, b = a_b_pair
5656
return self.table[a, b]
5757

5858
def set_score(self, a, b, val, foldcase1=False, foldcase2=False):

lib/bx/pwm/position_weight_matrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def __init__(self, id, rows, alphabet, background=None, score_correction=True):
210210
fields, consensus = rows[i][:nsymbols], rows[i][-1]
211211
for x, count in enumerate(fields):
212212
try:
213-
(w, s) = self.parse_weight(count)
213+
w, s = self.parse_weight(count)
214214
except ValueError:
215215
raise ValueError("pwm row {} has bad weight {}".format(" ".join(fields), w))
216216

@@ -229,7 +229,7 @@ def __init__(self, id, rows, alphabet, background=None, score_correction=True):
229229
for i in range(len(rows)):
230230
hashRows.append({})
231231
for x, sym in enumerate(alphabet):
232-
(w, s) = rows[i][x]
232+
w, s = rows[i][x]
233233
hashRows[i][sym] = w * scale / s
234234
assert hashRows[i][sym] >= 0
235235
if sym not in self.matrix_base_counts:

lib/bx/seq/fasta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self, file, revcomp=False, name="", gap=None, lookahead=None, conti
5050
currContig = 1
5151
while True:
5252
if self.lookahead is not None:
53-
(line, self.lookahead) = (self.lookahead, None)
53+
line, self.lookahead = (self.lookahead, None)
5454
else:
5555
line = self.file.readline()
5656
if not isinstance(line, str):

lib/bx/seq/qdna.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __next__(self):
169169

170170
class QdnaCodebook:
171171
def __init__(self, file):
172-
(self.alphabet, self.codeToProbs) = self.read_codebook(file)
172+
self.alphabet, self.codeToProbs = self.read_codebook(file)
173173

174174
def __str__(self):
175175
codeSet = sorted(codeNum for codeNum in self.codeToProbs)

lib/bx_extras/stats.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
outputpairedstats
155155
findwithin
156156
"""
157+
157158
# CHANGE LOG:
158159
# ===========
159160
# 02-11-19 ... fixed attest_ind and attest_rel for div-by-zero Overflows
@@ -300,7 +301,7 @@ def lmedian(inlist, numbins=1000):
300301
Heiman's Basic Stats (1st Edition), or CRC Probability & Statistics.
301302
302303
Usage: lmedian (inlist, numbins=1000)"""
303-
(hist, smallest, binsize, extras) = histogram(inlist, numbins) # make histog
304+
hist, smallest, binsize, extras = histogram(inlist, numbins) # make histog
304305
cumhist = cumsum(hist) # make cumulative histogram
305306
for i in range(len(cumhist)): # get 1st(!) index holding 50%ile score
306307
if cumhist[i] >= len(inlist) / 2.0:
@@ -2217,7 +2218,7 @@ def amedian(inarray, numbins=1000):
22172218
Returns: median calculated over ALL values in inarray
22182219
"""
22192220
inarray = N.ravel(inarray)
2220-
(hist, smallest, binsize, extras) = ahistogram(inarray, numbins)
2221+
hist, smallest, binsize, extras = ahistogram(inarray, numbins)
22212222
cumhist = N.cumsum(hist) # make cumulative histogram
22222223
otherbins = N.greater_equal(cumhist, len(inarray) / 2.0)
22232224
otherbins = list(otherbins) # list of 0/1s, 1s start at median bin

script_tests/line_select_tests.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,18 @@
55

66
class Test(base.BaseScriptTest, unittest.TestCase):
77
command_line = "./scripts/line_select.py ${features}"
8-
input_features = base.TestFile(
9-
"""0
8+
input_features = base.TestFile("""0
109
1
1110
1
1211
0
1312
1
14-
0"""
15-
)
16-
input_stdin = base.TestFile(
17-
"""a
13+
0""")
14+
input_stdin = base.TestFile("""a
1815
b
1916
2017
d
2118
e
22-
f"""
23-
)
24-
output_stdout = base.TestFile(
25-
"""b
19+
f""")
20+
output_stdout = base.TestFile("""b
2621
27-
e"""
28-
)
22+
e""")

script_tests/maf_select_tests.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,27 @@
55

66
class Test(base.BaseScriptTest, unittest.TestCase):
77
command_line = "./scripts/maf_select.py ${features}"
8-
input_features = base.TestFile(
9-
"""0
8+
input_features = base.TestFile("""0
109
0
1110
0
1211
0
1312
0
1413
0
1514
0
16-
1"""
17-
)
15+
1""")
1816
input_stdin = base.TestFile(filename="./test_data/maf_tests/mm8_chr7_tiny_no_index.maf")
1917
output_stdout = base.TestFile(filename="./test_data/maf_tests/mm8_chr7_tiny_last_selected.maf")
2018

2119

2220
class TestWithE(base.BaseScriptTest, unittest.TestCase):
2321
command_line = "./scripts/maf_select.py ${features}"
24-
input_features = base.TestFile(
25-
"""0
22+
input_features = base.TestFile("""0
2623
1
2724
0
2825
0
2926
0
3027
0
3128
0
32-
0"""
33-
)
29+
0""")
3430
input_stdin = base.TestFile(filename="./test_data/maf_tests/mm10_chr12_lessspe.maf")
3531
output_stdout = base.TestFile(filename="./test_data/maf_tests/mm10_chr12_lessspe_one_selected.maf")

0 commit comments

Comments
 (0)