Skip to content

Commit

Permalink
Merge branch 'CW-4474' into 'dev'
Browse files Browse the repository at this point in the history
fix run_spoa.py faililng when all reads come from the same strand [CW-4474]

Closes CW-4474

See merge request epi2melabs/workflows/wf-amplicon!89
  • Loading branch information
julibeg committed Jul 24, 2024
2 parents 70768df + f621b32 commit 95c630f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.1.2]
### Fixed
- The workflow failing in _de novo_ mode when all reads for a sample came from the same strand.

## [v1.1.1]
### Changed
- Updated Medaka to v1.12.0.
Expand All @@ -13,8 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The now redundant `--basecaller_cfg` parameter as its value is now automatically detected from the input data on a per-sample basis.

### Added
- `--override_basecaller_cfg` parameter for cases where automatic selection fails or users wishes to override the automatic choice.

- `--override_basecaller_cfg` parameter for cases where automatic selection fails or users wish to override the automatic choice.

## [v1.1.0]
### Fixed
Expand Down
22 changes: 17 additions & 5 deletions bin/workflow_glue/run_spoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_seqs_from_fastx_and_check_lengths(file, logger, max_len=None):
f"{max_len}. This is what assemblers are for. "
"Aborting..."
)
sys.exit()
sys.exit(0)
yield seq


Expand Down Expand Up @@ -95,7 +95,13 @@ def main(args):
seqs = get_seqs_from_fastx_and_check_lengths(
args.fastq, logger, args.max_allowed_read_length
)
first_seq = next(seqs)
try:
first_seq = next(seqs)
except StopIteration:
# looks like the input file was empty; this shouldn't happen, but we might as
# well catch it and exit gracefully
logger.error(f"Input file '{args.fastq}' appears to be empty. Aborting...")
sys.exit(0)
for seq in seqs:
rc = reverse_complement(seq)
fwd_score = align(seq, first_seq).score
Expand All @@ -105,9 +111,15 @@ def main(args):
else:
rev.append(rc)

# uniformly interleave the reads
interleaved_reads = interleave_lists(fwd, rev)
logger.info("Finished interleaving reads.")
# uniformly interleave the reads (as long as we got fwd and rev reads)
if fwd and rev:
interleaved_reads = interleave_lists(fwd, rev)
logger.info("Finished interleaving reads.")
else:
# we know that we got either fwd or rev reads as otherwise the file must have
# been empty (which we checked above)
logger.info("Only got reads from one strand; not interleaving...")
interleaved_reads = fwd or rev

# determine minimum coverage if param was provided
min_cov = None
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ manifest {
description = 'Amplicon workflow'
mainScript = 'main.nf'
nextflowVersion = '>=23.04.2'
version = 'v1.1.1'
version = 'v1.1.2'
}

epi2melabs {
Expand Down

0 comments on commit 95c630f

Please sign in to comment.