From 030ac240e049aa123ccca6cfec962a7f96857d92 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Jan 2024 15:40:58 +0800 Subject: [PATCH] change fasta_to_ali --- build_modeller.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build_modeller.py b/build_modeller.py index e613a6d..11c6d09 100755 --- a/build_modeller.py +++ b/build_modeller.py @@ -6,6 +6,10 @@ import time from typing import List import sys import glob +import pyfastx +from Bio import SeqIO +from Bio.Seq import Seq +from Bio.SeqRecord import SeqRecord @dataclass class PDBModeler: @@ -108,13 +112,13 @@ class PDBModeler: if ali_file.exists(): ali_file.unlink() - with open(self.fasta_file, 'r') as f: - seq = f.readlines()[1].strip() + fx = pyfastx.Fasta(self.fasta_file.as_posix(), build_index=True) + assert len(fx) == 1, "FASTA file should contain only one sequence" with open(ali_file, 'w') as f: f.write(f'>P1;{self.sequence}\n') f.write(f'sequence:{self.sequence}:::::::0.00: 0.00\n') - f.write(f'{seq}*') + f.write(f'{fx[0].seq}*') return ali_file