-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I will work on refactoring the visualise function in core.py to break it up in smaller functions and improve the way temporary files are managed.
Here is some starter code generated by GitHub Copilot that streamlines tempfile management:
from dataclasses import dataclass
@dataclass
class TempFiles:
filename_template: str
def __post_init__(self):
suffixes = [
"fasta", "sto", "depaired", "stk", "stk_original", "sto_unfiltered",
"seed_list", "post_prob", "pfam_stk", "pfam_stk_original", "afa",
"afa_original", "map"
]
for suffix in suffixes:
setattr(self, suffix, self.generate_filename(suffix))
def generate_filename(self, suffix: str) -> str:
return self.filename_template.replace("type", suffix)
# Example usage
if not os.path.exists(output_folder):
os.makedirs(output_folder)
filename_template = os.path.join(output_folder, f"{seq_id.replace('/', '_')}_type.txt")
temp_files = TempFiles(filename_template)
# Access the temporary file paths using dot syntax
temp_fasta = temp_files.fasta
temp_sto = temp_files.sto
temp_depaired = temp_files.depaired
temp_stk = temp_files.stk
temp_stk_original = temp_files.stk_original
temp_sto_unfiltered = temp_files.sto_unfiltered
temp_acc_list = temp_files.seed_list
temp_post_prob = temp_files.post_prob
temp_pfam_stk = temp_files.pfam_stk
temp_pfam_stk_original = temp_files.pfam_stk_original
temp_afa = temp_files.afa
temp_afa_original = temp_files.afa_original
temp_map = temp_files.map
# Example usage: print all temporary file paths
print(temp_files)
# get sequence from fasta file
seq_range = f"-c {start}..{end}" if start and end else ""
if not os.path.exists(f"{fasta_input}.ssi"):
runner.run(f"esl-sfetch --index {fasta_input}")
cmd = f"esl-sfetch {seq_range} {fasta_input} {seq_id} > {temp_fasta}"
result = runner.run(cmd)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog