Webservice::InterMine::Path - functions for finding problems with paths
For validation using functions/static methods:
use Webservice::InterMine::Path qw(:validate); my @errors; push @errors, validate_path($model, $path_string); push @errors, end_is_class($model, $path_string); push @errors, b_is_subclass_of_a($model, $path_stringA, $path_stringB); confess @errors if @errors;
For queries for path based information from query services:
use Webservice::InterMine; my $service = Webservice::InterMine->get_testmine; my $path = $service->new_path('Department.employees.name'); my $has_guessed_correctly = 0; for my $name ($path->get_possible_values) { last if $has_guessed_correctly; print "Is your name $name?: y|N:"; chomp(my $resp = <STDIN>); $has_guessed_correctly++ if ($resp =~ /y(es)?/i); }
Construct a new path object for use with path based webservice. The path is immediately validated before use, so any subclass constraints that affect this path need to be included in the subtypes hash.
This constructor is not meant to be used directly; rather, obtain Webservice::InterMine:Path objects from their respective Service objects via their new_path methods.
new_path
Return an object for iterating over rows of results. The formats that are supported by the possible values service are jsonobjects (the default), and count formats. However, for accessing counts, and even values, it is probably easier to use the convenience methods listed below.
Paths can be refined by adding subtype constraints after they have been constructed. EG:
my $path = $service->new_path("Department.employees.name") # now the path represents that names of employees $path->set_subtype("Department.employees" => "CEO"); # And now it represents the names of CEOs
Returns the values this path may potentially have. Be aware that in list context it returns, as expected, as list of values, whereas in scalar context it resturns an Array-Reference to that list of values. If you just want the number of items in the list, use get_possible_values_count instead, which is much more efficient.
get_possible_values_count
Returns the number of different values this path may represent. This is the most efficient way to retrieve this information from the server.
Return true if this object represents a path that ends in an attribute.
Return the path before this one. eg, for "Gene.exons.name", return a path representing "Gene.exons". The resulting path with have all the same data as this one, including subclass information.
Return a path representing a path made from this one with further parts added on. Eg, for a path representing "Gene.exons", a call to $path->append("name") should return a path representing "Gene.exons.name".
$path->append("name")
Usage : validate_path($model, 'Department.name'); Function: Return errors for this path, nothing if the path is valid Args : $model - the InterMine::Model to use for validating $path_string - the path in string format
Usage : last_bit($model, 'Department.name'); Function: Returns the metaclass for the last part of the path-string Args : $model - the InterMine::Model to use for validating $path_string - the path in string format
Resolves a path to a class descriptor, or an attribute descriptor.
Usage : type_of($model, 'Department.name'); Function : returns a string with the type that this string evaluates to ie: Department.name => String Department.employees => Employee
Usage : end_is_class($model, 'Department.name'); Function: Returns an error if the last bit does not evaluate to a class (ie. is an attribute) Args : $model - the InterMine::Model to use for validating $path_string - the path in string format
Returns undef if $classA represents a subclass of $classB, or if they do not represent valid paths, otherwise returns a message.
Usage : class_of($instance); Function: Returns the meta-class that an object refers to. Args : an Webservice::InterMine::Field or ClassDescriptor instance
FlyMine <support@flymine.org>
<support@flymine.org>
Please report any bugs or feature requests to support@flymine.org.
support@flymine.org
You can find documentation for this module with the perldoc command.
perldoc Webservice::InterMine::Path
You can also look for information at:
FlyMine
http://www.flymine.org
Copyright 2009,2010 FlyMine, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Webservice::InterMine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Webservice::InterMine
CPAN shell
perl -MCPAN -e shell install Webservice::InterMine
For more information on module installation, please visit the detailed CPAN module installation guide.