Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
5baf420d
Commit
5baf420d
authored
May 12, 2020
by
Yoann Dufresne
Browse files
local score computation
parent
01d8b380
Changes
1
Hide whitespace changes
Inline
Side-by-side
deconvolution/barcodes/partialorder.py
View file @
5baf420d
...
...
@@ -22,7 +22,8 @@ class PartialOrder:
self
.
len_sets
=
0
# The number of successive udg. Same as len(udg_order)
self
.
len_udgs
=
0
# TODO: score
# This score must be updated when the order is modified
self
.
score
=
0
def
_get_right_overlaps
(
self
,
udg
):
"""" Get the overlap of an udg with the right part of the multiset partial order.
...
...
@@ -78,11 +79,48 @@ class PartialOrder:
self
.
len_barcodes
+=
sum
(
new_multiset
.
values
())
# Step 4 - Add the udg as covering the right multisets
for
idx
in
range
(
max
(
0
,
leftmost_idx
),
len
(
self
.
udg_per
_set
)
):
for
idx
in
range
(
max
(
0
,
leftmost_idx
),
self
.
len
_set
s
):
self
.
udg_per_set
[
idx
].
add
(
udg
)
# TODO: Step 5 - Modify score
def
get_add_score
(
self
,
udg
):
score
=
0
leftmost_idx
,
left_non_overlap
,
remaining_right
=
self
.
_get_right_overlaps
(
udg
)
# 1 point for the rightmost future multiset
if
len
(
remaining_right
)
>
0
:
score
+=
1
# x points if the leftmost multiset is split in 2 (x = covering udg number)
if
len
(
left_non_overlap
)
>
0
:
score
+=
len
(
self
.
udg_per_set
[
leftmost_idx
])
# covering number points for the new udg
score
+=
self
.
len_sets
-
leftmost_idx
# Negative points for redundant elements
# shift one left
remaining_size
=
sum
(
remaining_right
.
values
())
-
sum
(
left_non_overlap
.
values
())
leftmost_idx
-=
1
# Search for non overlapped common barcodes
while
remaining_size
>
0
and
leftmost_idx
>=
0
:
ms
=
self
.
barcode_order
[
leftmost_idx
]
# Compute intersection
common
=
ms
&
remaining_right
candidate_negative
=
sum
(
common
.
values
())
score
-=
min
(
candidate_negative
,
remaining_size
)
# Update structures
remaining_right
-=
common
remaining_size
-=
sum
(
ms
.
values
())
leftmost_idx
-=
1
return
score
def
__len__
(
self
):
return
self
.
len_barcodes
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment