Skip to content

Commit

Permalink
change cli to remove inputs as options (#185)
Browse files Browse the repository at this point in the history
* add compression for output fasta

* add gz to fasta

* change cli to remove inputs as options

* update rule to match new cli

* update summary for new api

* rm redundant required= from argparse [skip cli]
  • Loading branch information
pdimens authored Jan 28, 2025
1 parent 3792721 commit 257b831
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions harpy/bin/inline_to_haplotag.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
parser = argparse.ArgumentParser(
prog = 'inline_to_haplotag.py',
description = 'Moves inline linked read barcodes to read headers (OX:Z) and converts them into haplotag ACBD format (BX:Z). Barcodes must all be the same length.',
usage = f"inline_to_haplotag.py -f <forward.fq.gz> -r <reverse.fq.gz> -b <barcodes.txt> -p <prefix>",
usage = f"inline_to_haplotag.py -b <barcodes.txt> -p <prefix> FORWARD.fq.gz REVERSE.fq.gz",
exit_on_error = False
)
parser.add_argument("-f", "--forward", required = True, type = str, help = "Forward reads of paired-end FASTQ file pair (gzipped)")
parser.add_argument("-r", "--reverse", required = True, type = str, help = "Reverse reads of paired-end FASTQ file pair (gzipped)")
parser.add_argument("-p", "--prefix", required = True, type = str, help = "Prefix for outfile files (e.g. <prefix>.R1.fq.gz)")
parser.add_argument("-b", "--barcodes", required = True, type=str, help="File listing the linked-read barcodes to convert to haplotag format, one barcode per line")
parser.add_argument("-b", "--barcodes", required = True, type=str, help="Barcode conversion key file with format: ATCG<tab>ACBD")
parser.add_argument("forward", type = str, help = "Forward reads of paired-end FASTQ file pair (gzipped)")
parser.add_argument("reverse", type = str, help = "Reverse reads of paired-end FASTQ file pair (gzipped)")
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -112,7 +112,6 @@ def process_record(fw_entry, rv_entry, barcode_database, bc_len):
sys.exit(1)

insert_key_value(bc_db, ATCG, ACBD)
#bc_dict[ATCG] = ACBD
lengths.add(len(ATCG))
if len(lengths) > 1:
sys.stderr.write("Can only search sequences for barcodes of a single length, but multiple barcode legnths detected: " + ",".join([str(i) for i in lengths]))
Expand Down
4 changes: 2 additions & 2 deletions harpy/snakefiles/simulate_linkedreads.smk
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ rule demultiplex_barcodes:
container:
None
shell:
"inline_to_haplotag.py -f {input.fw} -r {input.rv} -b {input.barcodes} -p {params} 2> {log}"
"inline_to_haplotag.py -b {input.barcodes} -p {params} {input.fw} {input.rv} 2> {log}"

rule workflow_summary:
default_target: True
Expand Down Expand Up @@ -202,7 +202,7 @@ rule workflow_summary:
haplosim += f"\tHaploSim.pl -g genome1,genome2 -a dwgsimreads1,dwgsimreads2 -l {params.lrbc_len} -p {params.lrsproj_dir}/linked_molecules/lrsim -b BARCODES -i {params.lrsoutdist} -s {params.lrsdist_sd} -x {params.lrsn_pairs} -f {params.lrsmol_len} -t {params.lrsparts} -m {params.lrsmols_per} -z THREADS {params.lrsstatic}"
summary.append(haplosim)
bxconvert = "Inline barcodes were converted in haplotag BX:Z tags using:\n"
bxconvert += "\tinline_to_haplotag.py -f <forward.fq.gz> -r <reverse.fq.gz> -b <barcodes.txt> -p <prefix>"
bxconvert += "\tinline_to_haplotag.py -b <barcodes.txt> -p <prefix> forward.fq.gz reverse.fq.gz"
summary.append(bxconvert)
sm = "The Snakemake workflow was called via command line:\n"
sm += f"\t{config['workflow_call']}"
Expand Down

0 comments on commit 257b831

Please sign in to comment.