kg_microbe.transform_utils.cog package

Submodules

kg_microbe.transform_utils.cog.cog module

Transform for COG (Clusters of Orthologous Groups) functional classifications.

class kg_microbe.transform_utils.cog.cog.COGTransform(input_dir=None, output_dir=None)

Bases: Transform

Transform COG functional classifications into KGX format.

add_cog_node(cog_id, cog_data)

Add a COG node.

Parameters:
  • cog_id (str) – COG identifier (e.g., ‘COG0178’)

  • cog_data (dict) – COG data dictionary

Return type:

None

add_edge(subject, predicate, obj, relation)

Add an edge to the collection.

Parameters:
  • subject (str) – Subject node ID

  • predicate (str) – Biolink predicate

  • obj (str) – Object node ID

  • relation (str) – RO or other relation ontology term

Return type:

None

add_functional_category_node(cat_id, cat_data)

Add a functional category node.

Parameters:
  • cat_id (str) – Category ID (single letter, e.g., ‘C’, ‘P’)

  • cat_data (dict) – Category data dictionary

Return type:

None

add_group_node(group_id)

Add a COG functional category group node.

Parameters:

group_id (str) – Group ID (1-4)

Return type:

None

run(data_file=None, show_status=True)

Run the COG transform.

Parameters:
  • data_file (Optional[Path]) – Not used (kept for API compatibility)

  • show_status (bool) – Show progress messages (default: True)

Return type:

None

write_output()

Write nodes and edges to TSV files.

Return type:

None

kg_microbe.transform_utils.cog.utils module

Utility functions for COG transform.

kg_microbe.transform_utils.cog.utils.get_category_group_name(group_id)

Get the name of a functional category group.

Parameters:

group_id (str) – Group ID (1-4)

Return type:

str

Returns:

Group name

kg_microbe.transform_utils.cog.utils.parse_cog_definitions(def_file)

Parse COG definitions file (cog-24.def.tab).

Parameters:

def_file (Path) – Path to cog-24.def.tab file

Return type:

Dict[str, Dict[str, str]]

Returns:

Dictionary mapping COG ID to definition data

kg_microbe.transform_utils.cog.utils.parse_functional_categories(fun_file)

Parse COG functional categories file (cog-24.fun.tab).

Parameters:

fun_file (Path) – Path to cog-24.fun.tab file

Return type:

Dict[str, Dict[str, str]]

Returns:

Dictionary mapping category ID to category data

kg_microbe.transform_utils.cog.utils.split_functional_categories(category_string)

Split multi-category string into individual categories.

COG entries can have multiple functional categories (e.g., “CP” means both C and P).

Parameters:

category_string (str) – Functional category string (e.g., “C”, “CP”, “PTM”)

Return type:

List[str]

Returns:

List of individual category letters

Module contents

COG (Clusters of Orthologous Groups) transform.

class kg_microbe.transform_utils.cog.COGTransform(input_dir=None, output_dir=None)

Bases: Transform

Transform COG functional classifications into KGX format.

add_cog_node(cog_id, cog_data)

Add a COG node.

Parameters:
  • cog_id (str) – COG identifier (e.g., ‘COG0178’)

  • cog_data (dict) – COG data dictionary

Return type:

None

add_edge(subject, predicate, obj, relation)

Add an edge to the collection.

Parameters:
  • subject (str) – Subject node ID

  • predicate (str) – Biolink predicate

  • obj (str) – Object node ID

  • relation (str) – RO or other relation ontology term

Return type:

None

add_functional_category_node(cat_id, cat_data)

Add a functional category node.

Parameters:
  • cat_id (str) – Category ID (single letter, e.g., ‘C’, ‘P’)

  • cat_data (dict) – Category data dictionary

Return type:

None

add_group_node(group_id)

Add a COG functional category group node.

Parameters:

group_id (str) – Group ID (1-4)

Return type:

None

run(data_file=None, show_status=True)

Run the COG transform.

Parameters:
  • data_file (Optional[Path]) – Not used (kept for API compatibility)

  • show_status (bool) – Show progress messages (default: True)

Return type:

None

write_output()

Write nodes and edges to TSV files.

Return type:

None