Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goodbye Rmarkdown, hello Quarto #180

Merged
merged 62 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
6d457ba
move static snakemake cli calls to outside
pdimens Dec 26, 2024
cee60d8
add .conda here b/c that's the new name of the conda dir folder
pdimens Dec 26, 2024
31f43f3
make sure prefix is respected in container
pdimens Dec 26, 2024
b95d76d
migrate to qmd
pdimens Dec 26, 2024
3814bf7
simplify
pdimens Dec 26, 2024
54c2824
lets make it materia
pdimens Dec 26, 2024
c1b8719
touchups
pdimens Dec 27, 2024
a4fa2b1
update logo
pdimens Dec 27, 2024
34a3b63
finally update formatting
pdimens Dec 27, 2024
0b32d17
replace preflight_bam with quarto
pdimens Dec 27, 2024
5b345f3
clearer
pdimens Dec 27, 2024
9467ef9
update qc to qmd
pdimens Dec 27, 2024
488f34b
updates
pdimens Dec 27, 2024
13a5514
new mol_cov on the block and it's way more efficient
pdimens Dec 28, 2024
f1675d1
update to qmd
pdimens Dec 29, 2024
3b7ce09
improve text
pdimens Dec 29, 2024
4b8198a
update to qmd
pdimens Dec 29, 2024
b969d08
migrate to quarto
pdimens Dec 29, 2024
1d22f29
qmd migration
pdimens Dec 29, 2024
3acafd7
migrate to fixed SM call
pdimens Dec 29, 2024
5f358ca
add bai
pdimens Dec 29, 2024
d57a250
nicer ending text with time
pdimens Dec 30, 2024
cc65667
report to qmd
pdimens Dec 30, 2024
b1a19b0
leviathan to qmd
pdimens Dec 30, 2024
39b4112
update formatting
pdimens Dec 30, 2024
984e08d
update naibr to qmd
pdimens Dec 30, 2024
baf9cd8
update
pdimens Dec 30, 2024
d04ee78
update to qmd
pdimens Dec 30, 2024
7cd0747
migrate to qmd, remove info footer from DT tables
pdimens Dec 30, 2024
2b35332
legend secretly table
pdimens Dec 30, 2024
dfdb630
update
pdimens Dec 30, 2024
00a18f1
better quarto rendering
pdimens Dec 31, 2024
fa50545
correct the log
pdimens Dec 31, 2024
61df022
move quarto config to external yml
pdimens Dec 31, 2024
4116683
touchups
pdimens Dec 31, 2024
a5ee41d
update to qmd, make borders dark
pdimens Dec 31, 2024
fa6b3e3
start qmd migration
pdimens Dec 31, 2024
30f14c2
update
pdimens Dec 31, 2024
481b061
add pixi and conda install scripts
pdimens Jan 2, 2025
77d17bf
add pixi
pdimens Jan 2, 2025
dae9ef4
add pixi global as preferred
pdimens Jan 2, 2025
191fc5e
rm lines, they seem dumb now
pdimens Jan 2, 2025
7b15d39
clarification
pdimens Jan 2, 2025
70e0f34
swap to qmd
pdimens Jan 2, 2025
bd62dba
replace
pdimens Jan 2, 2025
b404425
complete transition
pdimens Jan 2, 2025
5ab310c
update
pdimens Jan 2, 2025
8161514
add hapcut to the quarto party
pdimens Jan 2, 2025
c69aeae
looks like we've ran out of reasons keeping you around
pdimens Jan 2, 2025
3b45653
final touches
pdimens Jan 2, 2025
730cf73
better reort logo
pdimens Jan 3, 2025
065614f
rm deprecated
pdimens Jan 3, 2025
f09d066
rm in favor of new dev scripts
pdimens Jan 3, 2025
5e850bc
suggestions and fixes
pdimens Jan 6, 2025
f4dc664
fix sql logic
pdimens Jan 7, 2025
de59fbc
rm prefix (it's redundant)
pdimens Jan 7, 2025
73a0dcc
sleeker printing
pdimens Jan 7, 2025
1853571
fix typo
pdimens Jan 7, 2025
1642551
fix call
pdimens Jan 7, 2025
035197f
fix quarto call
pdimens Jan 7, 2025
bdda55e
better printing
pdimens Jan 7, 2025
94f1b97
rm redundant F strings
pdimens Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ preflight: &preflight
- 'test/bam/**'
- 'harpy/bin/check_bam.py'
- 'harpy/bin/check_fastq.py'
- 'harpy/reports/preflight_fastq.Rmd'
- 'harpy/reports/preflight_bam.Rmd'
- 'harpy/reports/preflight_fastq.qmd'
- 'harpy/reports/preflight_bam.qmd'
deconvolve: &deconvolve
- *common
- *container
Expand All @@ -51,8 +51,8 @@ bwa: &bwa
- *container
- 'harpy/align.py'
- 'harpy/snakefiles/align_bwa.smk'
- 'harpy/reports/align_stats.Rmd'
- 'harpy/reports/align_bxstats.Rmd'
- 'harpy/reports/align_stats.qmd'
- 'harpy/reports/align_bxstats.qmd'
- 'harpy/bin/bx_stats.py'
- 'harpy/bin/count_bx.py'
- 'harpy/bin/assign_mi.py'
Expand All @@ -64,8 +64,8 @@ ema: &ema
- *container
- 'harpy/align.py'
- 'harpy/snakefiles/align_ema.smk'
- 'harpy/reports/align_stats.Rmd'
- 'harpy/reports/align_bxstats.Rmd'
- 'harpy/reports/align_stats.qmd'
- 'harpy/reports/align_bxstats.qmd'
- 'harpy/bin/bx_stats.py'
- 'harpy/bin/count_bx.py'
- 'harpy/bin/make_windows.py'
Expand All @@ -76,8 +76,8 @@ strobealign: &strobealign
- *container
- 'harpy/align.py'
- 'harpy/snakefiles/align_strobealign.smk'
- 'harpy/reports/align_stats.Rmd'
- 'harpy/reports/align_bxstats.Rmd'
- 'harpy/reports/align_stats.qmd'
- 'harpy/reports/align_bxstats.qmd'
- 'harpy/bin/assign_mi.py'
- 'harpy/bin/bx_stats.py'
- 'harpy/bin/count_bx.py'
Expand All @@ -89,15 +89,15 @@ mpileup: &mpileup
- *container
- 'harpy/snp.py'
- 'harpy/snakefiles/snp_mpileup.smk'
- 'harpy/reports/bcftools_stats.Rmd'
- 'harpy/reports/bcftools_stats.qmd'
- 'harpy/bin/make_windows.py'
- 'test/bam/**'
freebayes: &freebayes
- *common
- *container
- 'harpy/snp.py'
- 'harpy/snakefiles/snp_freebayes.smk'
- 'harpy/reports/bcftools_stats.Rmd'
- 'harpy/reports/bcftools_stats.qmd'
- 'harpy/bin/make_windows.py'
- 'test/bam/**'
impute: &impute
Expand All @@ -107,8 +107,8 @@ impute: &impute
- 'harpy/snakefiles/impute.smk'
- 'test/bam/**'
- 'test/vcf/test.bcf'
- 'harpy/reports/impute.Rmd'
- 'harpy/reports/stitch_collate.Rmd'
- 'harpy/reports/impute.qmd'
- 'harpy/reports/stitch_collate.qmd'
- 'harpy/scripts/stitch_impute.R'
leviathan: &leviathan
- *common
Expand All @@ -117,7 +117,7 @@ leviathan: &leviathan
- 'harpy/snakefiles/sv_leviathan**.smk'
- 'test/bam/**'
- 'harpy/bin/concatenate_bam.py'
- 'harpy/reports/leviathan**.Rmd'
- 'harpy/reports/leviathan**.qmd'
naibr: &naibr
- *common
- *container
Expand All @@ -127,7 +127,7 @@ naibr: &naibr
- 'test/bam/**'
- 'test/bam_phased/**'
- 'test/vcf/test.phased.bcf'
- 'harpy/reports/naibr**.Rmd'
- 'harpy/reports/naibr**.qmd'
- 'harpy/bin/infer_sv.py'
phase: &phase
- *common
Expand All @@ -136,7 +136,7 @@ phase: &phase
- 'harpy/snakefiles/phase.smk'
- 'test/bam/**'
- 'test/vcf/test.bcf'
- 'harpy/reports/hapcut.Rmd'
- 'harpy/reports/hapcut.qmd'
- 'harpy/bin/parse_phaseblocks.py'
simvars: &simvars
- *common
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
pip install dist/*.whl
resources/buildforCI.sh
- name: Clear Space
run: rm -rf /opt/hostedtoolcache
uses: jlumbroso/free-disk-space@main
- name: Rebuild Dockerfile
id: rebuild
if: ${{ needs.changes.outputs.container == 'true' }}
Expand Down
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.snakemake/
.vscode/
.condarc
.conda
.cache/
hpc/
QC/
Expand All @@ -20,11 +21,21 @@ Metassembly/
samples.populations
*.fasta
*.bcf
*.bai
genome.fasta
build/
harpy.egg-info/
__pycache__/
.Benchmark/
extractReads
haplotag.bc
_Inline
_Inline
# pixi environments
.pixi
pixi*
.gitattributes
*.egg-info

# pixi environments
.pixi
*.egg-info
82 changes: 71 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,33 @@


## 📥 Install
To avoid dependency conflicts with an existing environment, it is best to create a new environment for a harpy installation. The code below creates a new conda/mamba environment called `harpy` (via `-n harpy`) and installs harpy into it. You can name this environment whatever you like using the `-n somename` argument.
### 🐍 Conda
It's best to create a new environment for a harpy installation. The code below creates a new conda/mamba environment called `harpy` (via `-n harpy`) and installs harpy into it. You can name this environment whatever you like using the `-n somename` argument.
```bash
conda create -n harpy -c bioconda -c conda-forge harpy
```

Once conda/mamba finishes, activate the harpy conda/mamba environment with:
```bash
conda activate env_name
```
where `env_name` is the name of that environment. After doing so, the `harpy` executable should be callable from your path.

<details>
<summary>⚪️ install into an existing conda environment ⚪️</summary>
<summary>⬇️ install as local conda environment </summary>

Alternatively, you can create the environment locally within a specific project folder, just swap `-n harpy` for
`-p path/to/workdir/harpy`, which creates the environment in that specific folder (e.g. `potato_blight/harpy`).
```
# for local project directory
conda create -p path/to/workdir/harpy -c bioconda -c conda-forge harpy
```

</details>

---

<details>
<summary>⬇️ install into existing conda environment </summary>

If you wish to install harpy and its dependencies into an existing environment, activate that environment (`conda activate env_name`) and execute this installation code:
```bash
conda install -c conda-forge bioconda::harpy
Expand All @@ -28,22 +45,65 @@ Or provide `-n envname` to install it into an existing environment named `envnam
conda install -n envname -c conda-forge bioconda::harpy
```

---

</details>

## Update
<details>
<summary>⬆️ updating harpy </summary>

If installed via conda, you can update Harpy by activating the environment
and running `conda update` like so:

```bash
conda update -c conda-forge bioconda::harpy
```

## 🌟 Activate the harpy environment
Once conda/mamba finishes, activate the conda/mamba environment you installed harpy into with
</details>

### 🌟 Pixi
If you prefer [Pixi](https://pixi.sh/latest/) (it's pretty good, you should try it), you can
install Harpy to be accessible in your PATH-- just make sure `~/.pixi/bin` is in your PATH:
```
# ~/.zshrc or ~/.bashrc (or equivalent)
export PATH=~/.pixi/bin:$PATH
```
```bash
conda activate env_name
pixi global install -c conda-forge -c bioconda harpy
```
where `env_name` is the name of that environment. After doing so, the `harpy` executable should be callable from your path.

<details>
<summary>⬇️ install as local environment </summary>

Likewise, you can do an installation into a local project directory:

```bash
pixi init -c bioconda projectname && cd projectname
pixi add harpy
```
After that finishes, you can activate the environment with:
```bash
pixi shell
```
Or run `harpy` by prefixing it with `pixi run`:
```bash
pixi run harpy
```
</details>

<details>
<summary>⬆️ updating harpy </summary>

If installed via Pixi, you can update Harpy with `pixi update`:
```bash
# global install
pixi global update harpy

# local install
# project dir has the pixi.toml file
cd path/to/projectdir
pixi update harpy
```

</details>

## ⚡ Usage
Just call `harpy` or `harpy --help` on the command line to get started!
Expand Down
3 changes: 1 addition & 2 deletions harpy/_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ def create_conda_recipes(outdir: str, envs: list=None) -> None:
"conda-forge::pandoc",
"conda-forge::r-dt",
"conda-forge::r-dplyr",
"conda-forge::r-flexdashboard",
"conda-forge::r-ggplot2",
"conda-forge::r-highcharter",
"conda-forge::r-magrittr",
"conda-forge::r-plotly",
"conda-forge::r-quarto",
"conda-forge::r-scales",
"conda-forge::r-stringi",
"conda-forge::r-tidyr",
Expand Down
11 changes: 9 additions & 2 deletions harpy/_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import glob
import subprocess
from datetime import datetime
from rich import print as rprint
from rich.console import Console
from ._misc import gzip_file, harpy_progressbar, harpy_pulsebar
Expand All @@ -14,6 +15,7 @@
EXIT_CODE_GENERIC_ERROR = 1
EXIT_CODE_CONDA_ERROR = 2
EXIT_CODE_RUNTIME_ERROR = 3
SNAKEMAKE_CMD = "snakemake --rerun-incomplete --show-failed-logs --rerun-triggers input mtime params --nolock --conda-prefix .conda --conda-cleanup-pkgs cache --directory ."

def iserror(text):
"""logical check for erroring trigger words in snakemake output"""
Expand All @@ -30,6 +32,7 @@ def purge_empty_logs(target_dir):

def launch_snakemake(sm_args, workflow, starttext, outdir, sm_logfile, quiet, summaryfile = None):
"""launch snakemake with the given commands"""
start_time = datetime.now()
if not quiet:
print_onstart(starttext, workflow.replace("_", " "))
exitcode = None
Expand Down Expand Up @@ -153,14 +156,16 @@ def launch_snakemake(sm_args, workflow, starttext, outdir, sm_logfile, quiet, su
gzip_file(sm_logfile)
purge_empty_logs(outdir)
if not quiet:
print_onsuccess(outdir, summaryfile)
end_time = datetime.now()
elapsed_time = end_time - start_time
print_onsuccess(outdir, summaryfile, elapsed_time)
sys.exit(0)
else:
if exitcode in (1,2):
print_setup_error(exitcode)
elif exitcode == 3:
print_onerror(sm_logfile)
while output and not output.endswith("]") and not output.startswith("Shutting down"):
while output and not output.endswith("]") and not output.startswith("Shutting down"):
if "Exception" in output or "Error" in output:
rprint("[yellow bold]" + output.rstrip(), file = sys.stderr)
output = process.stderr.readline()
Expand All @@ -172,6 +177,8 @@ def launch_snakemake(sm_args, workflow, starttext, outdir, sm_logfile, quiet, su
if output:
if not output.startswith("Complete log"):
rprint("[red]" + output.replace("\t"," ").rstrip(), file = sys.stderr)
if output.startswith("Removing output files of failed job"):
break
output = process.stderr.readline()
gzip_file(sm_logfile)
purge_empty_logs(outdir)
Expand Down
9 changes: 9 additions & 0 deletions harpy/_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ def fetch_report(workdir, target):
print_solution("There may be an issue with your Harpy installation, which would require reinstalling Harpy. Alternatively, there may be in a issue with your conda/mamba environment or configuration.")
sys.exit(1)

with open(f"{workdir}/report/_quarto.yml", "w", encoding="utf-8") as yml:
if os.path.isfile(files(harpy.reports).joinpath("_quarto.yml")):
yml.write(files(harpy.reports).joinpath("_quarto.yml").read_text())
else:
print_error("report configuration missing", f"The required quarto configuration file [blue bold]_quarto.yml[/blue bold] was not found within the Harpy installation.")
print_solution("There may be an issue with your Harpy installation, which would require reinstalling Harpy. Alternatively, there may be in a issue with your conda/mamba environment or configuration.")
sys.exit(1)


def snakemake_log(outdir, workflow):
"""Return a snakemake logfile name. Iterates logfile run number if one exists."""
attempts = glob.glob(f"{outdir}/logs/snakemake/*.log*")
Expand Down
Loading
Loading