[InterMine Dev] Java classes querying backend

JD Wong jdmswong at gmail.com
Tue Aug 13 16:53:11 BST 2013


Thanks Alex, I'll try this out

Cheers!
-JD


On Tue, Aug 13, 2013 at 11:11 AM, Alex Kalderimis <alex at intermine.org>wrote:

> OK, well then I will suggest a Perl/Python/Ruby/JS based solution,
> and will outline what you would do if you really really wanted to do
> this in java.
>
> Using a webservice client:
> ==============================
>
>  a. Build the db & release a web-app on top of it.
>     The web application does not need to be super configured with
>     templates and stuff or even have much of a userprofile.
>  c. Compile a list of asserted relationships.
>  b. Process your asserted relationships.
>
> Examples of using python and perl to do this can be found below:
>
> Using Python to list the relationships to assert:
> --------------------------------------------------
>
> This script assumes all fields should be populated at least once,
> so it just lists them out.
>
> #!/usr/bin/env python
> # Usage:
> #  python /this/script url-of-mine
>
> import sys
> from intermine.webservice import Service
>
> mine = Service(sys.argv[1])
> fmt = "{0}.{1}{2}"
>
> for cls in mine.model.classes.itervalues():
>   for field in cls:
>     suffix = "" if field.fieldtype == "attribute" else ".id"
>     print(fmt.format(cls.name, field.name, suffix))
>
> exit()
>
> Perl:
> ------------------------------
>
> This script then checks that all those paths have at least a single
> piece of data associated with them. Obviously, this could be done with
> a curated and hand-written set of asserted paths.
>
> #!/usr/bin/perl
> # Usage: perl -x /this/mail/message $url_of_api < $file
>
> use Webservice::InterMine;
> my ($url_of_api) = @ARGV;
>
> my $mine = get_service $url_of_api;
>
> while ( <STDIN> ) {
>     chomp;
>     my $path = $mine->new_path($_);
>     my $count = $path->get_possible_values_count;
>     print "$path: $count\n";
> }
>
> __END__
>
> It would be similarly straightforward to do this in Ruby or using node.js.
>
> If you really really don't want to release a web-app
> ====================================================
>
> Then you have to use Java; there is no mechanism for using other
> languages without a web-application API layer.
>
> Now, it is possible to do similar things with Java _without_ releasing a
> web-app:
>  a. Build a db
>  b. Build a new application to run your program which:
>    i. Connects to the objectstore (this requires using the appropriate
> properties files).
>    ii. Parses the Model (much as above).
>    iii. Constructs path-queries for each path to assert.
>    iv. Runs them and interprets the results.
>
> There isn't much of a framework for building such applications,
> although it is totally possible. It involves writing an application
> that connects directly to the database, so it isn't the kind of thing
> we normally go around encouraging; if you would like to go down this
> avenue and need some help, let us know and we will see what we can do.
>
> All best,
>
> Alex Kalderimis.
>
>
>
> On Mon, Aug 12, 2013 at 01:05:22PM -0400, JD Wong wrote:
> > Not at all, in fact perl would be preferable if possible.  Types of
> > handling: query generation and database schema awareness would best
> > describe it.  Basically the java code and classes which interface to the
> > database that can be used to generate queries.
> >
> > Thanks!
> > -JD
> >
> >
> > On Mon, Aug 12, 2013 at 12:44 PM, Alex Kalderimis <alex at intermine.org
> >wrote:
> >
> > >
> > > On Mon, Aug 12, 2013 at 12:40:14PM -0400, JD Wong wrote:
> > >
> > > > Can anybody point me to where I can find
> > > > the java code which handles the production database?
> > >
> > > That's a very general question; what kind of handling did you have in
> > > mind? Also, does it need to be java?
> > >
> > > >
> > > > Thanks!
> > > > -JD
> > >
> > > > _______________________________________________
> > > > dev mailing list
> > > > dev at intermine.org
> > > > http://mail.intermine.org/cgi-bin/mailman/listinfo/dev
> > >
> > >
>
> > _______________________________________________
> > dev mailing list
> > dev at intermine.org
> > http://mail.intermine.org/cgi-bin/mailman/listinfo/dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.intermine.org/pipermail/dev/attachments/20130813/b2a1092e/attachment.html>


More information about the dev mailing list