Skip to content

Commit

Permalink
Fix main function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmig committed Oct 3, 2023
1 parent 70e432f commit a899036
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions workflow/scripts/weighted_distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ def build_cache(df: pd.DataFrame, reference: Seq):
return cache


def buildm(df: pd.DataFrame, sample_names: list, cache: dict) -> pd.DataFrame:
def buildm(positions: List[int], sample_names: list, cache: dict) -> pd.DataFrame:
# Compute matrix
logging.debug(f"Filling distance matrix")
nsamples = len(sample_names)
positions = df["POS"].astype("Int64").unique().tolist()
m = np.zeros((nsamples, nsamples), np.float64)
for i, sample1 in enumerate(sample_names):
for j, sample2 in enumerate(sample_names):
Expand Down Expand Up @@ -140,10 +139,11 @@ def main():

# Pre-compute one-sample measurements
logging.info(f"Caching computations")
cache = build_cache(df, ancestor.seq)
cache = build_cache(variant_table, ancestor.seq)

logging.info(f"Calculating matrix")
df = buildm(variant_table, sample_names, cache)
positions = variant_table["POS"].astype("Int64").unique().tolist()
df = buildm(positions, sample_names, cache)

logging.info("Writing results")
df.to_csv(snakemake.output.distances)
Expand Down

0 comments on commit a899036

Please sign in to comment.