Alignment.compare_with() — compare two alignments

compare_with(aln)
Output:
Percent residue-residue equivalence
This command compares two pairwise alignments read by the Alignment.append() commands. The alignment of the first sequence with the second sequence in aln is evaluated with respect to the current alignment. The numbers are not symmetric; i.e., they will change if the sequences or alignments are swapped. The output in the log file is self-explanatory. The percentage of equivalent residue-residue pairs in the two alignments is returned.

Example: examples/commands/compare_alignments.py

# Example for: Alignment.compare_with(), Alignment.append_model()

# Compare two alignments of two proteins each. In this case, the first
# alignment is a sequence-sequence alignment and the second alignment
# is a structure-structure alignment.

from modeller import *
log.level(1, 1, 1, 1, 0)
env = Environ()
env.io.atom_files_directory = ['../atom_files']

# Generate and save sequence-sequence alignment:
aln = Alignment(env)
for code in ('1fas', '2ctx'):
    mdl = Model(env, file=code)
    aln.append_model(mdl=mdl, align_codes=code, atom_files=code)
aln.align(gap_penalties_1d=(-600, -400))
aln.write(file='toxin-seq.ali')

# Generate and save structure-structure alignment:
aln.align3d(gap_penalties_3d=(0, 2.0))
aln.write(file='toxin-str.ali')

# Compare the two pairwise alignments:
aln  = Alignment(env, file='toxin-seq.ali', align_codes='all')
aln2 = Alignment(env, file='toxin-str.ali', align_codes='all')
aln.compare_with(aln2)