From 823fd759d2a211000ba6e2a49141b6dbdaa8f640 Mon Sep 17 00:00:00 2001 From: Thijs Date: Mon, 5 Feb 2024 19:45:19 +0100 Subject: [PATCH] Fix mut sequence output --- iss/error_models/__init__.py | 2 +- iss/generator.py | 6 +++--- iss/test/test_error_model.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iss/error_models/__init__.py b/iss/error_models/__init__.py index 17ea70f..413303a 100644 --- a/iss/error_models/__init__.py +++ b/iss/error_models/__init__.py @@ -78,7 +78,7 @@ def mut_sequence(self, record, orientation): 'reverse' Returns: - Seq: a sequence + SeqRecord: the read record with substitution errors """ # get the right subst_matrix diff --git a/iss/generator.py b/iss/generator.py index 2387e54..1b47ca7 100644 --- a/iss/generator.py +++ b/iss/generator.py @@ -155,7 +155,7 @@ def simulate_read(record, error_model, i, cpu_number, sequence_type): # add the indels, the qual scores and modify the record accordingly forward.seq = error_model.introduce_indels(forward, "forward", sequence, bounds) forward = error_model.introduce_error_scores(forward, "forward") - forward.seq = error_model.mut_sequence(forward, "forward") + forward = error_model.mut_sequence(forward, "forward") # generate the reverse read # assign start position reverse read @@ -187,7 +187,7 @@ def simulate_read(record, error_model, i, cpu_number, sequence_type): # add the indels, the qual scores and modify the record accordingly reverse.seq = error_model.introduce_indels(reverse, "reverse", sequence, bounds) reverse = error_model.introduce_error_scores(reverse, "reverse") - reverse.seq = error_model.mut_sequence(reverse, "reverse") + reverse = error_model.mut_sequence(reverse, "reverse") return (forward, reverse, forward.annotations["mutations"] + reverse.annotations["mutations"]) @@ -235,7 +235,7 @@ def worker_iterator(work, error_model, cpu_number, worker_prefix, seed, sequence random.seed(seed + cpu_number) np.random.seed(seed + cpu_number) - with forward_handle, reverse_handle: + with forward_handle, reverse_handle, mutation_handle: for record, n_pairs, mode in work: simulate_reads( record=record, diff --git a/iss/test/test_error_model.py b/iss/test/test_error_model.py index 6835665..fa7d863 100644 --- a/iss/test/test_error_model.py +++ b/iss/test/test_error_model.py @@ -52,7 +52,7 @@ def test_mut_sequence(): read = SeqRecord(Seq(str("AAAAA" * 25)), id="read_1", description="test read") read.letter_annotations["phred_quality"] = [5] * 125 - read.seq = err_mod.mut_sequence(read, "forward") + read = err_mod.mut_sequence(read, "forward") assert str(read.seq[:10]) == "AAAACAGAAA"