Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
aliby
alibylite
Commits
faba0626
Commit
faba0626
authored
3 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
refactor reassign_mothers fn
parent
b6ec9982
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extraction/core/lineage.py
+18
-13
18 additions, 13 deletions
extraction/core/lineage.py
with
18 additions
and
13 deletions
extraction/core/lineage.py
+
18
−
13
View file @
faba0626
from
copy
import
copy
def
reassign_mo_bud
(
mo_bud
,
trans
):
"""
FIXME:
Update mother_bud dictionary using another dict with tracks joined
input
...
...
@@ -14,18 +16,21 @@ def reassign_mo_bud(mo_bud, trans):
val2lst
=
lambda
x
:
[
j
for
i
in
x
.
values
()
for
j
in
i
]
bud_inter
=
set
(
val2lst
(
mo_bud
)).
intersection
(
trans
.
keys
())
bud_inter
=
set
(
val2lst
(
mo_bud
)).
intersection
(
trans
.
keys
())
# translate mothers and carry untranslated daughters
new_mb
=
copy
(
mo_bud
)
for
origin
,
target
in
trans
:
if
target
in
new_mb
:
new_mb
[
target
]
=
new_mb
.
get
(
target
,
set
()).
union
(
new_mb
[
origin
])
del
new_mb
[
origin
]
# translate daughters
mo_bud
=
copy
(
mo_bud
)
for
k
,
das
in
mo_bud
.
items
():
for
da
in
bud_inter
.
intersection
(
das
):
mo_bud
[
k
][
mo_bud
[
k
].
index
(
da
)]
=
trans
[
da
]
# translate mothers
mo_inter
=
set
(
mo_bud
.
keys
()).
intersection
(
trans
.
keys
())
for
k
in
mo_inter
:
mo_bud
[
trans
[
k
]]
=
mo_bud
.
get
(
trans
[
k
],
[])
+
mo_bud
[
k
]
del
mo_bud
[
k
]
return
mo_bud
for
origin
,
target
in
trans
:
if
origin
in
bud_inter
:
# Limit scope of searcg
for
mo
,
da
in
new_mb
.
items
():
if
origin
in
da
:
da
.
remove
(
origin
)
new_mb
[
mo
]
=
da
.
union
(
target
)
return
new_mb
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