Skip to content

Commit

Permalink
Merge pull request #331 from geneontology/add-cardinality-to-shex-val…
Browse files Browse the repository at this point in the history
…idation-report

Add cardinality to shex validation report
  • Loading branch information
goodb committed Jul 3, 2020
2 parents 5f802ca + fb08e88 commit bebdc86
Show file tree
Hide file tree
Showing 18 changed files with 543 additions and 606 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import com.google.gson.annotations.SerializedName;

import fr.inria.lille.shexjava.util.Interval;

/**
* @author bgood
*
Expand All @@ -16,12 +18,30 @@ public class ShexConstraint {
String property;
Set<String> node_types;
Set<String> object_types;
String cardinality;
int nobjects;

@SerializedName("matched_range_shapes")
Set<String> matched_range_shapes;



public String getCardinality() {
return cardinality;
}

public void setCardinality(String cardinality) {
this.cardinality = cardinality;
}

public int getNobjects() {
return nobjects;
}

public void setNobjects(int nobjects) {
this.nobjects = nobjects;
}

public Set<String> getMatched_range_shapes() {
return matched_range_shapes;
}
Expand Down Expand Up @@ -64,6 +84,13 @@ public ShexConstraint(String object, String property, Set<String> intended_range
this.object_types = object_types;
}

public ShexConstraint(String property, String cardinality, int nobjects) {
super();
this.property = property;
this.cardinality = cardinality;
this.nobjects = nobjects;
}

public Set<String> getIntended_range_shapes() {
return intended_range_shapes;
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,26 @@ public void testShexMetadata() throws IOException {
validate("src/test/resources/validation/should_pass/", shexMeta, should_be_valid);
}

@Test
public void testTmp() throws IOException {
boolean should_be_valid = false;
validate("src/test/resources/validation/tmp/", shex, should_be_valid);
}

public void validate(String dir, ShexValidator shex, boolean should_be_valid) throws IOException {
File directory = new File(dir);
if(directory.isDirectory()) {
for(File file : directory.listFiles()) {
if(file.getName().endsWith("ttl")) {
Model test_model = ModelFactory.createDefaultModel();
System.out.println("validating "+file.getAbsolutePath());
test_model.read(file.getAbsolutePath());
System.out.println("validating "+file.getAbsolutePath()+" size "+test_model.size());
//Note that in the live system, Arachne is executed on the model prior to this step, potentially adding inferred classes that are missed with this.
//this is faster and useful for debugging the shex though. See org.geneontology.minerva.server.validation.ValidationTest in the Test branch of Minerva server for a more complete test
test_model = shex.enrichSuperClasses(test_model);
ShexValidationReport report = shex.runShapeMapValidation(test_model);
if(should_be_valid) {
assertTrue(file+" not conformant", report.isConformant());
assertTrue(file+" not conformant "+report.getAsText()+"\n"+report.getAsTab(""), report.isConformant());
}else {
assertFalse(file+" is conformant (should not be)", report.isConformant());
}
Expand Down
20 changes: 14 additions & 6 deletions minerva-core/src/test/resources/validation/go-cam-shapes.shex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
#metadata
PREFIX bl: <https://w3id.org/biolink/vocab/>
PREFIX contributor: <http://purl.org/dc/elements/1.1/contributor>
Expand Down Expand Up @@ -75,6 +76,7 @@ PREFIX transports_or_maintains_localization_of: <http://purl.obolibrary.org/obo/
PREFIX directly_provides_input_for: <http://purl.obolibrary.org/obo/RO_0002413>
PREFIX directly_positively_regulates: <http://purl.obolibrary.org/obo/RO_0002629>
PREFIX located_in: <http://purl.obolibrary.org/obo/RO_0001025>
PREFIX location_of: <http://purl.obolibrary.org/obo/RO_0001015>
PREFIX happens_during: <http://purl.obolibrary.org/obo/RO_0002092>
PREFIX regulates: <http://purl.obolibrary.org/obo/RO_0002211>
PREFIX negatively_regulates: <http://purl.obolibrary.org/obo/RO_0002212>
Expand Down Expand Up @@ -122,6 +124,7 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
date: xsd:string *; #TODO can we make this an xsd:date?
provided_by: xsd:string *; #TODO would be better as an IRI
rdfs:comment xsd:string *;
skos:note xsd:string *;
}

<GoCamEntity> IRI @<ProvenanceAnnotated> AND EXTRA a {
Expand Down Expand Up @@ -339,7 +342,7 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
a ( @<MolecularFunctionClass> OR @<NegatedMolecularFunctionClass> ) {1};
enabled_by: ( @<InformationBiomacromolecule> OR @<ProteinContainingComplex> ) {0,1};
part_of: @<BiologicalProcess> {0,1};
occurs_in: ( @<AnatomicalEntity> OR @<ProteinContainingComplex> ) {0,1};
occurs_in: @<AnatomicalEntity> {0,1};
has_output: ( @<ChemicalEntity> OR @<ProteinContainingComplex> ) *;
has_input: ( @<ChemicalEntity> OR @<ProteinContainingComplex> ) *;
directly_provides_input_for: @<MolecularFunction> *;
Expand All @@ -358,6 +361,10 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
happens_during: ( @<BiologicalPhase> OR @<LifeCycleStage> OR @<PlantStructureDevelopmentStage> ) *;
} // rdfs:comment "A molecular function"

<IdealMolecularActivity> @<MolecularFunction> AND {
enabled_by: ( @<InformationBiomacromolecule> OR @<ProteinContainingComplex> ) {1};
}

<TransporterActivityClass> IRI @<OwlClass> AND EXTRA rdfs:subClassOf {
rdfs:subClassOf [ GoTransporterActivity: ];
}
Expand Down Expand Up @@ -407,6 +414,7 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
<AnatomicalEntity> @<GoCamEntity> AND EXTRA a {
a ( @<AnatomicalEntityClass> OR @<NegatedAnatomicalEntityClass> );
part_of: @<AnatomicalEntity> {0,1};
location_of: ( @<InformationBiomacromolecule> OR @<ProteinContainingComplex> ) {0,1};
} // rdfs:comment "an anatomical entity"

<NativeCellClass> IRI @<OwlClass> AND EXTRA rdfs:subClassOf {
Expand All @@ -432,12 +440,11 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
part_of: @<AnatomicalEntity> {0,1};
adjacent_to: @<AnatomicalEntity> *;
overlaps: @<AnatomicalEntity> *;
has_part:(@<InformationBiomacromolecule> OR @<ProteinContainingComplex>) {0,1};
} // rdfs:comment "a cellular component"

<ProteinContainingComplex> EXTRA a {
a @<ProteinContainingComplexClass>;
located_in: @<CellularComponent> {0,1};
located_in: @<AnatomicalEntity> {0,1};
has_part: @<InformationBiomacromolecule> *;
} // rdfs:comment "a protein complex"

Expand All @@ -458,7 +465,8 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
}
<Protein> @<ChemicalEntity> AND EXTRA a {
a @<ProteinClass> ;
located_in: @<CellularComponent> {0,1};
located_in: @<AnatomicalEntity> {0,1};
part_of: @<ProteinContainingComplex> {0,1};
}// rdfs:comment "a protein"


Expand All @@ -467,15 +475,15 @@ PREFIX results_in_remodeling_of: <http://purl.obolibrary.org/obo/RO_0002591>
}
<InformationBiomacromolecule> @<ChemicalEntity> AND EXTRA a {
a @<InformationBiomacromoleculeClass> +;
part_of: @<CellularComponent> {0,1};
located_in: @<AnatomicalEntity> {0,1};
part_of: @<ProteinContainingComplex> {0,1};
}// rdfs:comment "an information biomacromolecule - e.g. a protein or RNA product"

<EvidenceClass> IRI @<OwlClass> AND EXTRA rdfs:subClassOf {
rdfs:subClassOf [ GoEvidence: ] ;
}

<Evidence> @<ProvenanceAnnotated> AND EXTRA a {
<Evidence> @<GoCamEntity> AND EXTRA a {
a @<EvidenceClass> {1};
source: xsd:string {1};
with: xsd:string {0,1}
Expand Down
Loading

0 comments on commit bebdc86

Please sign in to comment.