Hi David and Ryan,
Thanks for your help. I had tried to run pi previously, and when presented with an error assumed that I was hitting the limits of what the pi implementation was designed to do. Here is a minimal CQL example showing the problem that I have with doing a pi transform:
//We handle only strings
typeside TyJava = literal {
java_types
string = "java.lang.String"
java_constants
string = "return input[0]"
}
//A collection of data files, each containing a wavelength
schema ADSC = literal: TyJava {
entities
adsc_file
attributes
adsc_file_to__diffrn_radiation_wavelength_dot_wavelength: adsc_file -> string
}
instance testdata = literal : ADSC {
generators
adsc_file_3 adsc_file_1 adsc_file_2 : adsc_file
multi_equations
adsc_file_to__diffrn_radiation_wavelength_dot_wavelength -> {
adsc_file_1 "0.710894" , adsc_file_2 "0.710894" , adsc_file_3 "0.710894"
}
}
//An ontology for image data, images are collected into diffraction experiments
//and one aspect of a diffraction experiment is the wavelength that it was run
//at. diffrn_radiation_wavelength is a separate entity because in more complex
//experiments we might describe the incident radiation as a table of weighted
//contributing wavelengths.
schema imgCIF = literal: TyJava {
entities
diffrn
diffrn_data_frame
diffrn_radiation_wavelength
foreign_keys
diffrn_data_frame_to_diffrn : diffrn_data_frame -> diffrn
diffrn_to_diffrn_radiation_wavelength : diffrn -> diffrn_radiation_wavelength
attributes
_diffrn_radiation_wavelength_dot_wavelength: diffrn_radiation_wavelength -> string
}
mapping ADSC_to_imgCIF = literal : ADSC -> imgCIF {
entity
adsc_file -> diffrn_data_frame
attributes
adsc_file_to__diffrn_radiation_wavelength_dot_wavelength ->diffrn_data_frame_to_diffrn.diffrn_to_diffrn_radiation_wavelength._diffrn_radiation_wavelength_dot_wavelength
}
instance Result = pi ADSC_to_imgCIF testdata
When running this using the (very cool) CQL IDE I get:
Error in Result: java.util.concurrent.ExecutionException: java.lang.RuntimeException: In transform for foreign key diffrn_data_frame_to_diffrn, In sknull, the type for labelled null sknull is not defined.
I think this is telling me that there is no type for the generator of diffrn_data_frame, even though if I run "sigma" instead of "pi" everything is fine. Is there a simple way to fix this?
Just as some background to this example, and how I think it should work, "imgCIF" is an ontology designed for describing raw data images from crystallographic experiments. In the imgCIF ontology, every diffraction experiment (identified by "diffrn") is run at a particular wavelength (attribute _diffrn_radiation_wavelength_dot_wavelength). A diffraction experiment consists of many image frames ("diffrn_data_frame"), each of which belongs to a particular value of "diffrn". Mapping into this imgCIF ontology is the source ontology for data files of type "ADSC", which describes a collection of single frame files, each of which includes a wavelength.
How I think the right pushforward should work is that "diffrn_radiation_wavelength" is populated with a single value, as there is only one distinct wavelength, and then likewise for "diffrn". The diffrn_data_frame_to_diffrn morphism maps each file to that single "diffrn" value. If there had been more than one value for wavelength, the right pushforward functor would create multiple values for "diffrn" and the diffrn_data_frame_to_diffrn morphism would be mapped appropriately.
From my point of view this is neat, as essentially the collection of attributes of "diffrn" self-organise data frames into diffraction experiments.
My long-term concern is that in real life such file collections could include up to about a thousand files, and if the pi data migration naively creates the product of all contributing object elements before discarding based on source category morphisms, memory usage could be rather large as there are many more attributes in each file than in the example. There do seem to be more efficient algorithms around, but I'm not sure if they are implemented in CQL.
Thanks for any insight you can provide!
James.