Skip to content

Commit 1ed71b6

Browse files
committed
Automatically remove redundant commas
Used this hack from psf/black#1288 $ pip install black==19.3b0 && black . && pip install black==19.10b && black . I then manually reverted changes to a handful of explicit data structures where the magic trailing comma should be retained (indicates to black not to squash into one line). Doing this dramatically improves the changes from trying black version 21.7b0 (right now just four minor changes).
1 parent 9bd28ed commit 1ed71b6

Some content is hidden

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

50 files changed

+124
-222
lines changed

Bio/AlignIO/MsfIO.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def __next__(self):
316316
)
317317

318318
records = (
319-
SeqRecord(Seq(s), id=i, name=i, description=i, annotations={"weight": w},)
319+
SeqRecord(Seq(s), id=i, name=i, description=i, annotations={"weight": w})
320320
for (i, s, w) in zip(ids, seqs, weights)
321321
)
322322

Bio/AlignIO/StockholmIO.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ def _write_record(self, record):
231231
seq_name = seq_name.replace(" ", "_")
232232

233233
if "start" in record.annotations and "end" in record.annotations:
234-
suffix = "/%s-%s" % (
235-
record.annotations["start"],
236-
record.annotations["end"],
237-
)
234+
suffix = "/%s-%s" % (record.annotations["start"], record.annotations["end"])
238235
if seq_name[-len(suffix) :] != suffix:
239236
seq_name = "%s/%s-%s" % (
240237
seq_name,

Bio/Blast/Record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def __str__(self):
252252
else:
253253
lines.append(
254254
"Query:%8s %s...%s %s"
255-
% (self.query_start, self.query[:45], self.query[-3:], self.query_end,)
255+
% (self.query_start, self.query[:45], self.query[-3:], self.query_end)
256256
)
257257
lines.append(" %s...%s" % (self.match[:45], self.match[-3:]))
258258
lines.append(

Bio/GenBank/Scanner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def parse_records(self, handle, do_features=True):
529529
yield record
530530

531531
def parse_cds_features(
532-
self, handle, alphabet=None, tags2id=("protein_id", "locus_tag", "product"),
532+
self, handle, alphabet=None, tags2id=("protein_id", "locus_tag", "product")
533533
):
534534
"""Parse CDS features, return SeqRecord object iterator.
535535

Bio/Nexus/Nexus.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def combine(matrices):
416416
combined.matrix[t] += Seq(
417417
str(m.matrix[t])
418418
.replace(m.gap, combined.gap)
419-
.replace(m.missing, combined.missing),
419+
.replace(m.missing, combined.missing)
420420
)
421421
# replace date of missing taxa with symbol for missing data
422422
for t in combined_only:
@@ -425,7 +425,7 @@ def combine(matrices):
425425
combined.matrix[t] = Seq(combined.missing * combined.nchar) + Seq(
426426
str(m.matrix[t])
427427
.replace(m.gap, combined.gap)
428-
.replace(m.missing, combined.missing),
428+
.replace(m.missing, combined.missing)
429429
)
430430
combined.taxlabels.extend(m_only) # new taxon list
431431
for cn, cs in m.charsets.items(): # adjust character sets for new matrix
@@ -1052,7 +1052,7 @@ def _matrix(self, options):
10521052
# Reformat sequence for non-standard datatypes
10531053
if self.datatype != "standard":
10541054
iupac_seq = Seq(
1055-
_replace_parenthesized_ambigs(chars, self.rev_ambiguous_values),
1055+
_replace_parenthesized_ambigs(chars, self.rev_ambiguous_values)
10561056
)
10571057
# first taxon has the reference sequence if matchhar is used
10581058
if taxcount == 1:

Bio/PDB/internal_coords.py

+4-18
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,7 @@
8484
from Bio.PDB.ic_data import ic_data_sidechain_extras, residue_atom_bond_state
8585

8686
# for type checking only
87-
from typing import (
88-
List,
89-
Dict,
90-
Set,
91-
TextIO,
92-
Union,
93-
Tuple,
94-
cast,
95-
TYPE_CHECKING,
96-
Optional,
97-
)
87+
from typing import List, Dict, Set, TextIO, Union, Tuple, cast, TYPE_CHECKING, Optional
9888

9989
if TYPE_CHECKING:
10090
from Bio.PDB.Residue import Residue
@@ -606,7 +596,7 @@ def init_atom_coords(self) -> None:
606596
a4shift[udFwd] = self.hedraIC[self.dH2ndx, 0][mdFwd] # len12
607597

608598
self.a4_pre_rotation[:, 2][self.dAtoms_needs_update] = numpy.add(
609-
self.a4_pre_rotation[:, 2][self.dAtoms_needs_update], a4shift,
599+
self.a4_pre_rotation[:, 2][self.dAtoms_needs_update], a4shift
610600
) # so a2 at origin
611601

612602
# build rz rotation matrix for dihedral angle
@@ -1649,7 +1639,7 @@ def clear_transforms(self):
16491639
d.rcst = None
16501640

16511641
def assemble(
1652-
self, resetLocation: bool = False, verbose: bool = False,
1642+
self, resetLocation: bool = False, verbose: bool = False
16531643
) -> Union[Dict["AtomKey", numpy.array], Dict[HKT, numpy.array], None]:
16541644
"""Compute atom coordinates for this residue from internal coordinates.
16551645
@@ -2841,11 +2831,7 @@ def __init__(self, *args: Union[List["AtomKey"], HKT], **kwargs: str) -> None:
28412831

28422832
if "len12" in kwargs:
28432833
self.lal = numpy.array(
2844-
(
2845-
float(kwargs["len12"]),
2846-
float(kwargs["angle"]),
2847-
float(kwargs["len23"]),
2848-
)
2834+
(float(kwargs["len12"]), float(kwargs["angle"]), float(kwargs["len23"]))
28492835
)
28502836
else:
28512837
self.lal = numpy.zeros(3)

Bio/SeqIO/FastaIO.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def iterate(self, handle):
203203
# Should we use SeqRecord default for no ID?
204204
first_word = ""
205205
yield SeqRecord(
206-
Seq(sequence), id=first_word, name=first_word, description=title,
206+
Seq(sequence), id=first_word, name=first_word, description=title
207207
)
208208

209209

@@ -239,7 +239,7 @@ def iterate(self, handle):
239239
# Should we use SeqRecord default for no ID?
240240
first_word = ""
241241
yield SeqRecord(
242-
Seq(sequence), id=first_word, name=first_word, description=title,
242+
Seq(sequence), id=first_word, name=first_word, description=title
243243
)
244244

245245

Bio/SeqIO/PirIO.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def iterate(self, handle):
171171

172172
# Return the record and then continue...
173173
record = SeqRecord(
174-
Seq(seq[:-1]), id=identifier, name=identifier, description=description,
174+
Seq(seq[:-1]), id=identifier, name=identifier, description=description
175175
)
176176
record.annotations["PIR-type"] = pir_type
177177
if _pir_mol_type[pir_type]:

Bio/SeqIO/SffIO.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ def iterate(self, handle):
10441044
# the index_offset so we can skip extra handle.tell() calls:
10451045
index_offset = 0
10461046
yield _sff_read_seq_record(
1047-
handle, number_of_flows_per_read, flow_chars, key_sequence, trim,
1047+
handle, number_of_flows_per_read, flow_chars, key_sequence, trim
10481048
)
10491049
_check_eof(handle, index_offset, index_length)
10501050

Bio/SeqIO/_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def get(self, offset):
141141
handle = self._handle
142142
handle.seek(offset)
143143
return SeqIO.SffIO._sff_read_seq_record(
144-
handle, self._flows_per_read, self._flow_chars, self._key_sequence,
144+
handle, self._flows_per_read, self._flow_chars, self._key_sequence
145145
)
146146

147147
def get_raw(self, offset):

Bio/codonalign/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _get_aa_regex(codon_table, stop="*", unknown="X"):
246246

247247

248248
def _check_corr(
249-
pro, nucl, gap_char, codon_table, complete_protein=False, anchor_len=10,
249+
pro, nucl, gap_char, codon_table, complete_protein=False, anchor_len=10
250250
):
251251
"""Check if the nucleotide can be translated into the protein (PRIVATE).
252252
@@ -571,7 +571,7 @@ def get_aa_from_codonre(re_aa):
571571

572572

573573
def _get_codon_rec(
574-
pro, nucl, span_mode, gap_char, codon_table, complete_protein=False, max_score=10,
574+
pro, nucl, span_mode, gap_char, codon_table, complete_protein=False, max_score=10
575575
):
576576
"""Generate codon alignment based on regular re match (PRIVATE).
577577

Bio/codonalign/codonalignment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __str__(self):
6565
rows = len(self._records)
6666
lines = [
6767
"CodonAlignment with %i rows and %i columns (%i codons)"
68-
% (rows, self.get_alignment_length(), self.get_aln_length(),)
68+
% (rows, self.get_alignment_length(), self.get_aln_length())
6969
]
7070

7171
if rows <= 60:

Bio/codonalign/codonseq.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,7 @@ def _get_codon_list(codonseq):
276276
return codon_lst
277277

278278

279-
def cal_dn_ds(
280-
codon_seq1, codon_seq2, method="NG86", codon_table=None, k=1, cfreq=None,
281-
):
279+
def cal_dn_ds(codon_seq1, codon_seq2, method="NG86", codon_table=None, k=1, cfreq=None):
282280
"""Calculate dN and dS of the given two sequences.
283281
284282
Available methods:

BioSQL/BioSeq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def _retrieve_annotations(adaptor, primary_id, taxon_id):
321321

322322
def _retrieve_alphabet(adaptor, primary_id):
323323
results = adaptor.execute_and_fetchall(
324-
"SELECT alphabet FROM biosequence WHERE bioentry_id = %s", (primary_id,),
324+
"SELECT alphabet FROM biosequence WHERE bioentry_id = %s", (primary_id,)
325325
)
326326
assert len(results) == 1
327327
alphabets = results[0]

Scripts/PDB/hsexpo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
default="HSEb",
4444
)
4545
ap.add_argument(
46-
"-o", "--out", dest="outfile", help="output to PDB file (B factor=exposure)",
46+
"-o", "--out", dest="outfile", help="output to PDB file (B factor=exposure)"
4747
)
4848
ap.add_argument(
4949
"-r",

Tests/common_BioSQL.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,7 @@ def test_convert(self):
495495
def test_addition(self):
496496
"""Check can add Seq objects from BioSQL together."""
497497
test_seq = self.item.seq
498-
for other in [
499-
Seq("ACGT"),
500-
MutableSeq("ACGT"),
501-
"ACGT",
502-
test_seq,
503-
]:
498+
for other in [Seq("ACGT"), MutableSeq("ACGT"), "ACGT", test_seq]:
504499
test = test_seq + other
505500
self.assertEqual(test, str(test_seq) + str(other))
506501
self.assertIsInstance(test, Seq)

Tests/pairwise2_testCases.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -855,10 +855,7 @@ def test_clean_alignments(self):
855855
("ACCGT", "AC-G-", 3.0, 0, 4),
856856
("ACCGT", "A-CG-", 3.0, 0, 4),
857857
]
858-
expected = [
859-
("ACCGT", "AC-G-", 3.0, 0, 4),
860-
("ACCGT", "A-CG-", 3.0, 0, 4),
861-
]
858+
expected = [("ACCGT", "AC-G-", 3.0, 0, 4), ("ACCGT", "A-CG-", 3.0, 0, 4)]
862859
result = pairwise2._clean_alignments(alns)
863860
self.assertEqual(expected, result)
864861

Tests/test_AlignIO.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def test_reading_alignments_nexus2(self):
451451
self.check_alignment_rows(
452452
alignment,
453453
[
454-
("Aegotheles", "AAAAAGGCATTGTGGTGGGAAT",),
454+
("Aegotheles", "AAAAAGGCATTGTGGTGGGAAT"),
455455
("Aerodramus", "?????????TTGTGGTGGGAAT"),
456456
],
457457
)

0 commit comments

Comments
 (0)