Skip to content

Commit

Permalink
#97 robot to dosdp migration completed except individuals
Browse files Browse the repository at this point in the history
  • Loading branch information
hkir-dev committed Aug 12, 2021
1 parent 19bdc80 commit 633bd1e
Show file tree
Hide file tree
Showing 21 changed files with 164,312 additions and 60,516 deletions.
223,178 changes: 164,231 additions & 58,947 deletions bdscratch-full.owl

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/dendrograms/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
JOBS = CCN202002013 #CCN201908210 CCN201810310 CCN201908211

TEMPLATE_FILES = $(patsubst %, ../templates/%.tsv, $(JOBS))
TEMPLATE_CLASS_FILES = $(patsubst %, ../templates/%_class.tsv, $(JOBS))
TEMPLATE_CLASS_FILES = $(patsubst %, ../patterns/data/bds/%_class.tsv, $(JOBS))
MARKER_DENORMALIZED_FILES = $(patsubst %, ../markers/%_markers_denormalized.tsv, $(JOBS))
EQUIVALENT_CLASS_MARKER_FILES = $(patsubst %, ../templates/%_equivalent_markers.tsv, $(JOBS))
EQUIVALENT_CLASS_REIFICATION_FILES = $(patsubst %, ../templates/%_equivalent_reification.tsv, $(JOBS))
TEMPLATE_MINIMAL_MARKER_FILES = $(patsubst %, ../templates/%_minimal_markers.tsv, $(JOBS))
NOMENCLATURE_TEMPLATE_FILES = $(patsubst %, ../templates/%_non_taxonomy_classification.tsv, $(JOBS))
EQUIVALENT_CLASS_REIFICATION_FILES = $(patsubst %, ../patterns/data/bds/%_equivalent_reification.tsv, $(JOBS))
TEMPLATE_MINIMAL_MARKER_FILES = $(patsubst %, ../patterns/data/bds/%_minimal_markers.tsv, $(JOBS))
NOMENCLATURE_TEMPLATE_FILES = $(patsubst %, ../patterns/data/bds/%_non_taxonomy_classification.tsv, $(JOBS))


all: $(TEMPLATE_FILES) $(TEMPLATE_CLASS_FILES) $(MARKER_DENORMALIZED_FILES) $(EQUIVALENT_CLASS_MARKER_FILES) $(EQUIVALENT_CLASS_REIFICATION_FILES) $(TEMPLATE_MINIMAL_MARKER_FILES) $(NOMENCLATURE_TEMPLATE_FILES)

../templates/%.tsv: %.json
python ../scripts/template_runner.py $< $@

../templates/%_class.tsv: %.json
../patterns/data/bds/%_class.tsv: %.json
python ../scripts/template_runner.py -c $< $@

../markers/%_markers_denormalized.tsv: %.json
Expand All @@ -23,12 +23,12 @@ all: $(TEMPLATE_FILES) $(TEMPLATE_CLASS_FILES) $(MARKER_DENORMALIZED_FILES) $(EQ
../templates/%_equivalent_markers.tsv: %.json
python ../scripts/template_runner.py -em $< $@

../templates/%_equivalent_reification.tsv: %.json
../patterns/data/bds/%_equivalent_reification.tsv: %.json
python ../scripts/template_runner.py -er $< $@

../templates/%_minimal_markers.tsv: %.json
../patterns/data/bds/%_minimal_markers.tsv: %.json
python ../scripts/template_runner.py -mm $< $@

../templates/%_non_taxonomy_classification.tsv: %.json
../patterns/data/bds/%_non_taxonomy_classification.tsv: %.json
python ../scripts/template_runner.py -n $< $@

51 changes: 23 additions & 28 deletions src/ontology/bdscratch.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ $(PATTERNDIR)/data/default/%.txt: $(PATTERNDIR)/dosdp-patterns/%.yaml $(PATTERND
if [ $(PAT) = true ]; then $(DOSDPT) terms --prefixes=template_prefixes.yaml --infile=$(word 2, $^) --template=$< --obo-prefixes=true --outfile=$@; fi

# hard wiring for now. Work on patsubst later
mirror/ensmusg.owl: ../templates/ensmusg.tsv
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(ROBOT) template --input bdscratch-edit.owl --template $< \
--add-prefixes template_prefixes.json \
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@; fi
mirror/ensmusg.owl: ../patterns/data/bds/ensmusg_data.tsv ../patterns/dosdp-patterns/ensmusg.yaml bdscratch-edit.owl
if [ $(MIR) = true ] && [ $(IMP) = true ]; then $(DOSDPT) generate --catalog=catalog-v001.xml --prefixes=template_prefixes.yaml \
--infile=$< --template=../patterns/dosdp-patterns/ensmusg.yaml \
--ontology=bdscratch-edit.owl --obo-prefixes=true --outfile=$@; fi

components/all_templates.owl: $(OWL_FILES) $(OWL_CLASS_FILES) $(OWL_EQUIVALENT_CLASS_FILES) $(OWL_MIN_MARKER_FILES) $(OWL_NOMENCLATURE_FILES)
$(ROBOT) merge $(patsubst %, -i %, $^) \
Expand All @@ -52,27 +51,23 @@ components/%.owl: ../templates/%.tsv bdscratch-edit.owl
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@

components/%_class.owl: ../templates/%_class.tsv bdscratch-edit.owl
$(ROBOT) template --input bdscratch-edit.owl --template $< \
--add-prefixes template_prefixes.json \
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@

components/%_equivalent_class.owl: ../templates/%_equivalent_reification.tsv bdscratch-edit.owl
$(ROBOT) template --input bdscratch-edit.owl --template $< \
--add-prefixes template_prefixes.json \
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@

components/%_minimal_markers.owl: ../templates/%_minimal_markers.tsv bdscratch-edit.owl
$(ROBOT) template --input bdscratch-edit.owl --template $< \
--add-prefixes template_prefixes.json \
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@

components/%_non_taxonomy_classification.owl: ../templates/%_non_taxonomy_classification.tsv bdscratch-edit.owl
$(ROBOT) template --input bdscratch-edit.owl --template $< \
--add-prefixes template_prefixes.json \
annotate --ontology-iri ${BDS_BASE}$@ \
convert --format ofn --output $@
components/%_class.owl: ../patterns/data/bds/%_class.tsv bdscratch-edit.owl ../patterns/dosdp-patterns/taxonomy_class.yaml bdscratch-edit.owl
$(DOSDPT) generate --catalog=catalog-v001.xml --prefixes=template_prefixes.yaml \
--infile=$< --template=../patterns/dosdp-patterns/taxonomy_class.yaml \
--ontology=bdscratch-edit.owl --obo-prefixes=true --outfile=$@

components/%_equivalent_class.owl: ../patterns/data/bds/%_equivalent_reification.tsv ../patterns/dosdp-patterns/taxonomy_equivalent_class.yaml bdscratch-edit.owl
$(DOSDPT) generate --catalog=catalog-v001.xml --prefixes=template_prefixes.yaml \
--infile=$< --template=../patterns/dosdp-patterns/taxonomy_equivalent_class.yaml \
--ontology=bdscratch-edit.owl --obo-prefixes=true --outfile=$@

components/%_minimal_markers.owl: ../patterns/data/bds/%_minimal_markers.tsv ../patterns/dosdp-patterns/taxonomy_minimal_markers.yaml bdscratch-edit.owl
$(DOSDPT) generate --catalog=catalog-v001.xml --prefixes=template_prefixes.yaml \
--infile=$< --template=../patterns/dosdp-patterns/taxonomy_minimal_markers.yaml \
--ontology=bdscratch-edit.owl --obo-prefixes=true --outfile=$@

components/%_non_taxonomy_classification.owl: ../patterns/data/bds/%_non_taxonomy_classification.tsv ../patterns/dosdp-patterns/taxonomy_non_taxonomy_classification.yaml bdscratch-edit.owl
$(DOSDPT) generate --catalog=catalog-v001.xml --prefixes=template_prefixes.yaml \
--infile=$< --template=../patterns/dosdp-patterns/taxonomy_non_taxonomy_classification.yaml \
--ontology=bdscratch-edit.owl --obo-prefixes=true --outfile=$@

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ID TYPE NAME
ID SC % A rdfs:label
defined_class TYPE NAME
ensembl:ENSMUSG00000064372 SO:0000704 mt-Tp
ensembl:ENSMUSG00000064371 SO:0000704 mt-Tt
ensembl:ENSMUSG00000064370 SO:0000704 mt-Cytb
Expand Down
27 changes: 27 additions & 0 deletions src/patterns/dosdp-patterns/ensmusg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pattern_name: bdsEnsmusg
pattern_iri: http://purl.obolibrary.org/obo/odk/bdsEnsmusg.yaml
description: "Ensmusg template for BDS."

classes:
"thing": "owl:Thing"

vars:
TYPE: "'thing'"

data_vars:
NAME: "xsd:string"

annotationProperties:
rdfsLabel: "rdfs:label"

logical_axioms:
- axiom_type: subClassOf
text: "%s"
vars:
- TYPE

annotations:
- annotationProperty: rdfsLabel
text: "%s"
vars:
- NAME
2 changes: 1 addition & 1 deletion src/patterns/dosdp-patterns/taxonomy_equivalent_class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ logical_axioms:
text: "'has_exemplar' value %s"
vars:
- Exemplar_SC
- axiom_type: subClassOf
- axiom_type: equivalentTo
text: "'native_cell' and 'has_exemplar' value %s"
vars:
- Exemplar
57 changes: 21 additions & 36 deletions src/scripts/template_generation_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,31 @@ def generate_curated_class_template(dend_json_path, output_filepath):

if taxonomy_config:
subtrees = get_subtrees(dend_tree, taxonomy_config)
robot_class_curation_seed = {'ID': 'ID',
'prefLabel': 'A skos:prefLabel',
'Synonyms_from_taxonomy': "A oboInOwl:hasExactSynonym SPLIT=|",
'Curated_synonyms': "A oboInOwl:hasExactSynonym SPLIT=|",
'Comment': 'A rdfs:comment',
'Classification': 'SC %',
'Classification_comment': ">A rdfs:comment",
'Classification_pub': ">A oboInOwl:hasDbXref SPLIT=|",
'Expresses': "SC 'expresses' some % SPLIT=|",
'Expresses_comment': ">A rdfs:comment",
'Expresses_pub': ">A oboInOwl:hasDbXref SPLIT=|"
}
class_template = [robot_class_curation_seed]
robot_class_curation_seed = ['defined_class',
'prefLabel',
'Synonyms_from_taxonomy',
'Curated_synonyms',
'Comment',
'Classification',
'Classification_comment',
'Classification_pub',
'Expresses',
'Expresses_comment',
'Expresses_pub']
class_template = []

for o in dend['nodes']:
if o['cell_set_accession'] in set.union(*subtrees) and (o['cell_set_preferred_alias'] or
o['cell_set_additional_aliases']):
d = dict()
d['ID'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['defined_class'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
if o['cell_set_preferred_alias']:
d['prefLabel'] = o['cell_set_preferred_alias']
elif o['cell_set_additional_aliases']:
d['prefLabel'] = str(o['cell_set_additional_aliases']).split(EXPRESSION_SEPARATOR)[0]
d['Synonyms_from_taxonomy'] = get_synonyms_from_taxonomy(o)
d['Comment'] = get_synonym_pairs(o)
for k in robot_class_curation_seed.keys():
for k in robot_class_curation_seed:
if not (k in d.keys()):
d[k] = ''
class_template.append(d)
Expand All @@ -123,18 +122,13 @@ def generate_equivalent_class_reification_template(dend_json_path, output_filepa

subtrees = get_subtrees(dend_tree, config_yaml)

robot_class_equivalent_seed = {'ID': 'ID',
'Exemplar': "EC CL:0000003 and 'has_exemplar' value %",
'Exemplar_SC': "SC 'has_exemplar' value %"
}

equivalent_template = [robot_class_equivalent_seed]
equivalent_template = []

for o in dend['nodes']:
if o['cell_set_accession'] in set().union(*subtrees) and (o['cell_set_preferred_alias'] or
o['cell_set_additional_aliases']):
d = dict()
d['ID'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['defined_class'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['Exemplar'] = 'AllenDend:' + o['cell_set_accession']
d['Exemplar_SC'] = 'AllenDend:' + o['cell_set_accession']
equivalent_template.append(d)
Expand Down Expand Up @@ -174,7 +168,7 @@ def generate_equivalent_class_marker_template(dend_json_path, marker_path, outpu
for o in dend['nodes']:
if o['cell_set_accession'] in set().union(*subtrees) and o['cell_set_accession'] in denormalized_markers.keys():
d = dict()
d['ID'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['defined_class'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['CLASS_TYPE'] = 'equivalent'
d['Evidence'] = 'http://www.semanticweb.org/brain_data_standards/AllenDend_' + o['cell_set_accession']

Expand Down Expand Up @@ -209,18 +203,13 @@ def generate_minimal_marker_template(dend_json_path, flat_marker_path, output_ma

if taxonomy_config:
subtrees = get_subtrees(dend_tree, taxonomy_config)
robot_min_marker_seed = {'ID': "ID",
'Markers': "SC 'expresses' some % SPLIT=|",
'part_of': "SC 'part of' some %",
'has_soma_location': "SC 'has soma location' some %"
}
min_marker_template = [robot_min_marker_seed]
min_marker_template = []

for o in dend['nodes']:
if o['cell_set_accession'] in set.union(*subtrees) and (o['cell_set_preferred_alias'] or
o['cell_set_additional_aliases']):
d = dict()
d['ID'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']
d['defined_class'] = 'http://www.semanticweb.org/brain_data_standards/AllenDendClass_' + o['cell_set_accession']

if o['cell_set_accession'] in marker_expressions:
d['Markers'] = EXPRESSION_SEPARATOR.join(marker_expressions[o['cell_set_accession']][EXPRESSIONS])
Expand Down Expand Up @@ -257,11 +246,7 @@ def generate_non_taxonomy_classification_template(dend_json_path, output_filepat

if taxonomy_config and os.path.exists(nomenclature_path):
nomenclature_records = read_csv(nomenclature_path, id_column=cell_set_accession)

nomenclature_table_seed = {'ID': "ID",
'Classification': "SC %"
}
nomenclature_template = [nomenclature_table_seed]
nomenclature_template = []

non_taxo_roots = {}
for root in taxonomy_config['non_taxonomy_roots']:
Expand All @@ -278,7 +263,7 @@ def generate_non_taxonomy_classification_template(dend_json_path, output_filepat
# child of root with cell_set_preferred_alias
if child not in non_taxo_roots and nomenclature_records[child][0]:
d = dict()
d['ID'] = ALLEN_DEND_CLASS + child
d['defined_class'] = ALLEN_DEND_CLASS + child
d['Classification'] = non_taxo_roots[columns[cell_set_accession]]
nomenclature_template.append(d)

Expand Down
Loading

0 comments on commit 633bd1e

Please sign in to comment.