Skip to content

Commit ad13e75

Browse files
committed
Fix DOID CI verify-edit
* FixX csv-related functions in Makefile FIXES: - csv cleaner no longer errors if no files are present to clean (was due to grep, errors when no files match) - ensures predictable behavior when no pattern for file matching is used * Update edit-verify-iris to match any non-DO IRI * Expand missing values identified by edit-verify-no-blank_annotations.rq
1 parent a49c34b commit ad13e75

File tree

3 files changed

+63
-30
lines changed

3 files changed

+63
-30
lines changed

Makefile

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,33 +126,46 @@ $(FASTOBO): | build
126126
# FILE UTILITIES
127127
# ----------------------------------------
128128

129-
# clean old result files from directory (prevents old file inclusion in concat_files)
130-
# args = input-directory, command-to-match-test-files
131-
define clean_prior_results
132-
@TMP_FILES=$$(find $(1) | $(2)) ; \
129+
# cleans csv files from a directory, optionally matching pattern(s)
130+
# --> to prevent existing file inclusion in concat_csv
131+
# args = input-directory, pattern(s)-to-match-files (should end with .csv)
132+
define clean_existing_csv
133+
@PATTERN=($(2)) ; \
134+
if [ "$$PATTERN" ]; then \
135+
TMP_FILES=$$(find $(1) -name "$(firstword $(2))" $(patsubst %,-o -name "%",$(wordlist 2,$(words $(2)),$(2)))) ; \
136+
else \
137+
TMP_FILES=$$(find $(1) -name "*.csv") ; \
138+
fi ; \
133139
if [ "$$TMP_FILES" ]; then \
134-
rm $$TMP_FILES ; \
135-
fi ;
140+
rm -f $$TMP_FILES ; \
141+
fi
136142
endef
137143

138-
# concatenate test results from multiple files into one
139-
# args = type ('TEST' will error if output), output-file, input-directory, command-to-match-test-files
140-
define concat_files
141-
@TMP_FILES=$$(find $(3) | $(4)) ; \
144+
# concatenate multiple CSV files into one
145+
# args = file category ('TEST' to error, if output), output-file, input-directory, pattern(s)-to-match-files (should end with .csv)
146+
define concat_csv
147+
@PATTERN=($(4)) ; \
148+
if [ "$$PATTERN" ]; then \
149+
TMP_FILES=$$(find $(3) -name "$(firstword $(4))" $(patsubst %,-o -name "%",$(wordlist 2,$(words $(4)),$(4)))) ; \
150+
else \
151+
TMP_FILES=$$(find $(3) -name "*.csv") ; \
152+
fi ; \
142153
if [ "$$TMP_FILES" ]; then \
143154
awk 'BEGIN { OFS = FS = "," } ; { \
144155
if (FNR == 1) { \
145-
gsub(/^.*verify-|\.csv/, "", FILENAME) ; \
156+
gsub(/^.*\/|\.csv/, "", FILENAME) ; \
146157
if (NR != 1) { print "" } ; \
147158
print "$(1): " FILENAME ; print $$0 \
148159
} \
149160
else { print $$0 } \
150161
}' $$TMP_FILES > $(2) \
151162
&& rm -f $$TMP_FILES ; \
152-
if [ "$(1)" = "TEST" ] ; then exit 1 ; fi ; \
153-
else \
154-
touch $(2) ; \
155-
fi ;
163+
if [ "$(1)" = "TEST" ] ; then \
164+
exit 1 ; \
165+
fi ; \
166+
elif [ "$(1)" = "TEST" ]; then \
167+
echo "" > $(2) ; \
168+
fi
156169
endef
157170

158171

@@ -204,13 +217,13 @@ EDIT_V_QUERIES := $(wildcard src/sparql/verify/edit-verify-*.rq src/sparql/verif
204217
.PRECIOUS: build/reports/edit-verify.csv
205218
verify-edit: build/reports/edit-verify.csv
206219
build/reports/edit-verify.csv: $(EDIT) | check_robot build/reports/temp
207-
$(call clean_prior_results,$(word 2,$|),grep -E "/(edit-)?verify-.*\.csv$$")
220+
$(call clean_existing_csv,$(word 2,$|),edit-verify-*.csv verify-*.csv)
208221
@$(ROBOT) verify \
209222
--input $< \
210223
--queries $(EDIT_V_QUERIES) \
211224
--fail-on-violation false \
212225
--output-dir $(word 2,$|)
213-
$(call concat_files,TEST,$@,$(word 2,$|),grep -E "/(edit-)?verify-.*\.csv$$")
226+
$(call concat_csv,TEST,$@,$(word 2,$|),edit-verify-*.csv verify-*.csv)
214227

215228
# Verify of doid-edit.owl that should be run quarterly (not part of release)
216229
QUARTER_V_QUERIES := $(wildcard src/sparql/verify/quarter-verify-*.rq)
@@ -219,13 +232,13 @@ QUARTER_V_QUERIES := $(wildcard src/sparql/verify/quarter-verify-*.rq)
219232
quarterly_test: build/reports/quarterly_test.csv
220233
build/reports/quarterly_test.csv: $(EDIT) | check_robot build/reports/temp
221234
@echo "Verifying $<..."
222-
$(call clean_prior_results,$(word 2,$|),grep -E "/quarter-verify-.*\.csv$$")
235+
$(call clean_existing_csv,$(word 2,$|),quarter-verify-*.csv)
223236
@$(ROBOT) verify \
224237
--input $< \
225238
--queries $(QUARTER_V_QUERIES) \
226239
--fail-on-violation false \
227240
--output-dir $(word 2,$|)
228-
$(call concat_files,TEST,$@,$(word 2,$|),grep -E "/quarter-verify-.*\.csv$$")
241+
$(call concat_csv,TEST,$@,$(word 2,$|),quarter-verify-*.csv)
229242

230243

231244
##########################################

src/sparql/verify/edit-verify-iris.rq

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
PREFIX oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
44
PREFIX owl: <http://www.w3.org/2002/07/owl#>
55

6-
SELECT DISTINCT ?s WHERE {
7-
?s a owl:Class ;
8-
oboInOwl:hasOBONamespace ?ns .
9-
FILTER(STR(?ns) = "disease_ontology")
10-
FILTER(!REGEX(STR(?s), "http://purl\\.obolibrary\\.org/obo/DOID_[0-9]{1,7}"))
6+
SELECT DISTINCT ?invalid_iri
7+
WHERE {
8+
?invalid_iri a owl:Class ;
9+
oboInOwl:hasOBONamespace "disease_ontology" .
10+
FILTER(!REGEX(STR(?invalid_iri), "^http://purl\\.obolibrary\\.org/obo/DOID_[0-9]{1,7}$"))
1111
}
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
# Ensure that there are no annotations with a value of empty string
1+
# Ensure that there are no annotations with a missing value
22

33
PREFIX owl: <http://www.w3.org/2002/07/owl#>
44

5-
SELECT DISTINCT ?s WHERE {
6-
?s ?ap ?xref .
7-
?ap a owl:AnnotationProperty .
8-
FILTER (str(?xref) = "")
9-
}
5+
SELECT DISTINCT ?entity ?predicate ?value
6+
WHERE {
7+
{
8+
?entity ?predicate ?value .
9+
?predicate a owl:AnnotationProperty .
10+
FILTER(REGEX(str(?value), "^\\s*$"))
11+
FILTER(!isBlank(?entity))
12+
}
13+
UNION
14+
{
15+
?iri ?p ?o .
16+
?axiom a owl:Axiom ;
17+
owl:annotatedSource ?iri ;
18+
owl:annotatedProperty ?p ;
19+
owl:annotatedTarget ?o ;
20+
?predicate ?value .
21+
?predicate a owl:AnnotationProperty .
22+
FILTER(REGEX(str(?value), "^\\s*$"))
23+
BIND(
24+
concat(
25+
"ANNOTATED:[", str(?iri), " ", str(?p), " ", str(?o), "]"
26+
) AS ?entity
27+
)
28+
}
29+
}

0 commit comments

Comments
 (0)