-
Notifications
You must be signed in to change notification settings - Fork 0
/
5th-diary.html
197 lines (180 loc) · 20.1 KB
/
5th-diary.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html lang="en">
<head>
<title>5th Diary</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="/theme/css/main.css" type="text/css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="/css/ie.css"/>
<script src="/js/IE8.js" type="text/javascript"></script><![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" media="all" href="/css/ie6.css"/><![endif]-->
</head>
<body id="index" class="home">
<header id="banner" class="body">
<h1><a href="/index.html">Codon Alignment GSoC Homepage </a></h1>
<nav><ul>
<li class="active"><a href="/category/gsoc.html">GSoC</a></li>
<li ><a href="/category/me.html">Me</a></li>
<li ><a href="/category/timeline.html">Timeline</a></li>
</ul></nav>
</header><!-- /#banner -->
<section id="content" class="body">
<article>
<header>
<h1 class="entry-title">
<a href="5th-diary.html" rel="bookmark"
title="Permalink to 5th Diary">5th Diary</a></h1>
</header>
<div class="entry-content">
<footer class="post-info">
<abbr class="published" title="2013-07-28T10:05:00">
Sun 28 July 2013
</abbr>
<address class="vcard author">
By <a class="url fn" href="/author/zheng-ruan.html">Zheng Ruan</a>
</address>
<p>In <a href="/category/gsoc.html">GSoC</a>. </p>
<p>tags: <a href="/tag/codon-alignment.html">Codon Alignment</a><a href="/tag/gsoc.html">GSoC</a></p></footer><!-- /.post-info --> <div class="section" id="things-have-been-done">
<h2>Things have been done</h2>
<p>In this week I added multiple frameshift support and mix frameshift
and mismatch support in <tt class="docutils literal">Bio.CodonAlign</tt>. However, only a single
backward or forward frameshift event is expect to happen within one
anchor. Therefore, the implementation is not a one-for-all solution
for the problem. In most situations, when biologists have nucleotide
sequence and their corresponding protein sequence for sure, they
probably have already known where frameshift event occurs. It is
desirable to have a simple function that allows the user to specify
where it locates and the program can handle it wisely rather than
input the <tt class="docutils literal">rf_table</tt> which is extreme inconvenient. In another
situation, the user might want to align coding gene and pseudogene
together and detect frameshift events in pseudogene. The user does
not have protein sequence and is not likely to acquire accurate
codon alignment from nucleotide sequence along, even though some
efforts have been paid to such analysis. I browsed the discussion
in biopython mailing list when proposing such project. It seems a
similar function like <tt class="docutils literal">pal2nal</tt> is expected
(<a class="reference external" href="https://redmine.open-bio.org/issues/3338">https://redmine.open-bio.org/issues/3338</a>). If this is the goal
of constructing codon alignment, this job has already been done and
my current implementation is probably more robust than <tt class="docutils literal">pal2nal</tt>
as it can handle frameshift <cite>de novo</cite>. I also added the <tt class="docutils literal">anchor_len</tt>
option in <tt class="docutils literal">build</tt> and some complex cases in
<tt class="docutils literal">Bio/Test/test_CodonAlignment.py</tt> for testing.</p>
</div>
<div class="section" id="some-examples">
<h2>Some Examples</h2>
<p>I don't have much example this week, but a rather complex alignment
in <tt class="docutils literal">Bio/Test/test_CodonAlignment.py</tt> may be suitable to be
explained here.</p>
<ol class="arabic simple">
<li>A complex case to constructing codon alignment.</li>
</ol>
<div class="highlight"><pre><span class="o">>>></span> <span class="kn">from</span> <span class="nn">Bio.CodonAlign</span> <span class="kn">import</span> <span class="n">CodonSeq</span><span class="p">,</span> <span class="n">build</span>
<span class="o">>>></span> <span class="kn">from</span> <span class="nn">Bio.Alphabet</span> <span class="kn">import</span> <span class="n">IUPAC</span>
<span class="o">>>></span> <span class="kn">from</span> <span class="nn">Bio.Seq</span> <span class="kn">import</span> <span class="n">Seq</span>
<span class="o">>>></span> <span class="kn">from</span> <span class="nn">Bio.SeqRecord</span> <span class="kn">import</span> <span class="n">SeqRecord</span>
<span class="o">>>></span> <span class="kn">from</span> <span class="nn">Bio.Align</span> <span class="kn">import</span> <span class="n">MultipleSeqAlignment</span>
<span class="o">>>></span> <span class="n">seq1</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTTGAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC'</span><span class="p">,</span> \
<span class="o">...</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">IUPACUnambiguousDNA</span><span class="p">()),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro1'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">seq2</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'ATGAAAAAGCACGAGTTCTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTTGAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAATGTGAGGTGGTC'</span><span class="p">,</span> \
<span class="o">...</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">IUPACUnambiguousDNA</span><span class="p">()),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro2'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">seq3</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCTTGGGCACTTTTGAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC'</span><span class="p">,</span> \
<span class="o">...</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">IUPACUnambiguousDNA</span><span class="p">()),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro3'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">seq4</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'ATGAAAAAGCACGAGGTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAATTGGGCACTTTTGAAGACCACTTTCTGAGCCTACCGAGGATGTTCAACAACTGTGAGGTGGTC'</span><span class="p">,</span> \
<span class="o">...</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">IUPACUnambiguousDNA</span><span class="p">()),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro4'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">seq5</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTTGGGAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC'</span><span class="p">,</span> \
<span class="o">...</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">IUPACUnambiguousDNA</span><span class="p">()),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro5'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">pro1</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'MKKHELLCQGTSNKLTQLGTFEDHFLSLQRMFNNCEVV'</span><span class="p">,</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">protein</span><span class="p">),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro1'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">pro2</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'MKKHEFLCQGTSNKLTQLGTFEDHFLSLQRMFNNCEVV'</span><span class="p">,</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">protein</span><span class="p">),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro2'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">pro3</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'MKKHELLCQGTSNKLTLLGTFEDHFLSLQRMFNNCEVV'</span><span class="p">,</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">protein</span><span class="p">),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro3'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">pro4</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'MKKHELLCQGTSNKLTQLGTFEDHFLSLQRMFNNCEVV'</span><span class="p">,</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">protein</span><span class="p">),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro4'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">pro5</span> <span class="o">=</span> <span class="n">SeqRecord</span><span class="p">(</span><span class="n">Seq</span><span class="p">(</span><span class="s">'MKKHELLCQGTSNKLTQLGTFEDHFLSLQRMFNNCEVV'</span><span class="p">,</span> <span class="n">alphabet</span><span class="o">=</span><span class="n">IUPAC</span><span class="o">.</span><span class="n">protein</span><span class="p">),</span> <span class="nb">id</span><span class="o">=</span><span class="s">'pro5'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">aln</span> <span class="o">=</span> <span class="n">MultipleSeqAlignment</span><span class="p">([</span><span class="n">pro1</span><span class="p">,</span> <span class="n">pro2</span><span class="p">,</span> <span class="n">pro3</span><span class="p">,</span> <span class="n">pro4</span><span class="p">,</span> <span class="n">pro5</span><span class="p">])</span>
<span class="o">>>></span> <span class="n">codon_aln</span> <span class="o">=</span> <span class="n">build</span><span class="p">(</span><span class="n">aln</span><span class="p">,</span> <span class="p">[</span><span class="n">seq1</span><span class="p">,</span> <span class="n">seq2</span><span class="p">,</span> <span class="n">seq3</span><span class="p">,</span> <span class="n">seq4</span><span class="p">,</span> <span class="n">seq5</span><span class="p">],</span> <span class="n">anchor_len</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">rz</span><span class="o">/</span><span class="n">Working</span><span class="o">.</span><span class="n">Dir</span><span class="o">/</span><span class="n">GSoC</span><span class="o">/</span><span class="n">biopython</span><span class="o">/</span><span class="n">Bio</span><span class="o">/</span><span class="n">CodonAlign</span><span class="o">/</span><span class="n">__init__</span><span class="o">.</span><span class="n">py</span><span class="p">:</span><span class="mi">588</span><span class="p">:</span> <span class="ne">UserWarning</span><span class="p">:</span> <span class="n">Codon</span> <span class="n">of</span> <span class="n">pro4</span> <span class="p">(</span><span class="n">Q</span> <span class="mi">28</span><span class="p">)</span> <span class="n">does</span> <span class="ow">not</span> <span class="n">correspond</span> <span class="n">to</span> <span class="n">pro4</span> <span class="p">(</span><span class="n">CCG</span><span class="p">)</span>
<span class="o">%</span> <span class="p">(</span><span class="n">pro</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="n">aa</span><span class="p">,</span> <span class="n">aa_num</span><span class="p">,</span> <span class="n">nucl</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="n">this_codon</span><span class="p">))</span>
<span class="o">>>></span> <span class="k">for</span> <span class="n">rec</span> <span class="ow">in</span> <span class="n">codon_aln</span><span class="p">:</span> <span class="k">print</span> <span class="nb">str</span><span class="p">(</span><span class="n">rec</span><span class="o">.</span><span class="n">seq</span><span class="p">)[</span><span class="mi">0</span><span class="p">:</span><span class="n">aln_len</span><span class="p">],</span> <span class="n">rec</span><span class="o">.</span><span class="n">id</span>
<span class="n">ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTT</span><span class="o">---</span><span class="n">GAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC</span> <span class="n">pro1</span>
<span class="n">ATGAAAAAGCACGAGTT</span><span class="o">-</span><span class="n">CTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTT</span><span class="o">---</span><span class="n">GAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAA</span><span class="o">-</span><span class="n">TGTGAGGTGGTC</span> <span class="n">pro2</span>
<span class="n">ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCC</span><span class="o">--</span><span class="n">TTGGGCACTTTT</span><span class="o">---</span><span class="n">GAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC</span> <span class="n">pro3</span>
<span class="n">ATGAA</span><span class="o">-</span><span class="n">AAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAATTGGGCACTTTT</span><span class="o">---</span><span class="n">GAAGACCACTTTCTGAGCCTACCGAGGATGTTCAACAACTGTGAGGTGGTC</span> <span class="n">pro4</span>
<span class="n">ATGAAAAAGCACGAGTTACTTTGCCAAGGGACAAGTAACAAGCTCACCCAGTTGGGCACTTTTGG</span><span class="o">-</span><span class="n">GAAGACCACTTTCTGAGCCTACAGAGGATGTTCAACAACTGTGAGGTGGTC</span> <span class="n">pro5</span>
</pre></div>
<p>We can see from the example above, a lot of frameshift situation is shown.
<tt class="docutils literal">pro1</tt> is a normal case for reference. In <tt class="docutils literal">pro2</tt>, <tt class="docutils literal">TT-</tt> and <tt class="docutils literal">AA-</tt>
indicate two 1 base pair backward frameshift events. In <tt class="docutils literal">pro3</tt>, <tt class="docutils literal"><span class="pre">C--</span></tt>
is a 2 base pair backward frameshift event and it is correctly detected
by the program. <tt class="docutils literal">pro4</tt> is a complext case that contain two types of
unexpected events, one mismatches are seen
(<tt class="docutils literal">28Q</tt> doesn't correspond to <tt class="docutils literal">CCG</tt>) and <tt class="docutils literal">AA-</tt> is a backward frameshift.
In <tt class="docutils literal">pro5</tt>, <tt class="docutils literal">GG-</tt> indicates a forward frameshift event, where the two <tt class="docutils literal">G</tt>
are skipped by translation.</p>
<p>To this point, codon alignment construction is finished, this is the first part
of my original GSoC plan. In the following days, I will mainly focus on some
simple usage of codon alignment. It mainly involves <tt class="docutils literal">dN/dS</tt> ratio estimation
and evolutionary test.</p>
<p>Since I will be traveling next week, I expect less update.
Thanks for your comments and suggestions!</p>
</div>
<div class="section" id="future-plan">
<h2>Future Plan</h2>
<ol class="arabic simple">
<li>Add a score option for alignment construction;</li>
<li>Rewrite some methods of <tt class="docutils literal">CodonSeq</tt> and <tt class="docutils literal">CodonAlignment</tt> that inherit
from <tt class="docutils literal">Seq</tt> and <tt class="docutils literal">MultipleSeqAlignment</tt> but do not run correctly.</li>
<li>Write documentation for codon alignment construction.</li>
</ol>
<p>For more info, please visit my
[CodonAlign github repo](<a class="reference external" href="https://github.com/zruan/biopython/tree/master/Bio/CodonAlign">https://github.com/zruan/biopython/tree/master/Bio/CodonAlign</a>)</p>
</div>
</div><!-- /.entry-content -->
<div class="comments">
<h2>Comments !</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_identifier = "5th-diary.html";
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://zruansblog.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
</div>
</article>
</section>
<section id="extras" class="body">
<div class="blogroll">
<h2>blogroll</h2>
<ul>
<li><a href="http://informatics.nescent.org/wiki/Phyloinformatics_Summer_of_Code_2013#Codon_Alignment_and_Analysis_in_Biopython">NESCent GSoC Project wiki</a></li>
<li><a href="http://biopython.org/wiki/Main_Page">Biopython</a></li>
<li><a href="http://iob.uga.edu/">UGA Bioinformatics</a></li>
<li><a href="http://getpelican.com/">Pelican</a></li>
<li><a href="http://python.org/">Python.org</a></li>
<li><a href="http://jinja.pocoo.org/">Jinja2</a></li>
</ul>
</div><!-- /.blogroll -->
<div class="social">
<h2>social</h2>
<ul>
<li><a href="https://www.facebook.com/ruan.zheng.7">Facebook</a></li>
<li><a href="http://zr1991.blogspot.com/">Google Blogger</a></li>
<li><a href="http://user.qzone.qq.com/8390905">Qzone</a></li>
</ul>
</div><!-- /.social -->
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
</footer><!-- /#contentinfo -->
<script type="text/javascript">
var disqus_shortname = 'zruansblog';
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
</body>
</html>