Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EBA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
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
schwede
EBA
Commits
1628ccb3
Commit
1628ccb3
authored
10 months ago
by
Lorenzo Pantolini
Browse files
Options
Downloads
Patches
Plain Diff
fix cosine_sim_matrix input
parent
d32a1794
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
eba/alignments.py
+2
-2
2 additions, 2 deletions
eba/alignments.py
eba/score_matrices.py
+3
-2
3 additions, 2 deletions
eba/score_matrices.py
eba_example.py
+1
-1
1 addition, 1 deletion
eba_example.py
with
6 additions
and
5 deletions
eba/alignments.py
+
2
−
2
View file @
1628ccb3
...
...
@@ -3,7 +3,7 @@ import numba as nb
MIN_FLOAT64
=
np
.
finfo
(
np
.
float64
).
min
@nb.njit
(
cache
=
False
)
@nb.njit
def
_make_dtw_matrix
(
score_matrix
:
np
.
ndarray
,
gap_open_penalty
:
float
=
0.0
,
...
...
@@ -78,7 +78,7 @@ def _make_dtw_matrix(
return
matrix
,
backtrack
@nb.njit
(
cache
=
False
)
@nb.njit
def
_get_dtw_alignment
(
start_direction
,
backtrack
:
np
.
ndarray
,
n1
,
m1
):
"""
Finds optimal warping path from a backtrack matrix
...
...
This diff is collapsed.
Click to expand it.
eba/score_matrices.py
+
3
−
2
View file @
1628ccb3
import
torch
import
numpy
as
np
from
scipy
import
spatial
def
compute_similarity_matrix
(
embedding1
,
embedding2
,
l
=
1
,
p
=
2
):
...
...
@@ -48,7 +49,7 @@ def compute_similarity_matrix_plain(embedding1, embedding2, l=1, p=2):
def
compute_cosine_similarity_matrix
(
embedding1
,
embedding2
,
l
=
1
,
p
=
2
):
def
compute_cosine_similarity_matrix
(
embedding1
,
embedding2
):
"""
Take as input 2 sequence embeddings (at a residue level) and returns the cosine similarity matrix
with the signal enhancement based on Z-scores. The signal enhancement seems to be redundant
when used with the cosine similarity score, therefore we don
'
t recommend this version.
...
...
@@ -84,5 +85,5 @@ def compute_cosine_similarity_matrix_plain(embedding1, embedding2):
:type embedding2: pytorch tensor
"""
return
torch
.
tensor
(
1
-
spatial
.
distance
.
cdist
(
embedding1
,
embedding2
,
'
cosine
'
))
return
torch
.
tensor
(
1
-
spatial
.
distance
.
cdist
(
embedding1
.
cpu
().
numpy
(),
embedding2
.
cpu
().
numpy
()
,
'
cosine
'
))
This diff is collapsed.
Click to expand it.
eba_example.py
+
1
−
1
View file @
1628ccb3
...
...
@@ -20,7 +20,7 @@ print(emb1.shape)
similarity_matrix
=
sm
.
compute_similarity_matrix
(
emb1
,
emb2
)
eba_results
=
methods
.
compute_eba
(
similarity_matrix
)
### to return the alignment itself use:
#eba_results =
eba.EBA
(similarity_matrix, extensive_output=True)
#eba_results =
methods.compute_eba
(similarity_matrix, extensive_output=True)
### show results
print
(
'
EBA raw:
'
,
eba_results
[
'
EBA_raw
'
])
...
...
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