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

Switch CLI over to typer, change command to "anglerfish run" #81

Merged
merged 8 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion .github/workflows/anglerfish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ jobs:
- shell: bash -l {0}
name: Run anglerfish with test data
run: |
anglerfish -s test/samples.csv
anglerfish run -s test/samples.csv

# Run anglerfish explore
- shell: bash -l {0}
name: Run anglerfish explore
run: |
anglerfish explore -f test/BC18_P14351_1001.fastq.gz -o test/explore_output
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ P12345_101,truseq,CAGGACGT,/path/to/*.fastq.gz
Then run:

```
anglerfish -s /path/to/samples.csv
anglerfish run -s /path/to/samples.csv
```

### Options
Expand Down Expand Up @@ -173,10 +173,10 @@ In folder `anglerfish_????_??_??_?????/`

## Anglerfish Explore (Experimental)

`anglerfish-explore` is a command that aims to explore a sequencing pool without a given samplesheet and give hints on what adapter types are present, which index lenghts are used and whether there are any UMIs within the index sequence. The Anglerfish explore command is still under heavy development but can be triggered by running, e.g. for help text:
`anglerfish explore` is a command that aims to explore a sequencing pool without a given samplesheet and give hints on what adapter types are present, which index lenghts are used and whether there are any UMIs within the index sequence. The Anglerfish explore command is still under heavy development but can be triggered by running, e.g. for help text:

```shell
anglerfish-explore --help
anglerfish explore --help
```

## Credits
Expand Down
4 changes: 2 additions & 2 deletions anglerfish/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import multiprocessing

from .anglerfish import anglerfish
from .cli import app

if __name__ == "__main__":
multiprocessing.freeze_support()
anglerfish()
app()
120 changes: 14 additions & 106 deletions anglerfish/anglerfish.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env python
import argparse
import glob
import gzip
import logging
import multiprocessing
import os
import sys
import uuid
from collections import Counter
from datetime import datetime as dt
from itertools import groupby

import numpy as np
Expand Down Expand Up @@ -39,7 +38,18 @@ def run_demux(args):
ss = SampleSheet(args.samplesheet, args.ont_barcodes)
version = pkg_resources.get_distribution("bio-anglerfish").version
report = Report(args.run_name, run_uuid, version)

sys.stderr.write("""
___
( ) \ -..__
_.|~”~~~”…_
^´ `>.
(+ (+ ) “<..<^(
`´ ``´ ___ (
\__..~ __( _…_(
\ /
“--…_ _..~%´
```´´
""")
log.info(f" version {version}")
log.info(f" arguments {vars(args)}")
log.info(f" run uuid {run_uuid}")
Expand Down Expand Up @@ -118,7 +128,7 @@ def run_demux(args):
"i5": {"i7_reversed": False, "i5_reversed": True},
"i7+i5": {"i7_reversed": True, "i5_reversed": True},
}
if args.force_rc is not None:
if args.force_rc != "original":
log.info(
f" Force reverse complementing {args.force_rc} index for adaptor {adaptor_name}. Lenient mode is disabled"
)
Expand Down Expand Up @@ -245,105 +255,3 @@ def run_demux(args):
report.write_report(args.out_fastq)
report.write_json(args.out_fastq)
report.write_dataframe(args.out_fastq, ss)

if args.skip_fastqc:
log.warning(
" As of version 0.4.1, built in support for FastQC + MultiQC is removed. The '-f' flag is redundant."
)


def anglerfish():
parser = argparse.ArgumentParser(
description="Tools to demux I7 and I5 barcodes when sequenced by single-molecules"
)
parser.add_argument(
"--samplesheet",
"-s",
required=True,
help="CSV formatted list of samples and barcodes",
)
parser.add_argument(
"--out_fastq",
"-o",
default=".",
help="Analysis output folder (default: Current dir)",
)
parser.add_argument(
"--threads",
"-t",
default=4,
type=int,
help="Number of threads to use (default: 4)",
)
parser.add_argument(
"--skip_demux",
"-c",
action="store_true",
help="Only do BC counting and not demuxing",
)
parser.add_argument(
"--skip_fastqc", "-f", action="store_true", help=argparse.SUPPRESS
)
parser.add_argument(
"--max-distance",
"-m",
type=int,
help="Manually set maximum edit distance for BC matching, automatically set this is set to either 1 or 2",
)
parser.add_argument(
"--max-unknowns",
"-u",
type=int,
help="Maximum number of unknown indices to show in the output (default: length of samplesheet + 10)",
)
parser.add_argument(
"--run_name",
"-r",
default="anglerfish",
help="Name of the run (default: anglerfish)",
)
parser.add_argument(
"--lenient",
"-l",
action="store_true",
help="Will try reverse complementing the I5 and/or I7 indices and choose the best match.",
)
parser.add_argument(
"--lenient_factor",
"-x",
default=4.0,
type=float,
help="If lenient is set, this is the minimum factor of additional matches required to reverse complement the index (default: 4.0)",
)
parser.add_argument(
"--force_rc",
"-p",
choices=["i7", "i5", "i7+i5"],
help="Force reverse complementing the I5 and/or I7 indices. This will disregard lenient mode.",
)
parser.add_argument(
"--ont_barcodes",
"-n",
action="store_true",
help="Will assume the samplesheet refers to a single ONT run prepped with a barcoding kit. And will treat each barcode separately",
)
parser.add_argument(
"--debug", "-d", action="store_true", help="Extra commandline output"
)
parser.add_argument(
"--version",
"-v",
action="version",
help="Print version and quit",
version=f'anglerfish {pkg_resources.get_distribution("bio-anglerfish").version}',
)
args = parser.parse_args()
utcnow = dt.utcnow()
runname = utcnow.strftime(f"{args.run_name}_%Y_%m_%d_%H%M%S")

assert os.path.exists(args.out_fastq)
assert os.path.exists(args.samplesheet)
args.out_fastq = os.path.join(os.path.abspath(args.out_fastq), runname)
args.samplesheet = os.path.abspath(args.samplesheet)
args.run_name = runname
run_demux(args)
Loading
Loading