Linking COPASI and Cytoscape

76 views
Skip to first unread message

Hikmet Emre Kaya

unread,
Apr 7, 2021, 10:03:44 AM4/7/21
to cytoscape-app-dev
Hello Everyone!

For my PhD project, I am trying to create a COPASI plugin for Cytoscape. COPASI is a software application for simulation and analysis of biochemical networks and their dynamics.

I am currently doing my Ph.D. in Computational Science at the University of Cape Town. My project is about developing systems biology tools for the modelling, simulation, and analysis of glycosylation networks found in Muc-1 type breast cancer tumours.

Unlike many system biology tools on Cytoscape, I want to approach the network from an enzyme kinetics angle because glycosylation networks involve a lot of glycosyltransferases that determine the final structure of glycan chains.

Long story short, I found the java language bindings for COPASI, and decompiled the .class files into the .java files.

Then, I created a maven project in cytoscape-api using eclipse, and copied these java files here.

I know that I need to write a proper CyActivator.java file, but have no idea where to start. The language bindings for COPASI are way too many and a bit complicated. What would be a simple first-step to see that it can at least be installed successfully and start without failing?

I created a .jar file after updating the pom.xml file (find attached), but when I copy the .jar file to CytoscapeConfiguration/3/apps/installed, Cytoscape crashes and gives the following error:

Native code library failed to load.                                                                                                                                                      
java.lang.UnsatisfiedLinkError: no CopasiJava in java.library.path: [/home/people/hkaya/Cytoscape_v3.8.2/framework/lib, /home/people/hkaya/Cytoscape_v3.8.2/framework/lib, /usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]

Any guidance would be greatly appreciated!

All the best,

Emre.


pom.xml

Hikmet Emre Kaya

unread,
Apr 7, 2021, 10:06:26 AM4/7/21
to cytoscape-app-dev

Hikmet Emre Kaya

unread,
Apr 8, 2021, 6:18:41 AM4/8/21
to cytoscape-app-dev
Update: I solved the error mentioned above by linking the native code library (libCopasiJava.so) to my java.library.path, so Cytoscape does start without crashing now.

But, the app fails to start with the following error:

org.cytoscape.app.internal.exception.AppStartupException: Bundle start error
    at org.cytoscape.app.internal.manager.BundleApp.start(BundleApp.java:84) ~[?:?]
    at org.cytoscape.app.internal.manager.AppManager.startApps(AppManager.java:404) ~[?:?]
    at org.cytoscape.app.internal.manager.AppManager.initializeApps(AppManager.java:374) ~[?:?]
    at org.cytoscape.app.internal.manager.AppManager.lambda$attemptInitialization$0(AppManager.java:235) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.osgi.framework.BundleException: Activator start error in bundle org.cytoscape.COPASI [123].
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2290) ~[?:?]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2146) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) ~[?:?]
    at org.cytoscape.app.internal.manager.BundleApp.start(BundleApp.java:82) ~[?:?]
    ... 8 more
Caused by: java.lang.UnsatisfiedLinkError: 'void org.cytoscape.COPASI.COPASIJNI.initCopasi()'
    at org.cytoscape.COPASI.COPASIJNI.initCopasi(Native Method) ~[?:?]
    at org.cytoscape.COPASI.COPASIJNI.<clinit>(COPASIJNI.java:25) ~[?:?]
    at org.cytoscape.COPASI.CCopasiMessage.<init>(CCopasiMessage.java:87) ~[?:?]
    at org.cytoscape.COPASI.CyActivator.start(CyActivator.java:52) ~[?:?]
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697) ~[?:?]
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2240) ~[?:?]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2146) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998) ~[?:?]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984) ~[?:?]
    at org.cytoscape.app.internal.manager.BundleApp.start(BundleApp.java:82) ~[?:?]
    ... 8 more

Scooter Morris

unread,
Apr 8, 2021, 9:07:09 AM4/8/21
to cytoscape-app-dev
Hi Emre,
   JNI can be a bit tricky.  So the problem is that is seems like OSGi is failing when your CyActivator is trying to open up the native library.   I looked at you pom, and you don't seem to be defining any dependencies for you COPASI libraries.  The typical trick for doing that is to add some instructions to the maven-bundle-plugin:

            <Embed-Dependency>*;scope=!provided</Embed-Dependency>
            <Embed-Transitive>true</Embed-Transitive>
            <Import-Package>*;resolution:=optional</Import-Package>

and then to add your dependency:

    <dependency>
      <groupId>org.openscience.cdk</groupId>
      <artifactId>cdk-qsarmolecular</artifactId>
      <version>2.2</version>
      <optional>true</optional>
    </dependency>

this example was taken from the chemViz app, which also uses JNI.  In your case, you'll need to install your dependencies locally using maven.  Hopefully, there is a JNI module that includes the .so files and will put those in place for you (the CDK ones do that).

Good luck!

-- scooter

Hikmet Emre Kaya

unread,
Apr 14, 2021, 10:40:22 AM4/14/21
to cytoscape-app-dev

Hello Scooter,

Thank you for your reply.

I have added the lines you suggested to my pom.xml, and added the COPASI dependencies from Properties - Java Build Path - Add External Jar, but that I am still getting the bundle start error I have previously reported.

This part of the error makes me wonder:

Caused by: java.lang.UnsatisfiedLinkError: 'void org.cytoscape.COPASI.COPASIJNI.initCopasi()'
    at org.cytoscape.COPASI.COPASIJNI.initCopasi(Native Method) ~[?:?]

if adding the libCopasiJava.so to my java.build.path failed. I have specified the file containing the library on Eclipse, as well as from the terminal

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my path/COPASI/

This seems to be the main problem because all the class files in the COPASI source code link back to CopasiJNI.java

I am not sure how to approach this issue.

Scooter Morris

unread,
Apr 22, 2021, 8:40:49 AM4/22/21
to cytoscape-app-dev
I think the first step is to make sure all of your dependencies are made as part of your jar.  Let's leave Eclipse out of it for the moment and just deal with Cytoscape and OSGi.  Eclipse adds some complexities that might get things confused.  So, once you run your maven to build your jar file, can you do a jar t on the jar file?  You should see your COPASI Java wrapper jar as part of your Jar.  The next step will be to make sure all of your native files are accessible.  OSGi knows how to find Java dependencies, but not JNI dependencies.  You may need to use something like JNATI to manage those.  Again, first step is to make sure we have the jar loaded.

-- scooter
Message has been deleted

Hikmet Emre Kaya

unread,
Apr 29, 2021, 9:11:48 AM4/29/21
to cytoscape-app-dev
Hi Scooter,

Thanks for your reply! I have made sure that the COPASI Java wrapper jar is part of the final jar.

For the native files, I tried the NativeUtils code that I found here, but it didn't work. I also downloaded the jnati code and added its dependencies to my pom.xml, but I am not sure how to use this code.

Also, I am quite confused about writing CyActivator.java. I did check various examples of sample apps, but I still don't understand which java classes to call when I write my own version of CyActivator. The jar file for COPASI contains several classes, almost all of which are dependent on the COPASIJNI.java class

Hikmet Emre Kaya

unread,
Apr 29, 2021, 9:18:27 AM4/29/21
to cytoscape-app-dev
More specifically, NativeUtils throws FileNotFoundException: the .so file could not be found inside the JAR.

Scooter Morris

unread,
May 6, 2021, 11:10:06 AM5/6/21
to cytoscape-app-dev
Greetings again.  You may want to try this: https://subscription.packtpub.com/book/application_development/9781783287796/5/ch05lvl1sec23/native-libraries-in-osgi-bundles and see if it helps.  There is also a discussion in the lwjgl3 group about how they figured things out.  See here: https://github.com/LWJGL/lwjgl3/issues/277

-- scooter

Hikmet Emre Kaya

unread,
Jun 17, 2021, 8:06:27 AM6/17/21
to cytoscape-app-dev
Hello Scooter,

Apologies for the late reply, I was busy with something else.

Here are some methods I have tried:

- I added <Bundle-NativeCode>${native.path}/libCopasiJava.so</Bundle-NativeCode> to the pom.xml file (native.path is where the .so file is located)
- I used an example java class that creates a COPASI model from an SBML file (this example code was in the Java Bindings Folder of COPASI's website), created a task factory for it, and the CyActivator
- Making sure I correctly load the native library with System.loadLibrary

the mvn -X package debug command gives this warning:

Bundle org.cytoscape.CyCopasi:CyCopasi:bundle:1 : Unknown attribute in native code: libCopasiJava.so=null


If I don't call any native method from COPASI, the app is installed without any apparent error, but is not visible on the app menu or anywhere else for that matter. I am not sure if this is related to the native library issue or not.

Also, when I disable and re-enable the app in Cytoscape, I get the following error:


Native code library failed to load.                                                                                                                                                      
java.lang.UnsatisfiedLinkError: Native Library /home/people/hkaya/Cytoscape_v3.8.2/framework/lib/libCopasiJava.so already loaded in another classloader

Continuing to look into the error...
Reply all
Reply to author
Forward
0 new messages