{#-

  Jinja2 Template for multile dynamic files

  See odk.py for how this is processed.

  This is first expanded into a single text file;
  Each entry starting with ^^^ denotes a single file

-#}
{#-

  Ontology source file, e.g. src/ontology/foo-edit.owl

  We seed this with basic info such as ontology IRI and
  a fake root class (this can be customized).

  Note that when running odk.py, you can pass in a --source
  argument to substitute this with your own edit file

#}
^^^ src/ontology/{{ project.id }}-edit.{{ project.edit_format }}
{% if project.edit_format == "obo" -%}
format-version: 1.2
{%   if project.manage_import_declarations -%}
{%     if project.import_group is defined -%}
{%       if project.import_group.use_base_merging -%}
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/merged_import.owl
{%       else -%}
{%         for imp in project.import_group.products -%}
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ imp.id }}_import.owl
{%         endfor -%}
{%       endif -%}
{%     endif -%}
{%     if project.use_dosdps -%}
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/patterns/definitions.owl
{%       if project.import_pattern_ontology -%}
import: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/patterns/pattern.owl
{%       endif -%}
{%     endif -%}
{%   endif -%}
ontology: {{project.id}}
property_value: http://purl.org/dc/terms/description "{{ project.description }}" xsd:string
property_value: http://purl.org/dc/terms/title "{{ project.title }}" xsd:string
property_value: http://purl.org/dc/terms/license {{ project.license }}

[Term]
id: {{ project.id | upper }}:0000000
name: root node

[Typedef]
id: http://purl.org/dc/terms/description
name: description
is_metadata_tag: true

[Typedef]
id: http://purl.org/dc/terms/title
name: title
is_metadata_tag: true

[Typedef]
id: http://purl.org/dc/terms/license
name: license
is_metadata_tag: true

{% else %}{# ! project.edit_format == "obo" -#}
Prefix(:=<{{ project.uribase }}/{{ project.id }}.owl#>)
Prefix(dce:=<http://purl.org/dc/elements/1.1/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(dcterms:=<http://purl.org/dc/terms/>)


Ontology(<{{ project.uribase }}/{{ project.id }}.owl>
{%   if project.manage_import_declarations -%}
{%     if project.import_group is defined %}
{%       if project.import_group.use_base_merging -%}
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/merged_import.owl>)
{%       else -%}
{%         for imp in project.import_group.products -%}
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ imp.id }}_import.owl>)
{%         endfor -%}
{%       endif -%}
{%     endif %}

{%     if project.use_dosdps -%}
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/patterns/definitions.owl>)
{%       if project.import_pattern_ontology -%}
Import(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/patterns/pattern.owl>)
{%       endif -%}
{%     endif -%}
{%   endif -%}
Annotation(dcterms:description "{{ project.description }}")
Annotation(dcterms:license <{{ project.license }}>)
Annotation(dcterms:title "{{ project.title }}")


Declaration(Class(<{{ project.uribase }}/{{ project.id | upper }}_0000000>))
Declaration(AnnotationProperty(dcterms:description))
Declaration(AnnotationProperty(dcterms:license))
Declaration(AnnotationProperty(dcterms:title))

############################
#   Annotation Properties
############################

AnnotationAssertion(rdfs:label dcterms:description "description")
AnnotationAssertion(rdfs:label dcterms:license "license")
AnnotationAssertion(rdfs:label dcterms:title "title")

############################
#   Classes
############################

# Class: <{{ project.uribase }}/{{ project.id | upper }}_0000000> (root node)

AnnotationAssertion(rdfs:label <{{ project.uribase }}/{{ project.id | upper }}_0000000> "root node"@en)


)
{% endif %}{# ! project.edit_format != "obo" -#}
{#

  ID ranges file

-#}
^^^ src/ontology/{{ project.id }}-idranges.owl
## ID Ranges File
Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix: idsfor: <http://purl.obolibrary.org/obo/IAO_0000598>
Prefix: dce: <http://purl.org/dc/elements/1.1/>
Prefix: xsd: <http://www.w3.org/2001/XMLSchema#>
Prefix: allocatedto: <http://purl.obolibrary.org/obo/IAO_0000597>
Prefix: xml: <http://www.w3.org/XML/1998/namespace>
Prefix: idprefix: <http://purl.obolibrary.org/obo/IAO_0000599>
Prefix: iddigits: <http://purl.obolibrary.org/obo/IAO_0000596>
Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix: idrange: <http://purl.obolibrary.org/obo/ro/idrange/>
Prefix: owl: <http://www.w3.org/2002/07/owl#>

Ontology: <{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/{{ project.id }}-idranges.owl>


Annotations: 
    idsfor: "{{ project.id | upper }}",
    idprefix: "{{ project.uribase }}/{{ project.id | upper }}_",
    iddigits: 7

AnnotationProperty: idprefix:

    
AnnotationProperty: iddigits:

    
AnnotationProperty: idsfor:

    
AnnotationProperty: allocatedto:

Datatype: idrange:1

    Annotations: 
        allocatedto: "ONTOLOGY-CREATOR"
    
    EquivalentTo: 
        xsd:integer[>= 0 , <= 999999]

    
Datatype: idrange:2

    Annotations: 
        allocatedto: "ADDITIONAL EDITOR"
    
    EquivalentTo: 
        xsd:integer[>= 1000000 , <= 1999999]
    
    
Datatype: xsd:integer
Datatype: rdf:PlainLiteral

^^^ src/ontology/{{ project.id }}.Makefile
## Customize Makefile settings for {{project.id}}
## 
## If you need to customize your Makefile, make
## changes here rather than in the main Makefile
{% if project.import_group is defined -%}
{%   if 'custom' == project.import_group.module_type -%}
imports/%_import.owl: mirror/%.owl
	echo "ERROR: You have configured your default module type to be custom; this behavior needs to be overwritten in {{ project.id }}.Makefile!" && touch $@
{%   endif -%}
{%   if project.import_group.use_base_merging -%}
{#

  Single merged import file

-#}
^^^ src/ontology/imports/merged_import.owl
Prefix(:=<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/merged_import.owl>)
Prefix(obo:=<http://purl.obolibrary.org/obo/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(oboInOwl:=<http://www.geneontology.org/formats/oboInOwl#>)

Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/merged_import.owl>
# This is a placeholder, it will be regenerated when makefile is first executed.
)
{%   else %}{# ! project.import_group.use_base_merging -#}
{#

  Imports files, one per import

-#}
{%     for imp in project.import_group.products -%}
^^^ src/ontology/imports/{{ imp.id }}_import.owl
Prefix(:=<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ imp.id }}_import.owl>)
Prefix(obo:=<http://purl.obolibrary.org/obo/>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(oboInOwl:=<http://www.geneontology.org/formats/oboInOwl#>)

Ontology(<{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/imports/{{ imp.id }}_import.owl>
# This is a placeholder, it will be regenerated when makefile is first executed.
)
{%     endfor -%}
{%   endif -%}
{#

  Import Term files

  We seed each of these with some random terms. This is a little unsatisfactory and fragile;
  ROBOT extract will fail if it cannot find any of the terms. While this doesn't matter in the long term,
  as the ontology maintainer will provide their own lists, but it is problematic for the initial seed.

  TODO: Decide if we should either query ontobee for seed terms OR have the seed list provided in the project.yaml

-#}
{%   for imp in project.import_group.products -%}
^^^ src/ontology/imports/{{ imp.id }}_terms.txt
{%   endfor -%}
{% endif %}{# ! project.import_group is defined -#}
{#

  Metadata files.

  These are convenient for submission to OBO. Note that OBO maintains two files, a .md and a .yml

  TODO: include a script that makes it easy for maintainers to do this.

-#}
{% if project.create_obo_metadata -%}
^^^ src/metadata/README.md
Metadata files for the OBO Library

 * [{{ project.id }}.yml]({{ project.id }}.yml)
     * Determines how your purl.obolibrary.org/obo/{{ project.id }}/ redirects will be handled
     * Go here: https://github.com/OBOFoundry/purl.obolibrary.org/tree/master/config
     * Click [New File](https://github.com/OBOFoundry/purl.obolibrary.org/new/master/config)
     * Paste in the contents of [{{ project.id }}.yml]({{ project.id }}.yml)
     * Click "Commit new file"
     * IMPORTANT: remember to make a pull request
     * An OBO admin will merge your Pull Request *providing it meets the requirements of the OBO library*
 * [{{ project.id }}.md]({{ project.id }}.md)
     * Determines how your metadata is shown on OBO Library, OLS and AberOWL
     * Go here: https://github.com/OBOFoundry/OBOFoundry.github.io/tree/master/ontology
     * Click [New File](https://github.com/OBOFoundry/OBOFoundry.github.io/new/master/ontology)
     * Paste in the contents of [{{ project.id }}.md]({{ project.id }}.md)
     * Click "Commit new file"
     * IMPORTANT: remember to make a pull request
     * An OBO admin will merge your Pull Request *providing it meets the requirements of the OBO library*
     
For more background see:

 * http://obofoundry.org/
 * http://obofoundry.org/faq/how-do-i-edit-metadata.html

^^^ src/metadata/{{ project.id }}.md
---
layout: ontology_detail
id: {{ project.id }}
title: {{ project.title }}
jobs:
  - id: https://travis-ci.org/{{ project.github_org }}/{{ project.repo }}
    type: travis-ci
build:
  checkout: git clone https://github.com/{{ project.github_org }}/{{ project.repo }}.git
  system: git
  path: "."
contact:
  email: {{ project.contact.email }}
  label: {{ project.contact.name }}
  github: {{ project.contact.github }}
description: {{ project.title }} is an ontology...
domain: stuff
homepage: https://github.com/{{ project.github_org }}/{{ project.repo }}
products:
  - id: {{ project.id }}.owl
    name: "{{ project.title }} main release in OWL format"
  - id: {{ project.id }}.obo
    name: "{{ project.title }} additional release in OBO format"
  - id: {{ project.id }}.json
    name: "{{ project.title }} additional release in OBOJSon format"
  - id: {{ project.id }}/{{ project.id }}-base.owl
    name: "{{ project.title }} main release in OWL format"
  - id: {{ project.id }}/{{ project.id }}-base.obo
    name: "{{ project.title }} additional release in OBO format"
  - id: {{ project.id }}/{{ project.id }}-base.json
    name: "{{ project.title }} additional release in OBOJSon format"
dependencies:
{%   for imp in project.import_group.products -%}
- id: {{ imp.id }}
{%   endfor -%}
tracker: https://github.com/{{ project.github_org }}/{{ project.repo }}/issues
license:
  url: http://creativecommons.org/licenses/by/3.0/
  label: CC-BY
activity_status: active
---

Enter a detailed description of your ontology here. You can use arbitrary markdown and HTML.
You can also embed images too.

^^^ src/metadata/{{ project.id }}.yml
# PURL configuration for http://purl.obolibrary.org/obo/{{ project.id }}

idspace: {{ project.id|upper }}
base_url: /obo/{{ project.id }}

products:
- {{ project.id }}.owl: https://raw.githubusercontent.com/{{ project.github_org }}/{{ project.repo }}/{{ project.git_main_branch }}/{{ project.id }}.owl
- {{ project.id }}.obo: https://raw.githubusercontent.com/{{ project.github_org }}/{{ project.repo }}/{{ project.git_main_branch }}/{{ project.id }}.obo

term_browser: ontobee
example_terms:
- {{ project.id.upper() }}_0000000

entries:

- prefix: /releases/
  replacement: https://raw.githubusercontent.com/{{ project.github_org }}/{{ project.repo }}/v

- prefix: /tracker/
  replacement: https://github.com/{{ project.github_org }}/{{ project.repo }}/issues

- prefix: /about/
  replacement: http://www.ontobee.org/ontology/{{ project.id|upper }}?iri=http://purl.obolibrary.org/obo/

## generic fall-through, serve direct from github by default
- prefix: /
  replacement: https://raw.githubusercontent.com/{{ project.github_org }}/{{ project.repo }}/{{ project.git_main_branch }}/
{% endif %}{# ! project.create_obo_metadata -#}
{% if project.use_templates -%}
^^^ src/templates/README.md
# ROBOT templates
{%   if project.components is not none -%}
{%     for component in project.components.products -%}
{%       if component.use_template -%}
{%         if component.templates is not none -%}
{%           for template in component.templates -%}
^^^ src/templates/{{ template }}
ID	LABEL
ID	LABEL
{%           endfor -%}
{%         else -%}
^^^ src/templates/{{ component.filename.split('.') | first }}.tsv
ID	LABEL
ID	LABEL
{%         endif -%}
{%       endif -%}
{%     endfor -%}
{%   endif -%}
{% endif %}{# ! project.use_templates -#}
{% if project.use_mappings -%}
^^^ src/mappings/README.md
# Directory for managing SSSOM mappings files

{%   if project.sssom_mappingset_group is not none -%}
{%     for mapping in project.sssom_mappingset_group.products -%}
^^^ src/mappings/{{ mapping.id }}.sssom.tsv
# curie_map:
#   semapv: https://w3id.org/semapv/vocab/
#   skos: http://www.w3.org/2004/02/skos/core#
#   sssom: https://w3id.org/sssom/
#   {{ project.id | upper }}: {{ project.uribase }}/{{ project.id | upper }}_
# license: https://creativecommons.org/publicdomain/zero/1.0/
# mapping_set_id: http://purl.obolibrary.org/obo/{{ project.id }}/mappings/{{ mapping.id }}.sssom.tsv
subject_id	predicate_id	object_id	mapping_justification
{{ project.id | upper }}:0000000	skos:exactMatch	sssom:NoTermFound	semapv:ManualMappingCuration

{%     endfor -%}
{%   endif -%}
{% endif %}{# ! project.use_mappings -#}
{% if project.bridge_group is not none -%}
{%   for bridge in project.bridge_group.products -%}
^^^ src/scripts/bridge-{{ bridge.ruleset }}.sssomt
prefix {{ project.id | upper }}: <{{ project.uribase }}/{{ project.id | upper }}_>

# Make sure {{ project.id | upper }} entities are on the subject side
object=={{ project.id | upper }}:* -> invert();

# Ignore any mapping to something else than {{ project.id | upper }}
!subject=={{ project.id | upper }}:* -> stop();

predicate==skos:exactMatch -> create_axiom("%subject_id EquivalentTo: %object_id");
predicate==skos:broadMatch -> create_axiom("%subject_id SubClassOf: %object_id");
predicate==skos:narrowMatch -> create_axiom("%object_id SubClassOf: %subject_id");
{%   endfor -%}
{% endif %}{# ! project.bridge_group is not none -#}
{% if project.use_translations -%}
^^^ src/translations/README.md
# Directory for managing translation files

{%   if project.babelon_translation_group is not none -%}
{%     for translation in project.babelon_translation_group.products -%}
^^^ src/translations/{{ translation.id }}.babelon.tsv
source_language	translation_language	subject_id	predicate_id	source_value	translation_value	translation_status
{%       if translation.include_robot_template_synonyms -%}
^^^ src/translations/{{ translation.id }}.synonyms.tsv
subject_id	translation_value	comment
ID	AL oboInOwl:hasExactSynonym@{{ translation.language }}	
{%       endif -%}
{%     endfor -%}
{%   endif -%}
{% endif %}{# ! project.use_translations -#}
{#
    Example pattern implementation TSV
-#}
{% if project.use_dosdps -%}
^^^ src/patterns/definitions.owl
Prefix(:=<http://purl.obolibary.org/obo/{{ project.id }}/definitions.owl#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://purl.obolibary.org/obo/{{ project.id }}/definitions.owl>

)
^^^ src/patterns/pattern.owl
Prefix(:=<http://purl.obolibary.org/obo/{{ project.id }}/pattern.owl#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)


Ontology(<http://purl.obolibary.org/obo/{{ project.id }}/pattern.owl>

)
^^^ src/patterns/README.md
# DOSDP patterns - editors docs
^^^ src/patterns/data/default/example.tsv
defined_class	example

^^^ src/patterns/dosdp-patterns/example.yaml
pattern_name: example
pattern_iri: {{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/example.yaml
description: "This is a minimal example pattern."

classes:
  example: owl:Thing

relations:
  part_of: BFO:0000050

vars:
  example: "'example'"

name:
  text: "Part of %s"
  vars:
   - example

equivalentTo:
  text: "'part_of' some %s"
  vars:
    - example
^^^ src/patterns/dosdp-patterns/external.txt
^^^ src/patterns/data/default/README.md
Documentation of the Default DOSDP Pipeline
{%   if project.pattern_pipelines_group is defined -%}
{%     for pipeline in project.pattern_pipelines_group.products -%}
^^^ src/patterns/data/{{ pipeline.id }}/README.md
# Documentation of the {{ pipeline.id }} DOSDP Pipeline
{%     endfor -%}
{%   endif -%}
{% endif %}{# ! project.use_dosdps -#}
{% if project.use_context -%}
^^^ src/ontology/config/context.json
{
	"@context": {
		"obo": "http://purl.obolibrary.org/obo/",
		"oboInOwl": "http://www.geneontology.org/formats/oboInOwl#",

		"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
		"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
		"rdfa": "http://www.w3.org/ns/rdfa#",
		"xml": "http://www.w3.org/XML/1998/namespace",
		"xsd": "http://www.w3.org/2001/XMLSchema#",
		"owl": "http://www.w3.org/2002/07/owl#",

		"dc": "http://purl.org/dc/terms/",
		"foaf": "http://xmlns.com/foaf/0.1/",
		"prov": "http://www.w3.org/ns/prov#",
		"skos": "http://www.w3.org/2004/02/skos/core#",
		"void": "http://rdfs.org/ns/void#"
	}
}
{% endif -%}
{% if project.components is defined -%}
{%   for component in project.components.products -%}
^^^ src/ontology/components/{{ component.filename }}
<?xml version="1.0"?>
<rdf:RDF 
     xml:base="{{ project.uribase }}/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:oboInOwl="http://www.geneontology.org/formats/oboInOwl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:obo="http://purl.obolibrary.org/obo/">
    <owl:Ontology rdf:about="{{ project.uribase }}/{% if project.uribase_suffix is not none %}{{ project.uribase_suffix }}{% else %}{{ project.id }}{% endif %}/components/{{ component.filename }}"/>

    <!-- This is a placeholder, it will be regenerated when makefile is first executed -->
</rdf:RDF>
{%   endfor -%}
{% endif -%}
{% if 'basic' in project.release_artefacts or project.primary_release == 'basic' -%}
^^^ src/ontology/keeprelations.txt
BFO:0000050
{% endif -%}
{% if project.use_custom_import_module -%}
^^^ src/templates/external_import.tsv
ID	Entity Type
ID	TYPE
owl:Thing	owl:Class
{% endif -%}
