Skip to content
Browse files

Tweaked super() in Alts for multiple inheritance.

  • Loading branch information...
1 parent cc894c5 commit 1640ff0ffe14e4083ce9318cb8d16ad3aeb36ad2 @lennax lennax committed Jul 1, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 vcf/model.py
View
21 vcf/model.py
@@ -411,7 +411,8 @@ class _AltRecord(object):
'''An alternative allele record: either replacement string, SV placeholder, or breakend'''
__metaclass__ = ABCMeta
- def __init__(self, type):
+ def __init__(self, type, **kwargs):
+ super(_AltRecord, self).__init__(**kwargs)
#: String to describe the type of variant, by default "SNV" or "MNV", but can be extended to any of the types described in the ALT lines of the header (e.g. "DUP", "DEL", "INS"...)
self.type = type
@@ -426,11 +427,11 @@ def __eq__(self, other):
class _Substitution(_AltRecord):
'''A basic ALT record, where a REF sequence is replaced by an ALT sequence'''
- def __init__(self, nucleotides):
+ def __init__(self, nucleotides, **kwargs):
if len(nucleotides) == 1:
- super(_Substitution, self).__init__("SNV")
+ super(_Substitution, self).__init__(type="SNV", **kwargs)
else:
- super(_Substitution, self).__init__("MNV")
+ super(_Substitution, self).__init__(type="MNV", **kwargs)
#: Alternate sequence
self.sequence = str(nucleotides)
@@ -453,8 +454,8 @@ def __eq__(self, other):
class _Breakend(_AltRecord):
'''A breakend which is paired to a remote location on or off the genome'''
- def __init__(self, chr, pos, orientation, remoteOrientation, connectingSequence, withinMainAssembly):
- super(_Breakend, self).__init__("BND")
+ def __init__(self, chr, pos, orientation, remoteOrientation, connectingSequence, withinMainAssembly, **kwargs):
@superbobry
superbobry added a note Jul 31, 2012

Why CamelCase for keyword arguments, when most of the code uses pythonic under_score?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ super(_Breakend, self).__init__(type="BND", **kwargs)
#: The chromosome of breakend's mate.
self.chr = str(chr)
#: The coordinate of breakend's mate.
@@ -502,15 +503,15 @@ def __eq__(self, other):
class _SingleBreakend(_Breakend):
'''A single breakend'''
- def __init__(self, orientation, connectingSequence):
- super(_SingleBreakend, self).__init__(None, None, orientation, None, connectingSequence, None)
+ def __init__(self, orientation, connectingSequence, **kwargs):
+ super(_SingleBreakend, self).__init__(None, None, orientation, None, connectingSequence, None, **kwargs)
class _SV(_AltRecord):
'''An SV placeholder'''
- def __init__(self, type):
- super(_SV, self).__init__(type)
+ def __init__(self, type, **kwargs):
+ super(_SV, self).__init__(type, **kwargs)
@superbobry
superbobry added a note Jul 31, 2012

Maybe a constructor can be removed, since it doesn't have anything else besides a super call?

@lennax
lennax added a note Jul 31, 2012

The constructor passes an arg to the superclass. Also, the rest of the classes in the project use super(), and my goal here was to allow for possible multiple inheritance. I provided some examples and links in pull request 64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
def __str__(self):
return "<" + self.type + ">"

0 comments on commit 1640ff0

Please sign in to comment.
Something went wrong with that request. Please try again.