updated example PFAM accession
[jalview-manual.git] / TheJalviewTutorial.tex
1 \documentclass[a4paper,11pt]{report}
2 \usepackage{graphicx}
3 \usepackage{amssymb}
4 \usepackage{epstopdf}
5 \usepackage{hyperref}
6 \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
7
8 \textwidth = 6.5 in \textheight = 9 in \oddsidemargin = 0.0 in \evensidemargin =
9 0.0 in \topmargin = 0.0 in \headheight = 0.0 in \headsep = 0.0 in \parskip =
10 0.2in \parindent = 0.0in
11
12 \newtheorem{theorem}{Theorem}
13 \newtheorem{corollary}[theorem]{Corollary}
14 \newtheorem{definition}{Definition}
15
16 \title{Jalview 2.4: A manual and introductory tutorial }
17 \author{David Martin, James Procter, Andrew Waterhouse, Geoff Barton}
18 % how the hell do we add another panel with text like : This tutorial introduces
19 % the user to the features of Jalview, a multiple sequence alignment editor and
20 % viewer available from http://www.jalview.org to the title page.
21
22 % \renewcommand{menustyle}{\tt} %do something more advanced here.
23 \begin{document}
24
25 \newcounter{ecount} 
26 \newcounter{exstep}[ecount]
27 \renewcommand{\theecount} {\arabic{ecount}}
28 \renewcommand{\theexstep} {\arabic{ecount}.\alph{exstep}}
29
30 \newcommand{\exercise}[2] { \refstepcounter{ecount}
31 \begin{center} \fbox{\parbox[b][\height]{6in}{ 
32 {\bf Exercise \theecount  :  #1  } 
33 \par #2 }} \end{center}
34 % this doesn't work - page refs are off \addcontentsline{toc}{subsection}{ Exercise \theecount : #1 }
35 }
36 \newcommand{\exstep}[1]{ \stepcounter{exstep} {\sl \theexstep.}  \begin{minipage}[t]{5.5in} #1 \end{minipage} \par \vspace *{1mm} }
37 %%% Remove the % on the next 2 lines to hide tutorials.
38 %\renewcommand{\exercise}[2]{} 
39 %\renewcommand{\exstep}[1]{} 
40
41
42 \maketitle
43 \tableofcontents
44
45 \chapter{Basics}
46 \section{Introduction}
47 \subsection{Jalview}
48 Jalview is a sequence multiple alignment viewer, editor and analysis tool.
49 Jalview is designed to be platform independent (running on Mac, MS Windows, Linux
50 and any other platform that supports Java), capable of editing and analysing
51 large alignments (thousands of sequences) with minimal degradation in
52 performance, and able to show multiple integrated views of the alignment and
53 other data. Jalview can read and write many common sequence formats including
54 FASTA, Clustal, MSF(GCG) and PIR.
55
56
57 There are two types of Jalview program. The Jalview Desktop is a stand alone
58 application that provides powerful editing, visualization, annotation and
59 analysis capabilities. The JalviewLite applet has the same core visualization,
60 editing and analysis capabilities as the desktop, but is designed to be embedded
61 in a web page, allowing customised integration with alignment databases such as
62 pFam\footnote{A demonstration version of Jalview (Jalview Micro Edition) also
63 runs on a mobile phone but the functionality is limited to sequence colouring.}.
64
65
66 Jalview 2.4 was released in September 2008. The Jalview Desktop in this version
67 provides access to sequence, alignment and protein structure databases, and
68 alignment and analysis web services, and includes the Jmol\footnote{ Provided
69 under the LGPL licence at http://www.jmol.org} protein structure viewer. It is
70 also a Distributed Annotation System (DAS) client\footnote{with thanks to Andreas
71 Prlic} which facilitates the retrieval and display of third party sequence
72 annotation in association with sequences and any associated structure. 
73
74 \subsection{Jalview's Capabilities}
75 % TODO add references to appropriate sections for each capability described here.
76 Figure \ref{jvcapabilities} gives an overview of the main features of the Jalview desktop application. Its primary function is the editing and visualization of sequence alignments, and their interactive analysis. Tree building, principle components analysis, physico-chemical property conservation and sequence consensus analyses are built in to the program. Web services enable Jalview to access remote alignment and secondary structure prediction services, as well as to retrieve protein and nucleic acid sequences, alignments, protein structures and sequence annotation. Sequences, alignments, trees, structures, features and alignment annotation may also be exchanged with the local filesystem. Multiple visualizations of an alignment may be worked on simultaneously, and the user interface provides a comprehensive set of controls for colouring and layout. Alignment views are dynamically linked with Jmol structure displays, a tree viewer and spatial cluster display, facilitating interactive exploration of alignment structure. Finally, the application provides a Jalview project format enabling the current state of an alignment and analysis windows to be stored, and WYSIWIG style figure generation capabilities for use in publications.
77 \begin{figure}[htbp]
78 \begin{center}
79 \includegraphics[width=5.5in]{images/jvcapabilities.pdf}
80 \label{jvcapabilities}
81 \end{center}
82 \caption{{\bf Capabilities of the Jalview Desktop.} The Jalview Desktop Application provides a stable environment for the creation, editing and analysis of alignments and the generation of figures.}
83 \end{figure}
84
85 \subsubsection{Jalview History}
86 Jalview was initially developed in 1996 by Michele Clamp, James Cuff, Steve
87 Searle and Geoff Barton at the University of Oxford and then the European
88 Bioinformatics Institute. Development of Jalview 2 was made possible with
89 eScience funding from the BBSRC\footnote{Biotechnology and Biological Sciences
90 Research Council grant  {\sl "VAMSAS: Visualisation and Analysis of Molecules,
91 Sequence Alignments and Structures"}, a joint project to enable interoperability
92 between Jalview, TOPALi and AstexViewer.} in 2004, enabling Andrew Waterhouse and
93 Jim Procter to re-engineer the original program to introduce current developments
94 in bioinformatics and take advantage of the latest web and Java technology. The
95 2.4 version released in September 2008 introduces experimental support for a data
96 exchange framework developed as part of this project, to enable Jalview to be
97 used in conjunction with other programs for the analysis of sequences, alignments
98 and structures. Jalview continues to be one of the worlds most
99 popular\footnote{and in the authors opinion, the best.} sequence alignment and
100 analysis tools.
101
102 \subsubsection{Citing Jalview}
103 If you use Jalview in your work you should cite {\sl "The Jalview Java alignment
104 editor"} Michele Clamp, James Cuff, Stephen M. Searle and Geoffrey J. Barton
105 (2004) {\sl Bioinformatics} {\bf 20} 426-427.
106   \r\subsection{About this tutorial }
107
108 This tutorial is written in a manual format with short exercises where
109 appropriate, typically at the end of each section. The first chapter concerns the
110 basic operation of Jalview and should be sufficient for those who just want to
111 open an alignment, perform basic editing and colouring, and produce publication
112 and presentation quality graphical output.
113
114 The second chapter covers analysis in Jalview, sequence alignment and
115 visualisation of external features and structural data.
116
117 The third chapter covers the detail of Jalview and is aimed at the user who is
118 already familiar with Jalview operation but wants to get more out of their
119 Jalview experience.
120
121 \subsubsection{Typographic Conventions}
122
123 Keystrokes using the special non-symbol keys are represented in the tutorial by enclosing the pressed keys with square brackets ({\em e.g.} [RETURN] or [CTRL]). Keystroke combinations are combined with a '-' symbol ({\em e.g.} [CTRL]-C means press [CTRL] and the 'C' key). Menu options are given as a path from the menu that contains them - for example {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From URL} means to select the 'From URL' option from the 'Input Alignment' submenu of a window's 'File' dropdown menu.
124 \r\section{Obtaining and starting The Jalview Desktop Application}
125 \begin{figure}[htbp]
126 \begin{center}
127 \includegraphics[width=4.5in]{images/download.pdf}
128 \caption{{\bf Download page on the Jalview web site}}
129 \label{download}
130 \end{center}
131 \end{figure}
132
133 This tutorial is based on the application version of Jalview, the Jalview
134 Desktop. Much of the information will also be useful for users of the JalviewLite
135 applet. This version of Jalview 2 is designed to be launched from web pages, but
136 has the same core editing, analysis and visualization capabilities (see the
137 \href{http://www.jalview.org/examples/applets.html}{JalviewLite Applet Examples}
138 page for examples). The Jalview Desktop, however, is much more powerful, and
139 includes additional support for interaction with external web services, and
140 production of publication quality graphics.
141
142 The Jalview Desktop can be run in two ways; as an application launched from the
143 web via Java Web Start, or as an application loaded onto your hard drive. Both
144 versions are obtained from the Download page at the the Jalview web site
145 (http://www.jalview.org/).
146
147 Jalview can be started directly with webstart by navigating to the Download page
148 (via the menu on the left hand side), and clicking the 'Start with Java Webstart'
149 button. (figure \ref{download}). This will always launch the latest stable
150 release of Jalview.\par
151
152 The application will start automatically though you may be prompted to accept a
153 security certificate signed by the Barton Group. You can trust us so click trust
154 or accept as appropriate. The splash screen (figure \ref{splash}) gives
155 information about the latest version and the paper to cite in your publications.
156 This information is also available on the Jalview web site and from the {\sl Help
157 $\Rightarrow$ About} menu option.
158
159 %[fig 2] 
160 \begin{figure}[htbp]
161
162 \begin{center}
163 \includegraphics[width=4.5in]{images/splash.pdf}
164 \caption{{\bf Jalview splash screen}}
165 \label{splash}
166 \end{center}
167 \end{figure}
168 \rWhen Jalview starts it will automatically load an example alignment from the
169 Jalview site. Later in the tutorial we will discover how to alter this behaviour.
170 This alignment looks like figure \ref{startpage}.
171
172 %[figure 3 ]
173 \begin{figure}[htbp]
174 \begin{center}
175 \includegraphics[width=4in]{images/start.pdf}
176 \caption{{\bf Default startup for Jalview}}
177 \label{startpage}
178 \end{center}
179 \end{figure}
180
181
182 \exercise{Starting Jalview}{
183 \label{start}
184 \exstep{Point your web browser at the \href{http://www.jalview.org}{Jalview web site} and start Jalview by clicking on the 'Start with Java WebStart' button.} }
185
186 \subsection{Getting Help}
187
188 \subsubsection{Built in documentation}
189 Jalview has comprehensive on-line help documentation. Select  {\sl Help $\Rightarrow$ Documentation} from the main window menu and a new window will open (Figure \ref{help}). The appropriate topic can then be selected from the navigation panel on the left hand side. To search for a specific topic, click the 'search' tab and enter keywords in the box which appears.
190
191
192 \begin{figure}[htbp]
193 \begin{center}
194 \parbox[c]{2in}{\centerline{\includegraphics[width=2.75in]{images/help1.pdf}}}
195 \parbox[c]{4in}{\includegraphics[width=4in]{images/help2.pdf}}
196 \caption{{\bf Accessing the built in Jalview documentation}}
197 \label{help}
198 \end{center}
199 \end{figure}
200
201 \subsubsection{Email lists}
202
203 The Jalview Discussion list {\tt jalview-discuss@jalview.org} provides a forum for Jalview users and developers to raise problems and exchange ideas. The Jalview developers may also be contacted directly in the case of specific bugs, feature requests and so on via the email address {\tt help@jalview.org}. Finally, the {\tt jalview-announce@jalview.org} list can be subscribed to if you wish to be kept informed of new releases and developments. Archives and mailing list subscription details can be found on the Jalview web site.
204 \r\section{Navigation}
205 The major features of the Jalview Desktop are illustrated in Figure \ref{anatomy}. The alignment window is the primary window for editing and visualization, and can contain several independent views of the alignment being worked with. The other windows (Trees, Structures, PCA plots, etc) are linked to a specific alignment view. Each area of the alignment window has a separate context menu accessed by clicking the right mouse button.  
206
207  Jalview has two navigation and editing modes: normal mode, where editing and navigation is performed using the mouse, and cursor mode where editing and navigation are performed using the keyboard. The F2 key is used to switch between these two modes. 
208
209 \begin{figure}[htb]
210 \begin{center}
211 \includegraphics[width=6.5in]{images/jalview_anatomy.pdf}
212 \caption{{\bf The anatomy of Jalview.} The major features of the Jalview Desktop Application are labelled.}
213 % TODO: modify text labels to be clearer - black on grey and black border for clarity
214 \label{anatomy}
215 \end{center}
216 \end{figure}
217
218 \subsection{Navigation in Normal mode}
219 \rJalview always starts up in Normal mode, where the mouse is used to interact with the displayed alignment view. You can move about the alignment by clicking and dragging the ruler scroll bar to move horizontally, or by clicking and dragging the alignment scroll bar to the right of the alignment to move vertically.  If all the rows or columns in the alignment are displayed, the scroll bars will not be visible.\r\r Each alignment view shown in the alignment window presents a window onto the visible regions of the alignment. This means that with anything more than a few residues or sequences, alignments can become difficult to visualise on the screen because only a small area can be shown at a time. It can help, especially when examining a large alignment, to have an overview of the whole alignment. Select {\sl View $\Rightarrow$ Overview Window} from the window menu (Figure \ref{overview}).\r%(figure 4)
220 \begin{figure}[htbp]
221 \begin{center}
222 \includegraphics[width=4.5in]{images/overview.pdf}
223 \caption{{\bf Alignment Overview Window}}
224 \label{overview}
225 \end{center}
226 \end{figure}
227 \rThe red box in the overview window shows the current view in the alignment window. A percent identity histogram is plotted below the alignment overview. Shaded parts indicate rows and columns of the alignment that are hidden (in this case, a single row at the bottom of the alignment). You can navigate around the alignment by dragging the red box. %Try this now and see how the view in the alignment window changes.\r\r\parbox[c]{3in}{Alignment and analysis windows are closed by clicking on the usual 'close' icon (indicated by arrows on Mac OS X). If you want to close all the alignments and analysis windows at once, then use the {\sl Window $\Rightarrow$ Close All} option from the Jalview desktop (\em{warning: make sure you have saved your work because this cannot be undone !}). }
228 \parbox[c]{3in}{\centerline{\includegraphics[width=2.5in]{images/start_closeall.pdf}
229 }}
230
231 \subsection{Navigation in Cursor mode}
232
233 \parbox[c]{5in}{Cursor mode navigation enables the experienced user to quickly and precisely navigate, select and edit parts of an alignment. On pressing F2 to enter cursor mode the position of the cursor is indicated by a black background and white text. The cursor can be placed using the mouse or moved by pressing the arrow keys ($\uparrow$, $\downarrow$, $\leftarrow$, $\rightarrow$). 
234 }\parbox[c]{1.25in}{\centerline{\includegraphics[width=0.8in]{images/cursor1.pdf}}}
235
236 Rapid movement to specific positions is accomplished as listed below:
237 \begin{list}{$\circ$}{}
238 \item {\bf Jump to Sequence {\sl n}:} Type a number {\sl n} then press [S] to move to sequence (row) {\sl n}  
239 \item {\bf Jump to Column {\sl n}:} Type a number {\sl n} then press [C] to move to column {\sl n} in the alignment.  
240 \item {\bf Jump to Residue {\sl n}:} Type a number {\sl n} then press [P] to move to residue number {\sl n} in the current sequence.  
241 \item {\bf Jump to  column {\sl m} row {\sl n}:} Type the column number {\sl m}, a comma, the row number {\sl n} and press [RETURN]. 
242 \end{list}
243
244 \exercise{Navigation}{
245 \label{navigate}
246 \exstep{Scroll around the alignment using the alignment (vertical) and ruler (horizontal) scroll bars.}
247 \exstep{Find and open the Overview Window. Move around the alignment by clicking and dragging the red box in the overview window.}
248 \exstep{Look at the status bar as you move the mouse over the alignment. It should indicate information about the sequence and residue under the cursor.
249 }
250 \exstep{Press [F2] to enter Cursor mode. Use the arrow keys to move the cursor around the alignment. 
251 Move to sequence 7 by pressing {\sl 7 S}. Move to column 18 by pressing {\sl 1 8 C}. Move to residue 18 by pressing {\sl 1 8 P}. Note that these can be two different positions if gaps are inserted into the sequence. Move to sequence 5, column 13 by typing {\sl 1 3 , 5 [RETURN]}.
252 }
253
254 \r\section{Loading your own sequences}\r\rJalview provides many ways to load your own sequences. %For this section of the tutorial you will need to download the file http://www.jalview.org/tutorial/alignment.fa to a suitable location on your hard drive.\r\r\subsection{Drag and Drop}\r In some operating systems (Mac OS X, Windows XP) you can just drag a file icon from a file browser window and drop it on an open Jalview application window. The file will then be opened as a new alignment window. %You can try this with the tutorial file you have downloaded. When you have opened the file, close it again by selecting the close control on the window.\rIf you drop an alignment file onto an open alignment window it will be appended to that alignment.\r%  (Figure \ref{drag})
255 % %[fig 5]\r% \begin{figure}[htbp]\r% \begin{center}\r% \includegraphics[width=2in]{images/drag2.pdf}\r% \includegraphics[width=2in]{images/drag3.pdf}\r% \caption{{\bf An alignment can be opened by dragging the file onto the Jalview window. }}\r% \label{drag}\r% \end{center}\r% \end{figure}\r\r% %\includegraphics[width=2in]{images/drag1.pdf}
256
257 \r\subsection{From a File}\r      Jalview can read sequence alignments from a sequence alignment file. This is a text file, not a word processor document. For entering sequences from a wordprocessor document see Cut and Paste  (section \ref{cutpaste}) below. Select {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From File} from the main menu (Figure \ref{loadfile}). You will then get a file selection window where you can choose the file to open. Remember to select the appropriate file type. Jalview can automatically identify some sequence file formats.\r\r%[fig 6]\r\begin{figure}[htbp]
258 \begin{center}
259 \includegraphics[width=2in]{images/loadfilebox.pdf}
260 %\includegraphics[width=2in]{images/loadfilebox2.pdf}
261 \includegraphics[width=3in]{images/loadfileboxdrop.pdf}
262 \caption{{\bf Opening an alignment from a file saved on disk. }}
263 \label{loadfile}
264 \end{center}
265 \end{figure}
266 \r\subsection{From a URL}\r       Jalview can read sequence alignments directly from a URL. Please note that the files must be in a sequence alignment format - a pretty HTML alignment or graphics file cannot be read by Jalview. \rSelect {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From URL} from the main menu and a window will appear asking you to enter the URL (figure \ref{loadurl}). Jalview will attempt to automatically discover the file format.\r\r%[fig 7]
267 \begin{figure}[htbp]
268 \begin{center}
269 \includegraphics[width=2in]{images/menuloadurl.pdf}
270 \includegraphics[width=3in]{images/loadurlbox.pdf}
271 \caption{{\bf Opening an alignment from a URL }}
272 \label{loadurl}
273 \end{center}
274 \end{figure}
275 \r\subsection{Cut and Paste}
276 \label{cutpaste}\rDocuments such as those produced by Microsoft Word cannot be readily understood by Jalview. The way to read sequences from these documents is to select the data from the document and copy it to the clipboard. Select {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From Textbox} from the main menu and a textbox window will appear (Figure \ref{loadtext}). Paste the sequences you have copied to the clipboard and, presuming that they are in the right format, Jalview will happily read them.\r%[fig 8]
277
278 \begin{figure}[htbp]
279 \begin{center}
280 \includegraphics[width=2in]{images/menuloadtext.pdf}
281 \includegraphics[width=3in]{images/loadtextbox.pdf}
282 \caption{{\bf Opening an alignment from pasted text }}
283 \label{loadtext}
284 \end{center}
285 \end{figure}
286
287 \r\subsection{From a public database}
288 \label{fetchseq}\rJalview can retrieve sequences and sequence alignments from the public databases housed at the European Bioinformatics Institute, such as Uniprot, Pfam and the PDB, as well as any DAS sequence server registered at the configured DAS registry. This facility avoids having to manually locate, save and load the sequences, and allows Jalview to gather additional metadata provided by the source, such as annotation and database cross references.
289 Select {\sl File $\Rightarrow$ Fetch Sequence(s) \ldots} from the main menu and a window will appear (Figure \ref{loadseq}). Use the menu box to select the appropriate database, enter a sequence ID/accession number, or several separated by a semicolon and Jalview will attempt to retrieve it/them from the chosen database source. Example queries are provided to test that a source is operational, but can also be used as a guide on the type of accession numbers understood by the source.\r%[fig 9]\r\begin{figure}[htbp]
290 \begin{center}
291 \includegraphics[width=2.5in]{images/fetchseq.pdf}
292 \caption{{\bf Retrieving sequences from a public database}}
293 \label{loadseq}
294 \end{center}
295 \end{figure}
296
297 \exercise{Loading sequences}{
298 \label{load}
299 \exstep{Start Jalview then close all windows by selecting {\sl Window $\Rightarrow$ Close All} from the main menu}
300 \exstep{Select {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From URL} from the main menu and enter \textsf{http://www.jalview.org/tutorial/alignment.fa} in the box. Click {\sl OK} and the alignment should load.
301 }
302 \exstep{Close all windows using the {\sl Window $\Rightarrow$ Close All} main menu option. Point your web browser to \textsf{http://www.jalview.org/tutorial/alignment.fa} and save the file to your desktop. Open this file in Jalview by selecting {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From File} from the main menu and browsing to the appropriate location. Click OK and load the alignment
303 }
304 \exstep{
305 Drag the alignment.fa file from the desktop onto the Jalview window. The alignment should open. Try dragging onto an empty Jalview and onto an existing alignment and observe the results.
306 }
307 \exstep{
308 Select {\sl File $\Rightarrow$ Fetch Sequence(s).. } from the main menu. Select the {\sl PFAM (seed)} database and enter the accession number PF03460. Click OK. An alignment of about 107 sequences should load.
309 }
310 \exstep{Open the URL \textsf{http://www.jalview.org/tutorial/alignment.fa}  in a web browser. Select and copy the entire text to the clipboard (usually via the browser's {\sl Edit $\Rightarrow$ Copy} menu option). Ensure Jalview is running and select {\sl File $\Rightarrow$ Input Alignment $\Rightarrow$ From Textbox} . Paste the clipboard into the large window using the {\sl Edit $\Rightarrow$ Paste} text box menu option. Click {\sl Close} and the alignment will be loaded.
311 }
312 }\r\section{Writing sequence alignments}\r\subsection{Saving the alignment}\rJalview allows the current sequence alignments to be saved to file so they can be restored at a later date, passed to colleagues or analysed in other programs. From the alignment window menu select {\sl File $\Rightarrow$ Save As} and a dialog box will appear (Figure \ref{savealign}). You can navigate to an appropriate directory in which to save the alignment. Jalview will remember the last filename and format used to save (or load) the alignment, enabling you to quickly update the file after editing by using the {\sl File $\Rightarrow$ Save} entry. 
313
314 Jalview offers several different formats in which an alignment can be saved. The jalview format is the only one which will preserve the colours, groupings and similar information in the alignment. The other formats produce text files containing just the sequences with no visualisation information, although some allow limited annotation and sequence features to be stored (e.g. AMSA). Unfortunately only Jalview can read Jalview files. The {\sl File $\Rightarrow$ Output To Textbox} menu option allows the alignment to be copied and pasted into other documents or web servers. 
315 \r%[fig 10]
316 \begin{figure}[htbp]
317 \begin{center}
318 \parbox[c]{1.0in}{
319 \includegraphics[width=1.0in]{images/saveas.pdf}
320 }
321 \parbox[c]{4in}{
322 \includegraphics[width=4in]{images/saveas2.pdf}
323 }
324 \caption{{\bf Saving alignments in Jalview to disk}}
325 \label{savealign}
326 \end{center}
327 \end{figure}
328
329 \subsection{Jalview Projects}\r\parbox[c]{4in}{If you wish to save the complete Jalview session rather than just one alignment (e.g. because you have calculated trees or multiple different alignments) then your work should be saved as a Jalview Project file. From the main menu select {\sl File $\Rightarrow$ Save Project} and a file save dialog box will appear. Loading a project will restore Jalview to exactly the view at which the file was saved, complete with all alignments, trees, annotation and displayed structures rendered appropriately.}
330 \parbox[c]{2in}{
331 \centerline {
332 \includegraphics[width=1.5in]{images/saveproj.pdf}
333 }}
334
335 \exercise{Saving Alignments}{
336 \label{save}
337 \exstep{Start Jalview, close all windows and load the ferrodoxin alignment from pFam (accession number PF03460 (see Exercise \ref{load}).
338 }
339 \exstep{
340 Select {\sl File $\Rightarrow$ Save As} from the alignment window menu. Choose a location into which to save the alignment and select a format. All formats except {\sl  Jalview } can be viewed in a normal text editor (e.g. Notepad) or in a web browser. Enter a file name and click {\sl Save}. Check this file by browsing to it with your web browser or by closing all windows and opening it with Jalview. 
341 }
342 \exstep{ Repeat the previous step trying different file formats.}
343 \exstep{Select {\sl File $\Rightarrow$ Output to Textbox $\Rightarrow$ FASTA}. You can select and copy this alignment to the clipboard using the textbox menu options {\sl Edit $\Rightarrow$ Select All} followed by {\sl Edit $\Rightarrow$ Copy}. The alignment can then be pasted into any application of choice, e.g. a word processor or web form.
344 }
345 \exstep{Ensure at least one alignment window is shown in Jalview. Open the overview window and scroll to any part of the alignment. Select {\sl File $\Rightarrow$ Save Project} from the main menu and save in a suitable place. Close all windows and then load the project via the {\sl File $\Rightarrow$ Save Project} menu option. Note how all the windows and positions  are exactly as they were when they were saved.
346 }
347 }
348 \r\r\section{Selecting and editing sequences} \rJalview makes extensive use of selections which are arbitrary regions in an alignment. This section illustrates how to make and use selections and groups. 
349 \r\subsection{Selecting parts of an alignment}
350 Selections can be of arbitrary regions in an alignment, one or more complete columns, or one or more complete sequences.
351  
352 A selected region can be copied and pasted as a new alignment using the {\sl Edit $\Rightarrow$ Copy} and {\sl Edit $\Rightarrow$ Paste $\Rightarrow$ As New Alignment}  alignment window menu options.
353
354 To clear (unselect)  the selection press the [ESC] (escape) key.
355
356 \subsubsection{Selecting arbitrary regions}\rTo select part of an alignment, place the mouse at the top left corner of the region you wish to select. Press the mouse button and drag the mouse to the bottom right corner of the chosen region before releasing the mouse button. A dashed red box appears around the selected region (Figure \ref{select}). \r%[fig 12]
357
358 \begin{figure}[htbp]
359 \begin{center}
360 \includegraphics[width=4in]{images/select1.pdf}
361 \caption{{\bf Selecting a region in an alignment}}
362 \label{select}
363 \end{center}
364 \end{figure}
365
366 \subsubsection{Selecting columns}\rTo select the same residues in all sequences, click and drag along the alignment ruler. This selects the entire height of the alignment. Ranges of positions can also be selected by clicking on the first position then holding down the [SHIFT] key whilst clicking the other end of the selection. Discontinuous regions can be selected by holding down [CTRL] and clicking on positions to add to the selection. Selected columns are indicated by red highlighting in the ruler bar (Figure \ref{selectcols}).\r%[fig 13]
367
368 \begin{figure}[htbp]
369 \begin{center}
370 \includegraphics[width=4in]{images/select2.pdf}
371 \caption{{\bf Selecting multiple columns in an alignment}}
372 \label{selectcols}
373 \end{center}
374 \end{figure}
375
376 \subsubsection{Selecting sequences}
377
378 \begin{figure}[htb]
379 \begin{center}
380 \includegraphics[width=4in]{images/select3.pdf}
381 \caption{{\bf Selecting multiple sequences in an alignment}}
382 \label{selectrows}
383 \end{center}
384 \end{figure}
385 \rTo select multiple complete sequences, click and drag the mouse along the sequence ID panel. Multiple sequences will be selected. The same technique as used for columns above can be used with SHIFT-Click and CTRL-Click to select discontinuous ranges of sequences (Figure \ref{selectrows}).\r%[fig 14]
386
387 \subsubsection{Making selections in Cursor mode}
388
389 To define a selection in cursor mode, navigate to the top left corner of the proposed selection. Pressing the [Q] key marks this as the corner. A red outline appears around the cursor (Figure \ref{cselect})
390
391 Navigate to the bottom right corner of the proposed selection and press the [M] key. This marks the bottom right corner of the selection. The selection can then be treated in the same way as if it had been created in normal mode.
392
393 \begin{figure}[htbp]
394 \begin{center}
395 \includegraphics[width=1.5in]{images/csel1.pdf}
396 \includegraphics[width=1.5in]{images/csel2.pdf}
397 \includegraphics[width=1.5in]{images/csel3.pdf}
398 \includegraphics[width=1.5in]{images/csel4.pdf}
399 \caption{{\bf Making a selection in cursor mode.} Navigate to the top left corner (left), press [Q] (left center), navigate to the bottom right corner (right center) and press [M] (right)}
400 \label{cselect}
401 \end{center}
402 \end{figure}
403
404 \subsubsection{Inverting the current selection}
405
406 The current sequence or column selection can be inverted, using  {\tr Select $\Rightarrow$ Invert {\bf Sequence/Column} Selection} in the Alignment window. Inverting the selection is particularly useful when hiding regions in a large alignment (see section \ref{hidecol} below). Instead of selecting the columns and rows that are to be hidden, simply select the region that is to be kept visible, and then invert the selection.
407 \r\r\subsection{Creating groups}\rSelections are lost as soon as a different region is selected. Groups can be created which are labeled regions of the alignment. To create a group, first select the region which is to comprise the group. Then click the right mouse button on the selection to bring up a context menu. Select {\sl Selection $\Rightarrow$ Group $\Rightarrow$ Group} then enter a name for the group in the dialogue box which appears. 
408
409 \begin{figure}[htbp]
410 \begin{center}
411 \includegraphics[width=3.5in]{images/group1.pdf}
412 \includegraphics[width=2in]{images/newgroup.pdf}
413 \caption{{\bf Creating a new group from a selection}}
414 \label{makegroup}
415 \end{center}
416 \end{figure}
417
418 By default the new group will have a box drawn around it. The appearance of the group can be changed (see section \ref{colours} below). This group will stay defined even when the selection is removed.
419
420 \subsection{Exporting the current selection}
421
422 The current selection can be copied to the system clipboard (in PFAM format). It can also be output to a textbox using the output functions in the pop-up menu obtained by right clicking the current selection. The textbox enables quick manual editing of the alignment prior to importing it into a new window (using the [New Window] button) or saving to a file with the {\sl File $\Rightarrow$ Save As } pulldown menu option from the text box.
423
424
425 \exercise{Making selections and groups}{
426 \label{exselect}
427 \exstep{Close all windows in  Jalview and load the ferrodoxin alignment (PFAM ID PF03460). Choose a residue and  place the mouse cursor on it. Click and drag the mouse cursor to create a selection. As you drag, a red box will 'rubber band' out to show the extent of the selection. Release the mouse button and a red box should border the selected region. Now press [ESC] to clear the selection.}
428 \exstep{
429 Select one sequence by clicking on the id panel. Note that the sequence ID takes on a highlighted background and a red box appears around the selected sequence. Now hold down [SHIFT] and click another sequence ID a few positions above or below. Note how the selection expands to include all the sequences between the two positions on which you clicked.
430 Now hold down [CTRL] and click on several sequences ID's both selected and unselected. Note how unselected IDs are individually added to the selection and previously selected IDs are individually deselected. 
431 }
432 \exstep{ Repeat the step above but selecting columns by clicking on the ruler bar instead of selecting rows by clicking on the sequence ID.
433 }
434 \exstep{Press [F2] to enter Cursor mode. Navigate to column 59, row 1 by pressing {\sl 5 9 , 1 [RETURN]}. Press {\sl Q} to mark this position. Now navigate to column 65, row 8 by pressing {\sl 6 5 , 8 [RETURN]}. Press {\sl M} to complete the selection.}
435 \exstep{
436 \label{exselectgrpcolour}
437 Open the popup menu by right-clicking the selected region with the mouse. Open the {\sl Selection $\Rightarrow$ Group $\Rightarrow$ Group Colour } menu and select 'Percentage Identity'. This will turn the selected region into a group. }
438 \exstep{Hold down [CTRL] and use the mouse to select and deselect sequences by clicking on their Sequence ID label. Note how the group expands to include newly selected sequences, and the 'Percentage Identity' colouring changes. }
439 \exstep{
440 Use the mouse to click and drag the right-hand edge of the selected group. Note again how the group resizes.}
441
442 \exstep{
443 Right click on the text area to open the selection popup-menu. Follow the menus an pick an output format from the {\sl Selection $\Rightarrow$ Output to Textbox \ldots} submenu. 
444 }
445 \exstep{Try manually editing the alignment and then press the [New Window] button to import the file into a new alignment window.}
446
447 % more? change colouring style. set border colour.
448 }
449 \r\subsection{Reordering the alignment}\rSequence reordering is simple. Highlight the sequences to move then press the up or down arrow keys as appropriate (Figure \ref{reorder}). If you wish to move a sequence up past several other sequences it is often quicker to select the group past which you want to move it and then move the group rather than the individual sequence.\r\r\begin{figure}[htbp]
450 \begin{center}
451 \includegraphics[width=3in]{images/move1.pdf}
452 \includegraphics[width=3in]{images/move2.pdf}
453 \caption{{\bf Reordering the alignment.} The selected sequence moves up one position on pressing the $\uparrow$ key}
454 \label{reorder}
455 \end{center}
456 \end{figure}
457
458 \exercise{Reordering the alignment}{
459 \exstep{Open an alignment (e.g.the PFAM domain PF03460). Select one sequence. Using the up and down arrow keys, alter its position in the alignment.
460 }
461 \exstep{Hold [CTRL] and select two sequences separated by one or more un-selected sequences. Note how multiple sequences are grouped together when they are re-ordered using the up and down arrow keys.
462 }
463 }
464
465
466 \subsection{Hiding regions}
467
468 It is sometimes convenient to exclude some sequences or residues in the alignment without actually deleting them. Jalview allows sequences or alignment columns within a view to be hidden, and this facility has been used to create several different views of the example alignment in the file that is loaded when Jalview is first started (See Figure \ref{startpage}).
469
470 To hide a set of sequences, select them and right-click the mouse on the selected sequence IDs to bring up the context menu. Select {\sl Hide Sequences} and the sequences will be concealed, with a small triangle indicating their position (Figure \ref{hideseq}). To unhide (reveal) the sequences, right click on the triangle and select {\sl Reveal Sequences} from the context menu.
471
472
473  \begin{figure}[htbp]
474 \begin{center}
475 \includegraphics[width=1.5in]{images/hide1.pdf}
476 \includegraphics[width=2.5in]{images/hide2.pdf}
477 \includegraphics[width=1.75in]{images/hide3.pdf}
478 \caption{{\bf Hiding Sequences} Hidden sequences are represented by a blue triangle in the sequence ID panel}
479 \label{hideseq}
480 \end{center}
481 \end{figure}
482
483
484
485 A similar mechanism applies to columns (Figure \ref{hidecol}). Selected columns (indicated by a red marker) can be hidden and revealed in the same way via the context menu (right click) on the ruler bar. The hidden selection is indicated by a blue triangle in the ruler bar.
486
487  \begin{figure}[htbp]
488 \begin{center}
489 \includegraphics[width=2in]{images/hide4.pdf}
490 \includegraphics[width=3in]{images/hide5.pdf}
491 \includegraphics[width=1in]{images/hide6.pdf}
492 \caption{{\bf Hiding Columns} Hidden columns are represented by a blue triangle in the ruler bar}
493 \label{hidecol}
494 \end{center}
495 \end{figure}
496
497 \subsubsection{Representing a group with a single sequence}
498
499 Instead of hiding a group completely, it is sometimes useful to work with just one representative sequence. The {\sl <Sequence ID> $\Rightarrow$ Represent group with <Sequence ID> } option from the sequence ID pop-up menu enables this variant of the hidden groups function. The remaining representative sequence can be visualized and manipulated like any other. However, any alignment edits that affect the sequence will also affect the whole sequence group. 
500
501 \exercise{Hiding and revealing regions}{
502 \exstep{Close all windows then open the PFAM accession PF03460. Select a contiguous set of sequences by clicking and dragging on the sequence ID panel. Right click on the selected sequence IDs and select {\sl Hide Sequences}.
503 }
504 \exstep{
505 Right click on the blue triangle indicating hidden sequences and select {\sl Reveal Sequences}. (If you have hidden all sequences then you will need to use the alignment window menu option {\sl View $\Rightarrow$ Show $\Rightarrow$ All Sequences.})
506 }
507 \exstep{
508 Repeat but using a non-contiguous set of sequences. Note that when multiple regions are hidden there are two options, {\sl Reveal Sequences} and {\sl Reveal All}.
509 }
510 \exstep{Repeat the above but hiding and revealing columns instead of sequences.
511 }
512 \exstep{Select some sequences and pick one to represent the rest. Bring up the sequence ID pop-up menu for that sequence and select the {\sl Represent group with <Sequence ID> } option. Use the pop-up menu again to reveal the hidden sequences that you just picked a representative for.}
513 }
514
515
516
517
518 \subsection{Introducing and removing gaps}
519
520 Jalview provides interactive editing, allowing sequences to be dragged to create gaps.
521
522 \subsubsection{Introducing gaps in a single sequence}
523
524 To introduce a gap, place the cursor on the residue to the immediate right of where the gap should appear. Hold down the SHIFT key and the left mouse button, then drag the sequence to the right till the required number of gaps has been inserted.
525
526 One common error is to forget to hold down [SHIFT]. This results in a selection which is one sequence high and one residue long. Gaps cannot be inserted in such a selection. The selection can be cleared and editing enabled by pressing the [SHIFT] key.
527
528 \begin{figure}[htb]
529 \begin{center}
530 \includegraphics[width=3in]{images/edit1.pdf}
531 \includegraphics[width=3in]{images/edit2.pdf}
532 \caption{{\bf Introducing gaps.} Gaps are introduced as the selected sequence is dragged to the right.}
533 \label{gapseq}
534 \end{center}
535 \end{figure}
536
537 \subsubsection{Introducing gaps in all sequences of a group}
538
539 To insert gaps in all sequences in a selection or group, place the mouse cursor on any residue in the selection or group to the immediate right of the position in which a gap should appear. Hold down the CTRL key and the left mouse button, then drag the sequences to the right until the required number of gaps has appeared.
540
541 \begin{figure}[htb]
542 \begin{center}
543 \includegraphics[width=3in]{images/edit3.pdf}
544 \includegraphics[width=3in]{images/edit4.pdf}
545 \caption{{\bf Introducing gaps.} Gaps are introduced as the selected group is dragged to the right.}
546 \label{gapgroup}
547 \end{center}
548 \end{figure}
549
550 Gaps can be removed by dragging the residue to the immediate right of the gap leftwards whilst holding down [SHIFT] (for single sequences) or [CTRL] (for a group of sequences).
551 \subsubsection{Sliding Sequences}
552
553 Pressing the [$\Leftarrow$] or [$\Rightarrow$] when one or more sequences are selected will ``slide'' the selected sequences to the left or right (respectively).      
554
555 \subsubsection{Locked Editing}
556 \label{lockededits}
557 Normally, when a gap is inserted or removed in the alignment, the whole row is affected. However, if the edit is performed within a selected region, gaps will only be removed or inserted within the selected region. Edits are similarly constrained when they occur adjacent to a hidden column. 
558  
559 \subsubsection{Undoing edits}
560 Jalview supports the undoing of edits via the {\sl Edit $\Rightarrow$ Undo Edit} alignment window menu option. Each editing action is stored and can be reversed in sequence. Colouring of the alignment is not reversible via the {\sl Undo} option.  
561
562 % % better idea to introduce hiding sequences, and use the invert selection, hide
563 % others, to simplify manual alignment construction
564 \exercise{Editing alignments}{
565 \label{mousealedit}
566 \exstep{ Load the URL
567 \textsf{http://www.jalview.org/tutorial/unaligned.fa} which contains part of the
568 ferrodoxin alignment from PF03460.
569
570  You are going to manually reconstruct the alignment that jalview loads by
571  default. Remember to use [CTRL]+Z to undo an edit, or the {\tr File $\LeftArrow$
572  Reload } function to revert the alignment back to the original version if you
573  want to start again.
574  }
575
576 \exstep{ Select the first 7 sequences, and press H to hide them (or right click
577 on the sequence IDs to open the sequence ID popup menu, and select {\tr Hide
578 Sequences}). }
579
580 \exstep{ Select FER3\_RAPSA and FER\_BRANA. Slide the sequences to
581 the left so the initial {\bf A} lies at column 57 using the $\Rightarrow$ key.}
582
583 \exstep{ Select FER1\_SPIOL, FER1\_ARATH, FER2\_ARATH, Q93Z60\_ARATH and
584 O80429\_MAIZE (Hint: press [CTRL]-I to invert the sequence selection and then
585 deleset FER1\_MAIZE), and use the $\Rightarrow$ key to slide them to so they
586 begin at column 5 of the alignment view.} 
587
588 \exstep{ Select all the visible
589 sequences in the block by pressing [CTRL]-A. Insert a single gap in all selected
590 sequences at column 38 by holding [CTRL] and clicking on the R in FER1\_SPIOL and
591 dragging one column to right. Insert another gap at column 47 in all sequences in
592 the same way.}
593
594 \exstep{ Correct the feredoxin domain alignment for FER1\_SPIOL by
595 insert two additional gaps after the gap at column 47: hold [SHIFT] and click and
596 drag on the G and move it two columns to the right.}
597
598 \exstep{ Now complete the
599 alignment of FER1\_SPIOL with a {\bf locked edit} by pressing [ESC] and select
600 columns 47 to 57 of the FER1\_SPIOL row. Move the mouse onto the G at column 50,
601 hold [SHIFT] and drag the G to the left by one column to insert a gap at column
602 57.}
603
604 \exstep{ In the next two steps you will complete the alignment of the last two sequences.
605
606 Select the last two sequences (FER1\_MAIZE and O80429\_MAIZE), then press [SHIFT]
607 and click and drag the initial methionine of O80429\_MAIZE 5 columns to the right
608 so it lies at column 10. Keep holding [SHIFT] and click and drag to insert
609 another gap at the proline at column 25 (16P). Remove the gap at
610 column 44, and insert 4 gaps at column 47 (after AAPM).}
611
612 \exstep{ Hold [SHIFT] and drag the I at column 39 of FER1\_MAIZE 2 columns to the
613 right. Remove the gap at FER1\_MAIZE column 49 by [SHIFT]+click and drag left by
614 one column. Insert three gaps in FER1\_MAIZE at column 47 by holding [SHIFT] and
615 click and drag the S in FER1\_MAIZE to the right by three columns. Finally,
616 remove the gap in O80429\_MAIZE at column 56 using [SHIFT]-drag to the left on
617 42R.}
618
619 \exstep{ Use the
620 {\sl Edit $\Rightarrow$ Undo Edit} and {\sl Edit $\Rightarrow$ Redo Edit} menu option to step backwards and replay the
621 edits you have made} 
622 }
623
624 \subsubsection{Editing in Cursor mode}
625
626 Gaps can be inserted in cursor mode by pressing [SPACE]. Gaps will be inserted at the cursor, pushing the residue under the cursor to the right. To insert {\sl n} gaps type {\sl n} and then press [SPACE]. To insert gaps into all sequences of a group, use [CTRL]-[SPACE] or [SHIFT]-[SPACE] (both keys held down together).
627
628 Gaps can be removed in cursor mode by pressing [BACKSPACE]. The gap under the cursor will be removed. To remove {\sl n} gaps, type {\sl n} and then press [BACKSPACE]. Gaps will be deleted up to the number specified. To delete gaps from all sequences of a group, use [CTRL]-[BACKSPACE] or [SHIFT]-[BACKSPACE] (both keys held down together).
629
630 \exercise{Keyboard edits}{
631 \exstep{Load the sequence alignment at \textsf{http://www.jalview.org/tutorial/unaligned.fa}, or continue using the edited alignment from exercise \ref{mousealedit}.  If you continue from the previous exercise, then first right click on the sequence ID panel and select {\tr Reveal All}.
632
633 Now, enter cursor mode by pressing [F2]}
634 \exstep{Insert 58 gaps at the start of the first sequence (FER\_CAPAA). Press {\sl 58} then {\sl [SPACE]}. }
635 \exstep{Go down one sequence and select rows 2-5 as a block. Click on the second sequence ID (FER\_CAPAN). Hold down shift and click on the fifth (FER1\_PEA). }
636 \exstep{Insert 6 gaps at the start of this group. Go to column 1 row 2 by typing {\sl 1,2} then pressing {\sl [RETURN]}. Now insert 6 gaps. Type {\sl 6} then hold down [CTRL] and press the space bar.}
637 \exstep{Now insert one gap at column 34 and another at 38. Insert 3 gaps at 47. Press {\sl 3 4 C} then [CTRL]-[SPACE].  Press {\sl 3 8 C} then [CTRL]-[SPACE]. Press {\sl 4 7 C} then {\sl 3 [CTRL-SPACE]} the first through fourth sequences are now aligned.} 
638 \exstep{The fifth sequence (FER1\_PEA) is poorly aligned. We will delete some gaps and add some new ones. Navigate to the start of sequence 5 and delete 3 gaps. Press {\sl 1 , 5 [RETURN]} then {\sl 3 [BACKSPACE]} to delete three gaps. Go to column 31 and delete the gap. Press {\sl 3 1 C [BACKSPACE]} .}
639 \exstep{ Similarly delete the gap now at column 34, then insert two gaps at column 38 . Press {\sl 3 4 C [BACKSPACE]  3 8 C  2 [SPACE]}. Delete three gaps at 44 and insert one at 47 by pressing {\sl 4 4 C 3 [BACKSPACE] 4 7 C [SPACE]}.  The top five sequences are now aligned.}
640 }
641 \r\section{Colouring sequences}
642 \label{colours}
643
644 Colouring sequences is a key aspect of alignment presentation. Jalview allows both for colouring of the whole alignment and colouring of selections/groups. There are two main types of colouring styles: simple static residue colourschemes, dynamic schemes which use conservation and consensus analysis to control colouring. A hybrid colouring is also possible, where static residue schemes are modified using a dynamic scheme. The individual schemes are described in section \ref{colscheme} below.
645
646 \subsection{Colouring the whole alignment}
647
648 \parbox[c]{3.75in}{The alignment can be coloured via the {\sl Colour} menu option in the alignment window. Selecting the colour scheme causes all residues to be coloured. The menu is divided into two three sections. The first section gives options for the behaviour of the menu options, the second lists static and dynamic colourschemes available for selection, and the last gives options for making hybrid colourschemes using conservation shading or colourscheme thresholding. 
649
650 }\parbox[c]{3in}{
651 \centerline {
652 \includegraphics[width=2.5in]{images/colour2.pdf}
653 }
654 }
655
656 \subsection{Colouring a group or selection}
657
658 Selections or groups can be coloured via two ways. The first is via the alignment Colour menu but ensuring that the Apply to all groups flag is not selected. This will have to be turned off specifically as it is on by default.
659
660 The second method is to use the  {\sl Selection $\Rightarrow$ Group $\Rightarrow$ Group Colour}  context menu option obtained by right clicking on the group (Figure \ref{colgrp}). 
661
662 \begin{figure}[htbp]
663 \begin{center}
664 \includegraphics[width=4in]{images/group_col.pdf}
665 \caption{{\bf Colouring a group via the context menu.}}
666 \label{colgrp}
667 \end{center}
668 \end{figure}
669
670 \subsection{Shading by conservation}
671 For many colour schemes, the intensity of the colour in a column can be scaled by the degree of amino acid property conservation. Selecting {\sl Colour $\Rightarrow$ By Conservation} brings up a selection box (the {\sl Conservation Threshold dialog box}) allowing the alignment colouring to be modified. Selecting a higher value limits colouring to higher conserved groups (Figure \ref{colcons}).
672
673  \begin{figure}[htbp]
674 \begin{center}
675 \includegraphics[width=2in]{images/colourcons1.pdf}
676 \includegraphics[width=2in]{images/colourcons3.pdf}
677 \includegraphics[width=2in]{images/colourcons5.pdf}
678 \caption{{\bf Conservation Shading} The density of the ClustalX style residue colouring is controlled by the conservation threshold. The effect of 0\% (left), 50\% (center) and 100\% (right) thresholds are shown.
679 }
680 \label{colcons}
681 \end{center}
682 \end{figure}
683
684 \subsection{Thresholding by percentage identity}
685
686 'Thresholding' is another hybrid colour model where a residue is only coloured if it is not excluded by an applied threshold. Selecting {\sl Colour $\Rightarrow$ Above Identity Threshold} brings up a selection box with a slider controlling the minimum percentage identity threshold to be applied. Selecting a higher threshold (by sliding to the right) limits the colouring to columns with a higher percentage identity (as shown by the Consensus histogram in the annotation panel). 
687
688 \subsection{Colouring by Annotation}
689 \parbox[c]{3in}{
690 Any of the quantitative annotation on an alignment can be used to threshold or shade the whole alignment. The {\sl Colour $\Rightarrow$ By Annotation} options opens a dialog which allows you to select which annotation to use, the minimum and maximum shading colours or whether an existing colouring is to be thresholded.
691 }\parbox[c]{3in}{
692 \centerline{\includegraphics[width=2.5in]{images/col_byannot.pdf}}}
693 \subsection{Colour schemes} 
694
695 \label{colscheme}
696 Full details on each colour scheme can be found in the Jalview on-line help. A brief description of each one is provided below:
697
698 \subsubsection{ClustalX}
699
700
701  \parbox[c]{3.5in}{This is an emulation of the default colourscheme used for alignments in Clustal X, a graphical interface for the ClustalW multiple sequence alignment program. Each residue in the alignment is assigned a colour if the amino acid profile of the alignment at that position meets some minimum criteria specific for the residue type. }
702 \parbox[c]{3in}{\includegraphics[width=2.75in]{images/col_clustalx.pdf}}
703
704 \subsubsection{Blosum62}
705
706 \parbox[c]{3.5in}{Gaps are coloured white. If a residue matches the consensus sequence residue at that position it is coloured dark blue. If it does not match the consensus residue but the Blosum 62 matrix gives a positive score, it is coloured light blue.}
707 \parbox[c]{3in}{
708 \includegraphics[width=2.75in]{images/col_blosum62.pdf}
709 }
710
711 \subsubsection{Percentage Identity}
712 \parbox[c]{3.5in}{
713 The Percent Identity  option colours the residues (boxes and/or text) according to the percentage of the residues in each column that agree with the consensus sequence. Only the residues that agree with the consensus residue for each column are coloured.
714 }
715 \parbox[c]{3in}{
716 \includegraphics[width=2.75in]{images/col_percent.pdf}
717 }
718
719 \subsubsection{Zappo}
720 \parbox[c]{3.5in}{
721 The residues are coloured according to their physicochemical properties. The physicochemical groupings are Aliphatic/hydrophobic, Aromatic, Positive, Negative, Hydrophillic, conformationally special, and Cyst(e)ine.
722 }
723 \parbox[c]{3in}{
724 \includegraphics[width=2.75in]{images/col_zappo.pdf}
725 }
726
727 \subsubsection{Taylor}
728
729 \parbox[c]{3.5in}{
730 This colour scheme was devised by Willie Taylor and an entertaining description of it's origin can be found in Protein Engineering, Vol 10 , 743-746 (1997)
731 }
732 \parbox[c]{3in}{
733 \includegraphics[width=2.75in]{images/col_taylor.pdf}
734 }
735
736 \subsubsection{Hydrophobicity}
737 \parbox[c]{3.5in}{
738 Residues are coloured according to the hydrophobicity table of Kyte, J., and Doolittle, R.F., J. Mol. Biol. 1157, 105-132, 1982. The most hydrophobic residues are coloured red and the most hydrophilic ones are coloured blue.
739 }
740 \parbox[c]{3in}{
741 \includegraphics[width=2.75in]{images/col_hydro.pdf}
742 }
743
744 \subsubsection{Helix Propensity}
745
746 \parbox[c]{3.5in}{
747 The residues are coloured according to their helix propensity. The highest propensity is magenta, the lowest is green.
748 }
749 \parbox[c]{3in}{
750 \includegraphics[width=2.75in]{images/col_helix.pdf}
751 }
752
753 \subsubsection{Strand Propensity}
754
755 \parbox[c]{3.5in}{
756 The residues are coloured according to their Strand propensity. The highest propensity is Yellow, the lowest is blue.
757 }
758 \parbox[c]{3in}{
759 \includegraphics[width=2.75in]{images/col_strand.pdf}
760 }
761
762
763
764 \subsubsection{Turn Propensity}
765 \parbox[c]{3.5in}{
766 The residues are coloured according to their turn propensity. The highest propensity is red, the lowest is cyan.
767 }
768 \parbox[c]{3in}{
769 \includegraphics[width=2.75in]{images/col_turn.pdf}
770 }
771
772 \subsubsection{Buried Index}
773 \parbox[c]{3.5in}{
774 The residues are coloured according to their burial propensity. The highest propensity is blue, the lowest is green.
775 }
776 \parbox[c]{3in}{
777 \includegraphics[width=2.75in]{images/col_buried.pdf}
778 }
779  
780
781 \subsubsection{Nucleotide}
782 \parbox[c]{3.5in}{
783 Residues are coloured with four colours corresponding to the four nucleotide bases. All non ACTG residues are uncoloured. See section \ref{workingwithnuc} for further information about working with nucleic acid sequences and alignments.
784 }
785 \parbox[c]{3in}{
786 \includegraphics[width=2.75in]{images/col_nuc.pdf}
787 }
788
789
790
791 \exercise{Colouring Alignments}{ 
792 \exstep{
793 Open a sequence alignment, for example the PFAM domain PF03460. Select the alignment menu option {\sl Colour $\Rightarrow$ ClustalX}. Note the colour change. Now try all the other colour schemes in the {\sl Colour} menu. Note that some colour schemes do not colour all residues.
794 }
795 \exstep{
796 Colour the alignment using {\sl Colour  $\Rightarrow$ Blosum62}. Select a group of around 4 similar sequences. Use the context menu (right click on the group) option {\sl Selection $\Rightarrow$ Group $\Rightarrow$ Group Colour $\Rightarrow$ Blosum62} to colour the selection. Notice how some residues which were not coloured are now coloured. The calculations performed for dynamic colouring schemes like Blosum62 are based on the group being coloured, not the whole alignment (this also explains the colouring changes observed in the group selection exercise step \ref{exselectgrpcolour}).
797 }
798 \exstep{
799 Keeping the same selection as before, colour the complete alignment using {\sl Colour  $\Rightarrow$ Taylor}. Select the menu option  {\sl Colour  $\Rightarrow$ By Conservation}. Slide the selector from side to side and observe the changes in the alignment colouring in the selection and in the complete alignment. 
800 }
801 }
802
803 \subsubsection{User Defined}
804 This dialogue allows the user to create any number of named colour schemes at will. Any residue may be assigned any colour. The colour scheme can then be named. If you save the colour scheme, this name will appear on the Colour menu
805
806
807 \begin{figure}[htbp]
808 \begin{center}
809 \includegraphics[width=2.5in]{images/col_user1.pdf}
810 \includegraphics[width=2in]{images/col_user2.pdf}
811 \includegraphics[width=1.75in]{images/col_user3.pdf}
812 \caption{{\bf Creation of a user defined colour scheme.} Residue types are assigned colours (left). The profile is saved (center) and can then be accessed via the {\sl Colour} menu (right).}
813 \label{usercol}
814 \end{center}
815 \end{figure}
816
817
818 \exercise{User defined colour schemes}{
819 \exstep{Load a sequence alignment. Select the alignment menu option {\sl Colour $\Rightarrow$ User Defined}. A dialogue window will open.
820 }
821 \exstep{Click on an amino acid button, then select a colour for that amino acid. Repeat till all amino acids are coloured to your liking.
822 }
823 \exstep{ Insert a name in the appropriate field and click {\sl Save Scheme}. You will be prompted for a file name in which to save the colour scheme. The dialogue window can now be closed.
824 }
825 \exstep{
826 The new colour scheme appears in the list of colour schemes in the {\sl Colour} menu and can be selected in future Jalview sessions.
827 }
828 }
829 \r\section{Alignment formatting and graphics output}
830
831 Jalview is a WYSIWIG alignment editor. This means that for most kinds of graphics output, the layout that is seen on screen will be the same as what is output in an exported graphics file. It is therefore important to pick the right kind of display layout prior to generating figures. 
832
833 \subsection{Multiple Alignment Views}
834
835 Jalview is able to create multiple independent visualizations of the same underlying alignment - these are called {\tr Views}. Because each view displays the same underlying data, any edits performed in one view will update the alignment or annotation visible in all views.
836
837 \parbox[c]{4in}{Alignment views are created using the {\tr View $\RightArrow$ New View} option of the alignment window. This will create a new view with the same groups, alignment layout and display options as the current one. Views may be gathered (by pressing G) together as named tabs on the alignment window, or displayed simultaneously in their own window (by pressing X).}\parbox[c]{2.75in}{
838 \begin{center}\centerline{
839 \includegraphics[width=2.5in]{images/mulv_tabs.pdf}}
840 \end{center}
841 }
842
843 % JBPNote make an excercise on views ?
844
845 \subsection{Alignment layout}
846 Jalview provides two screen layout modes, unwrapped (the default) where the alignment is in one long line across the window, and wrapped, where the alignment is on multiple lines, each the width of the window. Most layout options are controlled by the Format menu option in the alignment window.
847 \subsubsection{Wrapped alignments}
848 Wrapped alignments can be toggled on and off using the {\sl Format $\Rightarrow$ Wrap} menu option (Figure \ref{wrap}). Note that the annotation lines are also wrapped. Wrapped alignments are great for publications and presentations but are of limited use when working with large numbers of sequences. Furthermore, alignment annotation (see section \ref{featannot}) cannot be interactively created or edited in wrapped mode, and selection of large regions is difficult.
849 \begin{figure}[htbp]
850 \begin{center}
851 % this view still refers to Jalview 2.2 and the menu is missing the Center Columns option
852 \parbox[c]{2in}{\includegraphics[width=2in]{images/wrap1.pdf}}
853 \parbox[c]{4in}{\includegraphics[width=4in]{images/wrap2.pdf}}
854 \caption{{\bf Wrapping the alignment}}
855 \label{wrap}
856 \end{center}
857 \end{figure}
858
859
860 \subsubsection{Fonts}
861
862 \parbox[c]{4in}{Text appearance can be modified via the {\sl Format $\Rightarrow$ Font\ldots} alignment window menu. Additionally, font size and spacing can be adjusted rapidly by clicking the middle mouse button and dragging across the alignment window.}
863 \parbox[c]{2in}{\centerline{\includegraphics[width=1.75in]{images/font.pdf}}}
864
865 \subsubsection{Numbering and annotations}
866
867 The {\sl Format} menu also provides options to control the display of numbers and annotations on sequence alignments.
868 The annotation lines which appear below the sequence alignment can be hidden by toggling the {\sl View $\Rightarrow$ Show Annotations} menu option. Additionally, each annotation line can be hidden and revealed in the same way as sequences via the context menu on the annotation name panel (Figure \ref{annot}). Annotations can be reordered by dragging the annotation line label on the annotation label panel. Placing the mouse over the top annotation label brings up a resize icon. Dragging the top annotation line label up and down alters the relative size of the sequence alignment and annotation alignment panels.
869
870 \begin{figure}
871 \begin{center}
872 \includegraphics[width=2.5in]{images/annot1.pdf}
873 \includegraphics[width=2.5in]{images/annot2.pdf}
874 \caption{{\bf Hiding Annotations} Annotations can either be hidden from the {\sl View} menu (left) or individually from the context menu (right)}
875 \label{annot}
876 \end{center}
877 \end{figure}
878
879 \exercise{Alignment Layout}{
880 \label{exscreen}
881 \exstep{Start Jalview and open the URL \textsf{http://www.jalview.org/examples/exampleFile.jar}. Select {\sl Format $\Rightarrow$ Wrap} from the alignment window menu. Experiment with the various options from the {\sl Format} menu. to adjust the ruler placement, sequence ID format and so on. }
882 \exstep{Hide all the annotation rows by selecting {\sl View $\Rightarrow$ Show Annotations} from the alignment window menu. Reveal the annotations by selecting the same menu option.} 
883 \exstep{Right click on the annotation row labels to bring up the context menu.  Select {\sl Hide This Row}. Bring up the context menu again and select {\sl Show All Hidden Rows} to reveal them}
884 \exstep{Annotations can be reordered by clicking and dragging the row to the desired position. Click on the {\sl Consensus} row and drag it upwards to just above {\sl Quality}. The rows should now be reordered. Features and annotations are covered in more detail in section \ref{featannot} below.}
885 \exstep{Move the mouse to the top left hand corner of the Secondary Structure annotation row label - a grey up/down arrow symbol should appear - when this is shown, the height of the {\sl Annotation Area} can be changed by Clicking and dragging the mouse up or down.}
886 }
887
888 \subsection{Graphical output}
889
890 \parbox[c]{4in}{Jalview allows alignments figures to be exported in three different formats, each of which is suited to a particular purpose. Image export is via the {\sl File $\Rightarrow$ Export Image $\Rightarrow$ \ldots } alignment window menu option. }
891 \parbox[c]{2in}{\centerline{\includegraphics[width=1.25in]{images/image.pdf}}}
892
893 \subsubsection{HTML}
894
895 \parbox[c]{3in}{HTML is the format used by web pages. Jalview outputs the alignment as an HTML table with all the colours and fonts as seen. Any additional annotation will also be embedded as sensitive areas on the page, such as URL links for each seuqence's ID label. This file can then be viewed directly with any web browser. Each residue is placed in an individual table cell. Unwrapped alignments will produce a very wide page.}
896 \parbox[c]{3.5in}{\centerline{\includegraphics[width=3in]{images/image_html.pdf}}}
897
898 \subsubsection{EPS}
899 \parbox[c]{3in}{EPS is Encapsulated Postscript. It is the format of choice for publication and posters as it gives the highest quality output of any of the image types. It can be scaled indefinitely so will still look good on an A0 poster. This format can be read by most good presentation and graphics packages such as Adobe Illustrator.
900 }
901 \parbox[c]{3.5in}{\centerline{\includegraphics[width=3in]{images/image_eps.pdf}} \par \centerline{Zoom Detail of EPS image.}}
902
903 \subsubsection{PNG}
904 \parbox[c]{3in}{
905 PNG is Portable Network Graphics. This output option produces an image that can be easily included in web pages and incorporated in presentations using e.g. Powerpoint or Open Office. It is a bitmap image so does not scale and is unsuitable for use on posters.
906 }
907 \parbox[c]{3.5in}{\centerline{\includegraphics[width=3in]{images/image_png.pdf}} \par \centerline{Zoom Detail of PNG image.}}
908
909 \exercise{Graphical Output}{
910 \exstep{Load the example Jalview Jar file in Exercise \ref{exscreen}. Customise it how you wish but leave it unwrapped. Select {\sl File $\Rightarrow$ Export Image $\Rightarrow$ HTML} from the alignment menu. Save the file and open it in your favourite web browser.  }
911 \exstep{Now wrap the alignment (Exercise \ref{exscreen}) and export the image to HTML again. Compare the two images. Note that the exported image matches the format displayed in the alignment window but annotations are not exported.}
912 \exstep{Export the alignment using the {\sl File $\Rightarrow$ Export Image $\Rightarrow$ PNG} menu option. Open the file in an image viewer that allows zooming (eg. Paint or Photoshop on Windows, Preview on Mac OS X) and zoom in. Notice that the image is a bitmap and it becomes pixelated very quickly. Note also that the annotation lines are included in the image.}
913 \exstep{Export the alignment using the {\sl File $\Rightarrow$ Export Image $\Rightarrow$ EPS} menu option. Open the file in a suitable program such as Ghostview or Preview (Mac OS X). Zoom in and note that the image is indefinitely scalable.}
914 }
915
916 \chapter{Analysis and Annotation}
917
918 \section{Analysis of alignments}
919 Jalview provides support for sequence analysis in two ways. A number of analytical methods are 'built-in' and run inside Jalview itself and are mostly accessed from the {\sl Calculate} alignment window menu. Computationally intensive analyses are run outside Jalview via web services - these are typically accessed via the {\sl Web Services} menu. 
920
921 This section describes the built in analyses. Web Services are described in a subsequent section.
922  
923 \subsection{PCA}
924 This calculation creates a spatial representation of the similarities within the current selection or the whole alignment if no selection has been made. After the calculation finishes, a 3D viewer displays the each sequence as a point in 3D 'similarity space'. Sets of similar sequences tend to lie near each other in this space.
925 Note: The calculation is computationally expensive, and may fail for very large sets of sequences - because the JVM has run out of memory. See the FAQ on the Jalview web site for instructions on how to increase the memory available to Jalview.
926 \subsubsection{What is PCA?}
927
928 Principal components analysis is a technique for examining the structure of complex data sets. The components are a set of dimensions formed from the measured values in the data set, and the principle component is the one with the greatest magnitude, or length. The sets of measurements that differ the most should lie at either end of this principle axis, and the other axes correspond to less extreme patterns of variation in the data set.
929 In this case, the components are generated by an eigenvector decomposition of the matrix formed from the sum of BLOSUM scores at each aligned position between each pair of sequences. The basic method is described in the 1995 paper by {\sl G. Casari, C. Sander} and {\sl A. Valencia} \footnote{{\sl Nature Structural  Biology} (1995) {\bf 2}, 171-8. \rPMID: 7749921} and implemented at the SeqSpace server at the EBI.
930
931 \subsubsection{The PCA Viewer}
932
933 PCA analysis can be launched from the {\sl Calculate $\Rightarrow$ Principle Component Analysis} menu option. PCA requires a selection containing at least 4 sequences.  A window opens containing the PCA tool (Figure \ref{PCA}). Each sequence is represented by a square, coloured by the background colour of the sequence ID label. The axes can be rotated by clicking and dragging the left mouse button and zoomed using the $\uparrow$ and $\downarrow$ keys or the scroll wheel of the mouse (if available).  A tool tip appears if the cursor is placed over a sequence. Sequences can be selected by clicking on them. [CTRL]-Click can be used to select multiple sequences. 
934 \begin{figure}[hbtp]
935 \begin{center}
936 \includegraphics[width=2in]{images/PCA1.pdf}
937 \includegraphics[width=3in]{images/PCA3.pdf}
938 \caption{{\bf PCA Analysis} }
939 \label{PCA}
940 \end{center}
941 \end{figure}
942 Labels will be shown for each sequence by toggling the {\sl View $\Rightarrow$ Show Labels} menu option, and the plot background colour changed via the {\sl View $\Rightarrow$ Background Colour..} dialog box. A graphical representation of the PCA plot can be exported as an EPS or PNG image via the {\sl File $\Rightarrow$ Save As $\Rightarrow$ \ldots } submenu.
943
944 \exercise{Principle Component Analysis}{
945 \exstep{Load the alignment at \textsf{http://www.jalview.org/examples/exampleFile.jar} and select {\sl Edit $\Rightarrow$ Undefine Groups}.
946
947 \exstep{Select the menu option {\sl Calculate $\Rightarrow$ Principle Component Analysis}. A new window will open. Move this window so that the tree, alignment and PCA viewer window are all visible. Try rotating the plot by clicking and dragging the mouse on the plot in the PCA window. Note that clicking on points in the plot will highlight them on the alignment and tree.
948 }
949 \exstep{
950 Click on the tree window. Careful selection of the tree partition location will divide the alignment into a number of groups, each of a different colour. Note how the colour of the sequence ID label matches both the colour of the partitioned tree and the points in the PCA plot.
951 }
952 }
953
954 \subsection{Trees}
955 Jalview can calculate and display trees, providing interactive tree-based grouping of sequences though a tree viewer. All trees are calculated via the {\sl Calculate $\Rightarrow$ Calculate Tree $\Rightarrow$ \ldots} submenu. Trees can be calculated from distance matrices determined from \% identity or aggregate BLOSUM 62 score using either average distance (UPGMA) or Neighbour joining algorithms. The input data for a tree calculation is either the visible portions of the current selection, or the whole alignment if no selection is present.
956
957 On calculating a tree, a new window opens (Figure \ref{trees1}) which contains the tree. Various display options can be found in the tree window {\sl View} menu, and export options in the {\sl File $\Rightarrow$ Save As} submenu. Newick format is a standard file format for trees which allows them to be exported to other programs.  Jalview can also read in external trees in Newick format via the {\sl File $\Rightarrow$ Load Associated Tree} menu option. Leaf names on imported trees will be matched to the associated alignment - unmatched leaves will still be displayed, and can be highlighted using the {\sl View $\Rightarrow$ Show Unlinked Leaves }.
958
959
960 \begin{figure}
961 \begin{center}
962 \includegraphics[width=2.5in]{images/trees1.pdf}
963 \includegraphics[width=2.5in]{images/trees2.pdf}
964 \includegraphics[width=1.25in]{images/trees4.pdf}
965 \caption{{\bf Calculating Trees} Jalview provides four built in models for calculating trees. Jalview can also load precalculated trees in Newick format (right).}
966 \label{trees1}
967 \end{center}
968 \end{figure}
969
970
971 Clicking on the tree brings up a cursor across the height of the tree. The sequences are automatically partitioned and coloured (Figure \ref{trees2}). To group them together, select the {\sl Calculate $\Rightarrow$ Sort $\Rightarrow$ By Tree Order} alignment window menu option and the correct tree. The sequences will then be sorted to group them together. The coloured background to the sequence IDs can be removed with {\sl Select $\Rightarrow$ Undefine Groups}  from the alignment window menu.
972
973 \begin{figure}
974 \begin{center}
975 \includegraphics[width=5in]{images/trees3.pdf}
976 \caption{{\bf Interactive Trees} The tree level cutoff can be used to designate groups in Jalview}
977 \label{trees2}
978 \end{center}
979 \end{figure}
980
981 %\subsubsection{Multiple Views and Input Data recovery from PCA and Tree Viewers}
982 % move to ch. 3 ?
983 %Both PCA and Tree viewers are linked analysis windows. This means that their selection and display are linked to a particular alignment, and control and reflect the selection state for a particular view.
984
985 \subsubsection{Recovering input data for a tree or PCA plot calculation}
986 \parbox[c]{4in}{
987 The {\sl File $\RightArrow$ Input Data } option will open a new alignment window containing the original data used to calculate the tree or PCA plot (if available). This function is useful when a tree has been created and then the alignment subsequently changed. 
988 } \parbox[c]{3in}{\centerline{\includegraphics[width=2.75in]{images/pca_vmenu.pdf}
989 }}
990
991 \subsubsection{Changing the associated view for a tree or PCA viewer}
992 \parbox[c]{5in}{
993 The {\sl View $\Rightarrow$ Associated View $\Rightarrow$ .. } submenu is shown when the viewer is associated with an alignment that is involved in multiple views. Selecting a different view does not affect the tree or PCA data, but will change the colouring and display of selected sequences in the display in accord with the colouring and selection state of the newly associated view. 
994 } \parbox[c]{=2in}{\centerline{ \includegraphics[width=1.3in]{images/pca_fmenu}  
995 }}
996
997
998 \exercise{Trees}{
999 \exstep{ Open the alignment at \textsf{http://www.jalview.org/tutorial/alignment.fa}. Select {\sl Calculate $\Rightarrow$ Calculate Tree $\Rightarrow$ Neighbour Joining Using BLOSUM62}. A new tree window will appear.}
1000 \exstep{Click on the tree window. A cursor will appear. Note that placing this cursor divides the tree into a number of groups by colour. Place the cursor to give about 4 groups, then select {\sl Calculate $\Rightarrow$ Sort $\Rightarrow$ By Tree Order $\Rightarrow$ Neighbour Joining Tree using BLOSUM62 from ... }. The sequences are reordered to match the order in the tree and groups are formed implicitly.}
1001 \exstep{Select {\sl Calculate $\Rightarrow$ Calculate Tree $\Rightarrow$ Neighbour Joining Using \% Identity}. A new tree window will appear. The group colouring makes it easy to see the diferences between the two trees, calculated using different methods.}
1002 \exstep{Select from sequence 2 column 60 to sequence 12 column 123. Select  {\sl Calculate $\Rightarrow$ Calculate Tree $\Rightarrow$ Neighbour Joining Using BLOSUM62}. A new tree window will appear. It can be seen that the tree contains 11 sequences. It has been coloured according to the already selected groups from the first tree and is calculated purely from the residues in the selection. 
1003 Comparing the location of individual sequences between the two trees illustrates the importance of selecting appropriate regions of the alignment for the calculation of trees. 
1004 }
1005 \exstep{Recover the input data for the tree you just calculated. Check the {\sl Edit $\Rightarrow$ Pad Gaps } option is not ticked, and insert one gap in the alignment. Now select {\sl Calculate $\Rightarrow$ Calculate Tree $\Rightarrow$ Neighbour Joining Using BLOSUM62}. 
1006
1007 A warning dialog box {\bf ``Sequence's must be aligned'' } appears because the sequences input to the tree calculation are of different lengths. }
1008
1009 \exstep{Now select {\sl Edit $\RightArrow$ Pad Gaps } and try to perform the tree calculation again - this time a new tree should appear.
1010
1011 This demonstrates the use of the {\sl Pad Gaps } editing preference, which ensures that all sequences are the same length after editing. }
1012
1013 }
1014
1015 \subsection{Tree Based Conservation Analysis}
1016 \label{treeconsanaly}
1017 \exercise{Tree Based Conservation Analysis}{
1018 \exstep{Load the PF03460 Seed alignment using the sequence fetcher. Colour it with the {\sl Taylor colourscheme}, and apply {\sl Conservation } shading. }
1019 \exstep{Build a Neighbourjoining tree using BLOSUM62 and use the sort submenu to order alignment using the calculated tree.}
1020 \exstep{Select a point on the tree to partition the alignment, and examine the variation in colouring between different groups. 
1021
1022 You may find it easier to browse the alignment by if you uncheck the {\sl Show Annotations} view option, and open the overview window to aid navigation.}
1023 \exstep{Try changing the colourscheme to BLOSUM62 (whilst ensuring that {\sl Apply Colour to All Groups} is selected)}
1024 }
1025
1026 \subsection{Redundancy Removal}
1027
1028 The redundancy removal dialog box is opened using the {\sl Edit $\Rightarrow$ Remove Redundancy\ldots} option in the alignment menu. As its menu option placement suggests, this is actually an alignment editing function, but it is convenient to describe it here. The redundancy removal dialog box presents a percentage identity slider which sets the redundancy threshold. Aligned sequences which exhibit a percentage identity greater than the current threshold are highlighted in black. The [Remove] button can then be used to eliminate these sequences from the alignment as an edit operation.
1029 \begin{figure}
1030 \begin{center}
1031 \includegraphics[width=5.5in]{images/redundancy.pdf}
1032 \end{center}
1033 \label{removeredundancydialog}
1034 \caption{The Redundancy Removal dialog box opened from the edit menu. Sequences that exceed the current \%age identity threshold and are to be removed are highlighted in black.}
1035 \end{figure}
1036
1037 \exercise{Remove redundant sequences}{
1038 \exstep{Re-use or recreate the alignment and tree which you worked with in the tree based conservation analysis exercise (exercise \ref{treeconsanaly})}
1039 \exstep{Open the Remove Redundancy dialog and adjust the threshold to 90\%. Remove the seuqences that are more than 90\% similar under this alignment.}
1040 \exstep{Select the Tree viewer's {\sl View $\Rightarrow$ Show Linked Leaves} option, and note that the removed sequences are now prefixed with a * in the tree view.}
1041 \exstep{Use the [Undo] button on the dialog to recover the sequences. Note that the * symbols disappear from the tree display.}
1042 \exstep{Experiment with the redundancy removal and observe the relationship between the percentage identity threshold and the pattern of unlinked nodes in the tree display.}
1043 }
1044
1045 \subsection{Other Calculations}
1046
1047 On loading a sequence alignment, Jalview calculates alignment quality, conservation and consensus as alignment annotations. Conservation is calculated according to Livingstone and Barton\footnote{{\sl "Protein Sequence Alignments: A Strategy for the Hierarchical Analysis of Residue Conservation." } Livingstone C.D. and Barton G.J. (1993) {\sl CABIOS } {\bf 9}, 745-756}. Consensus is the modal residue (or {\tt +} where there is an equal top residue). The inclusion of gaps in the consensus calculation can be toggled by right-clicking on the the Consensus label and selecting {\sl Ignore Gaps in Consensus} from the context menu. Quality is a measure of the inverse likelihood of unfavourable mutations in the alignment. Further details on these calculations can be found in the on-line documentation.
1048
1049 These annotations can be hidden and deleted but are only created on loading an alignment. If they are deleted then the alignment should be saved and reloaded to restore them. Jalview provides a toggle to autocalculate a consensus sequence upon editing. This is normally left selected but for large alignments can be turned off via the {\sl Calculate $\Rightarrow$ Autocalculate Consensus} menu option if the interface is too sluggish.
1050
1051 \subsubsection{Pairwise Alignments}
1052
1053 Jalview can calculate optimal pairwise alignments between arbitrary sequences via the {\sl Calculate $\Rightarrow$ Pairwise Alignments\ldots} menu option. Global alignments of all pairwise combinations of the selected sequences are performed and the results returned in a text box.
1054
1055 \begin{figure}[htbp]
1056 \begin{center}
1057 \includegraphics[width=4in]{images/pairwise.pdf}
1058 \caption{{\bf Pairwise alignment of sequences.} Pairwise alignments of three selected sequences are shown in a textbox.}
1059 \label{pairwise}
1060 \end{center}
1061 \end{figure}
1062
1063
1064 \section{Web Services}
1065 Web services are a technology which allows the Jalview application to access databases remotely and offload computationally intensive tasks to High Performacne Computing facilities {\sl via} the internet. Access to remote database resources are described in other sections. They include sequence retrieval (in section \ref{fetchseq}), database reference retrieval (in section \ref{fetchdbrefs}) and sequence feature retrieval with DAS, which is described in \ref{das}. The next few sections describe the computational analysis services available to Jalview.
1066
1067 \subsection{Remote Analysis Services}
1068 Jalview will construct a job, ask the remote server to run the job, monitor status of the job and, finally, retrieve the results of the job and display them. The Jalview user is kept informed of the progress of the job through a status window.
1069
1070 Currently, web service jobs and their status windows are not stored in Jalview Project Files\footnote{This may be rectified in future versions.}, so it is important that you do not close Jalview whilst a job is running. It is also essential that you have a continuous network connection in order to successfully use Web Services from Jalview, since it periodically checks the progress of running jobs.
1071
1072 \subsection{Multiple Sequence Alignment}
1073
1074 Sequences can be aligned using any of three algorithms: ClustalW\footnote{{\sl "CLUSTAL W: improving the sensitivity of progressive multiple sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice."} Thompson JD, Higgins DG, Gibson TJ (1994) {\sl  Nucleic Acids Research} {\bf 22}, 4673-80}, Muscle\footnote{{\sl "MUSCLE: a multiple sequence alignment method with reduced time and space complexity"} Edgar, R.C. (2004) {\sl BMC Bioinformatics} {\bf 5}, 113}  or MAFFT\footnote{{\sl "MAFFT: a novel method for rapid multiple sequence alignment based on fast Fourier transform"}  Katoh, K., Misawa, K., Kuma, K. and Miyata, T. (2002) {\sl  Nucleic Acids Research} {\bf 30}, 3059-3066.  and {\sl "MAFFT version 5: improvement in accuracy of multiple sequence alignment"} Katoh, K., Kuma, K., Toh, H. and Miyata, T. (2005) {\sl Nucleic Acids Research} {\bf 33}, 511-518.} Of these, ClustalW is the slowest but is historically widely used. Muscle is fast and probably the most accurate for smaller alignments and MAFFT is probably the best for large alignments. 
1075
1076
1077 To run an alignment web service, select the appropriate method from the {\sl Web Service $\Rightarrow$  Alignment $\Rightarrow$ \ldots} submenu (Figure \ref{webservices}). A progress window will appear giving information about the job and any errors that occur. After successful completion of the job, a new window is opened with the results, in this case an alignment.
1078
1079 \begin{figure}[htbp]
1080 \begin{center}
1081 \parbox[c]{1.5in}{\includegraphics[width=1.5in]{images/ws1.pdf}}
1082 \parbox[c]{2.5in}{\includegraphics[width=2.5in]{images/ws2.pdf}}
1083 \parbox[c]{2in}{\includegraphics[width=2in]{images/ws3.pdf}}
1084 \caption{{\bf Multiple alignment via web services} The appropriate method is selected from the menu (left), a status box appears (center), and the results appear in a new window (right)}
1085 \label{webservices}
1086 \end{center}
1087 \end{figure}
1088
1089 \subsubsection{Realignment}
1090
1091 The re-alignment option (only supported by ClustalW currently) submits the current selection to the alignment service complete with existing gaps. Use this option to align additional sequences to an existing alignment (a simple form of profile alignment). 
1092
1093 \subsubsection{Alignments of sequences including hidden regions}
1094
1095 If the view or selected region that is submitted for alignment contains hidden regions, then only the visible sequences will be submitted to the service. Furthermore, each contiguous segment of sequences will be aligned independently (resulting a number of alignment 'subjobs' appearing in the status window). Finally, the results of each subjob will be concatenated with the hidden regions in the input data prior to their display in a new window. This approach ensures that 1) hidden column boundaries in the input data are preserved in the resulting alignment - in a similar fashion to the constraint that hidden columns place on alignment editing (see section \ref{lockededits}). 2) hidden columns can be used to preserve existing parts of an alignment whilst the visible parts are locally refined. 
1096
1097 \exercise{Multiple Sequence Alignment}{
1098 \exstep{ Close all windows and open the alignment at {\sf http://www.jalview.org/tutorial/unaligned.fa}.  Select {\sl Web Service $\Rightarrow$ Alignment $\Rightarrow$ Muscle Multiple Protein Sequence Alignment}. A window will open giving the job status. After a short time, a second window will open with the results of the alignment.}
1099 \exstep{Select the first sequence set by clicking on the window and try running ClustalW and MAFFT (from the {\sl Web Services $\Rightarrow$ Alignment} menu) on the same initial alignment. Compare them and you should notice small differences.
1100 }
1101 \exstep{Select the last three sequences in the MAFFT alignment, and de-align them with {\sl Edit $\Rightarrow$ Remove All Gaps}. Press [ESC] to deselect them and then submit the view for re-alignment with ClustalW.}
1102 \exstep{Use [CTRL]-Z to recover the alignment of the last three sequences in the MAFFT alignment. Once the ClustalW re-alignment has completed, compare the results of re-alignment of the three sequences with their alignment in the original MAFFT result.}
1103 \exstep{Select columns 60 to 125 in the original MAFFT alignment and hide them. Select {\sl Web Services $\RightArrow$ Alignment $\RightArrow$ MAFFT} to submit the visible portion of the alignment to MAFFT. When the web service job pane appears, note that there are now two alignment job status panes shown in the window.}
1104 \exstep{When the MAFFT job has finished, compare the alignment of the N-terminal visible region in the result with the corresponding region of the original alignment. If you wish, select and hide a few more columns in the N-terminal region, and submit the alignment to the service again and explore the effect of local alignment on the non-homologous parts of the N-terminal region.} 
1105 }
1106
1107
1108 \subsection{Secondary Structure Prediction}
1109
1110 Secondary structure prediction is performed using the Jpred\footnote{{\sl "Jpred: A Consensus Secondary Structure Prediction Server"} Cuff, J. A., Clamp, M. E., Siddiqui, A. S., Finlay, M. and Barton, G. J. (1998) {\sl Bioinformatics} {\bf 14}, 892-893} server at the University of Dundee\footnote{http://www.compbio.dundee.ac.uk/~www-jpred/}. The behaviour of this calculation depends on the current selection: 
1111 \begin{list}{$\circ$}{}
1112 \item If nothing is selected, and the displayed sequences appear to be aligned, then a JNet prediction will be run for the first sequence in the alignment, using the current alignment. Otherwise the first sequence will be submitted for prediction. 
1113 \item If just one sequence (or a region on one sequence) has been selected, it will be submitted to the automatic JNet prediction server for homolog detection and prediction. 
1114 \item If a set of sequences are selected, and they appear to be aligned, then the alignment will be used for a Jnet prediction on the first sequence in the set (that is, the one that appears first in the alignment window).
1115 \end{list}
1116
1117 Jpred is launched in the same way as the other web services. Select {\sl Web Services $\Rightarrow$ Secondary Structure Prediction $\Rightarrow$ JNet Secondary Structure Prediction} from the alignment window menu (figure \ref{jpred}). A status window opens to inform you of the progress of the job. Upon completion, a new alignment window opens and the Jpred predictions are included as annotations. Consult the Jpred documentation for information on interpreting these results.
1118
1119 \begin{figure}[htbp]
1120 \begin{center}
1121 \includegraphics[width=2.25in]{images/jpred1.pdf}
1122 \includegraphics[width=3in]{images/jpred2.pdf}
1123 \caption{{\bf Secondary Structure Prediction} Status (left) and results (right) windows for JNet predictions. }
1124 \label{jpred}
1125 \end{center}
1126 \end{figure}
1127
1128 \subsubsection{Hidden Columns and JNet Predictions}
1129 \label{hcoljnet}
1130 Hidden columns can be used to exclude parts of a sequence or profile from the input sent to the JNet service. For instance, if a sequence is known to include a large loop insertion, hiding that section prior to submitting the JNet prediction may\footnote{This, of course, cannot be guaranteed, but the profile calculated by JNet will at least be different.} result in a more reliable secondary structure prediction either side of the insertion. Prediction results returned from the service will be mapped back onto the visible parts of the sequence, to ensure a single frame of reference is maintained in your analysis.
1131
1132 \exercise{Secondary Structure Prediction}{
1133 \label{secstrpredex}
1134 \exstep{ Open the alignment at \textsf{http://www.jalview.org/tutorial/alignment.fa}. Select the sequence {\sl FER\_MESCR} by clicking on the sequence ID. Then select {\sl Web Services $\Rightarrow$ Secondary Structure Prediction $\Rightarrow$ JNet Secondary Structure Prediction} from the alignment window menu. A status window will appear and after some time a new window with the JPred prediction will appear. Note that the number of sequences in the results window is many more than in the original alignment as JNet performs a PSI-BLAST search to expand the prediction dataset.
1135 }
1136 % TODO: check how long this takes - about 2 mins once it gets on the cluster.
1137 \exstep{
1138 Select a different sequence and perform a JNet prediction in the same way. There will probably be minor differences in the predictions.
1139 }
1140 \exstep{
1141 Select the second sequence prediction, and copy and paste it into the first prediction window. You can now compare the two predictions. Jnet secondary structure prediction annotation are examples of {\bf sequence associated alignment annotation}.
1142 % which is described in section \ref{seqassocannot} below.
1143 }
1144 \exstep{
1145 Select and hide some columns in one of the profiles that were returned from the JNet service, and then submit the profile for prediction again. 
1146 }
1147 \exstep{
1148 When you get the result, verify that the prediction has not been made for the hidden parts of the profile, and that the JPred reliability scores differ from the prediction made on the full profile. 
1149
1150 {\sl Note: you may want to keep this data for use in exercise \ref{viewannotfileex}.}
1151 }
1152 }
1153
1154
1155 \section{Features and Annotation}
1156 \label{featannot}
1157 Features and annotations are additional information that is overlaid on the sequences and the alignment. Generally speaking, annotations are associated with columns in the alignment. Features are associated with specific residues in the sequence. 
1158
1159 Annotations are rendered below the alignment, in the annotation panel, and often reflect properties of the alignment as a whole.  The conservation, consensus and quality scores are examples of dynamic annotation. As the alignment changes, these annotations will change along with it. Conversely, features are properties of the individual sequences. They do not change with the alignment, but are shown mapped on to specific residues within the alignment. 
1160
1161 Features and annotation can be interactively created, or retrieved from external data sources. DAS (the Distributed Annotation System) is the primary source of sequence features, whilst webservices like JPred (see \ref{jpred} above) can be used to analyse a given sequence or alignment and generate annotation for it.
1162
1163
1164 \subsection{Creating sequence features}
1165 Sequence features can be created by simply selecting the area in a sequence (or sequences) to form the feature and selecting {\sl Selection $\Rightarrow$ Create Sequence Feature } from the right-click context menu (Figure \ref{features}). A dialogue box allows the user to customise the feature with respect to name, group, and colour. The feature is then associated with the sequence. Moving the mouse over a residue associated with a feature brings up a tool tip listing all features associated with the residue.
1166
1167 \begin{figure}[htbp]
1168 \begin{center}
1169 \includegraphics[width=2in]{images/feature1.pdf}
1170 \includegraphics[width=2.5in]{images/feature2.pdf}
1171 \includegraphics[width=1.5in]{images/feature3.pdf}
1172 \caption{{\bf Creating sequence features.} Features can readily be created from selections via the context menu and are then displayed on the sequence. }
1173 \label{features}
1174 \end{center}
1175 \end{figure}
1176
1177 Creation of features from a selection spanning multiple sequences results in the creation of one feature per sequence. Each feature remains associated with it's own sequence.
1178
1179 \subsection{Customising feature display}
1180
1181 Feature display can be toggled on or off by selecting the {\sl View $\Rightarrow$ Show Sequence Features} menu option. When multiple features are present it can be necessary to customise the display. Jalview allows the display, colour, rendering order and transparency of features to be modified via the {\sl View $\Rightarrow$ Feature Settings\ldots} menu option. This brings up a dialogue window (Figure \ref{custfeat}) which allows the visibility of individual feature types to be selected, colours changed (by clicking on the colour of each sequence feature type) and the rendering order modified by dragging feature types to a new position in the list. Dragging the slider alters the transparency of the feature rendering.
1182
1183 \begin{figure}[htbp]
1184 \begin{center}
1185 \includegraphics[width=4in]{images/features4.pdf}
1186 \caption{{\bf Multiple sequence features.} An alignment with many sequence features overlaid }
1187 \end{center}
1188 \end{figure}
1189
1190 \begin{figure}[htbp]
1191 \begin{center}
1192 \includegraphics[width=4in]{images/features5.pdf}
1193 \caption{{\bf Customising sequence features.} Features can be recoloured, switched on or off and have the rendering order changed. }
1194 \label{custfeat}
1195 \end{center}
1196 \end{figure}
1197
1198 \exercise{Creating features}{
1199 \exstep{Open the alignment at \textsf{http://www.jalview.org/tutorial/alignment.fa}. We know that the Cysteine residues at columns 97, 102, 105 and 135 are involved in iron binding so we will create them as features. Navigate to column 97, sequence 1. Select the entire column by clicking in the ruler bar. Then right-click on the selection to bring up the context menu and select {\sl Selection $\Rightarrow$ Create Sequence Feature}. A dialogue box will appear.
1200 }
1201 \exstep{
1202 Enter a suitable Sequence Feature Name  (e.g. "Iron binding site") in the appropriate box. Click on the Feature Colour bar to change the colour if desired, add a short description ("One of four Iron binding Cysteines") and press OK. The features will then appear on the sequences.
1203 }
1204 \exstep{Roll the mouse cursor over the new features. Note that the position given in the tool tip is the residue number, not the column number.  To demonstrate that there is one feature per sequence, clear all selections by pressing [ESC] then insert a gap in sequence 3 at position 95. Roll the mouse over the features and you will see that the feature has moved with the sequence. Delete the gap you created.
1205 }
1206 \exstep{
1207 Add a similar feature to column 102. When the feature dialogue box appears, clicking the Sequence Feature Name box brings up a list of previously described features. Using the same Sequence Feature Name allows the features to be grouped.}
1208 \exstep{Select {\sl View $\Rightarrow$ Feature Settings\ldots} from the alignment window menu. The Sequence Feature Settings window will appear. Move this so that you can see the features you have just created. Click the check box for "Iron binding site"  under {\sl Display} and note that display of this feature type is now turned off. Click it again and note that the features are now displayed. Close the sequence feature settings box by clicking {\sl OK} or {\sl Cancel}.}
1209 }
1210
1211 \subsection{Creating user defined annotation}
1212
1213 Annotations are properties that apply to the alignment as a whole and are visualised on rows in the annotation panel.
1214 To create a new annotation row, right click on the annotation label panel and select the {\sl Add New Row} menu option (Figure \ref{newannotrow}). A dialogue box appears. Enter the label to use for this row and a new row will appear.
1215
1216 \begin{figure}[htbp]
1217 \begin{center}
1218 \includegraphics[width=1.3in]{images/annots1.pdf}
1219 \includegraphics[width=2in]{images/annots2.pdf}
1220 \caption{{\bf Creating a new annotation row.} Annotation rows can be reordered by dragging them to the desired place.}
1221 \label{newannotrow}
1222 \end{center}
1223 \end{figure}
1224
1225 To create a new annotation, first select all the positions to be annotated on the appropriate row. Right-clicking on this selection brings up the context menu which allows the insertion of graphics for secondary structure ({\sl Helix} or {\sl Sheet}), text {\sl Label} and the colour in which to present the annotation (Figure \ref{newannot}). On selecting {\sl Label} a dialogue box will appear, requesting the text to place at that position. After the text is entered, the selection can be removed and the annotation becomes clearly visible\footnote{When annotating a block of positions, the text can be partly obscured by the selection highlight. Pressing the  [ESC] key clears the selection and the label is then visible.}. Annotations can be coloured or deleted as desired.
1226
1227 \begin{figure}[htbp]
1228 \begin{center}
1229 \includegraphics[width=2in]{images/annots3.pdf}
1230 \includegraphics[width=2in]{images/annots4.pdf}
1231 \includegraphics[width=2in]{images/annots5.pdf}
1232 \caption{{\bf Creating a new annotation.} Annotations are created from a selection on the annotation row and can be coloured as desired.}
1233 \label{newannot}
1234 \end{center}
1235 \end{figure}
1236
1237 \exercise{Annotating alignments}{
1238 \exstep{Load the alignment at \textsf{http://www.jalview.org/tutorial/alignment.fa}. Right-click on the annotation label for {\sl Conservation} to bring up the context menu and select {\sl Add New Row}. A dialogue box will appear asking for  {\sl Label for annotation}. Enter "Iron binding site" and click {\sl OK}. A new, empty, row appears.
1239 }
1240 \exstep{
1241 Navigate to column 97. Select column 97 on the new annotation row. Right click on the selection and select {\sl Label} from the context menu. Enter "Fe" in the box and click {\sl OK}. Right-click on the selection again and select {\sl Colour}. Choose a colour from the colour chooser dialogue and click {\sl OK}. Press [ESC] to remove the selection.
1242 }
1243 \exstep{ Select columns 70-77 on the annotation row. Right-click and choose {\sl Sheet} from the context menu. You will be prompted for a label. Enter "B" and press OK. A new line showing the sheet as an arrow appears. The colour of the label can be changed but not the colour of the sheet arrow. 
1244 }
1245 \exstep{Right click on the annotation row that you just created.  Select {\sl Export Annotation} and, in the {\bf Export Annotation} dialog box that will open, select the Jalview format and click the [To Textbox] button. 
1246
1247 The format for this file is given in the Jalview help. Press [F1] to open it, and find the ``Annotations File Format'' entry in the ``Alignment Annotations'' section of the contents pane. }
1248
1249 \exstep{Export the file to a text editor and edit the file to change the name of the annotation row. Save the file and drag it onto the alignment view.}
1250 \exstep{Try to add an additional helix somewhere along the row by editing the file and re-importing it.
1251 {\sl Hint: Use the {\bf Export Annotation} function to view what helix annotation looks like in a jalview annotation file.}}
1252 \exstep{Use the {\sl Alignment Window $\Rightarrow$ File $\Rightarrow$ Export Annotation..} function to export all the alignment's annotation to a file.}
1253 \exstep{Open the exported annotation in a text editor, and use the {\bf Annotation File Format} documentation to modify the style of the Conservation, Consensus and Quality annotation rows so they appear as several lines on a single line graph.
1254 {\sl Hint: You need to change the style of annotation row in the first field of the annotation row entry in the file, and create an annotation row grouping to overlay the three quantitative annotation rows.}
1255 }
1256 \exstep{ \label{viewannotfileex} Recover or recreate the secondary structure prediction that you made in exercise \ref{secstrpredex}. Use the {\sl File $\Rightarrow$ Export Annotation} function to view the jnet secondary structure prediction annotation row. Note the {\bf SEQUENCE\_REF} statements surrounding the row specifying the sequence association for the annotation. }
1257 }
1258
1259 \section{Importing features from databases}
1260
1261 Jalview supports feature retrieval from public databases either directly or {\sl via} the Distributed Annotation System (DAS\footnote{http://www.biodas.org/}). It includes built in parsers for Uniprot and EMBL records retrieved from the EBI. Sequences retrieved from these sources using the sequence fetcher (see section \ref{fetchseq}) will already posess features. 
1262
1263 \subsection{Sequence Database Reference Retrieval}
1264 \label{fetchdbrefs}
1265 Jalview maintains a list of external database references for each sequence in an alignment. These are listed in a tooltip when the mouse is moved over the sequence ID. Sequences retrieved using the sequence fetcher will always have at least one database reference, but alignments imported from a file, or retrieved from alignment datasources like PFAM, generally have no database references.
1266
1267 \subsubsection{Database References and Sequence Coordinate Systems}
1268
1269 Jalview displays features in the local sequence's coordinate system which is given by its 'start' and 'end'. Any sequence features on the sequence will be rendered relative to the sequence's start position. If the start/end positions do not match the coordinate system from which the features were defined, then the features will be displayed incorrectly. 
1270
1271 \subsubsection{Automatic retrieval of a sequence's database references}
1272 Jalview includes a function to automatically verify and update each sequence's start and end numbering against any of the sequence databases that the {\sl Sequence Fetcher} has access to. This function is accessed by selecting {\sl Webservices $\Rightarrow$ Fetch DB References} from the Alignment window. When selected, Jalview will use the ID string from each sequence in the alignment or in the currently selected set to retrieve records from the external source. Any sequences that are retrieved are matched against the local sequence, and if the local sequence is found to be a sub-sequence of the retrieved sequence then the local sequence's start/end numbering is updated.  A new database reference mapping is created mapping the local sequence to the external database, and the local sequence inherits any additional annotation retrieved from the database sequence. 
1273
1274 The database retrieval process terminates when a valid mapping is found for a sequence, or if all database queries failed to retrieve a matching sequence. 
1275
1276 \exercise{Retrieving Database References}{
1277 \exstep{Load the example alignment at http://www.jalview.org/tutorial/alignment.fa}
1278 \exstep{Move the mouse over the sequence IDs to verify there are no database references for the sequences.}
1279 \exstep{Use the {\sl Webservices $\Rightarrow$ Fetch DB References} menu option to retrieve database IDs for the sequences.}
1280 \exstep{Examine the tooltips for each sequence in the alignment as the retrieval progresses - note the appearance of new database references.}
1281 }
1282
1283 \subsection{Retrieving Features {\sl via} DAS}
1284 Jalview includes a client to retrieve features from DAS annotation servers. To retrieve features, select {\sl View $\Rightarrow$ Feature Settings\ldots} from the alignment window menu. Select the {\sl DAS Settings} tab in the Feature Settings Window (Figure \ref{das}). A list of DAS sources compiled from the currently configured DAS registry\footnote{By default, this will be the major public DAS server registry maintained by the Sanger Institute: http://www.dasregistry.org} is shown in the left hand pane. Highlighting an entry on the left brings up information about that source in the right hand panel.
1285
1286 \begin{figure}[htbp]
1287 \begin{center}
1288 \includegraphics[width=2.5in]{images/das1.pdf}
1289 \includegraphics[width=2.5in]{images/das2.pdf}
1290 \caption{{\bf Retrieving DAS annotations.} DAS features are retrieved using the {\sl DAS Settings} tab (left) and their display customised using the {\sl Feature Settings} tab (right).}
1291 \label{das}
1292 \end{center}
1293 \end{figure}
1294
1295
1296
1297 Select appropriate DAS sources as required then click on {\sl Fetch DAS Features}. If you know of additional sources not listed in the by the configured registry, then you may add them with the {\sl Add Local Source} button. Use the {\sl Authority},{\sl Type}, and {\sl Label} filters to restrict the list of sources to just those that will return features for the sequences in the alignment.
1298
1299 Following DAS feature retrieval, the {\sl Feature Settings} panel takes on a slightly different appearance (Figure \ref{das} (right)). Each data source is listed and groups of features from one data source can be selected/deselected by checking the labeled box at the top of the panel.
1300
1301
1302 \subsubsection{The Fetch Uniprot IDs dialog box}
1303 \label{discoveruniprotids}
1304 If any sources are selected which refer to Uniprot coordinates as their reference system, then you may be asked if you wish to retrieve Uniprot IDs for your sequence. Pressing [OK] instructs Jalview to verify the sequences against Uniprot records retrieved using the sequence's ID string. This operates in much the same way as the {\sl Web Services $\Rightarrow$ Fetch Database References } function described in section \ref{fetchdbrefs}. If a sequence is verified, then the start/end numbering will be adjusted to match the Uniprot record to ensure that features retrieved from the DAS source are rendered at the correct position. 
1305
1306 \subsubsection{Rate of feature retrieval}
1307 Feature retrieval can take some time if a large number of sources is selected and if the alignment contains a large number of sequences. This is because Jalview only queries a particular DAS source with one sequence at a time, to avoid overloading it.  As features are retrieved, they are immediately added to the current alignment view. The retrieved features are shown on the sequence and can be customised as described previously.
1308
1309
1310 \exercise{Retrieving features with DAS}{
1311 \exstep{Load the alignment at \textsf{http://www.jalview.org/tutorial/alignment.fa}.  Select {\sl View $\Rightarrow$ Sequence Features\ldots} from the alignment window menu. Select the {\sl DAS Settings} tab. A long list of available DAS sources is listed. Select a small number, eg Uniprot, DSSP, signalP and netoglyc. Click {\sl OK}. A window may prompt whether you wish Jalview to map the sequence IDs onto Uniprot IDs. Click {\sl Yes}. Jalview will start retrieving features. As features become available they will be mapped onto the alignment.
1312 }
1313 \exstep{If Jalview is taking too long to retrieve features, the process can be cancelled with the {\sl Cancel Fetch} button. Rolling the mouse cursor over the sequences reveals a large number of features annotated in the tool tip. Close the Feature Settings window.
1314 }
1315 \exstep{Move the mouse over the sequence ID panel. Non-positional features such as literature references and protein localisation predictions are given in the tooltip, below any database cross references associated with the sequence.}
1316 \exstep{Search through the alignment to find a feature with a link symbol next to it. Right click to bring up the alignment view popup menu, and find a corresponding entry in the {\sl Link } sub menu. }
1317 % TODO this doesn't work ! \includegraphics[width=.3in]{images/link.pdf}
1318
1319 \exstep{
1320 Select {\sl View $\Rightarrow$ Feature Settings\ldots} to reopen the Feature Settings window. All the loaded feature types should now be displayed. Those at the top of the list sit on top of and obscure those below. Move the feature settings window so that the alignment is visible and uncheck some of the feature types by clicking the tick box in the display column.. Observe how the alignment display changes. Note that unselected feature types do not appear in the tool tip.
1321 }
1322 \exstep{Reorder the features by dragging feature types up and down the order in the Feature Settings panel. e.g. Click on {\sl CHAIN} then move the mouse downwards to drag it below {\sl DOMAIN}. Note that {\sl DOMAIN} is now shown on top of {\sl CHAIN} in the alignment window. Drag {\sl METAL} to the top of the list. Observe how the cysteine residues are now highlighted as they have a {\sl METAL} feature associated with them.
1323 }
1324
1325 \exstep{Press the {\sl Optimise Order} button. The features will be ordered according to increasing length, placing features that annotate shorter regions of sequence higher on the display stack.}
1326
1327 \exstep{Select {\sl File $\Rightarrow$ Export Features} from the Alignment window. You can choose to export the retrieved features as a GFF file, or Jalview's own Features format. 
1328 % TODO: describe working with features files and GFF
1329 }
1330 }
1331 \subsection{Sequence Feature File Formats}
1332
1333 Jalview supports both GFF and its own Jalview Features file format for the import of sequence annotation. Features and alignment annotation are also extracted from other formats such as Stockholm, and AMSA. URL links may also be attached to features. See the online documentation for more details of the capabilities of the jalview features file.
1334
1335 \section{Working with structures}
1336 Jalview provides integration between protein sequences and protein structures by providing a linked view of structures associated with protein sequences in the alignment. The Java based GPL molecular viewer Jmol\footnote{see the Jmol homepage www.jmol.org for more information.} is incorporated, enabling sophisticated molecular visualization to be prepared and investigated alongside analysis of associated sequences. \footnote{Earlier versions of Jalview included MCView - a simple main chain structure viewer. Structures are visualised as an alpha carbon trace and can be viewed, rotated and coloured in a structure viewer and the results interpreted on a sequence alignment.}
1337
1338 PDB format files can be imported directly or structures can be retrieved from the the Macromolecular Structure Database (MSD) using the {\sl Sequence Fetcher}.
1339
1340 \subsection{Automatic association of PDB structures with sequences}
1341 Jalview can automatically determine which structures are associated with a sequence, if that sequence has an ID from a public database such as Uniprot. Right-click on any sequence ID and select {\sl $<$Sequence ID$>$ $\Rightarrow$ Associate Structure with Sequence $\Rightarrow$ Discover PDB IDs } from the context menu (where {\sl $<$Sequence ID$>$} is the ID of the sequence on which you clicked) (Figure \ref{auto}). Jalview will attempt to associate the sequence with a Uniprot sequence and from there discover any associated PDB structures. This takes a few seconds and applies to all sequences in the alignment which have valid Uniprot IDs. On moving the cursor over the sequence ID the tool tip now shows the Uniprot ID and any associated PDB structures. 
1342
1343 \begin{figure}[htbp]
1344 \begin{center}
1345 %TODO fix formatting
1346 \parbox{1.5in}{
1347 {\centering 
1348 \begin{center}
1349 \includegraphics[width=1.5in]{images/auto1.pdf}
1350 \end{center}}
1351 } \parbox{3.25in}{
1352 {\centering 
1353 \begin{center}
1354 \includegraphics[scale=0.5]{images/auto2.pdf}
1355 \end{center}
1356 }
1357 } \parbox{1.5in}{
1358 {\centering 
1359 \begin{center} 
1360 \includegraphics[width=1.5in]{images/auto3.pdf}
1361 \end{center}
1362 }
1363 }
1364
1365 \caption{{\bf Automatic PDB ID discovery.} The tooltip (left) indicates that no PDB structure has been associated with the sequence. After PDB ID discovery (center) the tool tip now indicates the Uniprot ID and any associated PDB structures (right)}
1366 \label{auto}
1367 \end{center}
1368 \end{figure}
1369
1370 \subsection{Viewing Protein Structures}
1371 The structure viewer can be launched through the sequence ID context menu. Select {\sl Structure $\Rightarrow$ View PDB entry $\Rightarrow$ $<$PDB ID$>$}. The structure will be downloaded or loaded from the local file system, and shown as a ribbon diagram coloured according to the associated sequence in the current alignment view (Figure \ref{structure} (right)). The structure can be rotated by clicking and dragging in the structure window. The structure can be zoomed using the mouse scroll wheel (if available).  Moving the mouse cursor over the sequence to which the structure is linked in the alignment panel highlights the respective residue by showing its sidechain. Moving the cursor over the structure shows a tooltip and highlights the corresponding residue in the alignment.
1372
1373 \begin{figure}[htbp]
1374 \begin{center}
1375 \parbox{3in}{
1376 {\centering 
1377 \begin{center}
1378 \includegraphics[scale=0.5]{images/structure1.pdf}
1379 \end{center}
1380 }
1381 }
1382 \parbox{3.2in}{
1383 {\centering 
1384 \begin{center}
1385 \includegraphics[width=3in]{images/structure2.pdf}
1386 \end{center}
1387 }
1388 }
1389 \caption{{\bf Structure visualisation} The structure viewer is launched from the sequence ID context menu (left) and allows the structure to be visualised using the embedded Jmol molecular viewer (right). }
1390 \label{structure}
1391 \end{center}
1392 \end{figure}
1393
1394 \subsubsection{Customising structure display}
1395
1396 Structure display can be modified using the {\sl Colour} and {\sl View} menus in the structure viewer. The background colour can be modified by selecting the {\sl Colours $\Rightarrow$ Background Colour\ldots} option.
1397
1398 By default, the structure will be coloured in the same way as the sequence in the associated alignment view. The structure can be coloured independently of the sequence by selecting an appropriate colour scheme from the {\sl Colours} menu. It can be coloured according to the alignment using the {\sl Colours $\Rightarrow$ By Sequence } option. The image in the structure viewer can be output to EPS or PNG format via the {\sl File $\Rightarrow$ Save As $\Rightarrow$ \ldots} submenu. The mapping between the structure and the sequence (How well and which parts of the  structure relate to the sequence) can be viewed with the {\sl File $\Rightarrow$ View Mapping} menu option.  
1399
1400 \subsubsection{Using the Jmol visualization interface }
1401
1402 Jmol has a comprehensive set of selection and visualization functions that are accessed from the Jmol popup menu (by right-clicking in the Jmol window or by clicking the Jmol logo). Molecule colour and rendering style can be manipulated, and distance measurements and molecular surfaces can be added to the view. It also has its own Rasmol\footnote{see www.rasmol.org}-like scripting language, and this is used by Jalview to store the state of a Jmol visualization within Jalview archives, in addition to the PDB data file originally loaded or retrieved by Jalview. To access the Jmol scripting environment directly, use the {\sl Jmol $\Rightarrow$ Console} menu option.
1403
1404
1405 \exercise{Viewing Structures}{
1406 \exstep{Load the alignment at \textsf{http://www.jalview.org/examples/exampleFile.jar}. Right-click on the sequence ID label for any of the sequences (e.g. {\sl FER1\_SPIOL}) to bring up the context menu. Select {\sl FER1\_SPIOL $\Rightarrow$ Associate Structure with Sequence $\Rightarrow$ Discover PDB ids}. Jalview will now attempt to find PDB structures for the sequences in the alignment.
1407 }
1408 \exstep{
1409 Right-click on the sequence ID for {\sl FER1\_SPIOL}. Select { \sl FER1\_SPIOL $\Rightarrow$ View PDB Entry: 1A70} A structure viewing window appears. Rotate the molecule by clicking and dragging in the structure viewing box. Zoom with the mouse scroll wheel.
1410 }
1411 \exstep{Roll the mouse cursor along the {\sl FER1\_SPIOL} sequence in the alignment. Note that if a residue in the sequence maps to one in the structure, a label will appear next to that residue in the structure viewer. Move the mouse over the structure. Placing the mouse over a part of the structure will bring up a tool tip indicating the name and number of that residue. The corresponding residue in the sequence is highlighted in black. Clicking the alpha carbon toggles the highlight and residue label on and off. Try this by clicking on a set of three or four adjacent residues so that the labels are persistent, then finding where they are in the sequence.
1412 }
1413 \exstep{Select {\sl Colours $\Rightarrow$ Background Colour\ldots} from the structure viewer menu and choose a suitable colour. Press {\sl OK} to apply this. Select {\sl File $\Rightarrow$ Save As $\Rightarrow$ PNG} and save the image. View this with your web browser.
1414 }
1415 \exstep{Select {\sl File $\Rightarrow$ View Mapping} from the structure viewer menu. A new window opens showing the residue by residue alignment between the sequence and the structure.} 
1416
1417 \exstep{Select {\sl File $\Rightarrow$ Save $\Rightarrow$ PDB file} and choose a new filename to save the PDB file. Once the file is saved, open the location in your file browser (or explorer window) and drag the PDB file that you just saved on to the Jalview desktop (or load it from the {\sl Jalview Desktop $\Rightarrow$ Input Alignment $\Rightarrow$ From File } menu). Verify that you can open and view the associated structure from the sequence ID pop-up menu's {\sl Structure } submenu in the new alignment window.}
1418
1419 \exstep{Right click on the structure to bring up the Jmol window. Explore the menu options. Try to change the style of molecular display - by first using the {\sl Jmol $\Rightarrow$ Select $\Rightarrow$ all} command, and then the {\sl Jmol $\Rightarrow$ Style $\Rightarrow$ Scheme $\Rightarrow$ Ball and stick} command.}
1420 \exstep{Use the {\sl File $\Rightarrow$ Save As .. } function to save the alignment as a Jalview Project. Now close the alignment and the structure view, and load the project file you just saved.
1421
1422 Verify that the Jmol display is as it was when you just saved the file.}
1423 }
1424
1425 \section{Working with DNA}
1426 \label{workingwithnuc}
1427 Jalview was originally developed for the analysis of protein sequences, but now includes some specific features for working with nucleic acid sequences and alignments. Nucleotide sequences and alignments are recognised based on the presence the nucleotide symbols [ACGT] of greater than 85\% in the sequences. Built in codon-translation tables can be used to translate ORFs into peptides for further analysis. EMBL records retrieved {\sl via} the sequence fetcher (see section \ref{fetchseq}) are also parsed in order to identify codon regions and extract peptide products. 
1428 Furthermore, Jalview records mappings between protein sequences that are derived from regions of a nucleotide sequence. Mappings are used to to transfer annotation between nucleic acid and protein sequences, and to dynamically highlight regions in one sequence that correspond to the position of the mouse pointer in another.
1429
1430 \subsection{Alignment and Colouring}
1431
1432 Jalview provides a simple colourscheme for DNA bases, but does not apply any specific conservation or substitution score model for the shading of nucleotide alignments. However, pairwise alignments performed using the {\sl Alignment Window $\Rightarrow$ Calculations $\Rightarrow$ Pairwise Alignment \ldots} option will utilise an identity score matrix to calculate alignment score when alignment two nucleotide sequences. 
1433
1434 \subsubsection{Aligning Nucleic Acid Sequences}
1435
1436 Jalview only has limited knowledge of the capabilities of the programs that are made available to it {\sl via} web services. In particular, only the ClustalW and MAFFT programs will successfuly recognise and align nucleic acid sequences. MAFFT will also choose an appropriate parameter model. Whilst Muscle may appear to align DNA, it simply treats the base symbols as amino-acids, often leading to a poor quality alignment. Furthermore, it will almost certainly fail to align RNA containing Uracil bases, since 'U' is not a valid one-letter amino acid code.
1437
1438 \subsection{Translate cDNA}
1439
1440 The {\sl Calculations $\Leftarrow$ Translate cDNA} function in the alignment window is only available when working with a nucleic acid alignment. It uses the standard codon translation table given in the online help to translate a nucleotide alignment, or the currently selected region, into a set of aligned peptide sequences. Any features or annotation present on the nucleotide alignment will also be translated, allowing DNA alignment analysis results to be transferred on to peptide products for further investigation.
1441
1442 \subsection{Linked DNA and Protein Views}
1443
1444 \parbox{3.5in}{
1445 Views of alignments involving DNA sequences are linked to views of alignments containing their peptide products in a similar way to views of protein sequences and views of their associated structures. Peptides translated from cDNA and extracted from EMBL records for DNA contigs are linked to their 'parent' coding regions. Mousing over a region of the peptide highlights codons in views showing the original coding region.
1446 }\parbox{3in}{
1447 \begin{center}
1448 %\begin{figure}[htbp]
1449
1450 \includegraphics[width=2.8in]{images/cdnatranslinkedwin.pdf}
1451
1452 %\caption{{\bf Linked DNA and Protein Views.} }
1453 %\end{figure}
1454 \end{center}
1455 }
1456
1457
1458 \subsection{Coding regions from EMBL records}
1459
1460 Many EMBL records that can be retrieved from the sequence fetcher contain exons. Coding regions will be marked as features on the EMBL nucleotide sequence, and Uniprot database cross references will be listed in the tooltip displayed when the mouse hovers over the sequence ID. Uniprot database cross references extracted from EMBL records are sequence cross references, and associate a Uniprot sequence's coordinate system with the coding regions annotated on the EMBL sequence. Jalview utilises cross-reference information in two ways.
1461 \subsubsection{Retrieval of Protein or DNA Cross References}
1462 The {\sl Calculations $\Rightarrow$ Get Cross References } function is only available when Jalview recognises that there are protein/DNA cross-references present on sequences in the alignment. When selected, it retrieves the cross references from the alignment's dataset (a set of sequence and annotation metadata shared between alignments) or using the sequence database fetcher. This function can be used for EMBL sequences containing coding regions to open the Uniprot protein products in a new alignment window. The new alignment window that is opened to show the protein products will also allow dynamic highlighting of codon positions in the EMBL record for each residue in the product(s).
1463
1464 \subsubsection{Retrieval of protein DAS features on coding regions}
1465
1466 The Uniprot cross-references derived from EMBL records can be used by Jalview to visualize protein sequence features directly on nucleotide alignments. This is because the database cross references include the sequence coordinate mapping information to correspond regions on the protein sequence with that of the nucleotide contig. Jalview will use the Uniprot accessions associated with the sequence to retrieve features, and then map them onto the nucleotide sequence's coordinate system using the coding region location.
1467
1468 \begin{figure}[htbp]
1469 \begin{center}
1470 \label{dnadasfeatures}
1471 \includegraphics[width=5in]{images/dnadasfeatures.pdf}
1472
1473 \caption{Uniprot and PDB sum features retrieved {\sl via} DAS and mapped onto coding regions of EMBL record V00488}
1474
1475 \end{center}
1476 \end{figure}
1477
1478 \exercise{Visualizing protein features on coding regions}
1479 {
1480 \exstep{Use the sequence fetcher to retrieve EMBL record V00488.}
1481 \exstep{Ensure that {\sl View $\Rightarrow$ Show Sequence Features} is checked and change the alignment view format to Wrapped mode so the distinct exons can be seen.}
1482 \exstep{Open the DAS sequence feature fetcher window and fetch features for V00488 the Uniprot reference server, and any additional servers that work with the Uniprot coordinate system.}
1483 \exstep{Mouse over the features retrieved, note that they have been mapped onto the coding regions, and in some cases broken into several parts to cover the distinct exons.}
1484 \exstep{Open a new alignment view containing the Uniprot protein product with {\sl Calculations $\Rightarrow$ Get Cross References $\Rightarrow$ Uniprot } and examine the database references and sequence features. Experiment with the interactive highlighting of codon position for each residue.
1485 }
1486 }
1487
1488 % \chapter{Advanced Jalview}
1489
1490 % \section{Customising Jalview}
1491 % \subsection{Setting preferences}
1492
1493 % The Jalview Desktop stores configuration and history information in a file stored in the users home directory, called '.jalview\_properties'. Many of the options stored in this file are presented in the {\sl Desktop $\Rightarrow$ Tools $\Rightarrow$ Preferences\ldots} dialog. These preferences include default settings for : {\bf Visual} layout settings for alignment views and controlling the display of the default alignment, {\bf Connection} preferences such as the standard set of URL paths that are available from the links menu and the URL which is opened when a Sequence's ID is double clicked, {\bf Editing} settings like {\sl Pad Gaps} and autocalculation of consensus, {\bf Output} settings control the degree of meta-information written in alignment files and mode of EPS figure generation, and finally the {\bf Das Settings} which allows the default DAS sources to be configured. 
1494
1495 % \subsection{Adding your own URL links}
1496
1497 % \subsection{Working with Databases and Database Cross References}
1498 % \label{getcrossrefs}
1499
1500 % {\sl Calculations $\Rightarrow$ Get Cross References }
1501
1502 % \section{Jalview IO Interface}
1503 % \subsection{Multiple views}
1504 % \subsection{Annotation files}
1505 % \subsection{Feature files}
1506 % \subsection{Moving sequence associated annotation}
1507 % \subsection{Propagating features}
1508 % \section{Structures}
1509 % \subsection{Working with Modeller files}
1510 % \subsection{Using local PDB files}
1511 % \section{Pairwise alignments}
1512 \r \end{document}