Skip to content

Commit

Permalink
reformatted with black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
reece committed Sep 11, 2023
1 parent 1073d1f commit 21e6106
Show file tree
Hide file tree
Showing 63 changed files with 1,857 additions and 1,622 deletions.
3 changes: 1 addition & 2 deletions src/hgvs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
import re
Expand Down
13 changes: 7 additions & 6 deletions src/hgvs/alignmentmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@
#


from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

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

import hgvs.location
from hgvs import global_config
from hgvs.enums import Datum
from hgvs.exceptions import (HGVSDataNotAvailableError, HGVSError,
HGVSInvalidIntervalError, HGVSUsageError)
from hgvs.exceptions import (
HGVSDataNotAvailableError,
HGVSError,
HGVSInvalidIntervalError,
HGVSUsageError,
)
from hgvs.utils import build_tx_cigar
from hgvs.utils.cigarmapper import CIGARMapper

Expand Down Expand Up @@ -88,7 +91,6 @@ def __init__(self, hdp, tx_ac, alt_ac, alt_aln_method):
self.alt_aln_method = alt_aln_method

if self.alt_aln_method != "transcript":

tx_info = hdp.get_tx_info(self.tx_ac, self.alt_ac, self.alt_aln_method)
if tx_info is None:
raise HGVSDataNotAvailableError(
Expand Down Expand Up @@ -126,7 +128,6 @@ def __init__(self, hdp, tx_ac, alt_ac, alt_aln_method):
self.tgt_len = self.cigarmapper.tgt_len

else:

# this covers the identity cases n <-> c
tx_identity_info = hdp.get_tx_identity_info(self.tx_ac)
if tx_identity_info is None:
Expand Down
16 changes: 9 additions & 7 deletions src/hgvs/assemblymapper.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# -*- coding: utf-8 -*-

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import logging

import hgvs
import hgvs.normalizer
from hgvs.exceptions import (HGVSDataNotAvailableError, HGVSError,
HGVSInvalidVariantError,
HGVSUnsupportedOperationError)
from hgvs.exceptions import (
HGVSDataNotAvailableError,
HGVSError,
HGVSInvalidVariantError,
HGVSUnsupportedOperationError,
)
from hgvs.variantmapper import VariantMapper

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -57,7 +59,7 @@ def __init__(
replace_reference=hgvs.global_config.mapping.replace_reference,
add_gene_symbol=hgvs.global_config.mapping.add_gene_symbol,
*args,
**kwargs
**kwargs,
):
"""
:param object hdp: instance of hgvs.dataprovider subclass
Expand All @@ -78,7 +80,7 @@ def __init__(
prevalidation_level=prevalidation_level,
add_gene_symbol=add_gene_symbol,
*args,
**kwargs
**kwargs,
)
self.assembly_name = assembly_name
self.alt_aln_method = alt_aln_method
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
import re
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/dataproviders/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import abc
import os
Expand Down
3 changes: 0 additions & 3 deletions src/hgvs/dataproviders/ncbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ def _get_cursor(self, n_retries=1):
n_tries_rem = n_retries + 1
while n_tries_rem > 0:
try:

conn = self._pool.getconn() if self.pooling else self._conn

# autocommit=True obviates closing explicitly
Expand All @@ -330,7 +329,6 @@ def _get_cursor(self, n_retries=1):
break

except psycopg2.OperationalError:

_logger.warning("Lost connection to {url}; attempting reconnect".format(url=self.url))
if self.pooling:
self._pool.closeall()
Expand All @@ -340,7 +338,6 @@ def _get_cursor(self, n_retries=1):
n_tries_rem -= 1

else:

# N.B. Probably never reached
raise HGVSError("Permanently lost connection to {url} ({n} retries)".format(url=self.url, n=n_retries))

Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/dataproviders/seqfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import logging
import os
Expand Down
6 changes: 1 addition & 5 deletions src/hgvs/dataproviders/uta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import contextlib
import inspect
Expand Down Expand Up @@ -580,7 +579,6 @@ def _get_cursor(self, n_retries=1):
n_tries_rem = n_retries + 1
while n_tries_rem > 0:
try:

conn = self._pool.getconn() if self.pooling else self._conn

# autocommit=True obviates closing explicitly
Expand All @@ -604,7 +602,6 @@ def _get_cursor(self, n_retries=1):
break

except psycopg2.OperationalError:

_logger.warning("Lost connection to {url}; attempting reconnect".format(url=self.url))
if self.pooling:
self._pool.putconn(conn)
Expand All @@ -616,7 +613,6 @@ def _get_cursor(self, n_retries=1):
n_tries_rem -= 1

else:

# N.B. Probably never reached
raise HGVSError("Permanently lost connection to {url} ({n} retries)".format(url=self.url, n=n_retries))

Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/decorators/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import collections
import warnings
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/decorators/lru_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

from collections import namedtuple
from functools import update_wrapper
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals

import attr
import six
Expand Down
3 changes: 1 addition & 2 deletions src/hgvs/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)
from __future__ import absolute_import, division, print_function, unicode_literals


class HGVSError(Exception):
Expand Down
31 changes: 16 additions & 15 deletions src/hgvs/extras/babelfish.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""translate between HGVS and other formats"""
import os

import hgvs
import hgvs.normalizer
from bioutils.assemblies import make_ac_name_map, make_name_ac_map
from bioutils.sequences import reverse_complement

import hgvs
import hgvs.normalizer
from hgvs.edit import NARefAlt
from hgvs.location import Interval, SimplePosition
from hgvs.normalizer import Normalizer
Expand Down Expand Up @@ -54,20 +55,20 @@ def hgvs_to_vcf(self, var_g):
start_i -= 1
alt = self.hdp.seqfetcher.fetch_seq(vleft.ac, start_i, end_i)
ref = alt[0]
elif typ == 'inv':
elif typ == "inv":
ref = vleft.posedit.edit.ref
alt = reverse_complement(ref)
else:
alt = vleft.posedit.edit.alt or ""

if typ in ('del', 'ins'): # Left anchored
if typ in ("del", "ins"): # Left anchored
start_i -= 1
ref = self.hdp.seqfetcher.fetch_seq(vleft.ac, start_i, end_i)
alt = ref[0] + alt
else:
ref = vleft.posedit.edit.ref
if ref == alt:
alt = '.'
alt = "."
return chrom, start_i + 1, ref, alt, typ

def vcf_to_g_hgvs(self, chrom, position, ref, alt):
Expand All @@ -82,25 +83,25 @@ def vcf_to_g_hgvs(self, chrom, position, ref, alt):
alt = alt[lp:]
position += lp

if ref == '': # Insert
if ref == "": # Insert
# Insert uses coordinates around the insert point.
start = position - 1
end = position
else:
start = position
end = position + len(ref) - 1

if alt == '.':
if alt == ".":
alt = ref

var_g = SequenceVariant(ac=ac,
type='g',
posedit=PosEdit(Interval(start=SimplePosition(start),
end=SimplePosition(end),
uncertain=False),
NARefAlt(ref=ref or None,
alt=alt or None,
uncertain=False)))
var_g = SequenceVariant(
ac=ac,
type="g",
posedit=PosEdit(
Interval(start=SimplePosition(start), end=SimplePosition(end), uncertain=False),
NARefAlt(ref=ref or None, alt=alt or None, uncertain=False),
),
)
n = Normalizer(self.hdp)
return n.normalize(var_g)

Expand Down

0 comments on commit 21e6106

Please sign in to comment.