Skip to content

Add new term 'has substitutable entity'#865

Merged
balhoff merged 3 commits into
masterfrom
issue-863
Sep 8, 2025
Merged

Add new term 'has substitutable entity'#865
balhoff merged 3 commits into
masterfrom
issue-863

Conversation

@balhoff

@balhoff balhoff commented Sep 2, 2025

Copy link
Copy Markdown
Member

Fixes #863.

Label: has substitutable entity

Definition: Relates one individual to another which is capable of standing in for the first individual in its other relations to other individuals.

Example of usage: Given individuals f, i, x, and y, where f is a 'molecular function', i is an 'information biomacromolecule', and x and y are instances of different types of gene products, if f 'enabled by' i within an OWL model of a biological pathway, and i 'has substitutable entity' both x and y, then either x or y are valid enablers of function f within the modeled biological context.

@balhoff balhoff requested a review from anitacaron as a code owner September 2, 2025 19:27
@balhoff balhoff requested a review from cmungall September 2, 2025 19:27

@cmungall cmungall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add an example of use?

@balhoff

balhoff commented Sep 2, 2025

Copy link
Copy Markdown
Member Author

Add an example of use?

I took a stab at it.

@nataled

nataled commented Sep 2, 2025

Copy link
Copy Markdown
Collaborator

The definition states this object property is to be used to relate "...one individual to another...". I would interpret that to mean that--using your example--x 'has substitutable entity' y. Perhaps the definition is not phrased as intended? I also think that the last part, "...in its other relations to other individuals", can be omitted.

@balhoff

balhoff commented Sep 2, 2025

Copy link
Copy Markdown
Member Author

I will try to reword to clarify. All of the lowercase letters are meant to be individuals, and i 'has substitutable entity' x and i 'has substitutable entity' y. The idea is that there is an instance graph involving a placeholder individual i, where in practice either x or y, doesn't matter which, could be in the place of i. I'm sure my example can be clearer.

@balhoff

balhoff commented Sep 3, 2025

Copy link
Copy Markdown
Member Author

@nataled I updated the example of usage to the following:

Given individuals f, i, x, and y, where f is a 'molecular function', i is an 'information biomacromolecule', and x and y are instances of different types of gene products, if f 'enabled by' i within an OWL model of a biological pathway, and i 'has substitutable entity' both x and y, then either x or y are valid enablers of function f within the modeled biological context.

@wdduncan wdduncan self-requested a review September 8, 2025 15:27
@balhoff balhoff merged commit c30d877 into master Sep 8, 2025
1 check passed
@balhoff balhoff deleted the issue-863 branch September 8, 2025 18:34
cmungall added a commit to geneontology/noctua-py that referenced this pull request Oct 24, 2025
This commit introduces high-level convenience methods for creating protein
complexes and entity sets (paralogy groups) in GO-CAM models, along with
corresponding CLI commands.

## Core Library Changes

### New Pydantic Models (src/noctua/models.py)
- Add ProteinComplexComponent model for specifying complex components
  - Fields: entity_id (required), label, evidence_type, reference
  - Includes comprehensive doctests demonstrating usage
- Add EntitySetMember model for specifying functionally interchangeable entities
  - Same field structure as ProteinComplexComponent
  - Used for paralogy groups and other substitutable entity sets

### New BaristaClient Methods (src/noctua/barista.py)
- Add add_protein_complex() method (lines 1386-1491)
  - Creates protein-containing complex (GO:0032991 by default)
  - Links components using BFO:0000051 (has part) relation
  - Supports optional labels and evidence for each component
  - Uses atomic batch execution with automatic rollback
  - Returns BaristaResponse with created complex and relationships

- Add add_entity_set() method (lines 1493-1599)
  - Creates entity set (CHEBI:33695 information biomacromolecule by default)
  - Links members using RO:0019003 (has substitutable entity) relation
  - Supports optional labels and evidence for each member
  - Uses atomic batch execution with automatic rollback
  - Returns BaristaResponse with created set and relationships

- Replace print statements with proper logging (lines 6, 46, 661, 826-827)
  - Use logging.getLogger(__name__) pattern
  - Appropriate log levels (warning, error, info)

### CLI Commands (src/noctua/cli.py)
- Add _parse_component_spec() helper function (lines 1106-1145)
  - Parses pipe-delimited format: entity_id|label=X|evidence=Y|ref=Z
  - Returns dict with entity_id, label, evidence_type, reference
  - Includes doctests for format validation

- Add barista add-protein-complex command (lines 1148-1230)
  - Syntax: --component "UniProtKB:P12345|label=X|evidence=Y|ref=Z"
  - Repeatable --component flag for multiple components
  - Default class: GO:0032991 (protein-containing complex)
  - Optional --var for variable assignment
  - Optional --session for variable persistence
  - Supports --dry-run mode for safe preview

- Add barista add-entity-set command (lines 1233-1315)
  - Syntax: --member "UniProtKB:P27361|label=X|evidence=Y|ref=Z"
  - Repeatable --member flag for multiple members
  - Default class: CHEBI:33695 (information biomacromolecule)
  - Optional --var for variable assignment
  - Optional --session for variable persistence
  - Supports --dry-run mode for safe preview

## Testing

### New Test Files
- tests/test_protein_complex.py (5 tests)
  - test_add_protein_complex_simple: Basic two-component complex
  - test_add_protein_complex_with_evidence: Complex with evidence annotations
  - test_add_protein_complex_no_components_error: Error handling validation
  - test_add_protein_complex_missing_entity_id: Pydantic validation
  - test_add_protein_complex_custom_class: Custom complex class usage

- tests/test_entity_set.py (6 tests)
  - test_add_entity_set_simple: Basic two-member set
  - test_add_entity_set_with_evidence: Set with evidence annotations
  - test_add_entity_set_no_members_error: Error handling validation
  - test_add_entity_set_missing_entity_id: Pydantic validation
  - test_add_entity_set_custom_class: Custom set class usage
  - test_add_entity_set_paralogy_group: Real-world ERK1/ERK2 example

- tests/test_cli_complex_and_set.py (6 tests)
  - test_add_protein_complex_dry_run: CLI dry-run with full options
  - test_add_entity_set_dry_run: CLI dry-run with full options
  - test_add_protein_complex_custom_class: Custom class via CLI
  - test_add_entity_set_simple: Minimal CLI arguments
  - test_protein_complex_help: Help text verification
  - test_entity_set_help: Help text verification

## Design Decisions

### Pipe-Delimited CLI Syntax
Chose pipe-delimited format (entity_id|label=X|evidence=Y|ref=Z) for CLI
as a practical compromise between expressiveness and command-line usability.
Alternatives considered:
- JSON: Too verbose and error-prone for shell usage
- Multiple flags: Would require --entity, --label, etc. per component
- YAML: Requires multiline input or files

### Ontology Terms
Based on GO-CAM project requirements:
- Protein complexes use BFO:0000051 (has part) - standard mereological relation
- Entity sets use RO:0019003 (has substitutable entity) - new relation for
  functionally interchangeable entities (see oborel/obo-relations#865)
- Set class is CHEBI:33695 (information biomacromolecule) - appropriate for
  representing gene products as information-bearing entities

### Session Integration
Both CLI commands support --session flag to save the created variable to
a persistent session, enabling workflows like:
  noctua-py barista add-entity-set --session mysession --var erk_set ...
  noctua-py barista add-fact --session mysession --subject erk_set ...

## Test Results
- 145 total tests passed (+17 new tests)
- 51 doctests passed (+3 new doctests)
- mypy: No type errors
- ruff: No linting issues

## Related Issues
- Implements protein complex functionality per internal requirements
- Implements entity sets per geneontology/project-management#114
- Uses has_substitutable_entity relation per oborel/obo-relations#865

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
cmungall added a commit to geneontology/noctua-py that referenced this pull request Oct 24, 2025
This commit introduces high-level convenience methods for creating protein
complexes and entity sets (paralogy groups) in GO-CAM models, along with
corresponding CLI commands.

- Add ProteinComplexComponent model for specifying complex components
  - Fields: entity_id (required), label, evidence_type, reference
  - Includes comprehensive doctests demonstrating usage
- Add EntitySetMember model for specifying functionally interchangeable entities
  - Same field structure as ProteinComplexComponent
  - Used for paralogy groups and other substitutable entity sets

- Add add_protein_complex() method (lines 1386-1491)
  - Creates protein-containing complex (GO:0032991 by default)
  - Links components using BFO:0000051 (has part) relation
  - Supports optional labels and evidence for each component
  - Uses atomic batch execution with automatic rollback
  - Returns BaristaResponse with created complex and relationships

- Add add_entity_set() method (lines 1493-1599)
  - Creates entity set (CHEBI:33695 information biomacromolecule by default)
  - Links members using RO:0019003 (has substitutable entity) relation
  - Supports optional labels and evidence for each member
  - Uses atomic batch execution with automatic rollback
  - Returns BaristaResponse with created set and relationships

- Replace print statements with proper logging (lines 6, 46, 661, 826-827)
  - Use logging.getLogger(__name__) pattern
  - Appropriate log levels (warning, error, info)

- Add _parse_component_spec() helper function (lines 1106-1145)
  - Parses pipe-delimited format: entity_id|label=X|evidence=Y|ref=Z
  - Returns dict with entity_id, label, evidence_type, reference
  - Includes doctests for format validation

- Add barista add-protein-complex command (lines 1148-1230)
  - Syntax: --component "UniProtKB:P12345|label=X|evidence=Y|ref=Z"
  - Repeatable --component flag for multiple components
  - Default class: GO:0032991 (protein-containing complex)
  - Optional --var for variable assignment
  - Optional --session for variable persistence
  - Supports --dry-run mode for safe preview

- Add barista add-entity-set command (lines 1233-1315)
  - Syntax: --member "UniProtKB:P27361|label=X|evidence=Y|ref=Z"
  - Repeatable --member flag for multiple members
  - Default class: CHEBI:33695 (information biomacromolecule)
  - Optional --var for variable assignment
  - Optional --session for variable persistence
  - Supports --dry-run mode for safe preview

- tests/test_protein_complex.py (5 tests)
  - test_add_protein_complex_simple: Basic two-component complex
  - test_add_protein_complex_with_evidence: Complex with evidence annotations
  - test_add_protein_complex_no_components_error: Error handling validation
  - test_add_protein_complex_missing_entity_id: Pydantic validation
  - test_add_protein_complex_custom_class: Custom complex class usage

- tests/test_entity_set.py (6 tests)
  - test_add_entity_set_simple: Basic two-member set
  - test_add_entity_set_with_evidence: Set with evidence annotations
  - test_add_entity_set_no_members_error: Error handling validation
  - test_add_entity_set_missing_entity_id: Pydantic validation
  - test_add_entity_set_custom_class: Custom set class usage
  - test_add_entity_set_paralogy_group: Real-world ERK1/ERK2 example

- tests/test_cli_complex_and_set.py (6 tests)
  - test_add_protein_complex_dry_run: CLI dry-run with full options
  - test_add_entity_set_dry_run: CLI dry-run with full options
  - test_add_protein_complex_custom_class: Custom class via CLI
  - test_add_entity_set_simple: Minimal CLI arguments
  - test_protein_complex_help: Help text verification
  - test_entity_set_help: Help text verification

Chose pipe-delimited format (entity_id|label=X|evidence=Y|ref=Z) for CLI
as a practical compromise between expressiveness and command-line usability.
Alternatives considered:
- JSON: Too verbose and error-prone for shell usage
- Multiple flags: Would require --entity, --label, etc. per component
- YAML: Requires multiline input or files

Based on GO-CAM project requirements:
- Protein complexes use BFO:0000051 (has part) - standard mereological relation
- Entity sets use RO:0019003 (has substitutable entity) - new relation for
  functionally interchangeable entities (see oborel/obo-relations#865)
- Set class is CHEBI:33695 (information biomacromolecule) - appropriate for
  representing gene products as information-bearing entities

Both CLI commands support --session flag to save the created variable to
a persistent session, enabling workflows like:
  noctua-py barista add-entity-set --session mysession --var erk_set ...
  noctua-py barista add-fact --session mysession --subject erk_set ...

- 145 total tests passed (+17 new tests)
- 51 doctests passed (+3 new doctests)
- mypy: No type errors
- ruff: No linting issues

- Implements protein complex functionality per internal requirements
- Implements entity sets per geneontology/project-management#114
- Uses has_substitutable_entity relation per oborel/obo-relations#865

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NTR 'has substitutable entity'

4 participants