Skip to content

Commit bf765c8

Browse files
committed
Reformat Python files
1 parent baa4123 commit bf765c8

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

flatgfa-py/examples/matrix.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import pathlib
2-
import flatgfa
32
from itertools import islice
3+
4+
import flatgfa
5+
6+
47
def iter_bits_ones_dash(path, chunk_bytes: int = 64 * 1024):
58
ws = b" \t\r\n\v\f"
69
with open(path, "rb") as f:
@@ -11,12 +14,15 @@ def iter_bits_ones_dash(path, chunk_bytes: int = 64 * 1024):
1114
for b in chunk:
1215
if b in ws:
1316
continue
14-
if b == ord('1'):
17+
if b == ord("1"):
1518
yield True
16-
elif b == ord('0'):
19+
elif b == ord("0"):
1720
yield False
1821
else:
19-
raise ValueError(f"Invalid character in file: {chr(b)!r} (expected '1' or '0')")
22+
raise ValueError(
23+
f"Invalid character in file: {chr(b)!r} (expected '1' or '0')"
24+
)
25+
2026

2127
def compare_row_to_file(row_bits, path) -> tuple[bool, int | None]:
2228
n = len(row_bits)
@@ -34,6 +40,7 @@ def compare_row_to_file(row_bits, path) -> tuple[bool, int | None]:
3440
raise ValueError(f"File ended early: got {i} bits, expected {n}.")
3541
return True, None
3642

43+
3744
TEST_DIR = pathlib.Path(__file__).parent
3845
TEST_GFA = TEST_DIR / "./matrix_gaf_folder/Chr3.gfa"
3946
GAF_DIR = (TEST_DIR / "./matrix_gaf_folder").resolve()
@@ -48,7 +55,7 @@ def compare_row_to_file(row_bits, path) -> tuple[bool, int | None]:
4855
# print("OK (all columns match)" if ok else f"Mismatch at column {where}")
4956
FIRST_N = 100
5057
for gaf_path, row in zip(gaf, pangenotype_matrix):
51-
row01 = [int(b) for b in row]
58+
row01 = [int(b) for b in row]
5259
# print(pathlib.Path(gaf_path).name, *row01)
5360
first_bits = islice(row, FIRST_N)
54-
print(pathlib.Path(gaf_path).name, *map(int, first_bits))
61+
print(pathlib.Path(gaf_path).name, *map(int, first_bits))

flatgfa-py/test/test_gaf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pathlib
2-
import flatgfa
2+
33
import numpy as np
44

5+
import flatgfa
6+
57
TEST_DIR = pathlib.Path(__file__).parent
68
TEST_GFA = TEST_DIR / "tiny.gfa"
79
TEST_GAF = TEST_DIR / "tiny.gaf"
@@ -26,10 +28,12 @@ def test_gaf_ranges():
2628
[(7, 8), (0, 18), (0, 0)],
2729
]
2830

31+
2932
def test_construct_pangenotype_matrix():
3033
gfa = flatgfa.parse_bytes(TEST_GFA.read_bytes())
3134
pangenotype_matrix = gfa.make_pangenotype_matrix([(str(TEST_GAF))])
32-
assert pangenotype_matrix == [[True, True,True,True]]
35+
assert pangenotype_matrix == [[True, True, True, True]]
36+
3337

3438
def test_pangenotype_regression():
3539
gfa = flatgfa.parse_bytes(TEST_GFA.read_bytes())

0 commit comments

Comments
 (0)