Search This Blog

Showing posts with label color scheme. Show all posts
Showing posts with label color scheme. Show all posts

Wednesday, August 18, 2010

Demonstration of GSoC Project

The features that developed for the GSoC project will be available in the next Jalview release. You can also contact me and I can send you a jar file with the new features, or download the code from the Google code hosting page for Jalview and see my post on how to set up Eclipse with Jalview. The code submitted to Google is the same as rev 32 on the Google code host site.

Addendum: Jim posted a comment with a link to the webstart version.


  1. You can fetch sequences from RFAM via the sequence fetcher. Go to "File > Fetch Sequence(s)..." and a dialog box will appear.


  2. From the database drop down menu select RFAM (Full) for the "Full" alignment from RFAM or RFAM (Seed) for the "Seed" alignment. Seed alignments are the original alignments constructed to create a covariance model for searching databases. Full alignment are the result of a search using the covariance model against the sequence database. For this demonstration, I used RFAM (Seed), but selecting the RFAM (Full) will be very similar.

  3. Click the "Example" button to load an alignment name. Click the "OK" button to fetch the alignment.


  4. A new dialog box will appear with the alignment. The RFAM sequence fetcher retrieves files in Stockholm format, so Jalview can interpret the secondary structure information in the file. The secondary structure information in the file is displayed in WUSS notation and helices that are determined from this information are displayed as blue arrows in the Annotation panel.




  5. You can color the helices with the "By RNA helices" color option. Go to "Colour > By RNA helices."


  6. The helices should now be colored.


  7. To view the consensus logo in the Annotation panel, go to "View > Autocalculated Annotation > Show Consensus logo". The coloring of the logo will change based on which color scheme is selected.


  8. Close up of Consensus logo when "By RNA helices" or "Purine/Pyrimidine coloring is selected.




  9. To change the color scheme to "Purine/Pyrimidine" go to "Colour > Purine/Pyrimidine"




Tuesday, August 3, 2010

Random colors for covariation color scheme

For the covariation color scheme, I want to generate random colors so I don't have to worry about storing an index of colors for an unknown number of helices. I found a nice algorithm at stackoverflow.com. I set up everything for the covariation color scheme and tried out the random color selection for each nucleotide.

Examples are below. I like the first example that uses pastels, but I worry that the colors are not distinct enough from each other. The problem with the second example is that the dark colors make it impossible to read the nucleotide; I could figure out how to make the text white in those cases.



Adding color schemes

Currently I'm adding color schemes, including the covariation color scheme. When you add a color scheme, files need to be edited in the jalview.schemes, jalview.jbgui, and jalview.gui packages. The jbgui package is named for the fact that JBuilder was used initially to automatically generate some of the code. The gui and jbgui classes have matching classes, but the classes in jbgui are preceded by a "G."

The GAlignFrame class maintains a shadow class for the user interface, and the class in the gui package, AlignFrame, has most of the logic. This class includes objects that you see in Jalview, such as buttons. The jbInit method adds the buttons into the gui and sets the properties of the buttons.

Step 1: Create a color scheme and put it in the jalview.schemes package
1a. make it a subclass of ResidueColourScheme (extends)
1b. You will probably write findColour methods that overrides the ones found in ResidueColourScheme
1c. May need to call an index of colors (eg. based on characters in the alignment); store these in ResidueProperties.java

Step 2: Edit ColourSchemeProperties.java in jalview.schemes package
2a. add in a new enumeration symbol for scheme
2b. List of functions to edit:
*getColourIndexFromName()
*getColourName(ColourSchemeI cs)
*getColourName(int index)
*getColour(java.util.Vector seqs, int width, int index)

Step 3: Add a new JRadioButtonMenuItem in GAlignFrame for scheme

Step 4: Edit setColourSelected function in GAlignFrame to check the menu item when the colourscheme is selected

Step 5: Add menu item text and action settings into the jbInit function so it calls a protected GAlignFrame action method (copy the nucleotideColour button example)
5a. Add protected void myButton_actionPerformed(ActionEvent e) function (at end of GAlignFrame)
5b. Add your menu item to the colourMenu window menu (at end of jbInit)
5c. Add your menu item to the colours ButtonGroup (above public void setColourSelected(String defaultColour)
*ButtonGroup colours -> syntax is colours.add(colorscheme)

Step 6. Create a new public method with the identical name (myButton_actionPerformed(ActionEvent e)) which calls changeColour(my new
colourscheme) in AlignFrame

Step 7: For more complex colourschemes, you'll need to make sure any calculated values (e.g. covariation) are completed before the color scheme is applied in the AlignFrame._actionPerformed function

Step 8: Repeat process in the PopupMenu
*There is no GPopupMenu! (this is because PopupMenu is a dynamic menu, so the JBuilder mechanism isn't used).

If you want to add the scheme to the Jmol applet:
Step 1: In jalview.gui package AppJmol.java
*Create public void method, scheme_actionPerformed method that creates new scheme object (right above setJalviewColourScheme method)

Step2: In jbgui.GStructureViewer.java
*add new JMenuItem for scheme
*setText for scheme and add actionlistner for scheme (setText and addActionListner)
*add empty public void scheme_actionPerformed method
*add scheme to colourMenu

If you want to add the scheme to the Jalview applet, it looks like you change these items:
*Add MenuItem in jalview.appletgui.AppletJmol.java
*Add action listener scheme.addActionListner(this);
*add to coloursMenu
*In actionPerformed method, setJalviewcolorscheme

Monday, August 2, 2010

Nucleotide codes

I've added a purine/pyrimidine color scheme to Jalview and added descriptions for lesser used nucleotide codes. The page at the KEGG database has a useful table. Here are the ones that I added:

W Weak (A or T)
S Strong (G or C)
M Amino (A or C)
K Keto (G or T)
B Not A (G or C or T)
H Not G (A or C or T)
D Not C (A or G or T)
V Not T (A or G or C