nodes: 0, module; 1, function_definition; 2, function_name:map_metabolite2kegg; 3, parameters; 4, block; 5, identifier:metabolite; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, return_statement; 13, comment:"""
      Return a KEGG compound identifier for the metabolite if it exists.
  
      First see if there is an unambiguous mapping to a single KEGG compound ID
      provided with the model. If not, check if there is any KEGG compound ID in
      a list of mappings. KEGG IDs may map to compounds, drugs and glycans. KEGG
      compound IDs are sorted so we keep the lowest that is there. If none of
      this works try mapping to KEGG via the CompoundMatcher by the name of the
      metabolite. If the metabolite cannot be mapped at all we simply map it back
      to its own ID.
  
      Parameters
      ----------
      metabolite : cobra.Metabolite
          The metabolite to be mapped to its KEGG compound identifier.
  
      Returns
      -------
      None
          If the metabolite could not be mapped.
      str
          The smallest KEGG compound identifier that was found.
  
      """; 14, call; 15, assignment; 16, comparison_operator:kegg_annotation is None; 17, comment:# TODO (Moritz Beber): Currently name matching is very slow and; 18, comment:#  inaccurate. We disable it until there is a better solution.; 19, comment:# if metabolite.name:; 20, comment:#     # The compound matcher uses regular expression and chokes; 21, comment:#     # with a low level error on `[` in the name, for example.; 22, comment:#     df = compound_matcher.match(metabolite.name); 23, comment:#     try:; 24, comment:#         return df.loc[df["score"] > threshold, "CID"].iat[0]; 25, comment:#     except (IndexError, AttributeError):; 26, comment:#         logger.warning(; 27, comment:#             "Could not match the name %r to any kegg.compound "; 28, comment:#             "annotation for metabolite %s.",; 29, comment:#             metabolite.name, metabolite.id; 30, comment:#         ); 31, comment:#         return; 32, comment:# else:; 33, block; 34, boolean_operator; 35, block; 36, elif_clause; 37, call; 38, attribute; 39, argument_list; 40, identifier:kegg_annotation; 41, call; 42, identifier:kegg_annotation; 43, None; 44, expression_statement; 45, return_statement; 46, call; 47, line_continuation:\; 48, call; 49, return_statement; 50, call; 51, block; 52, attribute; 53, argument_list; 54, identifier:logger; 55, identifier:debug; 56, string:"Looking for KEGG compound identifier for %s."; 57, attribute; 58, attribute; 59, argument_list; 60, call; 61, identifier:isinstance; 62, argument_list; 63, attribute; 64, argument_list; 65, identifier:kegg_annotation; 66, identifier:isinstance; 67, argument_list; 68, try_statement; 69, identifier:logger; 70, identifier:warning; 71, string:"No matching kegg.compound annotation for metabolite %s."; 72, attribute; 73, identifier:metabolite; 74, identifier:id; 75, attribute; 76, identifier:get; 77, string:"kegg.compound"; 78, attribute; 79, argument_list; 80, identifier:kegg_annotation; 81, identifier:string_types; 82, identifier:kegg_annotation; 83, identifier:startswith; 84, string:"C"; 85, identifier:kegg_annotation; 86, identifier:Iterable; 87, block; 88, except_clause; 89, identifier:metabolite; 90, identifier:id; 91, identifier:metabolite; 92, identifier:annotation; 93, identifier:logger; 94, identifier:warning; 95, string:"No kegg.compound annotation for metabolite %s."; 96, attribute; 97, return_statement; 98, identifier:ValueError; 99, block; 100, identifier:metabolite; 101, identifier:id; 102, call; 103, return_statement; 104, identifier:get_smallest_compound_id; 105, argument_list; 106, identifier:kegg_annotation
code: def map_metabolite2kegg(metabolite):
      """
      Return a KEGG compound identifier for the metabolite if it exists.
  
      First see if there is an unambiguous mapping to a single KEGG compound ID
      provided with the model. If not, check if there is any KEGG compound ID in
      a list of mappings. KEGG IDs may map to compounds, drugs and glycans. KEGG
      compound IDs are sorted so we keep the lowest that is there. If none of
      this works try mapping to KEGG via the CompoundMatcher by the name of the
      metabolite. If the metabolite cannot be mapped at all we simply map it back
      to its own ID.
  
      Parameters
      ----------
      metabolite : cobra.Metabolite
          The metabolite to be mapped to its KEGG compound identifier.
  
      Returns
      -------
      None
          If the metabolite could not be mapped.
      str
          The smallest KEGG compound identifier that was found.
  
      """
      logger.debug("Looking for KEGG compound identifier for %s.", metabolite.id)
      kegg_annotation = metabolite.annotation.get("kegg.compound")
      if kegg_annotation is None:
          # TODO (Moritz Beber): Currently name matching is very slow and
          #  inaccurate. We disable it until there is a better solution.
          # if metabolite.name:
          #     # The compound matcher uses regular expression and chokes
          #     # with a low level error on `[` in the name, for example.
          #     df = compound_matcher.match(metabolite.name)
          #     try:
          #         return df.loc[df["score"] > threshold, "CID"].iat[0]
          #     except (IndexError, AttributeError):
          #         logger.warning(
          #             "Could not match the name %r to any kegg.compound "
          #             "annotation for metabolite %s.",
          #             metabolite.name, metabolite.id
          #         )
          #         return
          # else:
          logger.warning("No kegg.compound annotation for metabolite %s.",
                         metabolite.id)
          return
      if isinstance(kegg_annotation, string_types) and \
              kegg_annotation.startswith("C"):
          return kegg_annotation
      elif isinstance(kegg_annotation, Iterable):
          try:
              return get_smallest_compound_id(kegg_annotation)
          except ValueError:
              return
      logger.warning(
          "No matching kegg.compound annotation for metabolite %s.",
          metabolite.id
      )
      return