Skip to content

Commit

Permalink
Add explicit GO relation
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Feb 2, 2024
1 parent 9f6829a commit c6dd7eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/pyobo/sources/rhea.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
has_output,
has_participant,
has_right_to_left_reaction,
reaction_enabled_by_molecular_function,
)
from pyobo.utils.path import ensure_df

Expand Down Expand Up @@ -45,6 +46,7 @@ class RheaGetter(Obo):
has_input,
has_output,
has_participant,
reaction_enabled_by_molecular_function,
]

def iter_terms(self, force: bool = False) -> Iterable[Term]:
Expand Down Expand Up @@ -180,7 +182,7 @@ def iter_terms(version: str, force: bool = False) -> Iterable[Term]:
("reactome", "rhea2reactome", None),
("macie", "rhea2macie", None),
("metacyc", "rhea2metacyc", None),
("go", "rhea2go", None), # TODO what is the relationship?
("go", "rhea2go", reaction_enabled_by_molecular_function),
("uniprot", "rhea2uniprot", enabled_by),
]:
xref_df = ensure_df(
Expand Down
22 changes: 18 additions & 4 deletions src/pyobo/struct/typedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
]


def _bool_to_obo(v: bool) -> str:
return "true" if v else "false"


@dataclass
class TypeDef(Referenced):
"""A type definition in OBO.
Expand Down Expand Up @@ -88,7 +92,7 @@ def iterate_obo_lines(self) -> Iterable[str]:
yield f'def: "{self.definition}"'

if self.is_metadata_tag is not None:
yield f'is_metadata_tag: {"true" if self.is_metadata_tag else "false"}'
yield f"is_metadata_tag: {_bool_to_obo(self.is_metadata_tag)}"

if self.namespace:
yield f"namespace: {self.namespace}"
Expand All @@ -113,6 +117,10 @@ def iterate_obo_lines(self) -> Iterable[str]:
yield f"holds_over_chain: {_chain} ! {_names}"
if self.inverse:
yield f"inverse_of: {self.inverse}"
if self.domain:
yield f"domain: {self.domain}"
if self.range:
yield f"range: {self.range}"

@classmethod
def from_triple(cls, prefix: str, identifier: str, name: Optional[str] = None) -> "TypeDef":
Expand Down Expand Up @@ -161,13 +169,19 @@ def get_reference_tuple(relation: RelationHint) -> Tuple[str, str]:
"species with RO:0002162 (in taxon)",
)
has_left_to_right_reaction = TypeDef(
Reference(prefix="debio", identifier="0000007", name="has left-to-right reaction")
Reference(prefix="debio", identifier="0000007", name="has left-to-right reaction"),
is_metadata_tag=True,
)
has_right_to_left_reaction = TypeDef(
Reference(prefix="debio", identifier="0000008", name="has right-to-left reaction")
Reference(prefix="debio", identifier="0000008", name="has right-to-left reaction"),
is_metadata_tag=True,
)
has_bidirectional_reaction = TypeDef(
Reference(prefix="debio", identifier="0000009", name="has bi-directional reaction")
Reference(prefix="debio", identifier="0000009", name="has bi-directional reaction"),
is_metadata_tag=True,
)
reaction_enabled_by_molecular_function = TypeDef(
Reference(prefix="debio", identifier="0000047", name="reaction enabled by molecular function")
)


Expand Down

0 comments on commit c6dd7eb

Please sign in to comment.