@@ -17,6 +17,7 @@ def generate_inputs(data, filename_map):
1717 if input_type not in filename_map :
1818 raise ValueError (f"{ input_type } filename is missing" )
1919
20+ # Get sources and targets for node input file
2021 if data .contains_node_columns (["sources" ,"targets" ]):
2122 sources = data .request_node_columns (["sources" ])
2223 targets = data .request_node_columns (["targets" ])
@@ -25,8 +26,8 @@ def generate_inputs(data, filename_map):
2526 else :
2627 raise ValueError ("Invalid node data" )
2728
29+ # Get edge data for network file
2830 edges = data .get_interactome ()
29-
3031 edges .to_csv (filename_map ['network' ],sep = '|' ,index = False ,columns = ['Interactor1' ,'Interactor2' ],header = False )
3132
3233
@@ -44,6 +45,7 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_frame
4445 raise ValueError (f"Edge { line } does not contain 2 nodes separated by '|'" )
4546 work_dir = '/spras'
4647
48+ # Each volume is a tuple (src, dest)
4749 volumes = list ()
4850
4951 bind_path , nodes_file = prepare_volume (nodes , work_dir )
@@ -52,7 +54,10 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_frame
5254 bind_path , network_file = prepare_volume (network , work_dir )
5355 volumes .append (bind_path )
5456
55- out_dir = Path (output_file ).parent
57+ # RWR does not provide an argument to set the output directory
58+ # Use its --output argument to set the output file prefix to specify an absolute path and prefix
59+ out_dir = Path (output_file ).parent
60+ # RWR requires that the output directory exist
5661 out_dir .mkdir (parents = True , exist_ok = True )
5762 bind_path , mapped_out_dir = prepare_volume (str (out_dir ), work_dir )
5863 volumes .append (bind_path )
@@ -63,6 +68,7 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_frame
6368 '--nodes' ,nodes_file ,
6469 '--output' , mapped_out_prefix ]
6570
71+ # Add alpha as an optional argument
6672 if alpha is not None :
6773 command .extend (['--alpha' , str (alpha )])
6874
@@ -74,6 +80,8 @@ def run(network=None, nodes=None, alpha=None, output_file=None, container_frame
7480 work_dir )
7581
7682 print (out )
83+ # Rename the primary output file to match the desired output filename
84+ # Currently RWR only writes one output file so we do not need to delete others
7785 output_edges = Path (out_dir ,'out' )
7886 output_edges .rename (output_file )
7987
0 commit comments