NAME

InterMine::Model - the representation of an InterMine model

SYNOPSIS

use InterMine::Model;

my $model_file = 'flymine/dbmodel/build/model/genomic_model.xml';
my $model = InterMine::Model->new(file => $model_file);
my $gene = $model->make_new(
  Gene => {
      primaryIdentifier => "FBgn0004053",
      secondaryIdentifier => "CG1046",
      symbol              => "zen",
      name                => "zerknullt",
      length              => "3474",
      organism            => {
          shortName => "D. melanogaster",
      }
      ncbiGeneNumber      => 40828,
  });

$gene->getName(); # "zerknullt"

...

DESCRIPTION

The class is the Perl representation of an InterMine data model. The new() method can parse the model file. The get_classdescriptor_by_name() method will return an InterMine::Model::ClassDescriptor object for the class with the given name, and the make_new() method will return an instantiated object of the given class.

For an example model see: http://trac.flymine.org/browser/trunk/intermine/objectstore/model/testmodel/testmodel_model.xml

CLASS METHODS

new( %options )

Standard constructor - accepts key/value pairs. Possible options are:

  • source: the source of the xml

    can be a ScalarRef, filehandle, filename, or string (or anything that overloads "") (tested in that order)

  • file: The file to load the model from

    [deprecated - use source instead]

  • string: A string containing the xml to load the model from

    [deprecated - use source instead]

  • origin: Where this model comes from

    usually a mine name - optional

get_classdescriptor_by_name

Title   : get_classdescriptor_by_name
Usage   : $cd = $model->get_classdescriptor_by_name("Gene");
Function: return the InterMine::Model::ClassDescriptor for the given class or
          undef if the class isn't in the model
Args    : the classname

make_new($class_name, [%attributes|$attributes])

Return an object of the desired class, with the attributes given

my $gene = $model->make_new(Gene => {symbol => "zen", organism => {name => 'D. melanogaster}});

say $gene->get_symbol             # "zen"
say $gene->get_organism->get_name # "D. melanogaster"

get_all_classdescriptors

Title   : get_all_classdescriptors
Usage   : @cds = $model->get_all_classdescriptors();
Function: return all the InterMine::Model::ClassDescriptor objects for this
          model
Args    : none

get_referenced_classdescriptor

Usage    : my $cd = $model->get_referenced_classdescriptor($ref);
Function : get the class descriptor at the other end of a reference
Args     : The reference

find_classes_declaring_field( $name )

Usage    : my @classes = $model->find_classes_declaring_field($str);
Function : get the class descriptors that declare fields of a certain name  
Args     : The field's name

package_name

Title   : package_name
Usage   : $package_name = $model->package_name();
Function: return the package name derived from the name space
          eg. "org.intermine.model"
Args    : none

model_name

Title   : model_name
Usage   : $model_name = $model->model_name();
Function: return the model name from the model file eg. "testmodel"
Args    : none

to_xml

Returns a string containing an XML representation of the model.

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::Model

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2006,2007,2008,2009, 2010, 2011 FlyMine, all rights reserved.

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