Validate an object's on-disk representation against the takane specifications.
This is done by dispatching to an appropriate validation function based on the type in the OBJECT
file.
validateObject(path, metadata = NULL)
registerValidateObjectFunction(type, fun, existing = c("old", "new", "error"))
registerValidateObjectHeightFunction(
type,
fun,
existing = c("old", "new", "error")
)
registerValidateObjectDimensionsFunction(
type,
fun,
existing = c("old", "new", "error")
)
registerValidateObjectSatisfiesInterface(
type,
interface,
action = c("add", "remove")
)
registerValidateObjectDerivedFrom(type, parent, action = c("add", "remove"))
String containing a path to a directory, itself created with a saveObject
method.
List containing metadata for the object.
If this is not supplied, it is automatically read from the OBJECT
file inside path
.
String specifying the name of type of the object.
For registerValidateObjectFunction
, a function that accepts path
and metadata
, and raises an error if the object at path
is invalid.
It can be assumed that metadata
is a list created by reading OBJECT
.
For registerValidateObjectHeightFunction
, a function that accepts path
and metadata
, and returns an integer specifying the “height” of the object.
This is usually the length for vector-like or 1-dimensional objects, and the extent of the first dimension for higher-dimensional objects.
For registerValidateObjectDimensionsFunction
, a function that accepts path
and metadata
, and returns an integer vector specifying the dimensions of the object.
This may also be NULL
to delete an existing registry from any of the functions mentioned above.
Logical scalar indicating the action to take if a function has already been registered for type
-
keep the old or new function, or throw an error.
String specifying the name of the interface that is represented by type
.
String specifying whether to add or remove type
from the list of types that implements interface
or is derived from parent
.
String specifying the parent object from which type
is derived.
For validateObject
, NULL
is returned invisibly upon success, otherwise an error is raised.
For the registerValidObject*Function
functions, the supplied fun
is added to the corresponding registry for type
.
If fun = NULL
, any existing entry for type
is removed; a logical scalar is returned indicating whether removal was performed.
For the registerValidateObjectSatisfiesInterface
and registerValidateObjectDerivedFrom
functions, type
is added to or removed from relevant list of types.
A logical scalar is returned indicating whether the type
was added or removed - this may be FALSE
if type
was already present or absent, respectively.
https://github.com/ArtifactDB/takane, for detailed specifications of the on-disk representation for various Bioconductor objects.
library(S4Vectors)
df <- DataFrame(A=1:10, B=LETTERS[1:10])
tmp <- tempfile()
saveObject(df, tmp)
validateObject(tmp)