加入如果两端都没有-对齐时候产生的错误ali文件问题

This commit is contained in:
2024-01-25 15:43:40 +08:00
parent 804062bc7a
commit f9be323d15

View File

@@ -46,7 +46,7 @@ class PDBModeler:
trim_index = 1 trim_index = 1
else: else:
# 如果两条链都不需要裁剪,就直接返回原文件 # 如果两条链都不需要裁剪,就直接返回原文件
return file return None
start, end = PDBModeler.find_non_dash_indices(seqs[trim_index].seq) start, end = PDBModeler.find_non_dash_indices(seqs[trim_index].seq)
@@ -92,19 +92,19 @@ class PDBModeler:
# save alignment in FASTA format # save alignment in FASTA format
aln.write(file=(self.outdir / 'alignment1.fasta').as_posix(), alignment_format='FASTA') aln.write(file=(self.outdir / 'alignment1.fasta').as_posix(), alignment_format='FASTA')
slice_fasta = PDBModeler.align_sequences(self.outdir / 'alignment1.fasta') slice_fasta = PDBModeler.align_sequences(self.outdir / 'alignment1.fasta')
slice_ali = self.outdir / 'alignment_slice.ali' if slice_fasta:
fx = pyfastx.Fasta(slice_fasta.as_posix(), build_index=True) slice_ali = self.outdir / 'alignment_slice.ali'
assert len(fx) == 1, "FASTA file should contain only one sequence" fx = pyfastx.Fasta(slice_fasta.as_posix(), build_index=True)
PDBModeler.write_ali(slice_ali, fx[0].name, fx[0].seq) assert len(fx) == 1, "FASTA file should contain only one sequence"
PDBModeler.write_ali(slice_ali, fx[0].name, fx[0].seq)
env2 = Environ() env2 = Environ()
mdl2 = Model(env2, file=self.structure_file.as_posix(), model_segment=(f'FIRST:{self.chain}', f'LAST:{self.chain}')) mdl2 = Model(env2, file=self.structure_file.as_posix(), model_segment=(f'FIRST:{self.chain}', f'LAST:{self.chain}'))
aln2 = Alignment(env2) aln2 = Alignment(env2)
aln2.append_model(mdl2, align_codes=self.structure, atom_files=self.structure_file.as_posix()) aln2.append_model(mdl2, align_codes=self.structure, atom_files=self.structure_file.as_posix())
aln2.append(file=slice_ali.as_posix(), align_codes=self.sequence) aln2.append(file=slice_ali.as_posix(), align_codes=self.sequence)
aln2.align2d() aln2.align2d()
aln2.write(file=(self.outdir / 'alignment2.ali').as_posix(), alignment_format='PIR') aln2.write(file=(self.outdir / 'alignment2.ali').as_posix(), alignment_format='PIR')
aln2.write(file=(self.outdir / 'alignment2.pap').as_posix(), alignment_format='PAP') aln2.write(file=(self.outdir / 'alignment2.pap').as_posix(), alignment_format='PAP')
log.verbose() log.verbose()