Skip to content

mutalyzer/crossmapper

Repository files navigation

HGVS position crossmapper

https://travis-ci.org/mutalyzer/crossmapper.svg?branch=master https://readthedocs.org/projects/mutalyzer-crossmapper/badge/?version=latest

This library provides an interface to convert (cross map) between different HGVS numbering systems.

Converting between the transcript oriented c. or n. and the genomic oriented g. numbering systems can be difficult, especially when the transcript in question resides on the complement strand.

Features:

  • Support for genomic positions to standard coordinates and vice versa.
  • Support for noncoding positions to standard coordinates and vice versa.
  • Support for coding positions to standard coordinates and vice versa.
  • Support for protein positions to standard coordinates and vice versa.
  • Basic classes for loci that can be used for genomic loci other than genes.

Please see ReadTheDocs for the latest documentation.

Quick start

The Crossmap class provides an interface to all conversions between positioning systems.

>>> from mutalyzer_crossmapper import Crossmap

When initialised with no gene information, the only conversions available are those between genomic positions and standard coordinates.

>>> crossmap = Crossmap()
>>> crossmap.coordinate_to_genomic(0)
1
>>> crossmap.genomic_to_coordinate(1)
0

When initialised with only exon information, conversions to and from noncoding positions are available as well.

>>> exons = [(5, 8), (14, 20), (30, 35), (40, 44), (50, 52), (70, 72)]
>>> crossmap = Crossmap(exons)
>>> crossmap.coordinate_to_noncoding(35)
(14, 1)
>>> crossmap.noncoding_to_coordinate((14, 1))
35

Add the flag inverted=True to the constructor when the transcript resides on the reverse complement strand.

When initialised with both exon information as well as a CDS, conversions to and from coding positions and protein positions are available as well.

>>> cds = (32, 43)
>>> crossmap = Crossmap(exons, cds)
>>> crossmap.coordinate_to_coding(31)
(-1, 0, 0)
>>> crossmap.coding_to_coordinate((-1, 0, 0))
31

Again, the flag inverted=True can be used for transcripts that reside on the reverse complement strand.