[ome-users] Custom annotations absent in exported metadata
Graham Klyne
graham.klyne at zoo.ox.ac.uk
Thu Sep 15 15:57:33 BST 2005
Ilya,
After a long break and many distractions, I'm back to figuring out how
to export new Semantic Type annotations on the OME/XML file...
Ilya Goldberg wrote:
> The best place to start is definitely the current XML Export module:
> src/perl2/OME/Web/XMLFileExport.pm
> The entire web UI is done using sub-classes of OME::Web (in
> src/perl2/OME/Web.pm and the src/perl2/OME/Web/ directory tree)
> I would follow the same inheritance pattern and simply make a new class
> similar to XMLFileExport - there's really no point to subclassing this
> since its just an HTML interface for
> src/perl2/OME/Tasks/OMEXMLImportExport.pm. This
> OME::Tasks::OMEXMLImportExport class performs the logic of gathering the
> objects to export. The export itself is performed by
> OME::Tasks::OMEExport, which is the generalized exporter.
>
> Since OMEXMLImportExport.pm just gathers objects and calls
> OME::Tasks::OMEExport, the thing to do is copy the
> OMEXMLImportExport->exportToXMLFile() method to your new class and
> modify it to look for additional objects using a OME::Factory call
> documented here:
> http://openmicroscopy.org/APIdocs/OME/Factory.html
Thanks.
I've made a start on this, but I'm familiar with neither Perl coding nor
the internal architecture details of OME. Here's my first attempt at an
extended export function: does it look reasonable as far as it goes?
Am I overlooking any key logic?
(The next here has got some rather ugly line-wrapping; I also attach a
copy of the source file I'm tinkering with.)
[[
sub exportToXMLFile {
my ($self, $images, $file) = @_ ;
my $session = OME::Session->instance();
my $factory = $session->Factory() ;
# To-do check if can write in file
my $exporter = OME::Tasks::OMEExport->new( session => $session ) ;
my @exportObjects = () ;
my $image_import_module = $session->Configuration()->image_import_module();
my $annotation_module =
$session->Configuration()->annotation_module(); ###new
my @outputs = $image_import_module->outputs();
foreach my $image (@$images) {
push(@exportObjects,$image) ; # Add the image
# Get the import mex for this image
my $import_MEX = $factory->findObject ("OME::ModuleExecution",
image_id => $image->id(),
module => $image_import_module,
);
### New code ###
# Get the DTGED annotation mex for this image
my $dtged_MEX = $factory->findObject ("OME::ModuleExecution",
image_id => $image->id(),
module => $annotation_module
);
### I guess this selects all annotations for the image;
### how do I restrict additional results to those with Untyped Oputput
### of the form/semantic type defined as "DTGEDImageAnnotation" ?
###
# Collect all the attributes produced by the import MEX
my @untyped_outputs = $import_MEX->untypedOutputs();
my @dtged_outputs = $dtged_MEX->untypedOutputs(); ### New
foreach my $output (@outputs, at untyped_outputs, at dtged_outputs) { ###
Changed
my $ST = $output->semantic_type();
next unless $ST; # Skip the untyped output itself
# Get the output's attributes, and push them on the list
my $attributes = OME::Tasks::ModuleExecutionManager->
getAttributesForMEX($import_MEX,$ST);
push(@exportObjects,@$attributes);
}
}
$exporter->buildDOM(\@exportObjects, ResolveAllRefs => 1, ExportSTDs =>
0) ;
$exporter->exportFile($file);
return ;
}
]]
As coded, I'm thinking this will add the untyped outputs of all
annotation module executions to the XML output. Is this close? If so,
how can I refine it to select just the "DTGEDImageAnnotation" values?
(This a detail I can't discern from
http://openmicroscopy.org/APIdocs/OME/Factory.html.)
Am I correct that the expression
(@outputs, at untyped_outputs, at dtged_outputs) "flattens" the content of
three lists into a single list?
If the new export function is about right, I guess I also need to modify
the new module's getPageBody function to reference
OME::Web::XMLFileExportDTGED->new($session) instead of
OME::Tasks::OMEXMLImportExport->new($session).
What does the "1;" at the end of the Perl module file do?
#g
--
Graham Klyne
Image Bioinformatics Research Group (http://www.bioimage.org/)
Department of Zoology, University of Oxford
South Parks Road, Oxford OX1 3PS, UK
E-mail: <Graham.Klyne at zoo.ox.ac.uk>
Direct phone: +44-(0)1865-281991
Departmental fax: +44-(0)1865-310447
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: XMLFileExportDTGED.pm
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20050915/b6f2ee79/attachment.ksh>
More information about the ome-users
mailing list