Skip to content

Commit

Permalink
Merge pull request biocommons#729 from davmlaw/issue_178_abc_EDit
Browse files Browse the repository at this point in the history
biocommons#178 - use abc for Edit class to ensure method definition
  • Loading branch information
davmlaw authored Mar 21, 2024
2 parents 3c6c265 + 76e5f01 commit 67f610b
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/hgvs/alignmentmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _hgvs_to_zbc(i):
return i


class AlignmentMapper(object):
class AlignmentMapper:
"""Maps hgvs location objects between genomic (g), non-coding (n) and
cds (c) coordinates according to a CIGAR string.
Expand Down
4 changes: 2 additions & 2 deletions src/hgvs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
logger = logging.getLogger(__name__)


class Config(object):
class Config:
"""provides an attribute-based lookup of configparser sections and
settings.
Expand Down Expand Up @@ -75,7 +75,7 @@ def __getattr__(self, k):
__getitem__ = __getattr__


class ConfigGroup(object):
class ConfigGroup:
def __init__(self, section):
self.__dict__["_section"] = section

Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/dataproviders/ncbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def connect(
return conn


class NCBIBase(object):
class NCBIBase:
required_version = "1.1"

_queries = {
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/dataproviders/seqfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
_logger = logging.getLogger(__name__)


class SeqFetcher(object):
class SeqFetcher:
"""This class is intended primarily as a mixin for HGVS data providers
that doen't otherwise have access to sequence data. It uses the
fetch_seq() function in this module to fetch sequences from
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/decorators/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import warnings


class deprecated(object):
class deprecated:
"""Decorator factory class which returns a decorator function that
marks a function as deprecated. It will result in a warning being
emitted when the function is used, once per invocation point and
Expand Down
9 changes: 8 additions & 1 deletion src/hgvs/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
location).
"""
import abc

import attr
import six
Expand All @@ -18,7 +19,7 @@


@attr.s(slots=True)
class Edit(object):
class Edit(abc.ABC):
def format(self, conf=None):
return str(self)

Expand Down Expand Up @@ -46,6 +47,12 @@ def _del_ins_lengths(self, ilen):
"internal function _del_ins_lengths not implemented for this variant type"
)

@property
@abc.abstractmethod
def type(self):
""" return the type of this Edit """
pass


@attr.s(slots=True)
class NARefAlt(Edit):
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/hgvsposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


@attr.s(slots=True, repr=False)
class HGVSPosition(object):
class HGVSPosition:
"""
HGVSPosition -- Represent partial HGVS tags that refer to a position without alleles
Expand Down
8 changes: 4 additions & 4 deletions src/hgvs/intervalmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

# N.B. This Interval is internal to intervalmapper.py. It is *NOT* the
# same as the Interval defined in location.py.
class Interval(object):
class Interval:
"""Represents a segment of a sequence in interbase
coordinates (0-based, right-open).
"""
Expand All @@ -78,7 +78,7 @@ def __repr__(self):
)


class IntervalPair(object):
class IntervalPair:
"""Represents a match, insertion, or deletion segment of an
alignment. If a match, the lengths must be equal; if an insertion or
deletion, the length of the ref or tgt must be zero respectively."""
Expand All @@ -101,7 +101,7 @@ def __repr__(self):
return "{self.__class__.__name__}(ref={self.ref},tgt={self.tgt})".format(self=self)


class IntervalMapper(object):
class IntervalMapper:
"""Provides mapping between sequence coordinates according to an
ordered set of IntervalPairs."""

Expand Down Expand Up @@ -181,7 +181,7 @@ def clip_to_iv(iv, pos):
return to_start_i, to_end_i


class CIGARElement(object):
class CIGARElement:
"""represents elements of a CIGAR string and provides methods for
determining the number of ref and tgt bases consumed by the
operation"""
Expand Down
8 changes: 4 additions & 4 deletions src/hgvs/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@attr.s(slots=True, repr=False, cmp=False)
@total_ordering
class SimplePosition(object):
class SimplePosition:
base = attr.ib(default=None)
uncertain = attr.ib(default=False)

Expand Down Expand Up @@ -79,7 +79,7 @@ def __lt__(lhs, rhs):

@attr.s(slots=True, repr=False, cmp=False)
@total_ordering
class BaseOffsetPosition(object):
class BaseOffsetPosition:
"""
Class for dealing with CDS coordinates in transcript variants.
Expand Down Expand Up @@ -219,7 +219,7 @@ def __lt__(lhs, rhs):


@attr.s(slots=True, repr=False, cmp=False)
class AAPosition(object):
class AAPosition:
base = attr.ib(default=None)
aa = attr.ib(default=None)
uncertain = attr.ib(default=False)
Expand Down Expand Up @@ -310,7 +310,7 @@ def __ge__(lhs, rhs):


@attr.s(slots=True, repr=False)
class Interval(object):
class Interval:
start = attr.ib(default=None)
end = attr.ib(default=None)
uncertain = attr.ib(default=False)
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
_logger = logging.getLogger(__name__)


class Normalizer(object):
class Normalizer:
"""Perform variant normalization"""

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from hgvs.generated.hgvs_grammar import createParserClass


class Parser(object):
class Parser:
"""Provides comprehensive parsing of HGVS variant strings (*i.e.*,
variants represented according to the Human Genome Variation
Society recommendations) into Python representations. The class
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/posedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@attr.s(slots=True, repr=False)
class PosEdit(object):
class PosEdit:
"""
represents a **simple** variant, consisting of a single position and edit pair
"""
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/projector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import hgvs.alignmentmapper


class Projector(object):
class Projector:
"""
The Projector class implements liftover between two transcripts via a
common reference sequence.
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/sequencevariant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


@attr.s(slots=True, repr=False)
class SequenceVariant(object):
class SequenceVariant:
"""
represents a basic HGVS variant. The only requirement is that each
component can be stringified; for example, passing pos as either a string
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/transcriptmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_logger.warning("This module is deprecated and will be removed in a future release")


class TranscriptMapper(object):
class TranscriptMapper:
"""Provides coordinate (not variant) mapping operations between
genomic (g), non-coding (n), cds (c), and protein (p) coordinates.
All coordinates are 1-based inclusive, per the HGVS
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/utils/altseq_to_hgvsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
DBG = False


class AltSeqToHgvsp(object):
class AltSeqToHgvsp:
def __init__(self, ref_data, alt_data):
"""Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/hgvs/utils/altseqbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
_logger = logging.getLogger(__name__)


class AltTranscriptData(object):
class AltTranscriptData:
def __init__(
self,
seq,
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(
self.is_ambiguous = is_ambiguous


class AltSeqBuilder(object):
class AltSeqBuilder:
EXON = "exon"
INTRON = "intron"
F_UTR = "five utr"
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/utils/reftranscriptdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hgvs.exceptions import HGVSDataNotAvailableError


class RefTranscriptData(object):
class RefTranscriptData:
def __init__(self, hdp, tx_ac, pro_ac):
"""helper for generating RefTranscriptData from for c_to_p"""
tx_info = hdp.get_tx_identity_info(tx_ac)
Expand Down
4 changes: 2 additions & 2 deletions src/hgvs/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
_logger = logging.getLogger(__name__)


class Validator(object):
class Validator:
"""invoke intrinsic and extrinsic validation"""

def __init__(self, hdp, strict=hgvs.global_config.validator.strict):
Expand All @@ -39,7 +39,7 @@ def validate(self, var, strict=None):
return self._ivr.validate(var, strict) and self._evr.validate(var, strict)


class IntrinsicValidator(object):
class IntrinsicValidator:
"""
Attempts to determine if the HGVS name is internally consistent
Expand Down
2 changes: 1 addition & 1 deletion src/hgvs/variantmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
_logger = logging.getLogger(__name__)


class VariantMapper(object):
class VariantMapper:
r"""Maps SequenceVariant objects between g., n., r., c., and p. representations.
g⟷{c,n,r} projections are similar in that c, n, and r variants
Expand Down
4 changes: 2 additions & 2 deletions tests/support/crosschecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hgvs.exceptions import HGVSDataNotAvailableError


class LineIterator(object):
class LineIterator:
"""iterate over a stream, keeping last line and # lines read"""

def __init__(self, fh, skip_comments=False):
Expand All @@ -29,7 +29,7 @@ def __iter__(self):
yield line


class CrossChecker(object):
class CrossChecker:
"""base class for testing a group of related variants. Checks all reasonable combinations of
g <-> t --> p
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hgvs_dataproviders_uta.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from hgvs.exceptions import HGVSDataNotAvailableError, HGVSError


class UTA_Base(object):
class UTA_Base:
def test_get_acs_for_protein_seq(self):
exp = ["NP_001005405.1", "MD5_8fc09b1d9a38a8c55176a0fa922df227"]
s = """
Expand Down

0 comments on commit 67f610b

Please sign in to comment.