Skip to content

Commit 7287479

Browse files
committed
black formatting
1 parent 9272b71 commit 7287479

File tree

6 files changed

+72
-52
lines changed

6 files changed

+72
-52
lines changed

src/decompose_ref.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414

1515
import polars as pl
@@ -59,12 +59,12 @@ def decompose_gtf(ref_dir: str, gtf_ref: str) -> None:
5959
]
6060

6161
full_df = pl.read_csv(
62-
gtf_ref,
63-
has_header=False,
64-
separator="\t",
65-
skip_rows=5,
62+
gtf_ref,
63+
has_header=False,
64+
separator="\t",
65+
skip_rows=5,
6666
new_columns=col_names,
67-
schema_overrides={"chr": pl.String}
67+
schema_overrides={"chr": pl.String},
6868
)
6969

7070
for name, group in full_df.group_by(["feature"]):

src/gene2peak.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414

1515
import pandas as pd
@@ -115,7 +115,7 @@ def find_nearest(
115115
num_features,
116116
True,
117117
None,
118-
0.2
118+
0.2,
119119
),
120120
]
121121
)

src/peak2gene.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414

1515
import pandas as pd
@@ -35,7 +35,7 @@ def peak2gene(
3535
down_bound: int = None,
3636
consensus: bool = False,
3737
drop_columns: bool = False,
38-
view_window: float = 0.2
38+
view_window: float = 0.2,
3939
) -> None:
4040
"""
4141
Find the nearest genes for a given list of peaks.
@@ -67,7 +67,14 @@ def peak2gene(
6767
peaks = process_peaks(peak_file, peak_type, option, boundary, consensus)
6868
decomposed_peaks = decompose_features(peaks)
6969
output = find_nearest(
70-
decomposed_peaks, species_genome, num_features, ref_dir, up_bound, down_bound, drop_columns, view_window
70+
decomposed_peaks,
71+
species_genome,
72+
num_features,
73+
ref_dir,
74+
up_bound,
75+
down_bound,
76+
drop_columns,
77+
view_window,
7178
)
7279
if output_type == "xlsx":
7380
write_to_excel(output, output_name, out_dir)
@@ -85,7 +92,7 @@ def find_nearest(
8592
up_bound: int,
8693
down_bound: int,
8794
drop_columns: bool,
88-
view_window: float
95+
view_window: float,
8996
) -> pd.DataFrame:
9097
"""
9198
Find the nearest genes for a given list of peaks. Place these in a Pandas DataFrame.
@@ -111,9 +118,7 @@ def find_nearest(
111118
output = pl.DataFrame()
112119
for key in decomposed_peaks.keys():
113120
try:
114-
starts = pl.read_csv(
115-
os.path.join(ref_dir, "gene", key) + "_start.csv"
116-
)
121+
starts = pl.read_csv(os.path.join(ref_dir, "gene", key) + "_start.csv")
117122
ends = pl.read_csv(os.path.join(ref_dir, "gene", key) + "_end.csv")
118123
output = pl.concat(
119124
[
@@ -128,7 +133,7 @@ def find_nearest(
128133
num_features,
129134
drop_columns,
130135
species_genome,
131-
view_window
136+
view_window,
132137
),
133138
]
134139
)

src/process_features.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414
import polars as pl
1515
import numpy as np
@@ -25,7 +25,7 @@ def get_nearest_features(
2525
k: int,
2626
drop_columns: bool,
2727
species_genome: str,
28-
view_window: float = 0.2
28+
view_window: float = 0.2,
2929
) -> pl.DataFrame:
3030
"""
3131
Determine the nearest k features to each peak in roi using the reference
@@ -182,7 +182,15 @@ def get_nearest_features(
182182

183183
index += 1
184184

185-
return gen_return_roi(return_roi, feature, features_to_add, dists_to_add, k, species_genome, view_window)
185+
return gen_return_roi(
186+
return_roi,
187+
feature,
188+
features_to_add,
189+
dists_to_add,
190+
k,
191+
species_genome,
192+
view_window,
193+
)
186194

187195

188196
def constrain_features(
@@ -309,7 +317,7 @@ def gen_return_roi(
309317
dists_to_add: dict,
310318
k: int,
311319
species_genome: str,
312-
view_window: float = 0.2
320+
view_window: float = 0.2,
313321
) -> pl.DataFrame:
314322
"""
315323
Generates Polars DataFrame containing peak information, the nearest k features to that peak,
@@ -341,16 +349,21 @@ def gen_return_roi(
341349
),
342350
]
343351
)
344-
352+
345353
if species_genome:
346-
species_genome_col = get_ucsc_browser_urls(species_genome, return_roi, view_window)
354+
species_genome_col = get_ucsc_browser_urls(
355+
species_genome, return_roi, view_window
356+
)
347357
return_roi = return_roi.with_columns(
348358
pl.Series("ucsc_genome_browser_urls", species_genome_col)
349359
)
350360

351361
return return_roi
352362

353-
def get_ucsc_browser_urls(species_genome: str, df: pl.DataFrame, view_window: float=0.2) -> list:
363+
364+
def get_ucsc_browser_urls(
365+
species_genome: str, df: pl.DataFrame, view_window: float = 0.2
366+
) -> list:
354367
"""
355368
Generates UCSC Genome Browser URLs for each peak in the DataFrame.
356369
@@ -364,10 +377,12 @@ def get_ucsc_browser_urls(species_genome: str, df: pl.DataFrame, view_window: fl
364377
Outputs:
365378
None
366379
"""
367-
base_url = "https://genome.ucsc.edu/cgi-bin/hgTracks?db=" + species_genome + "&position="
380+
base_url = (
381+
"https://genome.ucsc.edu/cgi-bin/hgTracks?db=" + species_genome + "&position="
382+
)
368383
highlight = "&highlight="
369384
urls = []
370-
385+
371386
for row in df.iter_rows(named=True):
372387
chr = row["chr"]
373388
start = row["start"]
@@ -377,7 +392,7 @@ def get_ucsc_browser_urls(species_genome: str, df: pl.DataFrame, view_window: fl
377392
window_end = int(end + peak_length / ((1 - view_window) / 2))
378393
url = f"{base_url}chr{chr}:{window_start}-{window_end}{highlight}chr{chr}:{start}-{end}"
379394
urls.append(url)
380-
395+
381396
return urls
382397

383398

src/process_input.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414

1515
import polars as pl

src/write_output.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# ------------------------------------------------------------------------------
2-
# __ _____ __
2+
# __ _____ __
33
# ____ ___ ____ _/ /__/ ___/_________ __ __/ /_
44
# / __ \/ _ \/ __ `/ //_/\__ \/ ___/ __ \/ / / / __/
5-
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6-
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7-
# /_/
5+
# / /_/ / __/ /_/ / ,< ___/ / /__/ /_/ / /_/ / /_
6+
# / .___/\___/\__,_/_/|_|/____/\___/\____/\__,_/\__/
7+
# /_/
88
#
99
# Copyrigh 2025 GNU AFFERO GENERAL PUBLIC LICENSE
1010
# Alexander L. Lin, Lana A. Cartailler, Jean-Philippe Cartailler
1111
# https://github.com/vandydata/peakScout
12-
#
12+
#
1313
# ------------------------------------------------------------------------------
1414

1515
import pandas as pd

0 commit comments

Comments
 (0)