The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

next_stanza

Skip the rest of this stanza and go to the next

input: self, optional hashref of stanza types to parse

if the hashref is specified, will continue to skip stanzas until the stanza type matches one of those in the hash ref

NAME

GOBO::Parsers::OBOParser

SYNOPSIS

  my $parser = new GOBO::Parsers::OBOParser(file => "t/data/cell.obo");
  $parser->parse;
  print $parser->graph;

  my $writer = new GOBO::Writers::OBOWriter;
  $writer->graph($parser->graph);
  $writer->write();

DESCRIPTION

An GOBO::Parsers::Parser that parses OBO Files.

The goal is to be obof1.3 compliant:

http://www.geneontology.org/GO.format.obo-1_3.shtml

however, obof1.2 and obof1.0 are also supported

Term stanzas

These are converted to GOBO::TermNode objects

Typedef stanzas

These are converted to GOBO::RelationNode objects

Instance stanzas

These are converted to GOBO::InstanceNode objects

Statements

is_a and relationship tags are converted to GOBO::LinkStatement objects and added to the graph

intersection_of tags

These are added to the graph as GOBO::LinkStatement objects, with is_intersection=>1

You can call

  $g->convert_intersection_links_to_logical_definitions

To move these links from the graph to $term->logical_definition

TBD: do this as the default? TBD: generalize for all links? sometimes it is convenient to have the links available in the Node object...?

Parser options

The default behaviour of the parser is to parse everything it comes across. Customized parsing can be achieved by giving the parser a hash ref of options encoding the parsing preferences:

$parser->set_options($options);

To set parser options, use the following structures:

Header parsing instructions should be contained in the options hash with the key 'header':

 $options->{header} = ...

# parse only tag_1, tag_2 and tag_3, and ignore any other tags in the header $options->{header} = { parse_only => [ 'tag_1', 'tag_2', 'tag_3' ], }

# parse everything apart from tag_4, tag_5 and tag_6 $options->{header} = { ignore => [ 'tag_4', 'tag_5', 'tag_6' ], }

# ignore all information in the header $options->{header}{ignore} = '*';

There is no need to specify $options->{header}{parse_only} = '*' : this is the default behaviour. There is also no need to specify both 'ignore' and 'parse_only'.

Body parsing options

Body parsing instructions should be contained in the options hash with the key 'body':

 $options->{body} = ...

## parsing or ignore tags

# parse only tag_1, tag_2 and tag_3 from $stanza_type stanzas $options->{body}{parse_only}{$stanza_type} = [ 'tag_1', 'tag_2', 'tag_3' ],

# ignore 'tag_4', 'tag_5', 'tag_6' from $stanza_type stanzas $options->{body}{ignore}{$stanza_type} = [ 'tag_4', 'tag_5', 'tag_6' ],

## parsing or ignoring stanzas

# parse only stanzas where the type matches the key $stanza_type $options->{body}{parse_only}{ $stanza_type } = '*'

# ignore stanzas where the type matches the key $stanza_type $options->{body}{ignore}{ $stanza_type } = '*'

# ignore all information in the body $options->{body}{ignore} = '*';

There is no need to specify $options->{body}{parse_only} = '*' : this is the default behaviour. There is also no need to specify both 'ignore' and 'parse_only'.

Examples

# parse everything from the header; parse only instance stanzas and the id, name and namespace tags from term stanzas $parser->set_options({ body => { parse_only => { term => [ qw(id name namespace) ] }, instance => '*' } });

# ignore the header; parse everything in the body $parser->set_options({ header => { ignore => '*' } });

# parse the date from the header; ignore instance and annotation stanzas $parser->set_options({ header => { parse_only => [ 'date' ] }, body => { ignore => { instance => '*', annotation => '*' }, }, });

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 8:

=cut found outside a pod block. Skipping to next block.

Around line 18:

=cut found outside a pod block. Skipping to next block.