Skip to content

Commit

Permalink
Remove Python2 legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Dec 23, 2024
1 parent 894bc65 commit 9952c1b
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 108 deletions.
70 changes: 35 additions & 35 deletions docs/examples/using-hgvs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Using hgvs

This notebook demonstrates major features of the hgvs package.

.. code:: ipython2
.. code:: ipython3
import hgvs
hgvs.__version__
Expand All @@ -24,7 +24,7 @@ Variant I/O
Initialize the parser
~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython2
.. code:: ipython3
# You only need to do this once per process
import hgvs.parser
Expand All @@ -33,11 +33,11 @@ Initialize the parser
Parse a simple variant
~~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython2
.. code:: ipython3
v = hp.parse_hgvs_variant("NC_000007.13:g.21726874G>A")
.. code:: ipython2
.. code:: ipython3
v
Expand All @@ -50,7 +50,7 @@ Parse a simple variant
.. code:: ipython2
.. code:: ipython3
v.ac, v.type
Expand All @@ -63,7 +63,7 @@ Parse a simple variant
.. code:: ipython2
.. code:: ipython3
v.posedit
Expand All @@ -76,7 +76,7 @@ Parse a simple variant
.. code:: ipython2
.. code:: ipython3
v.posedit.pos
Expand All @@ -89,7 +89,7 @@ Parse a simple variant
.. code:: ipython2
.. code:: ipython3
v.posedit.pos.start
Expand All @@ -105,11 +105,11 @@ Parse a simple variant
Parsing complex variants
~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython2
.. code:: ipython3
v = hp.parse_hgvs_variant("NM_003777.3:c.13552_*36del57")
.. code:: ipython2
.. code:: ipython3
v.posedit.pos.start, v.posedit.pos.end
Expand All @@ -123,7 +123,7 @@ Parsing complex variants
.. code:: ipython2
.. code:: ipython3
v.posedit.edit
Expand All @@ -142,7 +142,7 @@ Formatting variants
All objects may be formatted simply by “stringifying” or printing them
using ``str``, ``print()``, or ``"".format()``.

.. code:: ipython2
.. code:: ipython3
str(v)
Expand All @@ -155,7 +155,7 @@ using ``str``, ``print()``, or ``"".format()``.
.. code:: ipython2
.. code:: ipython3
print(v)
Expand All @@ -165,7 +165,7 @@ using ``str``, ``print()``, or ``"".format()``.
NM_003777.3:c.13552_*36del57
.. code:: ipython2
.. code:: ipython3
"{v} spans the CDS end".format(v=v)
Expand All @@ -189,7 +189,7 @@ raw sequence. These are provided by a ``hgvs.dataprovider`` instance.
The only dataprovider provided with hgvs uses UTA. You may write your
own by subsclassing hgvs.dataproviders.interface.

.. code:: ipython2
.. code:: ipython3
import hgvs.dataproviders.uta
hdp = hgvs.dataproviders.uta.connect()
Expand All @@ -206,7 +206,7 @@ AssemblyMapper builds on VariantMapper and handles identifying
appropriate sequences. It is configured for a particular genome
assembly.

.. code:: ipython2
.. code:: ipython3
import hgvs.variantmapper
#vm = variantmapper = hgvs.variantmapper.VariantMapper(hdp)
Expand All @@ -220,13 +220,13 @@ This is the easiest case because there is typically only one alignment
between a transcript and the genome. (Exceptions exist for
pseudoautosomal regions.)

.. code:: ipython2
.. code:: ipython3
var_c = hp.parse_hgvs_variant("NM_015120.4:c.35G>C")
var_g = am37.c_to_g(var_c)
var_g
.. code:: ipython2
.. code:: ipython3
am38.c_to_g(var_c)
Expand All @@ -236,7 +236,7 @@ g_to_c
In order to project a genomic variant onto a transcript, you must tell
the AssemblyMapper which transcript to use.

.. code:: ipython2
.. code:: ipython3
am37.relevant_transcripts(var_g)
Expand All @@ -249,7 +249,7 @@ the AssemblyMapper which transcript to use.
.. code:: ipython2
.. code:: ipython3
am37.g_to_c(var_g, "NM_015120.4")
Expand All @@ -265,7 +265,7 @@ the AssemblyMapper which transcript to use.
c_to_p
~~~~~~

.. code:: ipython2
.. code:: ipython3
var_p = am37.c_to_p(var_c)
str(var_p)
Expand All @@ -279,7 +279,7 @@ c_to_p
.. code:: ipython2
.. code:: ipython3
var_p.posedit.uncertain = False
str(var_p)
Expand Down Expand Up @@ -316,7 +316,7 @@ CDS positions 35 and 39.
NC_000002.11 g 73613021 > CCGGGCGAGCT---GGAGGAGGAG > 73613041
NC_000002.11 g 73613021 < GGCCCGCTCGA---CCTCCTCCTC < 73613041

.. code:: ipython2
.. code:: ipython3
str(am37.c_to_g(hp.parse_hgvs_variant("NM_015120.4:c.35G>C")))
Expand All @@ -329,7 +329,7 @@ CDS positions 35 and 39.
.. code:: ipython2
.. code:: ipython3
str(am37.c_to_g(hp.parse_hgvs_variant("NM_015120.4:c.39G>C")))
Expand Down Expand Up @@ -359,12 +359,12 @@ should be shifted 3’ and is better written as dup, as shown below:
NM_001166478.1 n 41 < TCTTTCTTTTTATTTTGTTTC < 21 NM_001166478.1:n.35dupT
NM_001166478.1 c 41 < < 21 NM_001166478.1:c.30_31insT

.. code:: ipython2
.. code:: ipython3
import hgvs.normalizer
hn = hgvs.normalizer.Normalizer(hdp)
.. code:: ipython2
.. code:: ipython3
v = hp.parse_hgvs_variant("NM_001166478.1:c.30_31insT")
str(hn.normalize(v))
Expand Down Expand Up @@ -395,7 +395,7 @@ This example is based on https://github.com/biocommons/hgvs/issues/382/.
NM_001029882.3:n.832_833delAT
NC_000001.11:g.27552114_27552115delAT

.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.1A>G"))
Expand All @@ -408,7 +408,7 @@ This example is based on https://github.com/biocommons/hgvs/issues/382/.
.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.2T>G"))
Expand All @@ -421,7 +421,7 @@ This example is based on https://github.com/biocommons/hgvs/issues/382/.
.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.1_2del"))
Expand All @@ -439,7 +439,7 @@ del at c.1_2. Good!

Now, notice what happens with c.1_3del, c.1_4del, and c.1_5del:

.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.1_3del"))
Expand All @@ -452,7 +452,7 @@ Now, notice what happens with c.1_3del, c.1_4del, and c.1_5del:
.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.1_4del"))
Expand All @@ -465,7 +465,7 @@ Now, notice what happens with c.1_3del, c.1_4del, and c.1_5del:
.. code:: ipython2
.. code:: ipython3
am38.c_to_g(hp.parse_hgvs_variant("NM_001029882.3:c.1_5del"))
Expand Down Expand Up @@ -511,12 +511,12 @@ nucleotide in the variant matches that implied by the reference sequence
and position. Validation returns ``True`` if successful, and raises an
exception otherwise.

.. code:: ipython2
.. code:: ipython3
import hgvs.validator
hv = hgvs.validator.Validator(hdp)
.. code:: ipython2
.. code:: ipython3
hv.validate(hp.parse_hgvs_variant("NM_001166478.1:c.30_31insT"))
Expand All @@ -529,7 +529,7 @@ exception otherwise.
.. code:: ipython2
.. code:: ipython3
from hgvs.exceptions import HGVSError
Expand Down
2 changes: 0 additions & 2 deletions misc/bug-examples/332-demo-deprecation
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

import logging

import hgvs.parser
Expand Down
2 changes: 0 additions & 2 deletions misc/experimental/hgvs-guess-plausible-transcripts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ TNFRSF1A:n.426T>C 1 NR_144351.1:n.426T>C
"""

from __future__ import absolute_import, division, print_function, unicode_literals

import copy
import logging
import sys
Expand Down
2 changes: 0 additions & 2 deletions misc/experimental/vcf-add-hgvs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

__doc__ = """add HGVS tags to a VCF file on stdin, output to stdout
eg$ vcf-add-hgvs <in.vcf >out.vcf
Expand Down
1 change: 0 additions & 1 deletion misc/mutalyzer-comparison/bin/hgvs-g-to-c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals
"""compare hgvs and mutalyzer for c. and g. variants provided on the command line
The comparison has two basic cases:
Expand Down
1 change: 0 additions & 1 deletion misc/mutalyzer-comparison/bin/hgvs-mutalyzer-compare
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals
"""compare hgvs and mutalyzer outputs
eg$ ./bin/hgvs-mutalyzer-compare -vv -eid -H acmg-g-current-hgvs.tsv -M acmg-g-current-mzr.tsv -B bermuda.tsv
Expand Down
1 change: 0 additions & 1 deletion misc/refalt-repr-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import hgvs
import hgvs.parser
from tabulate import tabulate
from six.moves import map

hp = hgvs.parser.Parser()

Expand Down
2 changes: 0 additions & 2 deletions misc/tx-ref-discrepancies/tx-ref-discrepancies
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, print_function, unicode_literals

import csv
import logging
import re
Expand Down
1 change: 0 additions & 1 deletion src/hgvs/alignmentmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@


from bioutils.coordinates import strand_int_to_pm
from six.moves import range

import hgvs.location
from hgvs import global_config
Expand Down
5 changes: 1 addition & 4 deletions src/hgvs/dataproviders/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
import abc
import os

import six
from six.moves import map

import hgvs

from ..decorators.lru_cache import LEARN, RUN, VERIFY, lru_cache
from ..utils.PersistentDict import PersistentDict


class Interface(six.with_metaclass(abc.ABCMeta, object)):
class Interface(metaclass=abc.ABCMeta):
"""Variant mapping and validation requires access to external data,
specifically exon structures, transcript alignments, and protein
accessions. In order to isolate the hgvs package from the myriad
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/dataproviders/ncbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import psycopg2
import psycopg2.extras
import psycopg2.pool
import six
from six.moves.urllib import parse as urlparse
from urllib import parse as urlparse

import hgvs
from hgvs.exceptions import HGVSDataNotAvailableError, HGVSError
Expand Down
Loading

0 comments on commit 9952c1b

Please sign in to comment.