cool_seq_tool.utils#

Provide a small set of general helper functions.

cool_seq_tool.utils.get_inter_residue_pos(start_pos, end_pos, coordinate_type)[source]#

Return equivalent inter-residue position.

Residue coordinates start with 1, whereas inter-residue coordinates start with 0.

It is preferred to work with inter-residue coordinates where possible. Our rationale is detailed in an appendix to the VRS docs. This function is used internally to shift user-provided coordinates accordingly.

>>> from cool_seq_tool.utils import get_inter_residue_pos
>>> from cool_seq_tool.schemas import CoordinateType
>>> get_inter_residue_pos(10, CoordinateType.RESIDUE)
((9, 9), None)
Parameters:
  • start_pos (int) – Start position

  • end_pos (int) – End position

  • coordinate_type (CoordinateType) – Coordinate type for start_pos and end_pos

Return type:

tuple[int, int]

Returns:

Inter-residue coordinates

cool_seq_tool.utils.process_chromosome_input(chromosome, context='')[source]#

Perform processing on a chromosome arg.

E.g.

>>> from cool_seq_tool.utils import process_chromosome_input
>>> process_chromosome_input("7")
'chr7'
>>> process_chromosome_input("x")
'chrX'
>>> process_chromosome_input("chr7")
'chr7'

In the future, we could also use this method to be more opinionated about legal chromosome values, or throw exceptions in the event of invalid or unrecognized terms.

Parameters:
  • chromosome (str) – user-provided chromosome input

  • context (str) – calling context to provide in log

Return type:

str

Returns:

processed chromosome value. Idempotent – returns original value if no changes needed.

cool_seq_tool.utils.service_meta()[source]#

Return description of request and service, including parameters like software version for reproducibility.

Return type:

ServiceMeta

Returns:

ServiceMeta object