diff --git a/src/usefulgnom/serialize/total_coverage.py b/src/usefulgnom/serialize/total_coverage.py index be999ca..ed2860a 100644 --- a/src/usefulgnom/serialize/total_coverage.py +++ b/src/usefulgnom/serialize/total_coverage.py @@ -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 \ No newline at end of file + return df_out