Skip to content

Commit

Permalink
fixing formating black
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonkoehn committed Sep 10, 2024
1 parent 67523bb commit 40ca944
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/usefulgnom/serialize/total_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@
import gzip


def load_convert_total(
coverage_path : str,
pos : list[str]
) -> pd.DataFrame:
def load_convert_total(coverage_path: str, pos: list[str]) -> pd.DataFrame:
"""
Load and convert the total coverage data.
"""

with gzip.open(coverage_path, 'rt') as file:

with gzip.open(coverage_path, "rt") as file:
# Use pd.read_csv to read the file
df = pd.read_csv(file, delimiter='\t', usecols=[1, 2], header=None, index_col=None)[1:]
df = pd.read_csv(
file, delimiter="\t", usecols=[1, 2], header=None, index_col=None
)[1:]

df.columns = ['pos', 'coverage']
df.columns = ["pos", "coverage"]

# extract coverage for specified position and nt
# record columns for df
column = []
for position in pos:
coverage = (df.loc[df['pos'] == position, 'coverage'])
coverage = df.loc[df["pos"] == position, "coverage"]

column.append(coverage.iloc[0])

df_out = pd.DataFrame(column)

return df_out
return df_out

0 comments on commit 40ca944

Please sign in to comment.