Skip to content

Commit 578b685

Browse files
committed
revert reformatting
1 parent 4f85bc5 commit 578b685

16 files changed

+215
-53
lines changed

fgpyo/fasta/builder.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ class ContigBuilder:
9292
"""
9393

9494
def __init__(
95-
self, name: str, assembly: str, species: str,
95+
self,
96+
name: str,
97+
assembly: str,
98+
species: str,
9699
):
97100
self.name = name
98101
self.assembly = assembly
@@ -144,7 +147,10 @@ class FastaBuilder:
144147
"""
145148

146149
def __init__(
147-
self, assembly: str = "testassembly", species: str = "testspecies", line_length: int = 80,
150+
self,
151+
assembly: str = "testassembly",
152+
species: str = "testspecies",
153+
line_length: int = 80,
148154
):
149155
self.assembly: str = assembly
150156
self.species: str = species
@@ -156,7 +162,10 @@ def __getitem__(self, key: str) -> ContigBuilder:
156162
return self.__contig_builders[key]
157163

158164
def add(
159-
self, name: str, assembly: Optional[str] = None, species: Optional[str] = None,
165+
self,
166+
name: str,
167+
assembly: Optional[str] = None,
168+
species: Optional[str] = None,
160169
) -> ContigBuilder:
161170
"""
162171
Creates and returns a new ContigBuilder for a contig with the provided name.
@@ -181,7 +190,10 @@ def add(
181190
self.__contig_builders[name] = builder
182191
return builder
183192

184-
def to_file(self, path: Path,) -> None:
193+
def to_file(
194+
self,
195+
path: Path,
196+
) -> None:
185197
"""
186198
Writes out the set of accumulated contigs to a FASTA file at the `path` given.
187199
Also generates the accompanying fasta index file (`.fa.fai`) and sequence

fgpyo/fasta/tests/test_builder.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ def test_bases_length_from_ContigBuilder_add_default() -> None:
2525

2626

2727
@pytest.mark.parametrize(
28-
"name, bases, times, length_bases", [("chr1", "AAA", 3, 9), ("chr2", "TTT", 10, 30),],
28+
"name, bases, times, length_bases",
29+
[
30+
("chr1", "AAA", 3, 9),
31+
("chr2", "TTT", 10, 30),
32+
],
2933
)
3034
def test_bases_length_from_ContigBuilder_add(
31-
name: str, bases: str, times: int, length_bases: int,
35+
name: str,
36+
bases: str,
37+
times: int,
38+
length_bases: int,
3239
) -> None:
3340
"""Checks that the number of bases in each contig is correct"""
3441
builder = FastaBuilder()
@@ -53,10 +60,17 @@ def test_contig_dict_is_not_accessable() -> None:
5360

5461
@pytest.mark.parametrize(
5562
"name, bases, times, expected",
56-
[("chr3", "AAA a", 3, ("AAAA" * 3)), ("chr2", "TT T gT", 10, ("TTTGT" * 10)),],
63+
[
64+
("chr3", "AAA a", 3, ("AAAA" * 3)),
65+
("chr2", "TT T gT", 10, ("TTTGT" * 10)),
66+
],
5767
)
5868
def test_bases_string_from_ContigBuilder_add(
59-
name: str, bases: str, times: int, expected: str, tmp_path: Path,
69+
name: str,
70+
bases: str,
71+
times: int,
72+
expected: str,
73+
tmp_path: Path,
6074
) -> None:
6175
"""
6276
Reads bases back from fasta and checks that extra spaces are removed and bases are uppercase

fgpyo/io/tests/test_io.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,33 @@ def test_assert_path_is_writeable_pass() -> None:
8484

8585

8686
@pytest.mark.parametrize(
87-
"suffix, expected", [(".gz", io.TextIOWrapper), (".fa", io.TextIOWrapper),],
87+
"suffix, expected",
88+
[
89+
(".gz", io.TextIOWrapper),
90+
(".fa", io.TextIOWrapper),
91+
],
8892
)
89-
def test_reader(suffix: str, expected: Any,) -> None:
93+
def test_reader(
94+
suffix: str,
95+
expected: Any,
96+
) -> None:
9097
"""Tests fgpyo.io.to_reader"""
9198
with NamedTemp(suffix=suffix, mode="r", delete=True) as read_file:
9299
with fio.to_reader(path=Path(read_file.name)) as reader:
93100
assert isinstance(reader, expected)
94101

95102

96103
@pytest.mark.parametrize(
97-
"suffix, expected", [(".gz", io.TextIOWrapper), (".fa", io.TextIOWrapper),],
104+
"suffix, expected",
105+
[
106+
(".gz", io.TextIOWrapper),
107+
(".fa", io.TextIOWrapper),
108+
],
98109
)
99-
def test_writer(suffix: str, expected: Any,) -> None:
110+
def test_writer(
111+
suffix: str,
112+
expected: Any,
113+
) -> None:
100114
"""Tests fgpyo.io.to_writer()"""
101115
with NamedTemp(suffix=suffix, mode="w", delete=True) as write_file:
102116
with fio.to_writer(path=Path(write_file.name)) as writer:
@@ -107,7 +121,10 @@ def test_writer(suffix: str, expected: Any,) -> None:
107121
"suffix, list_to_write",
108122
[(".txt", ["Test with a flat file", 10]), (".gz", ["Test with a gzip file", 10])],
109123
)
110-
def test_read_and_write_lines(suffix: str, list_to_write: List[Any],) -> None:
124+
def test_read_and_write_lines(
125+
suffix: str,
126+
list_to_write: List[Any],
127+
) -> None:
111128
"""Test fgpyo.fio.read_lines and write_lines"""
112129
with NamedTemp(suffix=suffix, mode="w", delete=True) as read_file:
113130
fio.write_lines(path=Path(read_file.name), lines_to_write=list_to_write)

fgpyo/sam/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,11 @@ def all_recs(self) -> Iterator[AlignedSegment]:
863863
for rec in recs:
864864
yield rec
865865

866-
def write_to(self, writer: SamFile, primary_only: bool = False,) -> None:
866+
def write_to(
867+
self,
868+
writer: SamFile,
869+
primary_only: bool = False,
870+
) -> None:
867871
"""Write the records associated with the template to file.
868872
869873
Args:
@@ -879,7 +883,11 @@ def write_to(self, writer: SamFile, primary_only: bool = False,) -> None:
879883
for rec in rec_iter:
880884
writer.write(rec)
881885

882-
def set_tag(self, tag: str, value: Union[str, int, float, None],) -> None:
886+
def set_tag(
887+
self,
888+
tag: str,
889+
value: Union[str, int, float, None],
890+
) -> None:
883891
"""Add a tag to all records associated with the template.
884892
885893
Setting a tag to `None` will remove the tag.

fgpyo/sam/tests/test_sam.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def test_sam_file_open_writing(
154154

155155

156156
def test_sam_file_open_writing_header_keyword(
157-
expected_records: List[pysam.AlignedSegment], header_dict: AlignmentHeader, tmp_path: Path,
157+
expected_records: List[pysam.AlignedSegment],
158+
header_dict: AlignmentHeader,
159+
tmp_path: Path,
158160
) -> None:
159161
# Use SamWriter
160162
# use header as a keyword argument

fgpyo/sam/tests/test_template_iterator.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def test_to_templates() -> None:
7373
assert len(list(template2.all_recs())) == 2
7474

7575

76-
def test_write_template(tmp_path: Path,) -> None:
76+
def test_write_template(
77+
tmp_path: Path,
78+
) -> None:
7779
builder = SamBuilder()
7880
template = Template.build(
7981
[

fgpyo/tests/test_read_structure.py

+37-5
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,24 @@ def _S(off: int, len: int) -> ReadSegment:
3131
("1M", (_M(0, 1),)),
3232
("1S", (_S(0, 1),)),
3333
("101T", (_T(0, 101),)),
34-
("5B101T", (_B(0, 5), _T(5, 101),),),
34+
(
35+
"5B101T",
36+
(
37+
_B(0, 5),
38+
_T(5, 101),
39+
),
40+
),
3541
("123456789T", (_T(0, 123456789),)),
36-
("10T10B10B10S10M", (_T(0, 10), _B(10, 10), _B(20, 10), _S(30, 10), _M(40, 10),),),
42+
(
43+
"10T10B10B10S10M",
44+
(
45+
_T(0, 10),
46+
_B(10, 10),
47+
_B(20, 10),
48+
_S(30, 10),
49+
_M(40, 10),
50+
),
51+
),
3752
],
3853
)
3954
def test_read_structure_from_string(string: str, segments: Tuple[ReadSegment, ...]) -> None:
@@ -43,8 +58,24 @@ def test_read_structure_from_string(string: str, segments: Tuple[ReadSegment, ..
4358
@pytest.mark.parametrize(
4459
"string,segments",
4560
[
46-
("75T 8B 8B 75T", (_T(0, 75), _B(75, 8), _B(83, 8), _T(91, 75),),),
47-
(" 75T 8B 8B 75T ", (_T(0, 75), _B(75, 8), _B(83, 8), _T(91, 75),),),
61+
(
62+
"75T 8B 8B 75T",
63+
(
64+
_T(0, 75),
65+
_B(75, 8),
66+
_B(83, 8),
67+
_T(91, 75),
68+
),
69+
),
70+
(
71+
" 75T 8B 8B 75T ",
72+
(
73+
_T(0, 75),
74+
_B(75, 8),
75+
_B(83, 8),
76+
_T(91, 75),
77+
),
78+
),
4879
],
4980
)
5081
def test_read_structure_from_string_with_whitespace(
@@ -67,7 +98,8 @@ def test_read_structure_variable_once_and_only_once_last_segment_ok(
6798

6899

69100
@pytest.mark.parametrize(
70-
"string", ["++M", "5M++T", "5M70+T", "+M+T", "+M70T"],
101+
"string",
102+
["++M", "5M++T", "5M70+T", "+M+T", "+M70T"],
71103
)
72104
def test_read_structure_variable_once_and_only_once_last_segment_exception(string: str) -> None:
73105
with pytest.raises(Exception):

fgpyo/util/inspect.py

+32-7
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def split_at_given_level(
6868

6969

7070
def _get_parser(
71-
cls: Type, type_: TypeAlias, parsers: Optional[Dict[type, Callable[[str], Any]]] = None,
71+
cls: Type,
72+
type_: TypeAlias,
73+
parsers: Optional[Dict[type, Callable[[str], Any]]] = None,
7274
) -> partial:
7375
"""Attempts to find a parser for a provided type.
7476
@@ -112,7 +114,11 @@ def get_parser() -> partial:
112114
assert (
113115
len(subtypes) == 1
114116
), "Lists are allowed only one subtype per PEP specification!"
115-
subtype_parser = _get_parser(cls, subtypes[0], parsers,)
117+
subtype_parser = _get_parser(
118+
cls,
119+
subtypes[0],
120+
parsers,
121+
)
116122
return functools.partial(
117123
lambda s: list(
118124
[]
@@ -128,7 +134,11 @@ def get_parser() -> partial:
128134
assert (
129135
len(subtypes) == 1
130136
), "Sets are allowed only one subtype per PEP specification!"
131-
subtype_parser = _get_parser(cls, subtypes[0], parsers,)
137+
subtype_parser = _get_parser(
138+
cls,
139+
subtypes[0],
140+
parsers,
141+
)
132142
return functools.partial(
133143
lambda s: set(
134144
set({})
@@ -141,7 +151,12 @@ def get_parser() -> partial:
141151
)
142152
elif typing.get_origin(type_) == tuple:
143153
subtype_parsers = [
144-
_get_parser(cls, subtype, parsers,) for subtype in typing.get_args(type_)
154+
_get_parser(
155+
cls,
156+
subtype,
157+
parsers,
158+
)
159+
for subtype in typing.get_args(type_)
145160
]
146161

147162
def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
@@ -170,8 +185,16 @@ def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
170185
len(subtypes) == 2
171186
), "Dict object must have exactly 2 subtypes per PEP specification!"
172187
(key_parser, val_parser) = (
173-
_get_parser(cls, subtypes[0], parsers,),
174-
_get_parser(cls, subtypes[1], parsers,),
188+
_get_parser(
189+
cls,
190+
subtypes[0],
191+
parsers,
192+
),
193+
_get_parser(
194+
cls,
195+
subtypes[1],
196+
parsers,
197+
),
175198
)
176199

177200
def dict_parse(dict_string: str) -> Dict[Any, Any]:
@@ -231,7 +254,9 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
231254

232255

233256
def attr_from(
234-
cls: Type, kwargs: Dict[str, str], parsers: Optional[Dict[type, Callable[[str], Any]]] = None,
257+
cls: Type,
258+
kwargs: Dict[str, str],
259+
parsers: Optional[Dict[type, Callable[[str], Any]]] = None,
235260
) -> Any:
236261
"""Builds an attr class from key-word arguments
237262

fgpyo/util/logging.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def __exit__(
125125
return False
126126

127127
def record(
128-
self, reference_name: Optional[str] = None, position: Optional[int] = None,
128+
self,
129+
reference_name: Optional[str] = None,
130+
position: Optional[int] = None,
129131
) -> bool:
130132
"""Record an item at a given genomic coordinate.
131133
Args:
@@ -145,7 +147,10 @@ def record(
145147
else:
146148
return False
147149

148-
def record_alignment(self, rec: AlignedSegment,) -> bool:
150+
def record_alignment(
151+
self,
152+
rec: AlignedSegment,
153+
) -> bool:
149154
"""Correctly record pysam.AlignedSegments (zero-based coordinates).
150155
151156
Args:
@@ -159,7 +164,11 @@ def record_alignment(self, rec: AlignedSegment,) -> bool:
159164
else:
160165
return self.record(rec.reference_name, rec.reference_start + 1)
161166

162-
def _log(self, refname: Optional[str] = None, position: Optional[int] = None,) -> None:
167+
def _log(
168+
self,
169+
refname: Optional[str] = None,
170+
position: Optional[int] = None,
171+
) -> None:
163172
"""Helper method to print the log message.
164173
165174
Args:
@@ -178,7 +187,9 @@ def _log(self, refname: Optional[str] = None, position: Optional[int] = None,) -
178187

179188
self.printer(f"{self.verb} {self.count:,d} {self.noun}: {coordinate}")
180189

181-
def log_last(self,) -> bool:
190+
def log_last(
191+
self,
192+
) -> bool:
182193
"""Force logging the last record, for example when progress has completed."""
183194
if self._count_mod_unit != 0:
184195
self._log(refname=self._last_reference_name, position=self._last_position)

fgpyo/util/tests/test_logging.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ def test_progress_logger_as_context_manager() -> None:
4343

4444

4545
@pytest.mark.parametrize(
46-
"record", [(r1_mapped_named), (r2_unmapped_named), (r2_unmapped_un_named),],
46+
"record",
47+
[
48+
(r1_mapped_named),
49+
(r2_unmapped_named),
50+
(r2_unmapped_un_named),
51+
],
4752
)
4853
def test_record_alignment_mapped_record(record: pysam.AlignedSegment) -> None:
4954
# Define instance of ProgressLogger

0 commit comments

Comments
 (0)