---
# Biology Research Lab Ontology
#
# A comprehensive ontology for academic biology research labs covering
# full research lifecycle: PI leadership, grants, experiments, samples,
# publications, and compliance (IRB/IACUC/IBC).
#
# Compatible with: mif-base v1.0.0, shared-traits v1.0.0
#
# Version: 0.1.0
# Last Updated: 2026-01-26
#
# Sources:
# - NIH Grants & Funding Policies
#   https://grants.nih.gov/
# - NSF Proposal & Award Policies and Procedures Guide
#   https://www.nsf.gov/publications/pub_summ.jsp?ods_key=papp
# - Office for Human Research Protections (OHRP)
#   https://www.hhs.gov/ohrp/
# - IACUC Guidelines (OLAW/NIH)
#   https://olaw.nih.gov/
# - FAIR Data Principles
#   https://www.go-fair.org/fair-principles/
# - CRediT Contributor Roles Taxonomy
#   https://credit.niso.org/

ontology:
  id: biology-research-lab
  version: "0.1.0"
  description: "Biology research lab ontology with full lifecycle"
  schema_url: >-
    https://mif-spec.dev/schema/ontology/ontology.schema.json
  extends:
    - mif-base
    - shared-traits

# ===========================================================================
# CUSTOM NAMESPACES
# ===========================================================================

namespaces:
  semantic:
    children:
      # People & Organization
      personnel:
        description: "PIs, researchers, staff, students"
        type_hint: semantic
      collaborations:
        description: "External collaborators, consortia"
        type_hint: semantic

      # Funding
      grants:
        description: "Grants, awards, funding sources"
        type_hint: semantic
      budgets:
        description: "Budget allocations, expenditures"
        type_hint: semantic

      # Research Assets
      projects:
        description: "Research projects and aims"
        type_hint: semantic
      protocols:
        description: "Experimental protocols, methods"
        type_hint: semantic
      samples:
        description: "Biological samples, specimens"
        type_hint: semantic
      equipment:
        description: "Lab equipment, instruments"
        type_hint: semantic
      reagents:
        description: "Reagents, consumables, inventory"
        type_hint: semantic

      # Data & Publications
      datasets:
        description: "Research data, repositories"
        type_hint: semantic
      publications:
        description: "Papers, preprints, patents"
        type_hint: semantic

      # Compliance
      compliance:
        description: "IRB, IACUC, IBC protocols"
        type_hint: semantic

  episodic:
    children:
      experiments:
        description: "Experiment runs, data collection"
        type_hint: episodic
      grant-events:
        description: "Submissions, reviews, renewals"
        type_hint: episodic
      pub-events:
        description: "Submissions, peer reviews"
        type_hint: episodic
      training:
        description: "Training completions, certifications"
        type_hint: episodic

  procedural:
    children:
      lab-protocols:
        description: "SOPs, experimental procedures"
        type_hint: procedural
      grant-procedures:
        description: "Proposal preparation, reporting"
        type_hint: procedural
      safety:
        description: "Safety procedures, EHS protocols"
        type_hint: procedural

# ===========================================================================
# ENTITY TYPES
# ===========================================================================

entity_types:
  # -------------------------------------------------------------------------
  # PERSONNEL ENTITIES
  # -------------------------------------------------------------------------
  - name: principal-investigator
    description: "Lab PI - primary grant holder and lab leader"
    base: semantic
    traits:
      - contactable
      - certified
    schema:
      required:
        - name
        - institution
        - department
      properties:
        name:
          type: string
        title:
          type: string
          enum:
            - assistant_professor
            - associate_professor
            - professor
            - research_professor
            - senior_scientist
        institution:
          type: string
        department:
          type: string
        orcid:
          type: string
          description: "ORCID identifier"
          pattern: "^\\d{4}-\\d{4}-\\d{4}-\\d{3}[\\dX]$"
        era_commons_id:
          type: string
        research_focus:
          type: array
          items:
            type: string
        h_index:
          type: integer
        start_date:
          type: string
          format: date

  - name: lab-member
    description: "Lab personnel (postdocs, students, staff)"
    base: semantic
    traits:
      - lifecycle
      - certified
      - contactable
    schema:
      required:
        - name
        - role
        - pi_id
      properties:
        name:
          type: string
        role:
          type: string
          enum:
            - postdoc
            - graduate_student
            - undergraduate
            - research_scientist
            - lab_manager
            - technician
            - visiting_scholar
        pi_id:
          type: string
          description: "Supervising PI"
        email:
          type: string
          format: email
        orcid:
          type: string
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
        funding_source:
          type: string
        projects:
          type: array
          items:
            type: string

  - name: collaborator
    description: "External research collaborator"
    base: semantic
    traits:
      - contactable
    schema:
      required:
        - name
        - institution
      properties:
        name:
          type: string
        institution:
          type: string
        department:
          type: string
        role:
          type: string
          enum:
            - co_investigator
            - consultant
            - core_facility
            - data_provider
            - clinical_partner
        expertise:
          type: array
          items:
            type: string
        shared_projects:
          type: array
          items:
            type: string

  # -------------------------------------------------------------------------
  # GRANT & FUNDING ENTITIES
  # -------------------------------------------------------------------------
  - name: grant
    description: "Research grant or funding award"
    base: semantic
    traits:
      - lifecycle
      - budgeted
      - renewable
    schema:
      required:
        - title
        - agency
        - grant_number
        - pi_id
      properties:
        title:
          type: string
        agency:
          type: string
          enum:
            - nih
            - nsf
            - doe
            - dod
            - hhmi
            - foundation
            - industry
            - internal
        grant_number:
          type: string
        mechanism:
          type: string
          description: "Grant mechanism (R01, R21, etc.)"
        pi_id:
          type: string
        co_pis:
          type: array
          items:
            type: string
        status:
          type: string
          enum:
            - planning
            - submitted
            - under_review
            - funded
            - active
            - no_cost_extension
            - closed
            - not_funded
        total_budget:
          type: number
        direct_costs:
          type: number
        indirect_rate:
          type: number
        project_period:
          type: object
          properties:
            start:
              type: string
              format: date
            end:
              type: string
              format: date
        specific_aims:
          type: array
          items:
            type: string

  - name: grant-submission
    description: "Grant proposal submission event"
    base: episodic
    traits:
      - scheduled
      - reviewed
    schema:
      required:
        - grant_id
        - submission_type
        - submission_date
      properties:
        grant_id:
          type: string
        submission_type:
          type: string
          enum:
            - new
            - renewal
            - revision
            - resubmission
            - supplement
        submission_date:
          type: string
          format: date
        deadline:
          type: string
          format: date
        study_section:
          type: string
        review_date:
          type: string
          format: date
        priority_score:
          type: number
        percentile:
          type: number
        summary_statement:
          type: string
        reviewer_critiques:
          type: array
          items:
            type: object
            properties:
              criterion:
                type: string
              score:
                type: integer
              comments:
                type: string

  - name: grant-report
    description: "Progress or final report to funding agency"
    base: procedural
    traits:
      - scheduled
      - reviewed
    schema:
      required:
        - grant_id
        - report_type
        - due_date
      properties:
        grant_id:
          type: string
        report_type:
          type: string
          enum:
            - annual_progress
            - final
            - financial
            - invention
            - no_cost_extension
        due_date:
          type: string
          format: date
        submitted_date:
          type: string
          format: date
        status:
          type: string
          enum:
            - not_started
            - in_progress
            - submitted
            - accepted
            - revision_required
        key_accomplishments:
          type: array
          items:
            type: string
        publications_reported:
          type: array
          items:
            type: string

  # -------------------------------------------------------------------------
  # PROJECT & EXPERIMENT ENTITIES
  # -------------------------------------------------------------------------
  - name: project
    description: "Research project or specific aim"
    base: semantic
    traits:
      - lifecycle
      - owned
    schema:
      required:
        - name
        - pi_id
      properties:
        name:
          type: string
        description:
          type: string
        pi_id:
          type: string
        grant_ids:
          type: array
          items:
            type: string
        status:
          type: string
          enum:
            - planning
            - active
            - on_hold
            - completed
            - archived
        hypothesis:
          type: string
        objectives:
          type: array
          items:
            type: string
        team_members:
          type: array
          items:
            type: string
        start_date:
          type: string
          format: date

  - name: protocol
    description: "Experimental protocol or method"
    base: procedural
    traits:
      - versioned
      - reviewed
    schema:
      required:
        - name
        - protocol_type
      properties:
        name:
          type: string
        protocol_type:
          type: string
          enum:
            - cell_culture
            - molecular_biology
            - biochemistry
            - imaging
            - animal
            - computational
            - clinical
            - field_collection
        version:
          type: string
        author:
          type: string
        steps:
          type: array
          items:
            type: object
            properties:
              step_number:
                type: integer
              action:
                type: string
              duration:
                type: string
              notes:
                type: string
        reagents_required:
          type: array
          items:
            type: string
        equipment_required:
          type: array
          items:
            type: string
        safety_notes:
          type: string
        troubleshooting:
          type: array
          items:
            type: object
            properties:
              problem:
                type: string
              solution:
                type: string

  - name: experiment
    description: "Individual experiment run"
    base: episodic
    traits:
      - scheduled
      - measured
    schema:
      required:
        - experiment_id
        - protocol_id
        - project_id
        - date
      properties:
        experiment_id:
          type: string
        protocol_id:
          type: string
        project_id:
          type: string
        date:
          type: string
          format: date
        researcher:
          type: string
        hypothesis:
          type: string
        conditions:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              value:
                type: string
        samples_used:
          type: array
          items:
            type: string
        data_files:
          type: array
          items:
            type: string
        outcome:
          type: string
          enum:
            - success
            - partial
            - failed
            - inconclusive
        observations:
          type: string
        next_steps:
          type: string

  # -------------------------------------------------------------------------
  # SAMPLE & REAGENT ENTITIES
  # -------------------------------------------------------------------------
  - name: sample
    description: "Biological sample or specimen"
    base: semantic
    traits:
      - inventoried
      - lifecycle
    schema:
      required:
        - sample_id
        - sample_type
      properties:
        sample_id:
          type: string
        sample_type:
          type: string
          enum:
            - cell_line
            - primary_cells
            - tissue
            - blood
            - serum
            - dna
            - rna
            - protein
            - plasmid
            - virus
            - bacteria
            - organism
            - environmental
        organism:
          type: string
        source:
          type: string
        collection_date:
          type: string
          format: date
        storage_location:
          type: string
        storage_temp:
          type: string
          enum:
            - room_temp
            - 4C
            - minus20
            - minus80
            - liquid_nitrogen
        quantity:
          type: number
        unit:
          type: string
        passage_number:
          type: integer
        status:
          type: string
          enum:
            - available
            - in_use
            - depleted
            - contaminated
            - discarded
        irb_protocol:
          type: string
        iacuc_protocol:
          type: string

  - name: reagent
    description: "Lab reagent or consumable"
    base: semantic
    traits:
      - inventoried
    schema:
      required:
        - name
        - catalog_number
      properties:
        name:
          type: string
        catalog_number:
          type: string
        vendor:
          type: string
        lot_number:
          type: string
        quantity:
          type: number
        unit:
          type: string
        location:
          type: string
        storage_conditions:
          type: string
        expiration_date:
          type: string
          format: date
        hazard_class:
          type: string
        msds_url:
          type: string
          format: uri
        reorder_threshold:
          type: number

  - name: equipment
    description: "Lab equipment or instrument"
    base: semantic
    traits:
      - inventoried
      - maintainable
      - owned
    schema:
      required:
        - name
        - equipment_type
      properties:
        name:
          type: string
        equipment_type:
          type: string
          enum:
            - microscope
            - centrifuge
            - pcr_thermocycler
            - sequencer
            - flow_cytometer
            - spectrophotometer
            - incubator
            - freezer
            - biosafety_cabinet
            - fume_hood
            - mass_spec
            - hplc
            - other
        manufacturer:
          type: string
        model:
          type: string
        serial_number:
          type: string
        location:
          type: string
        purchase_date:
          type: string
          format: date
        service_contract:
          type: boolean
        training_required:
          type: boolean
        core_facility:
          type: boolean
        hourly_rate:
          type: number

  # -------------------------------------------------------------------------
  # DATA & PUBLICATION ENTITIES
  # -------------------------------------------------------------------------
  - name: dataset
    description: "Research dataset"
    base: semantic
    traits:
      - versioned
      - owned
    schema:
      required:
        - name
        - data_type
      properties:
        name:
          type: string
        description:
          type: string
        data_type:
          type: string
          enum:
            - sequencing
            - imaging
            - proteomics
            - metabolomics
            - clinical
            - behavioral
            - computational
            - survey
        format:
          type: string
        size_gb:
          type: number
        location:
          type: string
        repository:
          type: string
          enum:
            - geo
            - sra
            - dbgap
            - zenodo
            - figshare
            - dryad
            - local
        accession:
          type: string
        license:
          type: string
        fair_compliant:
          type: boolean
        associated_publication:
          type: string
        embargo_until:
          type: string
          format: date

  - name: publication
    description: "Research publication"
    base: semantic
    traits:
      - lifecycle
      - reviewed
    schema:
      required:
        - title
        - publication_type
      properties:
        title:
          type: string
        publication_type:
          type: string
          enum:
            - journal_article
            - preprint
            - review
            - book_chapter
            - conference
            - thesis
            - patent
        authors:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              orcid:
                type: string
              credit_roles:
                type: array
                items:
                  type: string
        journal:
          type: string
        doi:
          type: string
        pmid:
          type: string
        preprint_doi:
          type: string
        status:
          type: string
          enum:
            - in_preparation
            - submitted
            - in_review
            - revision
            - accepted
            - published
            - preprint
        publication_date:
          type: string
          format: date
        grant_citations:
          type: array
          items:
            type: string
        open_access:
          type: boolean

  - name: manuscript-submission
    description: "Manuscript submission to journal"
    base: episodic
    traits:
      - scheduled
    schema:
      required:
        - publication_id
        - journal
        - submission_date
      properties:
        publication_id:
          type: string
        journal:
          type: string
        submission_date:
          type: string
          format: date
        submission_number:
          type: string
        status:
          type: string
          enum:
            - submitted
            - with_editor
            - in_review
            - decision_pending
            - revision_requested
            - accepted
            - rejected
        decision_date:
          type: string
          format: date
        reviewer_comments:
          type: array
          items:
            type: object
            properties:
              reviewer:
                type: string
              recommendation:
                type: string
              comments:
                type: string
        response_due:
          type: string
          format: date

  # -------------------------------------------------------------------------
  # COMPLIANCE ENTITIES
  # -------------------------------------------------------------------------
  - name: irb-protocol
    description: "Institutional Review Board protocol"
    base: semantic
    traits:
      - renewable
      - auditable
      - lifecycle
    schema:
      required:
        - protocol_number
        - title
        - pi_id
      properties:
        protocol_number:
          type: string
        title:
          type: string
        pi_id:
          type: string
        review_type:
          type: string
          enum:
            - exempt
            - expedited
            - full_board
        status:
          type: string
          enum:
            - draft
            - submitted
            - approved
            - expired
            - suspended
            - closed
        approval_date:
          type: string
          format: date
        expiration_date:
          type: string
          format: date
        subjects_enrolled:
          type: integer
        subjects_approved:
          type: integer
        risk_level:
          type: string
          enum:
            - minimal
            - greater_than_minimal

  - name: iacuc-protocol
    description: "Animal use protocol"
    base: semantic
    traits:
      - renewable
      - auditable
      - lifecycle
    schema:
      required:
        - protocol_number
        - title
        - pi_id
      properties:
        protocol_number:
          type: string
        title:
          type: string
        pi_id:
          type: string
        species:
          type: array
          items:
            type: string
        animal_count:
          type: integer
        status:
          type: string
          enum:
            - draft
            - submitted
            - approved
            - expired
            - suspended
            - closed
        approval_date:
          type: string
          format: date
        expiration_date:
          type: string
          format: date
        pain_category:
          type: string
          enum:
            - B
            - C
            - D
            - E
        housing_location:
          type: string

  - name: ibc-protocol
    description: "Institutional Biosafety Committee protocol"
    base: semantic
    traits:
      - renewable
      - auditable
      - lifecycle
    schema:
      required:
        - protocol_number
        - title
        - pi_id
      properties:
        protocol_number:
          type: string
        title:
          type: string
        pi_id:
          type: string
        biosafety_level:
          type: string
          enum:
            - BSL1
            - BSL2
            - BSL3
        agents:
          type: array
          description: "Biological agents used"
          items:
            type: object
            properties:
              name:
                type: string
              risk_group:
                type: integer
        recombinant_dna:
          type: boolean
        status:
          type: string
          enum:
            - draft
            - submitted
            - approved
            - expired
            - suspended
        approval_date:
          type: string
          format: date
        expiration_date:
          type: string
          format: date

  - name: training-record
    description: "Required training completion record"
    base: episodic
    traits:
      - renewable
      - certified
    schema:
      required:
        - person_id
        - training_type
        - completion_date
      properties:
        person_id:
          type: string
        training_type:
          type: string
          enum:
            - lab_safety
            - bloodborne_pathogen
            - radiation_safety
            - animal_handling
            - biosafety
            - chemical_hygiene
            - rcr
            - hipaa
            - human_subjects
        completion_date:
          type: string
          format: date
        expiration_date:
          type: string
          format: date
        certificate_id:
          type: string
        provider:
          type: string

# ===========================================================================
# RELATIONSHIPS
# ===========================================================================

relationships:
  leads:
    description: "PI leads lab member or project"
    from:
      - principal-investigator
    to:
      - lab-member
      - project
      - grant
    symmetric: false

  funded_by:
    description: "Project funded by grant"
    from:
      - project
      - lab-member
    to:
      - grant
    symmetric: false

  uses_protocol:
    description: "Experiment uses protocol"
    from:
      - experiment
    to:
      - protocol
    symmetric: false

  produces:
    description: "Experiment produces dataset"
    from:
      - experiment
      - project
    to:
      - dataset
      - publication
    symmetric: false

  covered_by:
    description: "Sample/experiment covered by compliance protocol"
    from:
      - sample
      - experiment
    to:
      - irb-protocol
      - iacuc-protocol
      - ibc-protocol
    symmetric: false

  collaborates_with:
    description: "PI collaborates with external party"
    from:
      - principal-investigator
      - project
    to:
      - collaborator
    symmetric: true

  cites_grant:
    description: "Publication cites grant funding"
    from:
      - publication
    to:
      - grant
    symmetric: false

  uses_sample:
    description: "Experiment uses sample"
    from:
      - experiment
    to:
      - sample
    symmetric: false

  uses_equipment:
    description: "Protocol uses equipment"
    from:
      - protocol
      - experiment
    to:
      - equipment
    symmetric: false

# ===========================================================================
# DISCOVERY PATTERNS
# ===========================================================================

discovery:
  enabled: true
  confidence_threshold: 0.8

  patterns:
    # Grant patterns
    - content_pattern: "\\b(R01|R21|R03|K99|F31|T32|U01)\\b"
      suggest_entity: grant
      suggest_namespace: _semantic/grants
    - content_pattern: "\\b(NIH|NSF|grant|funding|award)\\b"
      suggest_entity: grant
      suggest_namespace: _semantic/grants
    - content_pattern: "\\b(specific aim|proposal|study section)\\b"
      suggest_entity: grant-submission
      suggest_namespace: _episodic/grant-events

    # Personnel patterns
    - content_pattern: "\\b(postdoc|graduate student|lab manager)\\b"
      suggest_entity: lab-member
      suggest_namespace: _semantic/personnel
    - content_pattern: "\\b(PI|principal investigator|ORCID)\\b"
      suggest_entity: principal-investigator
      suggest_namespace: _semantic/personnel

    # Experiment patterns
    - content_pattern: "\\b(protocol|SOP|procedure)\\b"
      suggest_entity: protocol
      suggest_namespace: _procedural/lab-protocols
    - content_pattern: "\\b(experiment|assay|Western|PCR|qPCR)\\b"
      suggest_entity: experiment
      suggest_namespace: _episodic/experiments

    # Sample patterns
    - content_pattern: "\\b(sample|specimen|cell line|tissue)\\b"
      suggest_entity: sample
      suggest_namespace: _semantic/samples
    - content_pattern: "\\b(reagent|antibody|primer|enzyme)\\b"
      suggest_entity: reagent
      suggest_namespace: _semantic/reagents

    # Publication patterns
    - content_pattern: "\\b(manuscript|paper|publication|preprint)\\b"
      suggest_entity: publication
      suggest_namespace: _semantic/publications
    - content_pattern: "\\b(DOI|PMID|journal|submitted)\\b"
      suggest_entity: manuscript-submission
      suggest_namespace: _episodic/pub-events

    # Compliance patterns
    - content_pattern: "\\b(IRB|human subjects|consent)\\b"
      suggest_entity: irb-protocol
      suggest_namespace: _semantic/compliance
    - content_pattern: "\\b(IACUC|animal protocol|animal use)\\b"
      suggest_entity: iacuc-protocol
      suggest_namespace: _semantic/compliance
    - content_pattern: "\\b(IBC|biosafety|BSL)\\b"
      suggest_entity: ibc-protocol
      suggest_namespace: _semantic/compliance

    # Data patterns
    - content_pattern: "\\b(dataset|GEO|SRA|repository)\\b"
      suggest_entity: dataset
      suggest_namespace: _semantic/datasets
