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
Get the InterMine::Model::ClassDescriptor (meta-class) with the given name.
my $cd = $model->get_classdescriptor_by_name("Gene");
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->getSymbol # "zen"
say $gene->getOrganism->getName # "D. melanogaster"
get_all_classdescriptors
Return all the InterMine::Model::ClassDescriptors for this model
my @cds = $model->get_all_classdescriptors();
get_referenced_classdescriptor
Get the class descriptor at the other end of a reference. The main use for this method is internal, during the construction of a model
my $cd = $model->get_referenced_classdescriptor($ref);
find_classes_declaring_field( $name )
Get the class descriptors that declare fields of a certain name
my @classes = $model->find_classes_declaring_field($str);
package_name
Return the package name derived from the original java name space, eg. org.intermine.model
my $java_package = $model->package_name;
model_name
Return the name of this model. Conceptually, this maps to the enclosing package for the generated classes.
my $model_name = $model->model_name();
to_xml
Returns a string containing an XML representation of the model.
lazy_fetch
Always returns undef. This can be overriden by subclasses to provide lazy fetching capabilities for items, from a web-service or directly from a database.
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:
FlyMine
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.