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 positionend_pos (
int) – End positioncoordinate_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 inputcontext (
str) – calling context to provide in log
- Return type:
str- Returns:
processed chromosome value. Idempotent – returns original value if no changes needed.