baj has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I would like to read a Perl object (Bio::DB::SeqFeature) that is stored in a MySQL database using some Java code.

Initially I was thinking of executing some perl code that would reformat the object and print it in a usable format, but that would require installing perl and even worse the bioperl package on the computer. Since I want to redistribute the program I cannot expect "simple" Windows users to install BioPerl...

How would you read a Perl object otherwise from Java?

Thanks a lot,

Bernd

Replies are listed 'Best First'.
Re: reading perl objects with java
by BioLion (Curate) on Feb 09, 2010 at 13:27 UTC

    From BioPerl.org :

    "Sometimes wrestling with Bio::DB::SeqFeature::Store is a waste of time"
    so maybe a simple "write out, read in" approach would be easiest, unless you have a vast number of sequence objects, or they are particularly complex?

    Looking at Bio::SeqFeature::Store, it says objects are stored as a hierarchy of "serialized feature"(s). So maybe Storeable? Is it worth the work to make a java interface to this?

    Just a something something...

      I believe they are stored using Storable. But how could I use this information?

      Can you point me to some documentation on how to use it to read with java?

      Thanks,

      Bernd

        Maybe you'd have more luck at a Java site? :O

Re: reading perl objects with java
by moritz (Cardinal) on Feb 09, 2010 at 11:06 UTC
    How is that object stored? via Storable, or by some other means?
    Perl 6 - links to (nearly) everything that is Perl 6.

      I don't know how it is stored... Looking at the code (http://doc.bioperl.org/releases/bioperl-current/bioperl-live/Bio/DB/SeqFeature/Store/DBI/mysql.html , http://doc.bioperl.org/releases/bioperl-current/bioperl-live/Bio/DB/SeqFeature/Store.html#CODE82 , http://doc.bioperl.org/releases/bioperl-current/bioperl-live/Bio/DB/SeqFeature.html) doesn't help me too much as I don't really understand what is going on there...

      Maybe I could write a web-service to provide the information I need...??
        This isn't a bad idea - you might consider delivering the data as JSON; I think that should be something that you could find a Java library to parse. It completely insulates the Java consumer from having to know anything about the data's on-disk format, which is the point here.

        You may need to provide something to impedance-match the Java code and the returned JSON, and supply that to the Java folks, most likely as another .jar file.

        I think this is really your best option, since it should be quite easy to do. You will need to write the BioPerl-to-JSON code to add to your server and the JSON-to-whatever-format library for the Java code, but those are both smallish and easily-testable pieces of code.

Re: reading perl objects with java
by philipbailey (Curate) on Feb 09, 2010 at 11:58 UTC

    It would seem that your options are (1) parse the Perl object from Java, or (2) write out the object from Perl in some pre-digested form which is easier to read from Java.

    (1) is said to be impossible in the general case (Perl Cannot Be Parsed: A Formal Proof), although might be doable for some suitable subset of Perl. (2) seems like the easier option, though.

Re: reading perl objects with java
by Mr. Muskrat (Canon) on Feb 09, 2010 at 16:39 UTC

    There's a reason that the BioPerl project exists. Perl is easy to learn, use and distribute. If you don't want to figure out how to distribute it to your users then perhaps you should look into using BioJava instead.

Re: reading perl objects with java
by molecules (Monk) on Feb 09, 2010 at 18:17 UTC