Skip to content

Commit

Permalink
Make all lines at most 80 chars long
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 19, 2024
1 parent 1e110bb commit c3802ab
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 181 deletions.
32 changes: 20 additions & 12 deletions src/aligntools/coordinate_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

class CoordinateMapping:
"""
Manages bidirectional mappings between reference and query coordinates, as well as operation indices.
Manages bidirectional mappings between reference and query
coordinates, as well as operation indices.
The mapping enables conversion from reference to query coordinates and vice versa. It also manages the
association of these coordinates with their respective operations in the alignment process.
The mapping enables conversion from reference to query coordinates
and vice versa. It also manages the association of these
coordinates with their respective operations in the alignment
process.
"""

def __init__(self) -> None:
Expand All @@ -28,20 +31,25 @@ def extend(self,
self.ref_to_op.extend(ref_index, op_index)
self.query_to_op.extend(query_index, op_index)

def translate(self, reference_delta: int, query_delta: int) -> 'CoordinateMapping':
def translate(self, reference_delta: int, query_delta: int) \
-> 'CoordinateMapping':
"""
Generate a new CoordinateMapping with shifted coordinate spaces.
This method creates a new mapping where each original coordinate in
the reference and query sequences is shifted. This allows for adapting
the CoordinateMapping to account for changes or offsets in sequence positions,
such as when sequences are trimmed or extended.
Generate a new CoordinateMapping with shifted coordinate
spaces.
This method creates a new mapping where each original
coordinate in the reference and query sequences is
shifted. This allows for adapting the CoordinateMapping to
account for changes or offsets in sequence positions, such as
when sequences are trimmed or extended.
"""

ret = CoordinateMapping()

ret.ref_to_query = self.ref_to_query.translate(reference_delta, query_delta)
ret.query_to_ref = self.query_to_ref.translate(query_delta, reference_delta)
ret.ref_to_query = self.ref_to_query.translate(
reference_delta, query_delta)
ret.query_to_ref = self.query_to_ref.translate(
query_delta, reference_delta)
ret.ref_to_op = self.ref_to_op.translate(reference_delta, 0)
ret.query_to_op = self.query_to_op.translate(query_delta, 0)

Expand Down
24 changes: 14 additions & 10 deletions src/aligntools/int_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

class IntDict(Mapping[int, int]):
"""
An extension of the basic Python dictionary designed for integer-to-integer mappings.
The IntDict maintains not just key-value pairs (as in a normal dictionary) but also
tracks additional sets called `domain` and `codomain`. These sets are supersets
of the keys and values respectively, as they include integers that might not be used
directly in mappings but are within the range of interest for the domain and codomain.
An extension of the basic Python dictionary designed for
integer-to-integer mappings.
The IntDict maintains not just key-value pairs (as in a normal
dictionary) but also tracks additional sets called `domain` and
`codomain`. These sets are supersets of the keys and values
respectively, as they include integers that might not be used
directly in mappings but are within the range of interest for the
domain and codomain.
"""

def __init__(self) -> None:
Expand All @@ -35,10 +38,11 @@ def right_min(self, index: int) -> Optional[int]:

def translate(self, domain_delta: int, codomain_delta: int) -> 'IntDict':
"""
Generates a new IntDict by shifting the entire mapping -- keys and values
are incremented by domain_delta and codomain_delta, respectively.
This shift operation preserves the inherent ordering and relative spacing within the mapping,
effectively repositioning the dataset within the integer space.
Generates a new IntDict by shifting the entire mapping -- keys
and values are incremented by domain_delta and codomain_delta,
respectively. This shift operation preserves the inherent
ordering and relative spacing within the mapping, effectively
repositioning the dataset within the integer space.
"""

ret = IntDict()
Expand Down
Loading

0 comments on commit c3802ab

Please sign in to comment.