InterMine > InterMine-Item > InterMine::Item::Document

Download:
InterMine-Item-0.98.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

InterMine::Item::Document - a module for writing InterMine-Items-XML files

SYNOPSIS ^

  use InterMine::Model;
  use InterMine::Item::Document;

  my ($model_file, $output_file) = @ARGV;

  my $model = InterMine::Model->new(file => $model_file);
 
  my $doc   = InterMine::Item::Document->new(
    model      => $model,
    output     => $output_file, # defaults to STDOUT
    auto_write => 1, # automatically write each item as it is made
  );

  my $organism = $doc->add_item(
    "Organism",
    "taxonId" => 7227
  );

  my $pub1 = $doc->add_item(
    "Publication",
    "pubMedId" => 11700288,
  );
  my $pub2 = $doc->make_item(
    "Publication",
    "pubMedId" => 16496002,
  );

  $doc->add_item(
    'Gene',
    'identifier'   => "CG10811",
    'organism'     => $organism,
    'publications' => [$pub1, $pub2],
  );

  $doc->close; # writes the end tags - only needed when auto_write is on

DESCRIPTION ^

This module allows you to make and write out InterMine-Items-XML for integrating data into InterMine databases

AUTHOR ^

FlyMine <support@flymine.org>

BUGS ^

Please report any bugs or feature requests to support@flymine.org.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc InterMine::ItemFactory

You can also look for information at:

COPYRIGHT & LICENSE ^

Copyright 2006,2007,2008 FlyMine, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

FUNCTIONS ^

new

return a factory that can be used to create Item objects.

 $document = new InterMine::Item::Document(model => $model);

Args:

model - the InterMine::Model object to use to check field validity
output - [optional] The file to write to (defaults to standard out)
ignore_null - [optional] Whether or not to be tolerant of undefined field values (defaults to intolerant)

writer

 Function : Return the writer for this document

add_default_fields(key => value, key => value)

 Function : add the given key value pairs to the default fields list
            that will be appplied to every item made. If a default field
            is not valid for a particular item, it will not be set.

get_default_fields()

 Function : get the current default fields
 Returns  : a hash in list context, or a hash-reference in scalar context

write

 Function : write all unwritten items to the xml output. This is 
            called automatically on item creation if auto_write is 
            set.

close

 Function : close the document by writing any unwritten
            items and closing the items tag.

make_item

 Title   : make_item
 Usage   : $item = $doc->make_item("Gene", [%attributes]);
 Function: return a new Item object of the given type
           while not storing it 
 Args    : the classname of the new Item
           Any attributes for the item

add_item

 Title   : add_item
 Usage   : $item = $doc->add_item("Gene");
 Function: return a new Item object of the given type,
           while storing it in an internal record for writing
           out later
 Args    : the classname of the new Item
           Any attributes for the item
syntax highlighting: