@@ -562,31 +562,25 @@ def _collect_boundary_reactions(path: Path) -> _BoundaryReactions:
562562 f"'Minimum Reaction Rate', and 'Maximum Reaction Rate'. Found: { column } "
563563 )
564564
565- reactions : list [str ] = []
565+ reactions : list [str ] = ["" ] * len ( df )
566566 boundary_type : list [str ] = df ["reaction" ].tolist ()
567567 reaction_abbreviation : list [str ] = df ["abbreviation" ].tolist ()
568568 reaction_compartment : list [str ] = df ["compartment" ].tolist ()
569- lower_bounds = df ["minimum reaction rate" ].tolist ()
570- upper_bounds = df ["maximum reaction rate" ].tolist ()
569+ lower_bound = df ["minimum reaction rate" ].tolist ()
570+ upper_bound = df ["maximum reaction rate" ].tolist ()
571+ boundary_map = {"exchange" : "EX" , "demand" : "DM" , "sink" : "SK" }
571572 for i in range (len (boundary_type )):
572- current_type : str = boundary_type [i ]
573- temp_reaction : str = ""
574-
575- match current_type .lower ():
576- case "exchange" :
577- temp_reaction += "EX_"
578- case "demand" :
579- temp_reaction += "DM_"
580- case "sink" :
581- temp_reaction += "SK_"
573+ boundary : str = boundary_type [i ].lower ()
574+ if boundary not in boundary_map :
575+ raise ValueError (f"Boundary reaction type must be 'Exchange', 'Demand', or 'Sink'. Found: { boundary [i ]} " )
582576
583577 shorthand_compartment = Compartments .get (reaction_compartment [i ])
584- temp_reaction + = f"{ reaction_abbreviation [i ]} [{ shorthand_compartment } ]"
585- reactions . append ( temp_reaction )
578+ reactions [ i ] = f"{ boundary_map . get ( boundary ) } _ { reaction_abbreviation [i ]} [{ shorthand_compartment } ]"
579+
586580 return _BoundaryReactions (
587581 reactions = reactions ,
588- lower_bounds = lower_bounds ,
589- upper_bounds = upper_bounds ,
582+ lower_bounds = lower_bound ,
583+ upper_bounds = upper_bound ,
590584 )
591585
592586
0 commit comments