Using JalView source code

Hi all,

I would like to write an interface that shows some tabularized data for a set of genes. The nature of this table is such that it pops up a window that shows a MSA using JalView (along with its cool features) upon selection of a gene. What I need is to somehow pipe info from my interface directly to JalView without having to open a separate JalView process each time. Is there some easy way I can do this or do I have to actually call the JalView source code?

Also, I appear to be having trouble compiling the JalView source code. It appears there are some non-standard characters being used in some of the classes. I’ve tried a few common encoding schemes like UTF-8, UTF-16, and ASCII, but these characters are still unreadable (I am using NetBeans IDE but I doubt that makes much of a difference). Based on what I gathered from the code-level descriptions, these are delimiter characters. Do you happen to know what encoding scheme I should be using?

Finally, it appears the JMol jar file is missing the org.jmol.applet.AppleConsole class. I nabbed that class from the JMol website, so it’s okay, but I am wondering if I am the only one having that problem.

Thanks.

Andy

Hi Andy.

I would like to write an interface that shows some tabularized data for a set of genes. The nature of this table is such that it pops up a window that shows a MSA using JalView (along with its cool features) upon selection of a gene. What I need is to somehow pipe info from my interface directly to JalView without having to open a separate JalView process each time. Is there some easy way I can do this or do I have to actually call the JalView source code?

How you do this depends very much on the environment where your interface is running. It sounds like you are developing a standalone application, so you really only have three choices. Launching separate Jalview Desktop processes is easy, but as you say - inelegant. The alternative is to launch one Jalview process - either within the same JVM as your application (assuming you're working in Java), or as a separate process, and communicate with that.

For the single process case (where Jalview lives in the same JVM), the currently released versions of the desktop application do not have a well defined java api or script-based control language that would allow you to do this easily, but its something we'd like to develop - so I'd be happy to give you a hand in identifying the best way of opening/closing jalview displays programmatically within the same JVM.

Alternately, you can launch a second Jalview process and communicate with that. Whilst the lack of a script-based control language makes this difficult (ie you cant simply open a pipe to the Jalview process and send commands and data down it), there is a mechanism that allows a program to dynamically share data with an existing Jalview process, but it's still very much a prototype. If you're working in Java, then you should take a look at the VAMSAS library at www.vamsas.ac.uk - this provides an api that allows a program to create a shared document for bioinformatics data and annotation and exchange selection and mouseover events with other applications that are connected to the same document (allowing you to raise a particular alignment window, for instance). I suspect that you might need a bit more control than this - but if not, then VAMSAS might be the quickest route to achieve what you want to do.

Also, I appear to be having trouble compiling the JalView source code. It appears there are some non-standard characters being used in some of the classes. I've tried a few common encoding schemes like UTF-8, UTF-16, and ASCII, but these characters are still unreadable (I am using NetBeans IDE but I doubt that makes much of a difference). Based on what I gathered from the code-level descriptions, these are delimiter characters. Do you happen to know what encoding scheme I should be using?

Typically, UTF-8 is the standard encoding format for source code in Java. However, the character encoding warnings are annoying but not serious - since most java compilers gracefully deal with the problem .. does netbeans fail to compile those classes ? If so, there may be a setting that will disable this check. Alternately, you might consider using the latest development version's source from the jalview git repository (http://source.jalview.org/git/jalview.git) - where I've fixed up some of these encoding problems. If you use this, however, then bear in mind that Jalview is under active development, and make sure you frequently pull updates from the server.

Finally, it appears the JMol jar file is missing the org.jmol.applet.AppleConsole class. I nabbed that class from the JMol website, so it's okay, but I am wondering if I am the only one having that problem.

This problem is because Jalview's source supports two compilation processes (Jalview Desktop and JalviewLite) that have slighly different external library dependencies. The desktop uses libraries in the lib directory at compile and runtime, whereas the applet uses the libraries in the appletlib directory. Just add all jars in both directories into the build path of your netbeans project. You should also bear in mind that there is a another gotcha that you need to deal with - Jalview has an ant build script which handles various precompilation steps (copying help files and non-compilable resources like images to the build directory). At the very least, make sure that netbeans executes the 'buildindices' ant target prior to launching Jalview. (for a complete description of this for eclipse, see Lauren Lui's blog here http://jalview-rnasupport.blogspot.com/)

If your interested in getting Jalview to play nice with your interface - via any of the approaches above or some other approach, then I suggest you request subscription to jalview's development mailing list (at http://www.jalview.org/mailman/listinfo/jalview-dev), and we can continue the discussion there.

Cheers for the email!
Jim.

···

On 22/06/2011 23:43, Andy Lai wrote:

Hello Andy - welcome to the Jalview development list !

The next thing you need to do is sign up at issues.jalview.org, so you can create and comment on bugs, and - should you wish to - gain commit rights to the Jalview git repository.

Yes, I am using Java. While VAMSAS sounds pretty cool, I suspect it may not be very hard to call JalView inside my JVM and get it to do whatever I want it to do (which is not a lot).

Fair enough :slight_smile: From what you say below, you might be able to do a lot of this via existing functions in Jalview, but there will definitely need to be a few modifications to Jalview's code to ensure the user's experience is sane.

Basically, I only need to call JalView to do two simple things:

(1) Take a MSA input (in CLUSTAL or FASTA format) and display it in a new window.

Where should the new window appear ? Specifically, does your app have a main desktop window like the Jalview desktop... or is it free-floating (ie each window appears on its own) ? and - do you want the alignment to appear in the same context as your app, or within a Jalview desktop ?

(2) Highlight an input set of regular expressions in specified colours. I am very new to JalView so I am not sure if that's possible, but even highlighting one should suffice, albeit sub-optimal for my purposes.

If the regular expressions are sequence motifs (ie the expression doesn't have to explicitly match gap characters), then this is no problem, but a bit of refactoring may be needed to make that code executable without opening dialog boxes and having to enact actionListener events.

The way I envision this to be done, without looking too much into your massive source code is that, I'd somehow call the code from the actionListener of the File -> Input Alignment -> From File -> New Window (to pipe in an alignment) and the "Find All" button from Ctrl + F (to pipe in and highlight a regex). Since I am not familiar with the source code yet, it's possible things are much more difficult than what I envisioned.

That's more or less right, but I'd generally recommend staying away from triggering Swing events (or calling their handlers directly) to achieve what you want - since they often depend on GUI state. Ideally, you should be able to use pure Jalview code do something like:

1. create a new jalview alignment view using the alignment provided by your program (can be passed in via a java.io.Reader instance).
2. create sequence annotation using the set of regular expressions, and define their appearance on the jalview alignment view.
3. show the alignment window.

There are also a few other considerations you need to take in to account. Step 0 will be initialising Jalview's environment - which depends on how you want the window to eventually appear to the user, and what you want them to be able to do with the alignment once it is displayed. Do you want to let the user treat this alignment as a standard jalview alignment window - or do you need some or all of the Jalview GUI (ie menu items, editing functions, etc) to be disabled ?

Jim.

[ for the record - this is a continuation from this thread : http://www.compbio.dundee.ac.uk/pipermail/jalview-discuss/2011-June/000624.html ]

···

On 24/06/2011 18:55, Andy Lai wrote:

Thanks Jim,

I will give issues.jalview.org a pass for now.

No, I don’t think I will mess with the handlers and events, but I suppose the code inside the listeners should have what I want. Yes, I do intend to allow full JalView functionality, but I am not sure if that’s possible (there are always technical reasons for things not working as they are supposed to).

I managed to compile the code and set buildindices as the default action in build.xml. However, I have run into an issue with paths and resources. It appears to me that the .jar file is expected to be in build/classes folder but in NetBeans, the JalView.jar is actually located in the dist folder. I am not sure if that’ intended or not. I also noticed that .build_properties and images folder are copied to the class folder (not build/class). However, these were not copied over to inside JalView.jar (which I assume should be the correct behaviour). So I think I’d need a little help over here, especially when I have close to zero experience with build scripts.

So far I am running JalView by running the main class of src/jalview/bin/JalView.java and it’s giving me a path issues (i.e. cannot load resources because they aren’t in the right places). While it’s possible to try this again in Eclipse, I think it’s probably good to try to make this work in Netbeans as well, since it’s a very popular IDE due to its UI building tool.

Thanks!

Andy

···

On Sat, Jun 25, 2011 at 6:46 AM, Jim Procter <jprocter@compbio.dundee.ac.uk> wrote:

Hello Andy - welcome to the Jalview development list !

The next thing you need to do is sign up at issues.jalview.org, so you
can create and comment on bugs, and - should you wish to - gain commit
rights to the Jalview git repository.

On 24/06/2011 18:55, Andy Lai wrote:

Yes, I am using Java. While VAMSAS sounds pretty cool, I suspect it
may not be very hard to call JalView inside my JVM and get it to do
whatever I want it to do (which is not a lot).
Fair enough :slight_smile: From what you say below, you might be able to do a lot
of this via existing functions in Jalview, but there will definitely
need to be a few modifications to Jalview’s code to ensure the user’s
experience is sane.
Basically, I only need to call JalView to do two simple things:

(1) Take a MSA input (in CLUSTAL or FASTA format) and display it in a
new window.
Where should the new window appear ? Specifically, does your app have a
main desktop window like the Jalview desktop… or is it free-floating
(ie each window appears on its own) ? and - do you want the alignment
to appear in the same context as your app, or within a Jalview desktop ?
(2) Highlight an input set of regular expressions in specified
colours. I am very new to JalView so I am not sure if that’s possible,
but even highlighting one should suffice, albeit sub-optimal for my
purposes.
If the regular expressions are sequence motifs (ie the expression
doesn’t have to explicitly match gap characters), then this is no
problem, but a bit of refactoring may be needed to make that code
executable without opening dialog boxes and having to enact
actionListener events.
The way I envision this to be done, without looking too much into your
massive source code is that, I’d somehow call the code from the
actionListener of the File → Input Alignment → From File → New
Window (to pipe in an alignment) and the “Find All” button from Ctrl +
F (to pipe in and highlight a regex). Since I am not familiar with the
source code yet, it’s possible things are much more difficult than
what I envisioned.
That’s more or less right, but I’d generally recommend staying away from
triggering Swing events (or calling their handlers directly) to achieve
what you want - since they often depend on GUI state. Ideally, you
should be able to use pure Jalview code do something like:

  1. create a new jalview alignment view using the alignment provided by
    your program (can be passed in via a java.io.Reader instance).
  2. create sequence annotation using the set of regular expressions, and
    define their appearance on the jalview alignment view.
  3. show the alignment window.

There are also a few other considerations you need to take in to
account. Step 0 will be initialising Jalview’s environment - which
depends on how you want the window to eventually appear to the user, and
what you want them to be able to do with the alignment once it is
displayed. Do you want to let the user treat this alignment as a
standard jalview alignment window - or do you need some or all of the
Jalview GUI (ie menu items, editing functions, etc) to be disabled ?

Jim.

[ for the record - this is a continuation from this thread :
http://www.compbio.dundee.ac.uk/pipermail/jalview-discuss/2011-June/000624.html
]


Jalview-dev mailing list
Jalview-dev@jalview.org
http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-dev

I will give issues.jalview.org a pass for now.

OK - however, we’d really prefer it if you at least register (which takes less than a minute), because you’ll then be able to track progress on any new implementation work that is carried out.

No, I don’t think I will mess with the handlers and events, but I suppose the code inside the listeners should have what I want.

yes - and I’ll happily help you refactor any of that code into public methods that can be called independently of the GUI.

Yes, I do intend to allow full JalView functionality, but I am not sure if that’s possible (there are always technical reasons for things not working as they are supposed to).

ok - so in reality, what you want is to provide an interface that allows the user to select from a database of alignments, and load them into the Jalview desktop, which is no problem. Do you want the user to be able to save annotation or edits back to the database as well ?

I managed to compile the code and set buildindices as the default action in build.xml. However, I have run into an issue with paths and resources. It appears to me that the .jar file is expected to be in build/classes folder but in NetBeans, the JalView.jar is actually located in the dist folder. I am not sure if that’ intended or not. I also noticed that .build_properties and images folder are copied to the class folder (not build/class). However, these were not copied over to inside JalView.jar (which I assume should be the correct behaviour). So I think I’d need a little help over here, especially when I have close to zero experience with build scripts.

hmm. I think you have not configured your netbeans project correctly. Jalview’s build script uses a classes directory to compile and assemble all the resources, then - assuming you execute the makedist or makefulldist targets, it assembles all the necessary Jars in the ‘dist’ directory. The build/classes folder sounds like something that netbeans created - so you need to tweak the netbeans project configuration to ensure the build directory is the same as the one that Jalview’s build.xml script is using.

Having said the above - It turns out that doing it is a real pain in NetBeans - and in fact, the easiest way was to add in a custom netbeans build script to ensure the ‘buildindices’ target in jalview’s build.xml is called with NetBean’s build/classes folder as the class output folder (see http://issues.jalview.org/browse/JAL-848 for the commit history). Now, you should be able to open the latest copy of the jalview development source (either from the web site, or pulling from the git repository) as a properly configured project in NetBeans.

So far I am running JalView by running the main class of src/jalview/bin/JalView.java and it’s giving me a path issues (i.e. cannot load resources because they aren’t in the right places). While it’s possible to try this again in Eclipse, I think it’s probably good to try to make this work in Netbeans as well, since it’s a very popular IDE due to its UI building tool.

Point taken - and I think it should be possible to set up any IDE to work with the Jalview source, since we all have our own preferred IDE. However, be warned - UI building tools like the one in NetBeans will probably fail to work correctly with many of Jalview’s classes, since a fair amount of Jalview’s UI is dynamic (ie certain menus and dialogs are created on the fly, rather than as static layouts).

Jim.

Thanks fo the reply.

ok - so in reality, what you want is to provide an interface that allows the user to select from a database of alignments, and load them into the Jalview desktop, which is no problem. Do you want the user to be able to save annotation or edits back to the database as well ?

No. I don’t think that functionality is needed

hmm. I think you have not configured your netbeans project correctly. Jalview’s build script uses a classes directory to compile and assemble all the resources, then - assuming you execute the makedist or makefulldist targets, it assembles all the necessary Jars in the ‘dist’ directory. The build/classes folder sounds like something that netbeans created - so you need to tweak the netbeans project configuration to ensure the build directory is the same as the one that Jalview’s build.xml script is using.

Having said the above - It turns out that doing it is a real pain in NetBeans - and in fact, the easiest way was to add in a custom netbeans build script to ensure the ‘buildindices’ target in jalview’s build.xml is called with NetBean’s build/classes folder as the class output folder (see http://issues.jalview.org/browse/JAL-848 for the commit history). Now, you should be able to open the latest copy of the jalview development source (either from the web site, or pulling from the git repository) as a properly configured project in NetBeans.

I downloaded the latest development source (2.6.1.) and it appears to give me the same results (I assume it includes the fixed build.xml from ticket JAL-848). Since my knowledge of ANT scripts is quite limited, it’d help if you can tell me what is expected in the dist folder and in the jar file.

I assume the dist folder should contain the lib folder and the jar. The jar, in turn, should contain resources and the properties file. So far, I don’t see any of this when I clean + build. You are right, though, that build/classes is a default NetBeans thing.

I am not very sure what else I can configure in NetBeans anyway… I did change the first line of build.xml from

to

.

Point taken - and I think it should be possible to set up any IDE to work with the Jalview source, since we all have our own preferred IDE. However, be warned - UI building tools like the one in NetBeans will probably fail to work correctly with many of Jalview’s classes, since a fair amount of Jalview’s UI is dynamic (ie certain menus and dialogs are created on the fly, rather than as static layouts).

Jim.

Yes, that’s fine. The part that uses NetBean’s UI builder is quite independent of JalView.

Andy