Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed case where match on not independent state was not incrementing … #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/python/anarci/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,21 @@ def _number_regions(sequence, state_vector, state_string , region_string, regio

# Check whether this position is in the scheme as an independent state
if state_string[state_id-1]=="I": # No, it should be treated as an insertion
if previous_state_type != 'd': # Unless there was a deletion beforehand in which case this should be a real pos.
if previous_state_type != 'd' and state_string[previous_state_id-1] == "X": # Unless there was a deletion beforehand in which case this should be a real pos.
# in case previous deletion was not on independent state - it should not be considered here
insertion +=1 # Increment the insertion annotation index
rels[region] -= 1 # Update the relative numbering from the imgt states
else: # Yes
insertion = -1 # Reset the insertions

# Add the numbering annotation to the appropriate region list
_regions[region].append( ( (state_id + rels[region], alphabet[insertion] ), sequence[si] ) )
previous_state_id = state_id # Record the previous state ID
if start_index is None:
start_index = si
end_index = si

previous_state_type = state_type
previous_state_id = state_id

elif state_type == "i": # It is an insertion
insertion +=1 # Increment the insertion annotation index
Expand All @@ -267,17 +268,18 @@ def _number_regions(sequence, state_vector, state_string , region_string, regio
end_index = si

previous_state_type = state_type
previous_state_id = state_id

else: # It is a deletion
previous_state_type = state_type
previous_state_id = state_id

# Check whether this position is in the scheme as an independent state
if state_string[state_id-1]=="I": # No, therefore irrelevant to the scheme.
rels[region] -= 1 # Update the relative numbering from the imgt states
continue

insertion = -1 # Reset the insertions
previous_state_id = state_id # Record the previous state ID, should not be needed (no delete to insert state transition)


# Reset the inssertion index if necessary and allowed. (Means the insertion code is meaningless and will be reannotated)
Expand Down