@@ -154,7 +154,14 @@ def _run_serial(self, progress_bar=False):
154
154
return True
155
155
156
156
def _write_interactions (self , results ):
157
- """Write the interactions to csv."""
157
+ """Write the interactions to file or to a dictionary"""
158
+ if self .interactions_dict is not None :
159
+ self ._write_to_dict (results )
160
+ elif self .writer is not None :
161
+ self ._write_to_file (results )
162
+
163
+ def _write_to_file (self , results ):
164
+ """Write the interactions to csv file"""
158
165
for index_pair , interactions in results .items ():
159
166
for interaction in interactions :
160
167
row = list (index_pair )
@@ -167,6 +174,16 @@ def _write_interactions(self, results):
167
174
self .writer .writerow (row )
168
175
self .num_interactions += 1
169
176
177
+ def _write_to_dict (self , results ):
178
+ """Write the interactions to memory"""
179
+ for index_pair , interactions in results .items ():
180
+ for interaction in interactions :
181
+ try :
182
+ self .interactions_dict [index_pair ].append (interaction )
183
+ except KeyError :
184
+ self .interactions_dict [index_pair ] = [interaction ]
185
+ self .num_interactions += 1
186
+
170
187
def _run_parallel (self , processes = 2 , progress_bar = False ):
171
188
"""
172
189
Run all matches in parallel
0 commit comments