From 3c1c34d0a9734a6a34e327757e439bdf5c561072 Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Sat, 2 Nov 2024 21:51:59 +1000 Subject: [PATCH 1/3] assemble/recover: Require users to specify coassembly or not. Fixes #219. --- .gitignore | 1 + aviary/aviary.py | 1 - aviary/modules/processor.py | 12 ++++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index da6698c7..5e1d3d8a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ aviary_genome.egg-info example/ test/data/.conda +test/data/wgsim.metaspades.assembly.fna.fai diff --git a/aviary/aviary.py b/aviary/aviary.py index 54d6d966..82274dfe 100755 --- a/aviary/aviary.py +++ b/aviary/aviary.py @@ -796,7 +796,6 @@ def main(): nargs='?', const=True, dest='coassemble', - default=False, ) assemble_group.add_argument( diff --git a/aviary/modules/processor.py b/aviary/modules/processor.py index a29bcf9a..324ed380 100644 --- a/aviary/modules/processor.py +++ b/aviary/modules/processor.py @@ -233,7 +233,6 @@ def __init__(self, self.pe2 = 'none' self.short_percent_identity = 'none' - try: self.kmer_sizes = args.kmer_sizes self.use_megahit = args.use_megahit @@ -246,7 +245,7 @@ def __init__(self, except AttributeError: self.kmer_sizes = ['auto'] self.use_megahit = False - self.coassemble = True + self.coassemble = False self.min_cov_long = 20 self.min_cov_short = 3 self.exclude_contig_cov = 100 @@ -346,6 +345,15 @@ def make_config(self): with open(template_conf_file) as template_config: conf = yaml.load(template_config) + + if self.assembly == 'none' or self.assembly is None: + # Check if coassembly or not needs to be specified by the user. + if self.coassemble is None: + if len(self.pe1) > 1 or len(self.longreads) > 1: + logging.error("Multiple readsets detected. Either specify '--coassemble' for coassembly of or '--coassemble no'.") + sys.exit(-1) + if self.coassemble is None: + self.coassemble = False # ensure that something is specified so that the config file is well formed if self.assembly != "none" and self.assembly is not None: self.assembly = list(dict.fromkeys([os.path.abspath(p) for p in self.assembly])) From 2288aeb9c5901a0b4c7812ee405ce9552ce4995c Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Sat, 2 Nov 2024 21:57:09 +1000 Subject: [PATCH 2/3] --coassemble: Improve help message. --- aviary/aviary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aviary/aviary.py b/aviary/aviary.py index 82274dfe..76161943 100755 --- a/aviary/aviary.py +++ b/aviary/aviary.py @@ -790,12 +790,12 @@ def main(): assemble_group.add_argument( '--coassemble', '--co-assemble', '--co_assemble', help='Specifies whether or not, when given multiple input reads, to coassemble them. \n' - 'If False, Aviary will use the first set of short reads and first set of long reads to perform assembly \n' + 'If False (no), Aviary will use the first set of short reads and first set of long reads to perform assembly \n' 'All read files will still be used during the MAG recovery process for differential coverage.', type=str2bool, nargs='?', const=True, - dest='coassemble', + metavar='yes|no', ) assemble_group.add_argument( From e2ccfeb8a048958dc01d84f4e9e544460de6406d Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Sat, 2 Nov 2024 22:05:52 +1000 Subject: [PATCH 3/3] --coassemble: Fix regression. --- aviary/modules/processor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aviary/modules/processor.py b/aviary/modules/processor.py index 324ed380..6de61027 100644 --- a/aviary/modules/processor.py +++ b/aviary/modules/processor.py @@ -349,7 +349,8 @@ def make_config(self): if self.assembly == 'none' or self.assembly is None: # Check if coassembly or not needs to be specified by the user. if self.coassemble is None: - if len(self.pe1) > 1 or len(self.longreads) > 1: + if (self.pe1 != 'none' and len(self.pe1) > 1) or \ + (self.longreads != 'none' and len(self.longreads) > 1): logging.error("Multiple readsets detected. Either specify '--coassemble' for coassembly of or '--coassemble no'.") sys.exit(-1) if self.coassemble is None: