Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cosy-Bio
Drugst.One
backend
Commits
a32cb948
Commit
a32cb948
authored
2 years ago
by
AndiMajore
Browse files
Options
Downloads
Patches
Plain Diff
analysis on analysis working properly
parent
356abbba
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
drugstone/views.py
+27
-14
27 additions, 14 deletions
drugstone/views.py
with
27 additions
and
14 deletions
drugstone/views.py
+
27
−
14
View file @
a32cb948
...
...
@@ -370,7 +370,7 @@ def result_view(request) -> Response:
edges
=
parameters
[
'
input_network
'
][
'
edges
'
]
edge_endpoint_ids
=
set
()
# TODO check for custom edges when working again
# TODO check for custom edges when working again
with ensemble gene ids
for
edge
in
edges
:
edge_endpoint_ids
.
add
(
edge
[
'
from
'
])
edge_endpoint_ids
.
add
(
edge
[
'
to
'
])
...
...
@@ -378,30 +378,43 @@ def result_view(request) -> Response:
nodes_mapped
,
id_key
=
query_proteins_by_identifier
(
edge_endpoint_ids
,
identifier
)
# change data structure to dict in order to be quicker when merging
nodes_mapped_dict
=
{
node
[
id_key
]:
node
for
node
in
nodes_mapped
}
for
edge
in
edges
:
# change edge endpoints if they were matched with a protein in the database
edge
[
'
from
'
]
=
nodes_mapped_dict
[
edge
[
'
from
'
]][
node_name_attribute
]
if
edge
[
'
from
'
]
in
nodes_mapped_dict
else
\
edge
[
'
from
'
]
edge
[
'
to
'
]
=
nodes_mapped_dict
[
edge
[
'
to
'
]][
node_name_attribute
]
if
edge
[
'
to
'
]
in
nodes_mapped_dict
else
edge
[
'
to
'
]
if
'
autofill_edges
'
in
parameters
[
'
config
'
]
and
parameters
[
'
config
'
][
'
autofill_edges
'
]:
proteins
=
{
node_name
[
1
:]
for
nodes
in
map
(
lambda
n
:
n
[
node_name_attribute
],
filter
(
lambda
n
:
node_name_attribute
in
n
,
parameters
[
'
input_network
'
][
'
nodes
'
]))
for
node_name
in
nodes
}
print
(
nodes_mapped
)
# nodes_mapped_dict = {node[id_key][0]: node for node in nodes_mapped}
# nodes_mapped_dict_reverse = {}
# for id, node in nodes_mapped_dict.items():
# for drugstone_id in node[node_name_attribute]:
# nodes_mapped_dict_reverse[node[drugstone_id]] = id
print
(
nodes
)
# for edge in edges:
# # change edge endpoints if they were matched with a protein in the database
# edge['from'] = nodes_mapped_dict[edge['from']][node_name_attribute] if edge['from'] in nodes_mapped_dict else \
# edge['from']
# edge['to'] = nodes_mapped_dict[edge['to']][node_name_attribute] if edge['to'] in nodes_mapped_dict else edge[
# 'to']
if
'
autofill_edges
'
in
parameters
[
'
config
'
]
and
parameters
[
'
config
'
][
'
autofill_edges
'
]:
proteins
=
{
node_name
[
1
:]
for
nodes
in
map
(
lambda
n
:
'
drugstoneType
'
in
n
and
n
[
node_name_attribute
],
filter
(
lambda
n
:
n
.
drugstoneType
==
'
protein
'
,
filter
(
lambda
n
:
'
drugstoneType
'
in
n
and
node_name_attribute
in
n
,
parameters
[
'
input_network
'
][
'
nodes
'
])))
for
node_name
in
nodes
}
dataset
=
DEFAULTS
[
'
ppi
'
]
if
'
interaction_protein_protein
'
not
in
parameters
[
'
config
'
]
else
\
parameters
[
'
config
'
][
'
interaction_protein_protein
'
]
dataset_object
=
models
.
PPIDataset
.
objects
.
filter
(
name__iexact
=
dataset
).
last
()
interaction_objects
=
models
.
ProteinProteinInteraction
.
objects
.
filter
(
Q
(
ppi_dataset
=
dataset_object
)
&
Q
(
from_protein__in
=
proteins
)
&
Q
(
to_protein__in
=
proteins
))
auto_edges
=
list
(
map
(
lambda
n
:
{
"
from
"
:
f
'
p
{
n
.
from_protein_id
}
'
,
"
to
"
:
f
'
p
{
n
.
to_protein_id
}
'
},
interaction_objects
))
auto_edges
=
list
(
map
(
lambda
n
:
{
"
from
"
:
f
'
p
{
n
.
from_protein_id
}
'
,
"
to
"
:
f
'
p
{
n
.
to_protein_id
}
'
},
interaction_objects
))
edges
.
extend
(
auto_edges
)
# TODO check what to do with edges with from and to id lists
result
[
'
network
'
][
'
edges
'
].
extend
(
edges
)
uniq_edges
=
dict
()
for
edge
in
result
[
'
network
'
][
'
edges
'
]:
print
(
edge
)
hash
=
edge
[
'
from
'
]
+
edge
[
'
to
'
]
uniq_edges
[
hash
]
=
edge
result
[
'
network
'
][
'
edges
'
]
=
list
(
uniq_edges
.
values
())
...
...
This diff is collapsed.
Click to expand it.
Maier, Andreas
@bba1660
mentioned in commit
2d03c068
·
1 year ago
mentioned in commit
2d03c068
mentioned in commit 2d03c06865a4056300be77980fb236aa1fd3878d
Toggle commit list
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