@@ -249,35 +249,57 @@ def build(self):
249249 self .impossible = np .unique (self .impossible ).tolist ()
250250 self .built = True
251251
252- def __str__ (self ):
253- old_counts = Counter (self .__conf_old .values ())
252+ def info (self , reversible = True ):
253+ """Gives basic performance infos about the reconstruction.
254+
255+ Generates an acceptably nice output describing which reactions
256+ from each confidence level were included in the reconstruction.
257+
258+ Args:
259+ reversible (Optional[boolean]): Whether the statistics should be
260+ given for the model allwoing for reversible reactions or for the
261+ model where each reaction is split into its forward and backward
262+ reactions.
263+
264+ Returns:
265+ A formatted output string.
266+ """
267+
268+ if reversible :
269+ m = deepcopy (self .model )
270+ revert_to_reversible (m )
271+ rids = [r .id for r in m .reactions ]
272+ else : rids = [r .id for r in self .model .reactions ]
273+
274+ old_counts = Counter ([self .__conf_old [k ] for k in self .__conf_old
275+ if k in rids ])
254276 if not self .built :
255277 out = "build status: not built\n " + \
256- "#reactions (including mock): {}\n " .\
257- format (len (self .__conf_old )) + \
278+ "#reactions (including mock): {}\n " .format (len (rids )) + \
258279 "Reaction confidence:\n " + \
259280 " - unclear: {}\n " .format (old_counts [0 ]) + \
260281 " - exclude: {}\n " .format (old_counts [- 1 ]) + \
261282 " - low and medium: {}\n " .format (old_counts [1 ] + \
262283 old_counts [2 ]) + \
263284 " - high: {}\n " .format (old_counts [3 ])
264285 else :
265- rids = self .conf .keys ()
266286 old = np .array ([self .__conf_old [k ] for k in rids ])
267287 new = np .array ([self .conf [k ] for k in rids ])
268288 med_inc = np .sum (((old == 1 ) | (old == 2 )) & (new == 3 ))
269289 noc_inc = np .sum ((old == - 1 ) & (new == 3 ))
270290 free_inc = np .sum ((old == 0 ) & (new == 3 ))
271291 high_inc = np .sum ((old == 3 ) & (new == 3 ))
272292 out = "build status: reconstruction complete\n " + \
273- "Inc. reactions: {}/{}\n " .format (np .sum (new == 3 ), len (old )) + \
293+ "Inc. reactions: {}/{}\n " .format (np .sum (new == 3 ), len (old )) + \
274294 " - unclear: {}/{}\n " .format (free_inc , old_counts [0 ]) + \
275295 " - exclude: {}/{}\n " .format (noc_inc , old_counts [- 1 ]) + \
276296 " - low and medium: {}/{}\n " .format (med_inc , old_counts [1 ] + \
277297 old_counts [2 ]) + \
278298 " - high: {}/{}\n " .format (high_inc , old_counts [3 ])
279299 return out
280300
301+ def __str__ (self ):
302+ return self .info (reversible = True )
281303
282304 def cobra_model (self , name , reversible = True , bound = 1000 ):
283305 """Constructs a cobra model for the reconstruction.
0 commit comments