Thread biopython alignment arguments through mapping functions#2257
Thread biopython alignment arguments through mapping functions#2257jamesmkrieger wants to merge 1 commit into
Conversation
Allow seq_alignment_method, match_score, mismatch_score, gap_penalty and gap_ext_penalty keyword arguments to flow through getAlignedMapping, getAlignedMatch, mapChainOntoChain, matchChains, mapOntoChains, alignChains and buildPDBEnsemble, overriding the module-level constants per call. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
karolamik13
left a comment
There was a problem hiding this comment.
I used two conformations of one protein structure to check it.
Received and expected values are the same.
Used code:
from prody import *
from unittest.mock import patch
import prody.proteins.compare as compare
target = parsePDB('5ir4', chain='A', subset='ca')
mobile = parsePDB('5ir5', chain='A', subset='ca')
alignment_kwargs = {
'pwalign': True,
'seqid': 1,
'overlap': 1,
'seq_alignment_method': 'global',
'match_score': 7.0,
'mismatch_score': -6.0,
'gap_penalty': -8.0,
'gap_ext_penalty': -1.5}
expected = ('global', 7.0, -6.0, -8.0, -1.5)
with patch.object(compare, 'alignBioPairwise', wraps=compare.alignBioPairwise) as mocked_align:
matchChains(mobile, target, **alignment_kwargs)
received = mocked_align.call_args[0][2:7]
assert received == expected
print('TEST results:', received)
Output:
@> PDB file is found in working directory (5ir4.pdb.gz).
@> 657 atoms and 1 coordinate set(s) were parsed in 0.03s.
@> PDB file is found in working directory (5ir5.pdb.gz).
@> 626 atoms and 1 coordinate set(s) were parsed in 0.03s.
@> Checking AtomGroup 5ir5A_ca: 1 chains are identified
@> Checking AtomGroup 5ir4A_ca: 1 chains are identified
@> Trying to match chains based on global sequence alignment:
@> Comparing Chain A from 5ir5A_ca (len=626) and Chain A from 5ir4A_ca (len=657):
/home/xxx/.local/lib/python3.10/site-packages/Bio/pairwise2.py:278: BiopythonDeprecationWarning: Bio.pairwise2 has been deprecated, and we intend to remove it in a future release of Biopython. As an alternative, please consider using Bio.Align.PairwiseAligner as a replacement, and contact the Biopython developers if you still need the Bio.pairwise2 module.
warnings.warn(
@> Match: 625 residues match with 100% sequence identity and 95% overlap.
TEST results: ('global', 7.0, -6.0, -8.0, -1.5)
Allow seq_alignment_method, match_score, mismatch_score, gap_penalty and gap_ext_penalty keyword arguments to flow through getAlignedMapping, getAlignedMatch, mapChainOntoChain, matchChains, mapOntoChains, alignChains and buildPDBEnsemble, overriding the module-level constants per call.