Skip to content

Commit

Permalink
add a verbose parameters and removed some print msg
Browse files Browse the repository at this point in the history
  • Loading branch information
r-trimbour authored Oct 11, 2024
1 parent 3f72dcd commit f05237f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions hummuspy/src/hummuspy/create_multilayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def __init__(
seeds,
self_loops,
restart_proba,
pr=None
pr=None,
verbose=True
):
"""
Constructs an object for the random walk with restart.
Expand All @@ -382,7 +383,8 @@ def __init__(
lamb=lamb,
seeds=seeds,
self_loops=self_loops,
restart_proba=restart_proba)
restart_proba=restart_proba,
verbose=verbose)

config_parser_obj.parse()

Expand Down Expand Up @@ -553,7 +555,6 @@ def __par_seed_random_walk_restart(prox_vector, r):
prox_vector, seed_score = individual_seed.get_seed_scores(transition=transition_matrixcoo)
prox_vectors.append(prox_vector)
seed_scores.append(seed_score)
print(len(prox_vectors))

# Run RWR algorithm parallelised
with LocalCluster(
Expand Down Expand Up @@ -660,9 +661,8 @@ def __init__(self, multiplex, bipartite, eta, lamb, seeds, self_loops, restart_p
self.self_loops = self_loops
self.seeds = seeds
self.restart_proba = restart_proba
print(self.multiplex)

def parse(self):
def parse(self, verbose=True):

"""Parses the config yaml file and give fields to specialized functions"""

Expand All @@ -673,15 +673,15 @@ def parse(self):
#
#######################################################################

self.multiplexall_obj = self.__parse_multiplex()
self.multiplexall_obj = self.__parse_multiplex(verbose=verbose)
self.multiplex = "Done"
#######################################################################
#
# Parses bipartite
#
#######################################################################

self.bipartitelist_obj = self.__parse_bipartite()
self.bipartitelist_obj = self.__parse_bipartite(verbose=verbose)
self.bipartite = "Done"

#######################################################################
Expand Down Expand Up @@ -741,7 +741,7 @@ def parse(self):
seed_count_list2d = [len(i) for i in self.seed_obj.multiplex_seed_list2d]
self.parameter_obj = self.__parse_parameters(seed_count_list2d=seed_count_list2d)

def __parse_bipartite(self):
def __parse_bipartite(self, verbose=True):
"""
Reads multiplex field and create MultiplexAll object
"""
Expand All @@ -765,12 +765,11 @@ def __parse_bipartite(self):
else:
raise KeyError("No 'target' field found for bipartite network")

print(self.bipartite[layer_key])

if type(self.bipartite[layer_key]['edge_list_df']) == str:
print("Opening network from {}.".format(
self.bipartite[layer_key]['edge_list_df']
))
if verbose:
print("Opening network from {}.".format(
self.bipartite[layer_key]['edge_list_df']
))
layer_obj = Bipartite(key=layer_key,
abspath=self.bipartite[layer_key]['edge_list_df'],
graph_type=graph_type,
Expand All @@ -788,7 +787,7 @@ def __parse_bipartite(self):

return BipartiteAll(source_target_bipartite_dic, multiplexall=self.multiplexall_obj)

def __parse_multiplex(self):
def __parse_multiplex(self, verbose=True):
"""
Reads multiplex field and create MultiplexAll object
"""
Expand All @@ -803,7 +802,6 @@ def __parse_multiplex(self):
layer_obj_list = []
multiplex_node_list = []
layer_key_tuple = tuple(self.multiplex[multiplex_key]['names'])
print(layer_key_tuple)
###################################################################
#
# tau
Expand Down Expand Up @@ -835,11 +833,13 @@ def __parse_multiplex(self):

# loop over layers
for layer_idx, layer_key in enumerate(layer_key_tuple):
print(layer_key)
if verbose:
print(layer_key)
if type(self.multiplex[multiplex_key]['layers'][layer_idx]) == str:
print("Opening network from {}.".format(
self.multiplex[multiplex_key]['layers'][layer_idx]
))
if verbose:
print("Opening network from {}.".format(
self.multiplex[multiplex_key]['layers'][layer_idx]
))
layer_obj = MultiplexLayer(key=layer_key,
abspath=self.multiplex[multiplex_key]['layers'][layer_idx],
graph_type=graph_type_lst[layer_idx],
Expand Down

0 comments on commit f05237f

Please sign in to comment.