# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Compute uni-mutational fractions

# %run "Header.ipynb"
# %run "GeneUtils.ipynb"

import pileup
seq2pos2pileup = pileup.load()

# ## Compute uni-mutational fraction for each position in the genome
#
# ... Rather than write it out again here, just see the paper appendix on this

# +
seq2pos2f = {}

for seq in SEQS:
    seq2pos2f[seq] = {}
    for pos in range(1, seq2len[seq] + 1):
        mismatch_cts = pileup.get_mismatch_cts(seq2pos2pileup[seq][pos])
        sum_mismatches = sum(mismatch_cts)
        if sum_mismatches > 0:
            f = max(mismatch_cts) / sum_mismatches
            seq2pos2f[seq][pos] = f
        else:
            # There are no non-matches, so N2, N3, and N4 are all 0. This means that f is undefined
            # (since it'd be 0 / 0).
            seq2pos2f[seq][pos] = None

StarcoderdataJupyterScriptsDedupFiltered