Skip to content

Testing

Gaurav Vaidya edited this page Sep 16, 2016 · 2 revisions

Testing phyloreferences

Why test phyloreferences?

  1. Prevent regressions: once a phyloreference works (identifies the correct nodes on a phylogenetic tree), it should keep working, however we change our ontology in the future.
  2. Test suite for all phyloreferences: our test suite could be used to validate any alternate way of calculating phyloreferences.
  3. Determining limits: particularly complicated phyloreferences could be added to the test suite to ensure that they work, and where logical reasoning might fail to function correctly.
  4. Comparing representations: we can try representing the same phyloreference in different ways and identify the best representation for (1) speed in computer reasoning, and (2) in human understanding.

What needs testing?

  • Our scripts: ensure that all our scripts provide predictable outputs to provided inputs.
  • Data representation: ensure that ontologies and phyloreferences are clearly and completely represented, with as much data being retained from the input and with no nodes being represented incorrectly.
  • Reasoning output: once phylogeny nodes have been categorized by the reasoner, we need to test to ensure that they are categorized correctly.

Libraries for testing

Tools for testing

  1. Comparisons of text files:
  • Many files can be easily compared to pre-generated files. If the output file has changed, a developer can compare the file using pytest (which can provide a diff of the two files: http://docs.pytest.org/en/latest/assert.html#making-use-of-context-sensitive-comparisons) and simply replace the pre-generated file if the change is an improvement.
  • This may require scripts to remove changeable parts of a file (e.g. date of creation) before comparisons, but this should be easy to avoid or work around.
  1. Comparison of RDF files as triples:
  • rdflib can load the major RDF representations (XML, Turtle) as a triple-store.
  • This can then be tested in four ways:
    1. Lists of expected objects can be checked to ensure that they exist and are of the right type.
    2. A list of expected triples can be checked to ensure that they have been generated correctly.
    3. Requirements could be expressed in Python, such as statements like "every instance in the Node class should have a sibling or a parent node".
    1. Two RDF/XML files can be compared at the level of triples, ensuring that they are identical (comparing them as text files will likely be easier).
  1. Validation of triples
  1. Validation of reasoning
  • Any of the techniques listed above for testing RDF or triples can also be applied to the output from a reasoner. Our primary goal will probably be to test whether a particular phyloreference matches the correct nodes in a phylogeny without matching any incorrect nodes.

  • This means we need three things:

    1. An input ontology (as Newick or RDF),
    2. An input phyloreference (as OWL), and
    3. A list of expected nodes that should be matched (as RDF)
  • These could be coded as Python tests using rdflib, as in the example above, but based on the reasoned triples.