egonw / bacting

Bacting is an open-source platform for chemo- and bioinformatics based on Bioclipse that defines a number of common domain objects and wraps common functionality, providing a toolkit independent, scriptable solution to handle data from the life sciences.
Other
13 stars 5 forks source link

BridgedbManager.loadRelationalDatabase with Scyjava does not work #57

Closed kozo2 closed 3 years ago

kozo2 commented 3 years ago

Bacting API method with unexpected output

loadRelationalDatabase did not work when importing BridgedbManager with scyjava.

See image

Expected Output

test will be IDMapper object

Actual Output

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-eee82142c20a> in <module>()
----> 1 test = bdbClass.loadRelationalDatabase("./metabolites_20210109.bridge")

TypeError: No matching overloads found for *static* net.bioclipse.managers.BridgedbManager.loadRelationalDatabase(str), options are:
    public org.bridgedb.IDMapper net.bioclipse.managers.BridgedbManager.loadRelationalDatabase(java.lang.String) throws net.bioclipse.core.business.BioclipseException

Additional context

You can reproduce this with https://colab.research.google.com/drive/1hs-yuKl_pOCIkUl5DM4h_Ecyp6rI2cOx?usp=sharing

egonw commented 3 years ago

@kozo2, sorry for the delay... could I ask you to try the following?

test = bdbClass.loadRelationalDatabase(to_java("./metabolites_20210109.bridge"))

Looking at the error message, I think it's trying to pass a Python str to the method, see also https://github.com/scijava/scyjava#available-functions

kozo2 commented 3 years ago

@egonw I updated https://colab.research.google.com/drive/1hs-yuKl_pOCIkUl5DM4h_Ecyp6rI2cOx?usp=sharing It tries

import scyjava
test = bdbClass.loadRelationalDatabase(scyjava.to_java("./metabolites_20210109.bridge"))

but, there is still the following TypeError

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-3d6a271882bf> in <module>()
----> 1 test = bdbClass.loadRelationalDatabase(scyjava.to_java("./metabolites_20210109.bridge"))
      2 #test = bdbClass.loadRelationalDatabase("./metabolites_20210109.bridge")

TypeError: No matching overloads found for *static* net.bioclipse.managers.BridgedbManager.loadRelationalDatabase(java.lang.String), options are:
    public org.bridgedb.IDMapper net.bioclipse.managers.BridgedbManager.loadRelationalDatabase(java.lang.String) throws net.bioclipse.core.business.BioclipseException

image

egonw commented 3 years ago

I got some time to look into the notebook more... there was at least a step missing... the bdbClass should not be used in a static way, but be instantiated around an "Eclipse workspace":

workspaceRoot = "."
bdbClass = jimport("net.bioclipse.managers.BridgedbManager")
bdb = bdbClass(workspaceRoot)

Then, put the BridgeDb database in a project (which will go into that workspace):

!mkdir -p BridgeDb; cd BridgeDb; wget https://ndownloader.figshare.com/files/26001794
!cp 26001794 metabolites_20210109.bridge

Then, the loading would be like this:

test = bdb.loadRelationalDatabase("/BridgeDb/metabolites_20210109.bridge")

But then I still run into a problem, a missing class. I will look into that next.

egonw commented 3 years ago

I can confirm this dependency is indeed not given. Fixing this now.

egonw commented 3 years ago

Okay, the method actually doesn't use the workspace approach :/

So, this is the code that works for me now:

from scyjava import config, jimport

config.add_endpoints('io.github.egonw.bacting:managers-bridgedb:0.0.23-SNAPSHOT')

workspaceRoot = "."
bdbClass = jimport("net.bioclipse.managers.BridgedbManager")
bdb = bdbClass(workspaceRoot)

test = bdb.loadRelationalDatabase("./Test/complexes_20200510.bridge")

I will try to release 0.0.23 today.

egonw commented 3 years ago

Fixed in https://github.com/egonw/bacting/commit/08a23fbea780b23a34f2ff13d09130f34b0f41b5

egonw commented 3 years ago

Bacting 0.0.23 is released which includes this fix.

kozo2 commented 3 years ago

@egonw Thanks. I updated https://colab.research.google.com/drive/1hs-yuKl_pOCIkUl5DM4h_Ecyp6rI2cOx?usp=sharing . It works well.