Skip to content

Commit

Permalink
merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
maxibor committed May 16, 2021
2 parents 019f9ad + 8612707 commit cb95935
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions pydamage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def cli(ctx, outdir):
@click.option(
"-f", "--force", is_flag=True, help="Force overwriting of results directory"
)
@click.option(
"-r",
"--count_reverse",
is_flag=True,
help="Also count GtoA mutations in reverse reads",
)
@click.option(
"-g",
"--group",
Expand Down
4 changes: 2 additions & 2 deletions pydamage/damage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __init__(self, reference, al_handle, wlen):
al_handle(pysam.AlignmentFile)
wlen (int): window length
"""
self.alignments = al_handle.fetch(reference)
self.reference = reference
Expand Down Expand Up @@ -174,7 +173,7 @@ def check_model_fit(model_dict, wlen, verbose):
return model_dict


def test_damage(ref, bam, mode, wlen, show_al, process, verbose):
def test_damage(ref, bam, mode, wlen, show_al, count_reverse, process, verbose):
"""Prepare data and run LRtest to test for damage
Args:
Expand All @@ -183,6 +182,7 @@ def test_damage(ref, bam, mode, wlen, show_al, process, verbose):
mode (str): opening mode of alignment file
wlen (int): window length
show_al (bool): Show alignment representations
count_reverse(bool): count reverse alignments as well
process (int): Number of process for parallelization
verbose (bool): Run in verbose mode
Returns:
Expand Down
7 changes: 5 additions & 2 deletions pydamage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@ def pydamage_analyze(
process=1,
outdir="",
plot=False,
count_reverse=False,
verbose=False,
force=False,
group=False,
):

if group:
pydamage_analyze_group(
bam, wlen, show_al, process, outdir, plot, verbose, force
bam, wlen, show_al, count_reverse, process, outdir, plot, verbose, force
)

else:
pydamage_analyze_multi(
bam, wlen, show_al, process, outdir, plot, verbose, force
bam, wlen, show_al, count_reverse, process, outdir, plot, verbose, force
)


def pydamage_analyze_multi(
bam,
wlen=30,
show_al=False,
count_reverse=False,
process=1,
outdir="",
plot=False,
Expand All @@ -62,6 +64,7 @@ def pydamage_analyze_multi(
"""
if verbose:
print(f"Pydamage version {__version__}\n")
print("force", force)
utils.makedir(outdir, force=force)

if not verbose:
Expand Down
2 changes: 2 additions & 0 deletions pydamage/model_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ def fit_models(
# Likelihood for model A - Damage Model
binom_p_damage = model_A.fit(c_sites, **optim_A)
LA = binom.logpmf(k=binom_k, n=binom_n, p=binom_p_damage)
sigma_damage = np.sqrt(binom_n * binom_p_damage * 1 - binom_p_damage)

# Likelihood for model B - Null Model
binom_p_null = model_B.fit(c_sites, **optim_B)
LB = binom.logpmf(k=binom_k, n=binom_n, p=binom_p_null)
sigma_null = np.sqrt(binom_n * binom_p_null * 1 - binom_p_null)

# Difference of number of paramters between model A and model B
pdiff = len(model_A.kwds) - len(model_B.kwds)
Expand Down

0 comments on commit cb95935

Please sign in to comment.