From 62fdada9c1fad567d31488d014af6f4df8d2eec3 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Thu, 13 Mar 2025 14:17:08 +0000 Subject: [PATCH] Added original filename to csv output --- src/autobigs/engine/reading.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/autobigs/engine/reading.py b/src/autobigs/engine/reading.py index 9949da4..61e998e 100644 --- a/src/autobigs/engine/reading.py +++ b/src/autobigs/engine/reading.py @@ -1,5 +1,6 @@ import asyncio from io import TextIOWrapper +from os import path from typing import Any, AsyncGenerator, Iterable, Union from Bio import SeqIO @@ -9,7 +10,7 @@ async def read_fasta(handle: Union[str, TextIOWrapper]) -> Iterable[NamedString] fasta_sequences = asyncio.to_thread(SeqIO.parse, handle=handle, format="fasta") results = [] for fasta_sequence in await fasta_sequences: - results.append(NamedString(fasta_sequence.id, str(fasta_sequence.seq))) + results.append(NamedString("{0}:{1}".format(path.basename(handle.name if isinstance(handle, TextIOWrapper) else handle), fasta_sequence.id), str(fasta_sequence.seq))) return results async def read_multiple_fastas(handles: Iterable[Union[str, TextIOWrapper]]) -> AsyncGenerator[Iterable[NamedString], Any]: