Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New source: BiGG Models Metabolite Database #124

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
68 changes: 68 additions & 0 deletions src/pyobo/sources/bigg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-

"""Converter for bigg."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix stylization of BiGG

import click
import bioversions
from typing import Iterable
from more_click import verbose_option
from pyobo.path_utils import ensure_df, ensure_tar_df
samuelbunga marked this conversation as resolved.
Show resolved Hide resolved
from pyobo.struct import Obo, Reference, Synonym, SynonymTypeDef, Term, from_species, TypeDef

HEADER = ['bigg_id', 'universal_bigg_id', 'name', 'model_list', 'database_links',
'old_bigg_ids']
PREFIX = 'bigg'

URL = 'http://bigg.ucsd.edu/static/namespace/bigg_models_metabolites.txt'

alias_type = SynonymTypeDef(id="alias", name="alias")
has_role = TypeDef(reference=Reference(prefix="bigg", identifier="has_role"))


def get_obo(force: bool = False) -> Obo:
"""Get bigg as OBO."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stylization

version = bioversions.get_version("bigg")
#version = '1.2'
return Obo(
ontology=PREFIX,
name="bigg models metabolites database",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title case + stylization

iter_terms=get_terms,
iter_terms_kwargs=dict(force=False),
typedefs=[has_role],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this included?

synonym_typedefs=[alias_type],
auto_generated_by=f"bio2obo:{PREFIX}",
data_version=version,
)


def get_terms(force: bool = False) -> Iterable[Term]:
bigg_df = ensure_df(
prefix=PREFIX,
url=URL,
sep="\t",
skiprows=18,
header=None,
names=HEADER,
)

for r, c in bigg_df.iterrows():
samuelbunga marked this conversation as resolved.
Show resolved Hide resolved
bigg_id = c[0]
name = c[2]
synonyms = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why include this blank list?

term = Term(
reference=Reference(prefix=PREFIX, identifier=bigg_id, name=name),
definition=[],
samuelbunga marked this conversation as resolved.
Show resolved Hide resolved
synonyms=synonyms,
)
yield term


@click.command()
@verbose_option
def _main():
obo = get_obo(force=True)
obo.write_default(force=True, write_obo=True)


if __name__ == "__main__":
#get_obo(force=True).write_default(write_obo=True, write_obograph=True, force=True)
_main()