Skip to content

Commit

Permalink
Merge pull request #38 from linkml/issue-32-empty-declarations
Browse files Browse the repository at this point in the history
Unpin funowl and fix bug in test example.
  • Loading branch information
cmungall authored Aug 8, 2023
2 parents f5dbb74 + e48765a commit 3ea977a
Show file tree
Hide file tree
Showing 13 changed files with 1,239 additions and 1,132 deletions.
21 changes: 18 additions & 3 deletions linkml_owl/dumpers/owl_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
else:
for obj_type in [ObjectProperty, DataProperty, AnnotationProperty, NamedIndividual, Class, Datatype]:
if obj_type.__name__ in cls_interps:
decl = Declaration(obj_type(subj))
if not subj:
raise ValueError(f"Cannot create {obj_type} without an identifier for {element}")
if not isinstance(subj, URIRef):
raise ValueError(f"Cannot create {obj_type} with non-URI identifier for {element}")
di = obj_type(subj)
decl = Declaration(di)
logging.debug(f"Inferred {decl} based on {obj_type.__name__} in {cls_interps}")
o.axioms.append(decl)
logging.info(f"Subject={subj}")
Expand Down Expand Up @@ -442,7 +447,7 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
elif axiom_type == AnnotationAssertion:
axiom = AnnotationAssertion(slot_uri, subj, parent)
else:
raise Exception(f'Unknown: {axiom_type}')
raise ValueError(f'Unknown axiom type: {axiom_type}')
if axiom is not None:
self.add_axiom(axiom, o, axiom_annotations)
else:
Expand Down Expand Up @@ -558,8 +563,18 @@ def _get_inferred_slot_annotations(self, slot: SlotDefinition, ann_key: str,
return list(vals)

def _get_inferred_class_annotations(self, cls: ClassDefinition, ann_key: str) -> List[str]:
"""
Retrieve owl annotations for a class, including those inherited from ancestors.
OWL annotations are specified in LinkML using the annotations slot, where the
key is "owl" or something in the owl namespace.
:param cls: class to query
:param ann_key: annotation key to query
:return:
"""
vals = set()
anc_classes = [cls]
anc_classes = []
sv = self.schemaview
for anc_c in sv.class_ancestors(cls.name, reflexive=True):
anc_classes.append(sv.get_class(anc_c))
Expand Down
1,882 changes: 884 additions & 998 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ linkml-data2owl = "linkml_owl.dumpers.owl_dumper:cli"
python = "^3.8"

click = "*"
funowl = "0.1.12"
Jinja2 = "^3.0.3"
linkml = "^1.3.0"
linkml-runtime = "^1.3.4"
funowl = ">=0.2.3"
Jinja2 = ">=3.0.3"
linkml = ">=1.3.0"
linkml-runtime = ">=1.3.4"

[tool.poetry.dev-dependencies]
tox = "^3.24.5"
pytest = "^6.2.5"
pytest-cov = "^3.0.0"
mkdocs = "^1.2.3"
black = "^22.10.0"
tox = ">=3.24.5"
pytest = ">=6.2.5"
pytest-cov = ">=3.0.0"
mkdocs = ">=1.2.3"
black = ">=22.10.0"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
Expand Down
162 changes: 162 additions & 0 deletions tests/inputs/behavior.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
ontology: behavior
description: Multimodal behavior ontology
roots:
NeuralPathway:
aliases:
- neural circuit
description: a series of connected neuronal activities where neurons send signals from one part of the brain to another.
children:
DopamineRewardPathway:
aliases: [Dopamine Pathway, Reward Pathway]
description: A neural pathway that, when activated, causes a reward signal to be sent to the brain, via the release of dopamine.
MesolimbicPathway:
aliases: [Mesolimbic Pathway, Mesolimbic Reward Pathway]
description: A neural pathway that, when activated, causes a reward signal to be sent to the brain, via the release of dopamine.
DrosophilaCourtshipNeuralCircuit:
references:
- PMID:23021897 # https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3563961/
MentalObject:
sources:
- MF
observable: false
description: A mental object is an object that exists in the mind.
children:
Memory:
description: A mental object that involves remembering something.
MentalState:
sources:
- MF
- MFOEM
observable: false
description: A mental state is a state of mind that an organism can be in at a given time.
children:
Perceiving:
description: A mental state that involves perceiving something.
Aggressive:
Hungry:
MentalProcess:
sources:
- MF
observable: false
description: A mental process is a process that an organism can undergo.
children:
Daydreaming:
description: A mental process that involves daydreaming.
Movement:
sources:
- NBO
observable: true
aliases:
- Kinesthetic Behavior
description: "Movement behavior of the body or its parts."
exact_mappings:
- NBO:0000338
children:
BodyPartMovement:
description: "A change of place or position of part of an organism that does not involve the entire organism [NBO:SMAC]"
WholeBodyMovement:
description: "A change of place or position of an entire organism"
CoordinatedSeriesOfMovements:
description: "A series of movements that are coordinated with each other"
children:
FlappingAppendanges:
description: "A coordinated series of movements involving repeated..."
Dancing:
description: "A coordinated series of movements that are performed in a rhythmic way"
defined_subclasses_by:
objective:
CourtshipDancing:
description: "A coordinated series of movements that are performed in a rhythmic way that is used for courtship"
differentia: Courtship
LocomotoryBehavior:
children:
Walking:
Running:
Swimming:
Flying:
BehavioralObjective:
sources:
- NBO but with rearrangement
children:
Playing:
characteristics:
- InvolvesOtherOrganismsOfSameSpecies
Communication:
#characteristics:
# - InvolvesOtherOrganismsOfSameSpecies
children:
Gesturing:
Vocalizing:
Predation:
characteristics:
- InvolvesOtherOrganisms
Escape:
characteristics:
- InvolvesOtherOrganisms
Submission:
Cannibalism:
Suicide:
Grooming:
sources:
- BCIO
children:
SelfGrooming:
characteristics:
- InvolvesSelfOnly
GroomingOfOthers:
characteristics:
- InvolvesOthers
Killing:
children:
KillingOrganismOfSameSpecies:
children:
KillingOfPersonByPerson:
aliases:
- Homicide
- Murder
SocialObjective:
children:
FinancialObjective:
children:
Payment:
Learning:
sources:
- NBO
Memory:
sources:
- NBO
MultiOrganismProcess:
children:
Predation:
BehaviorPattern:
children:
SmokingPattern:
BehavioralCharacteristic:
children:
InvolvesSelfOnly:
InvolvesOthers:
children:
InvolvesOtherOrganismsOfSameSpecies:
children:
Interpersonal:
defined_classes:
AddictiveBehavior:
type: BehaviorByMentalDisposition
genus: Behavior
disposition: Addiction
DrosophilaCourtshipBehavior:
description: >-
Drosophila males display a complex repertoire of behaviors that have evolved to achieve reproductive success.
This includes following the female, tapping her with his forelegs,
contacting her genitalia with his mouthparts,
singing a species-specific courtship song, and bending his abdomen to copulate [3].
It is presumed that Drosophila females assess a courting male by ‘summating’
sensory cues for species type and fitness before sanctioning mating [3].
A virgin female has the ability to be unreceptive to and resist the courtship of
a Drosophila male by exhibiting rejection behaviors, which include extruding her ovipositor,
kicking, or decamping [3–6].
If she decides to accept the male, she slows down, ceases rejection behaviors and opens her vaginal plate
for copulation [3]. After successful copulation, mated females become temporarily sexually unreceptive
to further copulatory attempts, increasing their rate of egg-laying (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3563961/)
type: BehaviorByNeuralCircuit
genus: ...
Loading

0 comments on commit 3ea977a

Please sign in to comment.