-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:maxibor/pydamage
- Loading branch information
Showing
27 changed files
with
379 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ __ homepage_ | |
API | ||
CLI | ||
output | ||
troubleshooting | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Troubleshooting | ||
|
||
## My alignment files don't have a MD tag | ||
|
||
You can use [samtools calmd](http://www.htslib.org/doc/samtools-calmd.html) to set the MD tag | ||
|
||
Example: | ||
|
||
```bash | ||
samtools calmd -b alignment.bam reference.fasta > aln.bam | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
__version__ = "0.50" | ||
from pydamage.main import analyze | ||
__version__ = "0.60" | ||
from pydamage.main import pydamage_analyze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def get_citation(): | ||
BIB = """ | ||
@article{Borry2021_pydamage, | ||
author = {Borry, Maxime and Huebner, Alexander and Rohrlach, Adam B and Warinner, Christina G}, | ||
doi = {10.1101/2021.03.24.436838}, | ||
elocation-id = {2021.03.24.436838}, | ||
eprint = {https://www.biorxiv.org/content/early/2021/03/24/2021.03.24.436838.full.pdf}, | ||
journal = {bioRxiv}, | ||
publisher = {Cold Spring Harbor Laboratory}, | ||
title = {PyDamage: automated ancient damage identification and estimation for contigs in ancient DNA de novo assembly}, | ||
url = {https://www.biorxiv.org/content/early/2021/03/24/2021.03.24.436838}, | ||
year = {2021} | ||
} | ||
""" | ||
print(BIB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,113 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import click | ||
from pydamage.main import analyze, analyze_group | ||
from pydamage.main import pydamage_analyze | ||
from pydamage.citation import get_citation | ||
from pydamage.kneedle import apply_filter | ||
from pydamage import __version__ | ||
from collections import OrderedDict | ||
|
||
class NaturalOrderGroup(click.Group): | ||
|
||
@click.command() | ||
def __init__(self, name=None, commands=None, **attrs): | ||
super(NaturalOrderGroup, self).__init__( | ||
name=name, commands=None, **attrs) | ||
if commands is None: | ||
commands = OrderedDict() | ||
elif not isinstance(commands, OrderedDict): | ||
commands = OrderedDict(commands) | ||
self.commands = commands | ||
|
||
def list_commands(self, ctx): | ||
return self.commands.keys() | ||
|
||
@click.group(cls=NaturalOrderGroup) | ||
@click.version_option(__version__) | ||
@click.pass_context | ||
@click.option( | ||
"-o", | ||
"--outdir", | ||
type=click.Path(writable=True, dir_okay=True), | ||
default="pydamage_results", | ||
show_default=True, | ||
help="Output directory", | ||
) | ||
def cli(ctx, outdir): | ||
"""\b | ||
PyDamage: Damage parameter estimation for ancient DNA | ||
Author: Maxime Borry | ||
Contact: <borry[at]shh.mpg.de> | ||
Homepage & Documentation: github.com/maxibor/pydamage | ||
""" | ||
|
||
ctx.ensure_object(dict) | ||
|
||
ctx.obj["outdir"] = outdir | ||
pass | ||
|
||
|
||
@cli.command() | ||
@click.pass_context | ||
@click.argument("bam", type=click.Path(exists=True)) | ||
@click.option( | ||
"-w", | ||
"--wlen", | ||
default=35, | ||
type=int, | ||
show_default=True, | ||
help="Window length for damage modeling", | ||
help="Window length (in bp) for damage modeling", | ||
) | ||
@click.option( | ||
"-p", | ||
"--process", | ||
default=2, | ||
type=int, | ||
show_default=True, | ||
help="Number of processes", | ||
help="Number of processes for parallel computing", | ||
) | ||
@click.option("-s", "--show_al", is_flag=True, help="Show alignments representations") | ||
@click.option("-pl", "--plot", is_flag=True, help="Make the damage plots") | ||
@click.option("--verbose", is_flag=True, help="Verbose mode") | ||
@click.option( | ||
"-o", | ||
"--outdir", | ||
type=click.Path(writable=True, dir_okay=True), | ||
default="pydamage_results", | ||
show_default=True, | ||
help="Output directory", | ||
"-s", "--show_al", is_flag=True, help="Display alignments representations" | ||
) | ||
@click.option("--force", is_flag=True, help="Force overwriting of results directory") | ||
@click.option("--group", is_flag=True, help="Group references together for analyis") | ||
def cli(no_args_is_help=True, **kwargs): | ||
@click.option("-pl", "--plot", is_flag=True, help="Write damage fitting plots to disk") | ||
@click.option("-vv", "--verbose", is_flag=True, help="Verbose mode") | ||
@click.option( | ||
"-f", "--force", is_flag=True, help="Force overwriting of results directory" | ||
) | ||
@click.option( | ||
"-g", | ||
"--group", | ||
is_flag=True, | ||
help="Use entire BAM file as single reference for analyis " | ||
"(ignore reference headers)", | ||
) | ||
def analyze(ctx, no_args_is_help=True, **kwargs): | ||
"""\b | ||
PyDamage: Damage parameter estimation for ancient DNA | ||
Author: Maxime Borry | ||
Contact: <borry[at]shh.mpg.de> | ||
Homepage & Documentation: github.com/maxibor/pydamage | ||
Run the PyDamage analysis | ||
BAM: path to BAM/SAM/CRAM alignment file. MD tags need to be set. | ||
""" | ||
pydamage_analyze(**kwargs, **ctx.obj) | ||
|
||
BAM: path to BAM/SAM/CRAM alignment file | ||
|
||
@cli.command() | ||
@click.pass_context | ||
@click.argument("csv", type=click.Path(exists=True)) | ||
def filter(ctx, no_args_is_help=True, **kwargs): | ||
"""\b | ||
Filter PyDamage results with optimal pred_accuracy threshold selection | ||
CSV: path to PyDamage result file | ||
""" | ||
analyze(**kwargs) | ||
print(kwargs, ctx.obj) | ||
|
||
apply_filter(**kwargs, **ctx.obj) | ||
|
||
@cli.command() | ||
def cite(): | ||
"""Get pydamage citation in bibtex format | ||
""" | ||
get_citation() | ||
|
||
if __name__ == "__main__": | ||
cli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Error(Exception): | ||
"""Base class for exceptions in this module.""" | ||
|
||
pass | ||
|
||
|
||
class AlignmentFileError(Error): | ||
"""Exception raised for errors in validating the dataset agains the standards. | ||
Attributes: | ||
message -- explanation of the error | ||
""" | ||
|
||
def __init__(self, message): | ||
self.message = message |
Oops, something went wrong.