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