Skip to content

Commit

Permalink
Fix imgt numbering of CDR1 and CDR2
Browse files Browse the repository at this point in the history
  • Loading branch information
prihoda committed Aug 8, 2022
1 parent a7d9905 commit 9b2db21
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
6 changes: 0 additions & 6 deletions abnumber/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ def _anarci_align(sequence, scheme, allowed_species, assign_germline=False) -> L
species = ali['species']
v_gene = ali['germlines']['v_gene'][0][1] if assign_germline else None
j_gene = ali['germlines']['j_gene'][0][1] if assign_germline else None
if scheme == 'imgt':
for (num, letter), aa in positions:
if str(num) == '61' and str(letter) == 'A':
raise NotImplementedError(f'Cannot parse sequence "{sequence}", '
f'ANARCI numbering of IMGT position 61A is currently broken: '
f'https://github.com/oxpig/ANARCI/issues/14')
aa_dict = {Position(chain_type=chain_type, number=num, letter=letter, scheme=scheme): aa
for (num, letter), aa in positions if aa != '-'}
tail = sequence[end+1:]
Expand Down
2 changes: 1 addition & 1 deletion abnumber/position.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def chain_type_prefix(self):
def _sort_key(self):
letter_ord = ord(self.letter) if self.letter else 0
if self.scheme == 'imgt':
if self.number == 112:
if self.number in [33, 61, 112]:
# position 112 is sorted in reverse
letter_ord = -letter_ord
elif self.scheme in ['chothia', 'kabat', 'aho']:
Expand Down
26 changes: 22 additions & 4 deletions test/test_bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@


def test_imgt_61A():
"""Related to ANARCI issue: https://github.com/oxpig/ANARCI/issues/14"""
assert Position.from_string('61A', 'H', 'imgt') > Position.from_string('61', 'H', 'imgt')
assert Position.from_string('61A', 'H', 'imgt') < Position.from_string('61', 'H', 'imgt')
seq = 'EVQLVESGGGLVQPGGSLRLSCAASGIILDYYPIGWFRQAPGKEREGVAFITNSDDSTIYTNYADSVKGRFTISRDKNSLYLQMNSLRAEDTAVYYCSSKASFLIGKDDQGIDAGEYDYWGQGTMVTVSS'
with pytest.raises(NotImplementedError):
chain = Chain(seq, 'imgt')
chain = Chain(seq, 'imgt')
assert chain.seq == seq

def test_imgt_33A():
assert Position.from_string('33A', 'H', 'imgt') < Position.from_string('33', 'H', 'imgt')
seq = 'EVQLVESGGGLVQPGGSLRLSCAASGIILELVISDYYPIGWFRQAPGKEREGVAFITNSDDSTIYTNYADSVKGRFTISRDKNSLYLQMNSLRAEDTAVYYCSSKASFLIGKDDQGIDAGEYDYWGQGTMVTVSS'
chain = Chain(seq, 'imgt')
assert chain.seq == seq


def test_kappa_imgt_21():
from anarci import run_hmmer
sequence = 'DVVMTQSPLSLPVTLGQPASISCRSSQSLVYSDGNTYLNWFQQRPGQSPRRLIYKVSNRDSGVPDRFSGSGSGTDFTLKISRVEAEDVGVYYCMQGTFGQGTKVEIK'
alignment = run_hmmer([('id', sequence)], hmm_database="ALL", hmmerpath="", ncpu=None, bit_score_threshold=80)[0]
print(len(alignment))
print('---')
for pos in alignment:
print(pos)
print('---')
for pos, aa in zip(alignment, sequence):
print(pos, aa)


def test_light_chain_IMGT_position_21():
Expand Down

0 comments on commit 9b2db21

Please sign in to comment.