code: def parse_reaction_file(path, default_compartment=None):
      
  
      context = FilePathContext(path)
  
      format = resolve_format(None, context.filepath)
      if format == 'tsv':
          logger.debug('Parsing reaction file {} as TSV'.format(
              context.filepath))
          with context.open('r') as f:
              for reaction in parse_reaction_table_file(
                      context, f, default_compartment):
                  yield reaction
      elif format == 'yaml':
          logger.debug('Parsing reaction file {} as YAML'.format(
              context.filepath))
          with context.open('r') as f:
              for reaction in parse_reaction_yaml_file(
                      context, f, default_compartment):
                  yield reaction
      else:
          raise ParseError('Unable to detect format of reaction file {}'.format(
              context.filepath))
docs: Open and parse reaction file based on file extension
  
      Path can be given as a string or a context.