Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
linked reads molecule ordering
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yoann DUFRESNE
linked reads molecule ordering
Commits
f78f16f2
Commit
f78f16f2
authored
Jan 13, 2020
by
Yoann Dufresne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring of the code to match package tree
parent
dd190fee
Changes
20
Hide whitespace changes
Inline
Sidebyside
Showing
20 changed files
with
138 additions
and
116 deletions
+138
116
README.md
README.md
+10
0
deconvolution/d2graph/__init__.py
deconvolution/d2graph/__init__.py
+0
0
deconvolution/d2graph/d2_algorithms.py
deconvolution/d2graph/d2_algorithms.py
+1
1
deconvolution/d2graph/d2_graph.py
deconvolution/d2graph/d2_graph.py
+2
2
deconvolution/d2graph/d2_reduction.py
deconvolution/d2graph/d2_reduction.py
+2
1
deconvolution/d2graph/path_algorithms.py
deconvolution/d2graph/path_algorithms.py
+1
1
deconvolution/d2graph/path_optimization.py
deconvolution/d2graph/path_optimization.py
+2
1
deconvolution/dgraph/FixedDGIndex.py
deconvolution/dgraph/FixedDGIndex.py
+2
1
deconvolution/dgraph/VariableDGIndex.py
deconvolution/dgraph/VariableDGIndex.py
+2
1
deconvolution/dgraph/d_graph.py
deconvolution/dgraph/d_graph.py
+91
91
deconvolution/main/__init__.py
deconvolution/main/__init__.py
+0
0
deconvolution/main/d2_to_path.py
deconvolution/main/d2_to_path.py
+1
1
deconvolution/main/generate_fake_barcode_graph.py
deconvolution/main/generate_fake_barcode_graph.py
+2
2
deconvolution/main/generate_fake_molecule_graph.py
deconvolution/main/generate_fake_molecule_graph.py
+1
1
deconvolution/main/to_d2_graph.py
deconvolution/main/to_d2_graph.py
+1
1
setup.py
setup.py
+10
0
tests/Index_test.py
tests/Index_test.py
+5
5
tests/d2_graph_test.py
tests/d2_graph_test.py
+2
4
tests/d_graph_test.py
tests/d_graph_test.py
+2
2
tests/graph_manipulation_test.py
tests/graph_manipulation_test.py
+1
1
No files found.
README.md
View file @
f78f16f2
...
...
@@ 2,6 +2,16 @@
Trying to deconvolve single tag assignment for multiple molecules
## Installation
Install the package from the root directory.
```
bash
# For users
pip
install
.
user
# For developers
pip
install
e
.
user
```
## Scripts
For the majority of the scripts, argparse is used.
...
...
deconvolution/d2graph/__init__.py
0 → 100644
View file @
f78f16f2
deconvolution/d2graph/d2_algorithms.py
View file @
f78f16f2
import
networkx
as
nx
from
d2graph.d2_path
import
Unitig
from
d
econvolution.d
2graph.d2_path
import
Unitig
""" Remove unnecessary transitions
...
...
deconvolution/d2graph/d2_graph.py
View file @
f78f16f2
...
...
@@ 3,8 +3,8 @@ import itertools
from
bidict
import
bidict
import
sys
from
dgraph.FixedDGIndex
import
FixedDGIndex
from
d
graph.d_graph
import
Dgraph
,
compute_all_max_d_graphs
,
list_domination_filter
from
d
econvolution.d
graph.FixedDGIndex
import
FixedDGIndex
from
d
econvolution.dgraph.d_graph
import
Dgraph
,
compute_all_max_d_graphs
class
D2Graph
(
nx
.
Graph
):
...
...
deconvolution/d2graph/d2_reduction.py
View file @
f78f16f2
...
...
@@ 4,7 +4,8 @@ import networkx as nx
import
argparse
import
sys
from
d2graph
import
d2_algorithms
as
d2a
,
d2_graph
as
d2
from
deconvolution.d2graph
import
d2_graph
as
d2
from
deconvolution.d2graph
import
d2_algorithms
as
d2a
def
parse_arguments
():
...
...
deconvolution/d2graph/path_algorithms.py
View file @
f78f16f2
from
d2graph.d2_path
import
Path
from
d
econvolution.d
2graph.d2_path
import
Path
""" Greedy algorithm. Start with th most probable unitig (ie lowest normalized penalty first and largest unitig for
equalities). Then extends on both side to the nearest interesting unitig.
...
...
deconvolution/d2graph/path_optimization.py
View file @
f78f16f2
import
random
from
d2graph.d2_path
import
Path
import
networkx
as
nx
from
deconvolution.d2graph.d2_path
import
Path
class
Optimizer
:
...
...
deconvolution/dgraph/FixedDGIndex.py
View file @
f78f16f2
from
dgraph.AbstractDGIndex
import
AbstractDGIndex
from
itertools
import
combinations
from
deconvolution.dgraph.AbstractDGIndex
import
AbstractDGIndex
class
FixedDGIndex
(
AbstractDGIndex
):
...
...
deconvolution/dgraph/VariableDGIndex.py
View file @
f78f16f2
from
dgraph.AbstractDGIndex
import
AbstractDGIndex
from
itertools
import
combinations
from
deconvolution.dgraph.AbstractDGIndex
import
AbstractDGIndex
class
VariableDGIndex
(
AbstractDGIndex
):
...
...
deconvolution/dgraph/d_graph.py
View file @
f78f16f2
import
networkx
as
nx
from
functools
import
total_ordering
import
community
# pip install pythonlouvain
import
community
# pip install pythonlouvain
TODO: Ajouter dans les requirements !!!
from
dgraph.FixedDGIndex
import
FixedDGIndex
from
d
econvolution.d
graph.FixedDGIndex
import
FixedDGIndex
@
total_ordering
...
...
@@ 312,92 +312,92 @@ def compute_all_max_d_graphs(graph, debug=False, clique_mode=None):
return
d_graphs
""" Add the new dg in the dgs list. If dg is dominated by another dg in the list, then it's
dropped. If any dg in the list is dominated by the dg to add, then, the new dg is added and
all the dominated dg are removed from the list.
@param dg A new dg to add/filter.
@param undominated_dgs_list A list of dg where any of them is dominated by another one.
@return The updated undominated list.
"""
def
add_new_dg_regarding_domination
(
dg
,
undominated_dgs_list
):
to_remove
=
[]
dominated
=
False
# Search for domination relations
for
u_dg
in
undominated_dgs_list
:
if
not
dominated
and
dg
.
is_dominated
(
u_dg
):
dominated
=
True
if
u_dg
.
is_dominated
(
dg
):
to_remove
.
append
(
u_dg
)
# Remove dominated values
size
=
len
(
undominated_dgs_list
)
for
dg2
in
to_remove
:
undominated_dgs_list
.
remove
(
dg2
)
# Add the new dg
if
not
dominated
:
undominated_dgs_list
.
append
(
dg
)
return
undominated_dgs_list
def
filter_dominated
(
d_graphs
,
overall
=
False
,
in_place
=
True
):
if
not
overall
:
return
local_domination_filter
(
d_graphs
,
in_place
)
all_d_graphs
=
[]
for
dgs
in
d_graphs
.
values
():
all_d_graphs
.
extend
(
dgs
)
all_d_graphs
=
list_domination_filter
(
all_d_graphs
)
return
d_graphs
""" Filter the dgraphs by node. In a list of dgraph centered on a node n, if a dgraph is
completely included in another and have a highest distance score to the optimal, then it is
filtered out.
@param d_graphs All the dgraphs to filter, sorted by central node.
@param in_place If true, modify the content of d_graph with the filtered version. If False,
copy all the content in a new dictionary.
@return The filtered dictionary of dgraph per node.
"""
def
local_domination_filter
(
d_graphs
,
in_place
=
True
):
filtered
=
d_graphs
if
in_place
else
{}
# Filter node by node
for
node
,
d_graph_list
in
d_graphs
.
items
():
lst
=
str
(
sorted
([
str
(
x
)
for
x
in
d_graph_list
]))
filtered
[
node
]
=
brutal_list_domination_filter
(
d_graph_list
,
node_name
=
str
(
node
))
return
filtered
""" Filter the input dgraphs list. In the list of dgraph centered on a node n, if a dgraph is
completely included in another and have a highest distance score to the optimal, then it is
filtered out.
@param d_graphs All the dgraphs to filter.
@return The filtered dictionary of dgraph per node.
"""
def
list_domination_filter
(
d_graphs
):
filtered
=
[]
# Filter dgraph by dgraph
for
dg
in
d_graphs
:
add_new_dg_regarding_domination
(
dg
,
filtered
)
return
set
(
filtered
)
def
brutal_list_domination_filter
(
d_graphs
,
node_name
=
""
):
undominated
=
set
(
d_graphs
)
to_remove
=
set
()
for
dg1
in
d_graphs
:
for
dg2
in
d_graphs
:
if
dg1
.
is_dominated
(
dg2
):
to_remove
.
add
(
dg1
)
break
return
undominated

to_remove
#
""" Add the new dg in the dgs list. If dg is dominated by another dg in the list, then it's
#
dropped. If any dg in the list is dominated by the dg to add, then, the new dg is added and
#
all the dominated dg are removed from the list.
#
@param dg A new dg to add/filter.
#
@param undominated_dgs_list A list of dg where any of them is dominated by another one.
# @return The updated undominated list.
#
"""
#
def add_new_dg_regarding_domination(dg, undominated_dgs_list):
#
to_remove = []
#
dominated = False
#
#
# Search for domination relations
#
for u_dg in undominated_dgs_list:
#
if not dominated and dg.is_dominated(u_dg):
#
dominated = True
#
if u_dg.is_dominated(dg):
#
to_remove.append(u_dg)
#
#
# Remove dominated values
#
size = len(undominated_dgs_list)
#
for dg2 in to_remove:
#
undominated_dgs_list.remove(dg2)
#
#
# Add the new dg
#
if not dominated:
#
undominated_dgs_list.append(dg)
#
#
return undominated_dgs_list
#
#
#
#
def filter_dominated(d_graphs, overall=False, in_place=True):
#
if not overall:
#
return local_domination_filter(d_graphs, in_place)
#
#
all_d_graphs = []
#
for dgs in d_graphs.values():
#
all_d_graphs.extend(dgs)
#
#
all_d_graphs = list_domination_filter(all_d_graphs)
#
#
return d_graphs
#
#
#
""" Filter the dgraphs by node. In a list of dgraph centered on a node n, if a dgraph is
#
completely included in another and have a highest distance score to the optimal, then it is
#
filtered out.
#
@param d_graphs All the dgraphs to filter, sorted by central node.
#
@param in_place If true, modify the content of d_graph with the filtered version. If False,
#
copy all the content in a new dictionary.
#
@return The filtered dictionary of dgraph per node.
#
"""
#
def local_domination_filter(d_graphs, in_place=True):
#
filtered = d_graphs if in_place else {}
#
#
# Filter node by node
#
for node, d_graph_list in d_graphs.items():
#
lst = str(sorted([str(x) for x in d_graph_list]))
#
filtered[node] = brutal_list_domination_filter(d_graph_list, node_name=str(node))
#
#
return filtered
#
#
#
""" Filter the input dgraphs list. In the list of dgraph centered on a node n, if a dgraph is
#
completely included in another and have a highest distance score to the optimal, then it is
#
filtered out.
#
@param d_graphs All the dgraphs to filter.
#
@return The filtered dictionary of dgraph per node.
#
"""
#
def list_domination_filter(d_graphs):
#
filtered = []
#
#
# Filter dgraph by dgraph
#
for dg in d_graphs:
#
add_new_dg_regarding_domination(dg, filtered)
#
#
return set(filtered)
#
#
def brutal_list_domination_filter(d_graphs, node_name=""):
#
undominated = set(d_graphs)
#
to_remove = set()
#
#
for dg1 in d_graphs:
#
for dg2 in d_graphs:
#
if dg1.is_dominated(dg2):
#
to_remove.add(dg1)
#
break
#
#
return undominated  to_remove
deconvolution/main/__init__.py
0 → 100644
View file @
f78f16f2
deconvolution/main/d2_to_path.py
View file @
f78f16f2
...
...
@@ 4,7 +4,7 @@ import networkx as nx
import
argparse
import
sys
from
d2graph
import
d2_graph
as
d2
,
path_optimization
as
po
from
d
econvolution.d
2graph
import
d2_graph
as
d2
,
path_optimization
as
po
def
parse_arguments
():
...
...
deconvolution/main/generate_fake_barcode_graph.py
View file @
f78f16f2
#!/usr/bin/env python3
import
networkx
as
nx
import
networkx
as
nx
import
random
import
argparse
from
dgraph
import
graph_manipulator
as
gm
import
deconvolution.dgraph.
graph_manipulator
as
gm
def
parse_arguments
():
...
...
deconvolution/main/generate_fake_molecule_graph.py
View file @
f78f16f2
...
...
@@ 2,7 +2,7 @@
import
argparse
from
dgraph
import
graph_manipulator
as
gm
from
d
econvolution.d
graph
import
graph_manipulator
as
gm
def
parse_arguments
():
...
...
deconvolution/main/to_d2_graph.py
View file @
f78f16f2
...
...
@@ 4,7 +4,7 @@ import networkx as nx
import
argparse
import
sys
from
d2graph
import
d2_graph
as
d2
from
d
econvolution.d
2graph
import
d2_graph
as
d2
def
parse_arguments
():
...
...
setup.py
View file @
f78f16f2
from
distutils.core
import
setup
setup
(
name
=
'10Xdeconvolve'
,
version
=
'0.1dev'
,
packages
=
[
'deconvolution.d2graph'
,
'deconvolution.dgraph'
,
'deconvolution.main'
],
license
=
'AGPL V3'
,
long_description
=
open
(
'README.md'
).
read
(),
)
tests/Index_test.py
View file @
f78f16f2
import
unittest
from
random
import
randint
from
dgraph.FixedDGIndex
import
FixedDGIndex
from
dgraph.VariableDGIndex
import
VariableDGIndex
from
dgraph.d_graph
import
Dgraph
from
dgraph.graph_manipulator
import
generate_d_graph_chain
from
deconvolution.dgraph.FixedDGIndex
import
FixedDGIndex
from
deconvolution.dgraph.VariableDGIndex
import
VariableDGIndex
from
deconvolution.dgraph.d_graph
import
Dgraph
from
deconvolution.dgraph.graph_manipulator
import
generate_d_graph_chain
class
TestIndex
(
unittest
.
TestCase
):
...
...
tests/d2_graph_test.py
View file @
f78f16f2
...
...
@@ 3,10 +3,8 @@ import tempfile
import
networkx
as
nx
from
scipy.special
import
comb
from
d2graph.d2_graph
import
D2Graph
from
dgraph
import
graph_manipulator
as
gm
from
d_graph_data
import
complete_graph
from
deconvolution.d2graph.d2_graph
import
D2Graph
from
deconvolution.dgraph
import
graph_manipulator
as
gm
class
TestD2Graph
(
unittest
.
TestCase
):
...
...
tests/d_graph_test.py
View file @
f78f16f2
import
unittest
from
d_graph_data
import
unit_d_graph
from
dgraph.d_graph
import
Dgraph
from
dgraph
import
graph_manipulator
as
gm
from
d
econvolution.d
graph.d_graph
import
Dgraph
from
d
econvolution.d
graph
import
graph_manipulator
as
gm
class
TestDGraph
(
unittest
.
TestCase
):
...
...
tests/graph_manipulation_test.py
View file @
f78f16f2
import
unittest
from
dgraph
import
graph_manipulator
as
gm
from
d
econvolution.d
graph
import
graph_manipulator
as
gm
class
TestGraphManipulation
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
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