Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
mutalyzer
Commits
61936296
Commit
61936296
authored
9 years ago
by
Jeroen F.J. Laros
Committed by
Vermaat
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Using composition instead of subclassing for the HGVSList class.
parent
378d6365
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mutalyzer/variant.py
+32
-8
32 additions, 8 deletions
mutalyzer/variant.py
with
32 additions
and
8 deletions
mutalyzer/variant.py
+
32
−
8
View file @
61936296
...
...
@@ -18,21 +18,41 @@ WEIGHTS = {
}
class
HGVSList
(
lis
t
):
class
HGVSList
(
objec
t
):
"""
Container for a list of sequences or variants.
"""
def
__init__
(
self
,
items
=
[]):
self
.
items
=
list
(
items
)
def
__getitem__
(
self
,
index
):
return
self
.
items
[
index
]
def
__bool__
(
self
):
return
bool
(
len
(
self
.
items
)
>
0
)
def
__nonzero__
(
self
):
# Python 2.x compatibility.
return
self
.
__bool__
()
def
__unicode__
(
self
):
if
len
(
self
)
>
1
:
return
'
[{}]
'
.
format
(
'
;
'
.
join
(
map
(
unicode
,
self
)))
return
unicode
(
self
[
0
])
if
len
(
self
.
items
)
>
1
:
return
'
[{}]
'
.
format
(
'
;
'
.
join
(
map
(
unicode
,
self
.
items
)))
return
unicode
(
self
.
items
[
0
])
def
append
(
self
,
item
):
self
.
items
.
append
(
item
)
def
weight
(
self
):
weight
=
sum
(
map
(
lambda
x
:
x
.
weight
(),
self
))
weight
=
sum
(
map
(
lambda
x
:
x
.
weight
(),
self
.
items
))
if
len
(
self
)
>
1
:
return
weight
+
(
len
(
self
)
+
1
)
*
extractor
.
WEIGHT_SEPARATOR
if
len
(
self
.
items
)
>
1
:
return
weight
+
(
len
(
self
.
items
)
+
1
)
*
extractor
.
WEIGHT_SEPARATOR
return
weight
...
...
@@ -82,10 +102,14 @@ class ISeq(object):
return
'
{}_{}{}
'
.
format
(
self
.
start
,
self
.
end
,
inverted
)
def
__
nonzero
__
(
self
):
def
__
bool
__
(
self
):
return
bool
(
self
.
sequence
)
def
__nonzero__
(
self
):
# Python 2.x compatibility.
return
self
.
__bool__
()
def
weight
(
self
):
if
self
.
type
==
'
ins
'
:
return
len
(
self
.
sequence
)
*
extractor
.
WEIGHT_BASE
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment