@@ -1726,19 +1726,35 @@ def subgraph_stats_process(u):
17261726 return Physlr .subgraph_stats (Physlr .graph , u )
17271727
17281728 def physlr_subgraphs_stats (self ):
1729- "Retrieve subgraphs' stats."
1730- gin = self .read_graph (self .args .FILES )
1731- Physlr .filter_edges (gin , self .args .m )
1732- print (
1733- int (timeit .default_timer () - t0 ),
1734- "Computing statistics of the subgraphs..." , file = sys .stderr )
1729+ """
1730+ Retrieve statistics of a set of subgraphs.
1731+ (Either all subgraphs, or a subset of them indicated by a second input file).
1732+ Usage: physlr subgraph-stats <graph .tsv> [TSV file listing barcodes in the first column]
1733+ """
1734+ nodes_of_interest = []
1735+ if len (self .args .FILES ) > 1 :
1736+ gin = self .read_graph ([self .args .FILES [0 ]])
1737+ with open (self .args .FILES [1 ]) as fin :
1738+ for line in fin :
1739+ nodes_of_interest .append (line .strip ().split ()[0 ])
1740+ print (
1741+ int (timeit .default_timer () - t0 ),
1742+ "Computing statistics for subgraphs of interest..." ,
1743+ file = sys .stderr )
1744+ else :
1745+ gin = self .read_graph (self .args .FILES )
1746+ print (
1747+ int (timeit .default_timer () - t0 ),
1748+ "Computing statistics of all subgraphs..." , file = sys .stderr )
1749+ nodes_of_interest = gin
1750+
17351751 if self .args .threads == 1 :
17361752 stats = dict (self .subgraph_stats (gin , u ) for u in progress (gin ))
17371753 else :
17381754 Physlr .graph = gin
17391755 with multiprocessing .Pool (self .args .threads ) as pool :
17401756 stats = dict (pool .map (
1741- self .subgraph_stats_process , progress (gin ), chunksize = 100 ))
1757+ self .subgraph_stats_process , progress (nodes_of_interest ), chunksize = 100 ))
17421758 Physlr .graph = None
17431759 print (int (timeit .default_timer () - t0 ), "Extracted subgraphs' statistics." , file = sys .stderr )
17441760 self .write_subgraphs_stats (stats , sys .stdout )
0 commit comments