Scroll to navigation

MAGE::XML::Reader(3pm) User Contributed Perl Documentation MAGE::XML::Reader(3pm)


Bio::MAGE::XML::Reader - a module for exporting MAGE-ML


  use Bio::MAGE::XML::Reader;
  my $reader = Bio::MAGE::XML::Reader->new(handler=>$handler,
  # set the sax1 attribute
  # get the current value
  $value = $reader->sax1();
  # set the content/document handler - this method is provided for completeness
  # the value should be set in the call to the constructor to be effective
  # get the current handler
  $handler = $reader->handler();
  # set the attribute
  # get the current value
  $value = $reader->verbose();
  # set the attribute
  # get the current value
  $value = $reader->log_file();
  # whether to read data cubes externally (default == FALSE)
  my $fh = \*STDOUT;
  my $mage = $reader->read($file_name);


Methods for transforming information from a MAGE-OM objects into MAGE-ML.


These methods have a polymorphic setter/getter method that sets an attribute which affects the parsing of MAGE-ML. If given a value, the method will save the value to the attribute, if invoked with no argument it will return the current value of the attribute.

These attributes can all be set in the call to the constructor using the named parameter style.

This attribute determines whether a SAX1 parser and DocumentHandler or a SAX2XMLReader and a ContentHandler will be used for parsing. The default is to use a SAX2 parser.
If an application needs a custom handler it can set this attribute in the call to the constructor. It is advised that the object use inherit either from Bio::MAGE::XML::Handler::ContentHandler (if using SAX2) or Bio::MAGE::DocumentHandler if using SAX1. In particular, whatever class is used, it needs to implement the following methods:
  • verbose

    called with the integer parameter that specifies the desired level of output

  • log_file

    called with the file handle to which output should be sent

  • init

    called during the constructor for any needed work


 Title   : parser
 Usage   : $obj->parser($newval)
 Example : 
 Returns : value of parser (a scalar)
 Args    : on set, new value (a scalar or undef, optional)
This attribute determines the desired level of output during the parse. The default is no output. A positive value increases the amount of information.
This attribute specifies a file handle to which parse output will be directed. It is only needed if verbose is positive.
If defined, this will cause all BioAssayData objects to read themselves out using the DataExternal format.

Default Value: false

This attribute specifies whether the reader should attempt to track unhandled identifiers in the document, and then resolve them when parsing is over. This can be a huge performance hit if you know that all identifiers wil not resolve.

Default Value: false


This method will open the MAGE-ML file specified by $file_name and if the "handler" attribute is not set, it will create either a SAX2 parser or a SAX1 parser (depending on the value of the C <sax1> attribute) and parse the file.

"read()" can read from STDIN by specifying '-' as the filename. This enables you to handle compressed XML files:

  gzip -dc file.xml.gz | [options]


Hey! The above document had some coding errors, which are explained below:

You forgot a '=back' before '=head2'
'=item' outside of any '=over'
2020-12-01 perl v5.32.0