From 5255692b7f712ddcd7e4e6ccaae49b27c16f6a64 Mon Sep 17 00:00:00 2001 From: Floreal Cabanettes Date: Wed, 21 Feb 2018 16:21:42 +0100 Subject: [PATCH] Close SeqIO --- src/dgenies/lib/functions.py | 3 ++- src/dgenies/lib/paf.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dgenies/lib/functions.py b/src/dgenies/lib/functions.py index e3bd5a7..a33cc25 100644 --- a/src/dgenies/lib/functions.py +++ b/src/dgenies/lib/functions.py @@ -166,8 +166,8 @@ def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mail is_compressed = fasta_file.endswith(".gz") if is_compressed: fasta_file = Functions.uncompress(fasta_file) - seq = SeqIO.index(fasta_file, "fasta") fasta_file_o = fasta_file + ".sorted" + seq = SeqIO.index(fasta_file, "fasta") with open(fasta_file_o, "w") as fasta_out: for name, props in index.items(): sequence = seq[name] @@ -180,6 +180,7 @@ def sort_fasta(job_name, fasta_file, index_file, lock_file, compress=False, mail sequence.name = s_name sequence.description = s_description SeqIO.write(sequence, fasta_out, "fasta") + seq.close() if is_compressed: os.remove(fasta_file) if compress: diff --git a/src/dgenies/lib/paf.py b/src/dgenies/lib/paf.py index c8ca29b..9a8c6fa 100644 --- a/src/dgenies/lib/paf.py +++ b/src/dgenies/lib/paf.py @@ -758,6 +758,7 @@ def build_query_chr_as_reference(self): seq = query_f[contig] seq.id += "_unaligned" SeqIO.write(seq, out, "fasta") + query_f.close() if uncompressed: os.remove(query_fasta) status = "success"