Skip to content

Commit

Permalink
start moving to newer matchms version
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-huber committed Aug 21, 2023
1 parent 2c66748 commit 7efcd1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions matchmsextras/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ def erode_clusters(graph_main, max_cluster_size=100, keep_weights_above=0.8):
return graph_main, links_removed


def add_intra_cluster_links(graph_main, scores, identifier="spectrum_id", min_weight=0.5, max_links=20):
def add_intra_cluster_links(graph_main,
scores,
score_name=None,
identifier="spectrum_id", min_weight=0.5, max_links=20):
""" Add links within each separate cluster if weights above min_weight.
Args:
Expand All @@ -401,6 +404,8 @@ def add_intra_cluster_links(graph_main, scores, identifier="spectrum_id", min_we
Graph, e.g. made using create_network() function. Based on networkx.
scores: matchms Scores
2D array with all reference similarity values between all-vs-all nodes.
score_name: str
Specify the score name if the Scores object contains different scores.
min_weight: float
Set minimum weight to be considered for making link. Default = 0.5.
"""
Expand All @@ -414,7 +419,7 @@ def add_intra_cluster_links(graph_main, scores, identifier="spectrum_id", min_we
del nodes0[0]
ID1 = node_to_ID[node]
IDs2 = [node_to_ID[n] for n in nodes0]
weights = scores.scores[ID1, IDs2]
weights = np.array([scores.scores[ID1, i, score_name] for i in IDs2])
weights_select = weights.argsort()[::-1][:max_links]
weights_select = np.where(weights[weights_select] >= min_weight)[0]
new_edges = [(node, nodes0[x], weights[x]) for x in weights_select]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
test_suite="tests",
python_requires='>=3.7',
install_requires=[
"matchms>=0.11.0",
"matchms>=0.18.0",
"spec2vec",
"python-louvain",
"networkx",
Expand Down

0 comments on commit 7efcd1b

Please sign in to comment.