Skip to content

Commit

Permalink
Merge pull request #103 from gbouras13/dev
Browse files Browse the repository at this point in the history
V0.10.0 flye extra parama
  • Loading branch information
gbouras13 authored Oct 18, 2024
2 parents ca1ed27 + 3580a4d commit 8348d42
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 3 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Updates Medaka to v2.0.1, implementing the `--bacteria` option by default.
* This is based on the recommendations of Ryan Wick [here](https://rrwick.github.io/2024/10/17/medaka-v2.html) who found it improved assemblies due to (likely) enhanced methylation error correction.
* If you still want to specify a Medaka model, the flag `--medaka_override` has been added. You need to include this along with your model via `--medakaModel`. This is most likely useful for older R9 data.
*

## v0.9.1 Updates (8 October 2024)

Expand Down
18 changes: 18 additions & 0 deletions hybracter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def common_options(func):
is_flag=True,
default=False,
),
click.option(
"--extra_params_flye",
help="Use this if want to add extra parameters to Flye.",
type=str,
default=None
),

click.option(
"--use-conda/--no-use-conda",
Expand Down Expand Up @@ -406,6 +412,7 @@ def hybrid(
depth_filter,
mac,
medaka_override,
extra_params_flye,
log,
configfile,
**kwargs
Expand Down Expand Up @@ -433,6 +440,7 @@ def hybrid(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"depth_filter": depth_filter,
"single": False,
"logic": logic,
Expand Down Expand Up @@ -532,6 +540,7 @@ def hybrid_single(
auto,
mac,
medaka_override,
extra_params_flye,
logic,
depth_filter,
log,
Expand Down Expand Up @@ -564,6 +573,7 @@ def hybrid_single(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"depth_filter": depth_filter,
"single": True,
"logic": logic,
Expand Down Expand Up @@ -627,6 +637,7 @@ def long(
auto,
mac,
medaka_override,
extra_params_flye,
logic,
depth_filter,
log,
Expand Down Expand Up @@ -655,6 +666,7 @@ def long(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"depth_filter": depth_filter,
"single": False,
"logic": logic,
Expand Down Expand Up @@ -732,6 +744,7 @@ def long_single(
auto,
mac,
medaka_override,
extra_params_flye,
logic,
depth_filter,
configfile,
Expand Down Expand Up @@ -760,6 +773,7 @@ def long_single(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"depth_filter": depth_filter,
"single": True,
"logic": logic,
Expand Down Expand Up @@ -913,6 +927,7 @@ def test_hybrid(
no_pypolca,
mac,
medaka_override,
extra_params_flye,
contaminants,
dnaapler_custom_db,
logic,
Expand Down Expand Up @@ -941,6 +956,7 @@ def test_hybrid(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"logic": logic,
"depth_filter": depth_filter,
"configfile": configfile
Expand Down Expand Up @@ -998,6 +1014,7 @@ def test_long(
auto,
mac,
medaka_override,
extra_params_flye,
logic,
depth_filter,
configfile,
Expand All @@ -1023,6 +1040,7 @@ def test_long(
"auto": auto,
"mac": mac,
"medaka_override": medaka_override,
"extra_params_flye": extra_params_flye,
"logic": logic,
"depth_filter": depth_filter,
"configfile": configfile
Expand Down
8 changes: 8 additions & 0 deletions hybracter/workflow/hybrid.smk
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ MIN_DEPTH = config.args.min_depth
AUTO = config.args.auto
MAC = config.args.mac
MEDAKA_OVERRIDE = config.args.medaka_override
EXTRA_PARAMS_FLYE = config.args.extra_params_flye
# flag to add extra arguments to flye
ADD_TO_FLYE = False

# Only if user specifies - otherwise None
if EXTRA_PARAMS_FLYE:
ADD_TO_FLYE = True
print(f"As you have used --extra_params_flye the extra parameters {EXTRA_PARAMS_FLYE} will be used with Flye.")

# By default, hybracter (linux) will use --bacteria from v0.10.0 onwards
# To take advantage of improvements with medaka v2 https://rrwick.github.io/2024/10/17/medaka-v2.html
Expand Down
9 changes: 9 additions & 0 deletions hybracter/workflow/long.smk
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ MIN_DEPTH = config.args.min_depth
AUTO = config.args.auto
MAC = config.args.mac
MEDAKA_OVERRIDE = config.args.medaka_override
EXTRA_PARAMS_FLYE = config.args.extra_params_flye
# flag to add extra arguments to flye
ADD_TO_FLYE = False

# Only if user specifies - otherwise None
if EXTRA_PARAMS_FLYE:
ADD_TO_FLYE = True
print(f"The extra parameters {EXTRA_PARAMS_FLYE} will be used with Flye ")


# By default, hybracter (linux) will use --bacteria from v0.10.0 onwards
# To take advantage of improvements with medaka v2 https://rrwick.github.io/2024/10/17/medaka-v2.html
Expand Down
10 changes: 8 additions & 2 deletions hybracter/workflow/rules/assembly/assemble.smk
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ rule assemble:
params:
model=FLYE_MODEL,
dir=os.path.join(dir.out.assemblies, "{sample}"),
add_to_flye = ADD_TO_FLYE,
extra_params_flye = EXTRA_PARAMS_FLYE
threads: config.resources.big.cpu
benchmark:
os.path.join(dir.out.bench, "assemble", "{sample}.txt")
log:
os.path.join(dir.out.stderr, "assemble", "{sample}.log"),
shell:
"""
flye {params.model} {input.fastq} -t {threads} --out-dir {params.dir} 2> {log}
flye --version > {output.version}
if [ "{params.add_to_flye}" = "True" ]; then
flye {params.model} {input.fastq} -t {threads} --out-dir {params.dir} {params.extra_params_flye} 2> {log}
else
flye {params.model} {input.fastq} -t {threads} --out-dir {params.dir} 2> {log}
fi
flye --version > {output.version}
cp {output.info} {output.infocopy}
"""

Expand Down
9 changes: 9 additions & 0 deletions hybracter/workflow/test_hybrid.smk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ MIN_DEPTH = config.args.min_depth
AUTO = config.args.auto
MAC = config.args.mac
MEDAKA_OVERRIDE = config.args.medaka_override
EXTRA_PARAMS_FLYE = config.args.extra_params_flye
# flag to add extra arguments to flye
ADD_TO_FLYE = False

# Only if user specifies - otherwise None
if EXTRA_PARAMS_FLYE:
ADD_TO_FLYE = True
print(f"The extra parameters {EXTRA_PARAMS_FLYE} will be used with Flye ")


# By default, hybracter (linux) will use --bacteria from v0.10.0 onwards
# To take advantage of improvements with medaka v2 https://rrwick.github.io/2024/10/17/medaka-v2.html
Expand Down
8 changes: 8 additions & 0 deletions hybracter/workflow/test_long.smk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ MIN_DEPTH = config.args.min_depth
AUTO = config.args.auto
MAC = config.args.mac
MEDAKA_OVERRIDE = config.args.medaka_override
EXTRA_PARAMS_FLYE = config.args.extra_params_flye
# flag to add extra arguments to flye
ADD_TO_FLYE = False

# Only if user specifies - otherwise None
if EXTRA_PARAMS_FLYE:
ADD_TO_FLYE = True
print(f"The extra parameters {EXTRA_PARAMS_FLYE} will be used with Flye ")

# By default, hybracter (linux) will use --bacteria from v0.10.0 onwards
# To take advantage of improvements with medaka v2 https://rrwick.github.io/2024/10/17/medaka-v2.html
Expand Down
15 changes: 14 additions & 1 deletion tests/test_hybracter.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test_hybracter_long(run_mac):
# test override
# bit useless for mac (as --bacteria won't work) but won't break anything so just leave

def test_hybracter_long(run_mac):
def test_hybracter_long_medaka_override(run_mac):
"""test hybracter long"""
outdir: Path = "test_hybracter_output_medaka_override"
input_csv: Path = test_data_path / "test_long_input.csv"
Expand All @@ -351,6 +351,19 @@ def test_hybracter_long(run_mac):
exec_command(cmd)
remove_directory(outdir)

# test --extra_params_flye

def test_hybracter_long_medaka_override(run_mac):
"""test hybracter long"""
outdir: Path = "test_hybracter_output_medaka_override"
input_csv: Path = test_data_path / "test_long_input.csv"
cmd = f"hybracter long --input {input_csv} --threads {threads} --output {outdir} --databases {db_dir} --extra_params_flye \"--meta\" "
if run_mac:
cmd += " --mac"
exec_command(cmd)
remove_directory(outdir)


def test_hybracter_long_auto(run_mac):
"""
Expand Down

0 comments on commit 8348d42

Please sign in to comment.