b5cb1c5484c011c7979e178d20e7a55d69fe0c77
[jalview.git] / wiki / PhyloBioRuby.wiki
1 #summary Tutorial for multiple sequence alignments and phylogenetic methods in BioRuby -- under development!
2
3
4
5 = Introduction =
6
7 Tutorial for multiple sequence alignments and phylogenetic methods in !BioRuby -- under development!
8
9 Author: [http://www.cmzmasek.net/ Christian M Zmasek], Sanford-Burnham Medical Research Institute
10
11  
12
13 Copyright (C) 2011 Christian M Zmasek
14
15
16 = Multiple Sequence Alignments =
17
18
19 == Multiple Sequence Alignment Input and Output ==
20
21 === Reading in a Multiple Sequence Alignment from a File ===
22
23 Reading in a clustalw formatted multiple sequence alignment:
24
25 {{{
26 #!/usr/bin/env ruby
27 require 'bio'
28
29 # Reads in a clustalw formatted multiple sequence alignment
30 # from a file named "infile_clustalw.aln" and stores it in 'report'.
31 report = Bio::ClustalW::Report.new(File.read('infile_clustalw.aln'))
32
33 # Accesses the actual alignment.
34 align = report.alignment
35
36 # Goes through all sequences in 'align' and prints the
37 # actual molecular sequence.
38 align.each do |entry|
39   puts entry.seq
40 end
41 }}}
42
43  
44
45 === Writing a Multiple Sequence Alignment to a File ===
46
47 Writing a multiple sequence alignment in fasta format:
48
49 {{{
50 #!/usr/bin/env ruby
51 require 'bio'
52
53 # Creates a new file named "outfile.fasta" and writes
54 # multiple sequence alignment 'align' to it in fasta format.
55 File.open('outfile.fasta', 'w') do |f|
56   f.write(align.output(:fasta))
57 end
58 }}}
59
60
61 Writing a multiple sequence alignment in clustalw format:
62
63 {{{
64 #!/usr/bin/env ruby
65 require 'bio'
66
67 # Creates a new file named "outfile.aln" and writes
68 # multiple sequence alignment 'align' to it in clustal format.
69 File.open('outfile.aln', 'w') do |f|
70   f.write(align.output(:clustal))
71 end
72 }}}
73
74
75 == Calculating Multiple Sequence Alignments ==
76
77 !BioRuby can be used to execute a variety of multiple sequence alignment
78 programs (such as [http://mafft.cbrc.jp/alignment/software/ MAFFT], [http://probcons.stanford.edu/ Probcons], [http://www.clustal.org/ ClustalW], [http://www.drive5.com/muscle/ Muscle], and [http://www.tcoffee.org/Projects_home_page/t_coffee_home_page.html T-Coffee]). 
79 In the following, examples for using the MAFFT and Muscle are shown.
80
81
82 === MAFFT ===
83
84 The following example uses the MAFFT program to align four sequences
85 and then prints the result to the screen.
86 Please note that if the path to the MAFFT executable is properly set `mafft=Bio::MAFFT.new(options)` can be used instead of explicitly indicating the path as in the example. 
87
88 {{{
89 #!/usr/bin/env ruby
90 require 'bio'
91
92 # 'seqs' is either an array of sequences or a multiple sequence 
93 # alignment. In general this is read in from a file as described in ?.
94 # For the purpose of this tutorial, it is generated in code.
95 seqs = ["KMLFGVVFFFGG",
96         "LMGGHHF",
97         "GKKKKGHHHGHRRRGR",
98         "KKKKGHHHGHRRRGR"] 
99
100
101 # Calculates the alignment using the MAFFT program on the local
102 # machine with options '--maxiterate 1000 --localpair'
103 # and stores the result in 'report'.
104 options = ['--maxiterate', '1000', '--localpair']
105 mafft = Bio::MAFFT.new('path/to/mafft', options)
106 report = mafft.query_align(seqs)
107
108 # Accesses the actual alignment.
109 align = report.alignment
110
111 # Prints each sequence to the console.
112 align.each { |s| puts s.to_s }
113
114 }}}
115
116 References:
117
118  * Katoh, Toh (2008) "Recent developments in the MAFFT multiple sequence alignment program" Briefings in Bioinformatics 9:286-298 
119
120  * Katoh, Toh 2010 (2010) "Parallelization of the MAFFT multiple sequence alignment program" Bioinformatics 26:1899-1900 
121
122
123
124 === Muscle ===
125
126 {{{
127 #!/usr/bin/env ruby
128 require 'bio'
129
130 # 'seqs' is either an array of sequences or a multiple sequence 
131 # alignment. In general this is read in from a file as described in ?.
132 # For the purpose of this tutorial, it is generated in code.
133 seqs = ["KMLFGVVFFFGG",
134         "LMGGHHF",
135         "GKKKKGHHHGHRRRGR",
136         "KKKKGHHHGHRRRGR"] 
137
138 # Calculates the alignment using the Muscle program on the local
139 # machine with options '-quiet -maxiters 64'
140 # and stores the result in 'report'.
141 options = ['-quiet', '-maxiters', '64']
142 muscle = Bio::Muscle.new('path/to/muscle', options)
143 report = muscle.query_align(seqs)
144
145 # Accesses the actual alignment.
146 align = report.alignment
147
148 # Prints each sequence to the console.
149 align.each { |s| puts s.to_s }
150
151 }}}
152
153 References:
154
155  * Edgar, R.C. (2004) "MUSCLE: multiple sequence alignment with high accuracy and high throughput" Nucleic Acids Res 32(5):1792-1797
156
157 === Other Programs ===
158
159 [http://probcons.stanford.edu/ Probcons], [http://www.clustal.org/ ClustalW], and [http://www.tcoffee.org/Projects_home_page/t_coffee_home_page.html T-Coffee] can be used in the same manner as the programs above. 
160
161
162 == Manipulating Multiple Sequence Alignments ==
163
164 Oftentimes, multiple sequence to be used for phylogenetic inference are 'cleaned up' in some manner. For instance, some researchers prefer to delete columns with more than 50% gaps. The following code is an example of how to do that in !BioRuby.
165
166
167 _... to be done_
168
169 {{{
170 #!/usr/bin/env ruby
171 require 'bio'
172
173 }}}
174
175
176 ----
177
178 = Phylogenetic Trees =
179
180 == Phylogenetic Tree Input and Output ==
181
182 === Reading in of Phylogenetic Trees ===
183
184 _... to be done_
185
186 {{{
187 #!/usr/bin/env ruby
188 require 'bio'
189
190 }}}
191
192 Also, see: https://www.nescent.org/wg_phyloinformatics/BioRuby_PhyloXML_HowTo_documentation
193
194
195
196 === Writing of Phylogenetic Trees ===
197
198 _... to be done_
199
200 {{{
201 #!/usr/bin/env ruby
202 require 'bio'
203
204 }}}
205
206 Also, see: https://www.nescent.org/wg_phyloinformatics/BioRuby_PhyloXML_HowTo_documentation
207
208
209
210 == Phylogenetic Inference ==
211
212 _Currently !BioRuby does not contain wrappers for phylogenetic inference programs, thus I am progress of writing a RAxML wrapper followed by a wrapper for FastME..._
213
214 _What about pairwise distance calculation?_
215
216
217
218 == Maximum Likelihood ==
219
220 === RAxML ===
221
222 _... to be done_
223
224 {{{
225 #!/usr/bin/env ruby
226 require 'bio'
227
228 }}}
229
230
231 === PhyML ===
232
233 _... to be done_
234
235 {{{
236 #!/usr/bin/env ruby
237 require 'bio'
238
239 }}}
240
241 == Pairwise Distance Based Methods ==
242
243 === FastME ===
244
245 _... to be done_
246
247 {{{
248 #!/usr/bin/env ruby
249 require 'bio'
250
251 }}}
252
253
254
255 === PHYLIP? ===
256
257
258
259 == Support Calculation? ==
260
261 === Bootstrap Resampling? ===
262
263
264 ----
265
266 = Analyzing Phylogenetic Trees =
267
268 == PAML ==
269
270
271 == Gene Duplication Inference ==
272
273 _need to further test and then import GSoC 'SDI' work..._
274
275
276 == Others? ==