From 8caa3529e9deb1095c56a07403e06445bc016036 Mon Sep 17 00:00:00 2001 From: Malte Siemers Date: Thu, 19 Sep 2024 10:41:59 +0200 Subject: [PATCH] Update 2.1.2_host_prediction_II.md --- _episodes/2.1.2_host_prediction_II.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/_episodes/2.1.2_host_prediction_II.md b/_episodes/2.1.2_host_prediction_II.md index de17b51..07e9409 100644 --- a/_episodes/2.1.2_host_prediction_II.md +++ b/_episodes/2.1.2_host_prediction_II.md @@ -73,16 +73,21 @@ forest model. This model matches the set of proteins with host proteins it was t > from Bio import SeqIO > > def main(): -> +> +> # define file paths from the arguments > assembly_path = os.path.abspath(sys.argv[1]) > assert assembly_path.endswith(".fasta") -> +> +> # set an output directory and create it if it does not exist > out_dir = os.path.abspath(sys.argv[2]) > if not os.path.exists(out_dir): os.makedirs(out_dir) -> +> +> # loop through the records in the combined assembly > with open(assembly_path) as handle: > for record in SeqIO.parse(handle, "fasta"): +> # set a filename per record > out_fasta = os.path.join(out_dir, f"{record.id}.fasta") +> # write the record to the file > with open(out_fasta, "w") as fout: > SeqIO.write([record], fout, "fasta") >