tag:blogger.com,1999:blog-53346658003639910992024-02-06T22:31:59.668-08:00What Is Bioinformatics?jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-5334665800363991099.post-23433724880426078132016-06-06T18:25:00.000-07:002016-06-06T18:27:47.386-07:00Sphinx Documentation with NumpydocI'm finally back from my proposal and orals! Now that I'm done with that mess, here's a fun little tutorial that I've already found helpful for myself. Hopefully others find it useful as well:<script src="https://gist.github.com/Jessime/ef978280f9e0d0f8097db024fb015430.js"></script>jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com1tag:blogger.com,1999:blog-5334665800363991099.post-90059803827102945412016-01-22T15:54:00.002-08:002016-01-22T16:50:27.757-08:00Using R in a Jupyter/Ipython Notebook with UbuntuI may have mentioned it before, but I love the Jupyter Notebook. It's the only way I come close to keeping my code and analyses organized. I'm not a huge fan of R, mostly because I'm not great at it, but I have to use it sometimes. Today was my third attempt at integrating the R kernel into the Notebook, and it took several hours. I figured it would be worthwhile to chronicle what finally worked, in case I need it later.<br />
<br />
Here's my setup:<br />
<br />
Ubuntu 14.04 LTS<br />
CPython 2.7.11<br />
<div>
IPython 4.0.1</div>
<div>
R version 3.2.3 (2015-12-10)</div>
<div>
<br /></div>
<div>
I have no idea how well these steps would work with any variation in any of these versions. One thing I do know, using R 3.2.x is critical. I was previously using R 3.0.2, which turned out to be the difficulty. 3.0.2 continues to be the default download of R on Ubuntu, so a couple of extra steps are necessary to get 3.2.3 So, if you need to upgrade R:</div>
<div>
<ol>
<li>Open the 'Ubuntu Software Center'.</li>
<li>Edit -> Software Sources.</li>
<li>Click the 'Other Software' tab.</li>
<li>Click the 'Add' button.</li>
<li>Fill in 'deb http://cran.fhcrc.org/bin/linux/ubuntu trusty/'</li>
<li>Click the '+ Add Source' button. </li>
</ol>
<div>
This will allow apt-get to properly upgrade R. You can then go to your terminal:<br />
<br /></div>
</div>
<pre class="brush:bash;">$sudo apt-get update
$sudo apt-get upgrade
$sudo apt-get install r-base r-base-dev
</pre>
<br />
At this point you should have a proper version of R. Next we can start working on kernel dependencies. Also from the terminal, run:<br />
<br />
<pre class="brush:bash;">$sudo apt-get install libzmq3-dev</pre>
<br />
We're almost done. From inside R (using either the terminal or an IDE like RStudio), run:<br />
<br />
<br />
<pre class="language-r"><code>install.packages(c('rzmq','repr','IRkernel','IRdisplay'),
repos = c('http://irkernel.github.io/', getOption('repos')),
type = 'source')
IRkernel::installspec()
</code></pre>
<br />
And there you go! Things should be up and running now, and you should have the option to create an R notebook:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfw6i_6De7wg4g9xU5ZMHXiBRKivpk_RWSkOwygK4EcQbrYJbrpANaHH98Bc6Rp_pZrmlkbhUeS4arT6QKmOLWyTB64bwAyziVl6PS0JjYkfBcgb_SOY0vtcmORTdgE5seTBwCCoyG1ncY/s1600/Screenshot+from+2016-01-22+19%253A46%253A24.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfw6i_6De7wg4g9xU5ZMHXiBRKivpk_RWSkOwygK4EcQbrYJbrpANaHH98Bc6Rp_pZrmlkbhUeS4arT6QKmOLWyTB64bwAyziVl6PS0JjYkfBcgb_SOY0vtcmORTdgE5seTBwCCoyG1ncY/s400/Screenshot+from+2016-01-22+19%253A46%253A24.png" width="400" /></a></div>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-54046079628259783522016-01-04T21:37:00.000-08:002016-01-04T21:37:27.111-08:00End of the Year Review (Part III)This post contains the last three question. The final two concern the phrase "your scientific approach", which I found a bit vague. I asked my PI for clarification, and he responded:<br />
<blockquote class="tr_bq">
We all employ short-term and long-term strategies to achieve our goals. These include our working habits, the way we think about scientific questions, strategies for surveying the literature, the way we set up experiments and controls, the way we analyze data, and how we set ourselves up today for questions we want to address in the future.</blockquote>
All in all, I found this exercise to be quite useful, and would encourage anyone reading this to mentally answer the questions for themselves. Anyway, here are the last three questions.<br />
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">What are your goals and milestones for 2016?</span></div>
<b id="docs-internal-guid-20dc4506-1049-4fa7-68c7-6aef48698531" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">If 2015 was about gathering my research tools, then 2016 is about applying my new skills towards my project. That isn’t to say that I think I can quit getting better at programming. I hope that next year, my code has improved as much as it did in the last 12 months. All of the shortcomings I previously listed, for example, are on my TODO list for 2016. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">This coming semester is going to be full. I want to learn a lot from my final class, Object Oriented Data Analysis, which should teach statistical techniques for high-dimensional data. Similarly, I’m hoping that the three classes I’m TAing will provide useful review opportunities and reinforce what I learned last year. Finally, I plan on not simply passing my oral preliminary exam, but using the preparation time to read and retain as much background literature as possible. I hope that I will stay focused enough to gain a full sense of everything that has been published in relation to my project. Hopefully, this clearer view of the field will then allow me to even more precisely define what research questions I am addressing.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">By beginning of summer, I plan on having a logical list of analyses to code and run. My goal for summer, then, is to minimize distractions and plow through the code. Again, I already have a well-defined project and a pretty good idea what the analyzes will be, but orals should set me up to be exceptionally productive (in terms of research results) during the summer months. By the end of the summer, I would like to have enough high-quality data to publish in a medium impact journal. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">This coming Fall, I should have no obligations in terms of classes, TAing, prelims, ect. I would be disappointed if I didn’t have a paper submitted by the end of the year. Projecting this far into the future is a bit difficult, but I think Fall should be broken into two section. Assuming that summer goes as I have outlined above, it seems appropriate to take some time to tie up loose ends and follow any especially interesting leads. In other words, I would like to take the first half of Fall to see if we have any data or insights from the summer that launch us into the high-impact range of journals. The second half of Fall should be spent writing; I don’t think it’s far-fetched to plan to have a full-fledged paper out the door before the Holidays. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">What aspects of your scientific approach will you look to maintain in 2016?</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Overall, I’m quite satisfied with my current scientific approach; I’ve gotten in a pretty good groove. Here are a few points I hope I keep up next year:</span></div>
<b style="font-weight: normal;"><br /></b>
<ul style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I’m optimistic and enthusiastic about my project. Too many graduate students don’t seem to enjoy their work for one reason or another, which hurts productivity.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I have a schedule that works for me. I may come in a bit late, but I stay fairly focused throughout the day and evening, and usually manage to pump out a few more hours of work from at night before bed. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">As I outlined in my ‘met goals’ section, I’m doing well at developing my analytical toolbox. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I’m generating logical and worthwhile research questions at a decent pace. A lot of them don’t pan out in the long run, of course, but I want to keep coming up with new questions.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">While I wish that I would simply make less mistakes, I want to continue to be conscientious enough about my analyses that I catch my errors sooner rather than later. Just because I generate a set of numbers doesn’t mean I quit thinking about the code or the problem.</span></div>
</li>
</ul>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">On a final note, I also want to make sure I stay generally healthy. Nothing makes it harder to do good science than being sick. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">What aspects of your scientific approach can you improve in 2016?</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I’ve always considered my propensity towards carving out quiet time one of my greatest intellectual strengths. Finding some time each day to reflect or just let your mind wander over the terrain of a problem is a critical component of creative problem solving. Creativity, in turn, is often necessary to overcome a difficult problem or see what everyone else is missing. Unfortunately, over the past few years, I have been finding it more and more difficult to make time for silence. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There’s a popular internet-term, ‘shower thoughts’, which describes the phenomenon I just mentioned. What I find depressing is the probable etymology of the term. Showers are literally the single time in any given day that the average person spends without mental stimulation. Therefore, it is the only time when people come up with little treasures like ‘The object of golf is to play the least amount of golf.’ Everyone recognizes how busy modern society is, but we don’t fully appreciate how damaging constant visual/auditory input is to our deeper mental capacities. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">So, this year, I want to make more of an effort for making the time to just sit and think about my project. This means I’m not listening to music, checking notifications on my phone, or talking to people. It also means I’m not coding, reading new literature, or watching a Python tutorial. I’m only thinking about the project. I honestly think this is the single biggest improvement I, or virtually anyone else, could make in my/their scientific approach for 2016. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">We all employ short-term and long-term strategies to achieve our goals. These include our working habits, the way we think about scientific questions, strategies for surveying the literature, the way we set up experiments and controls, the way we analyze data, and how we set ourselves up today for questions we want to address in the future.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Below are a few smaller improvements I want to make:</span></div>
<b style="font-weight: normal;"><br /></b>
<ul style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I want to spend a bit more time each week reading literature, particularly in small doses.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Sometimes, in the interest of time, I skip on computational controls because I assume I know what’s going on. It’s worth coding in more controls.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: disc; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">In the interest of health, I should spend more time exercising. </span></div>
</li>
</ul>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Overall, I want to be more deliberate and efficient with my time.</span></div>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-33565365079798074352016-01-02T10:18:00.000-08:002016-01-02T10:18:06.208-08:00End of Year Review (Part II)<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It's rarely fun to admit your failures, but here's a list of things I didn't mange to pull off in 2015.</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">What are the goals and milestones you missed in 2015?</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<b id="docs-internal-guid-e5df4f30-0380-9254-093d-602674b6debc" style="font-weight: normal;"><br /></b></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">It’s not like I immediately understood everything I tried to learn in the last year. There are a number of tools that I still don’t feel comfortable with:</span></div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There are several functionalities that I’ve played with in Python’s core language that would likely be useful, but I haven’t had the time to properly understand them, or how to efficiently implement them in my code.</span></div>
</li>
<ol style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Generators can save on memory. Things like lists of 10mers could be generators.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Decorators would be useful for cleanly modifying functions when I want to have several options for how to run some piece of core logic.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: lower-alpha; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Inheritance is going to become more important as I continue to switch over to a more OOP approach.</span></div>
</li>
</ol>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Matplotlib has some serious disadvantages for plotting large datasets. I’ve made several attempts at investigating other plotting libraries, especially bokeh, but nothing has clicked with me. Part of the problem is that some of these libraries are still under very active development, so things are changing quickly. Another issue is that I only devote a small amount of time to trying to plot something (like an animated plot), and if it doesn’t work out quickly, I give up because I feel like I’m falling behind on analyses.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I was really hoping my Machine Learning course would give me the skills I needed to implement a neural network in Theano. Given the past few months, my guess is that I still have a serious time investment barrier before I would be able to properly incorporate a deep learning model into my research. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I picked up the basics of git during my third rotation. I use it to store backup copies of my code, but I haven’t used it enough to employ it properly. I realize that if I used git enough though (creating branches, etc.) it could potentially save me from some goofy disaster while editing code or messing around with files. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Similarly, I got fairly comfortable with the Killdevil cluster during my third rotation as well. Because of the difficulties of visualization of the Notebook on Killdevil, I often avoid using Killdevil. This means I haven’t kept up my command lines skills as much as I should have. I was originally hoping to be regularly using tools like ‘grep’, ‘awk’ and bash scripting by now, but I can avoid a lot of it with the Ubuntu GUI. Now, every time I do need the cluster for something, it slows me down considerably. </span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">I’m in the same boat with regular expressions. Every once in awhile I find a problem suitable for regex, google until I have the answer, and move on. I still don’t have enough real understanding of the tool to have the solutions I find stick around in my memory, so I don’t really learn.</span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Statistics remains another weak area for me. The stats class I took at the beginning of grad school was a good introduction, but I need to find a way to stay fresh and continue to grow in this area. I still have a lot of trouble deciding when it’s appropriate to use what statistical test, for example.</span></div>
</li>
</ol>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<br /><span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">There’s a theme here. Every couple months, I run into a problem that can be patched and/or worked around, or actually fixed with one of these tools. I decided I’m going to try out one of these tools, and spend a couple hours reading and trying some stuff out. I learn a little bit, but not enough to fix whatever problem I’m having. I become frustrated because I wanted to have the problem fixed by the end of the day and I know I can apply my work around. So, I just give up, apply my monkey patch, and move on. By the time I run into a similar problem a couple months later, the little bit I learned during those few researching and practicing hours has been completely forgotten and the cycle starts over. This is an unfortunate waste of time, especially since all of the tools listed are extremely valuable resources. I’ve been aware of this issue for a while now, and was hoping that I would have some method for avoiding it by now.</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial; font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">If anyone has any suggestions on how to avoid and overcome the phenomenon I've described, I'd love to hear them!</span></div>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-4726943002346159442015-12-30T19:05:00.001-08:002015-12-30T19:05:12.984-08:00End of Year Review (Part I)My PI has requested that we answer a few questions as a reflection of the past year and as a mental preparation for the coming year. I figured it would be worthwhile to record at least a few of my answers here. This seems like a useful exercise and my answers are decently in depth. So the post isn't overwhelming, I'm going to dedicate a different post for each question.<br />
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">What are the goals and milestones you met in 2015?</span></span></div>
<b id="docs-internal-guid-20dc4506-f5f9-b517-20d2-a557d5de69ca" style="font-weight: normal;"><span style="font-family: inherit;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">I have a vivid memory from Christmas break last year of asking a friend for advice on how to tackle a dataset that was larger than I knew how to handle. I had been doing scientific programming for about a month, and was worried that I was going to have to pick up C instead of continuing with Python. My code was slow and it seemed like weird things were happening with my memory usage. Not only did I have no clue what I was doing, but I also didn’t have any idea how I was supposed to go about learning what to do. </span></span></div>
<b style="font-weight: normal;"><span style="font-family: inherit;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Part of the reason I remember the conversation is because the dataset I was struggling with was the same one that I use almost everyday now. Today, thinking back to my coding style a year ago makes me want to shake my head for a variety of reasons. I took the time to find some code from last year; it was as bad as I remembered. Here’s a small list of problems (in no particular order) with the code:</span></span></div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Most of the scripts have virtually no comments or documentation.</span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Everything is hard-coded. Occasionally, there are chunks of data stored in the script. There are random strings referring to data files throughout the code. There’s no way I would reliably have found and changed all those strings if I wanted to use different data.</span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">There’s only minimal use of libraries like numpy and scipy; I didn’t feel very comfortable with them yet.</span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Several scripts have no functions whatsoever, just 100 lines of straight code. All of these scripts were obviously capable of doing exactly one thing. </span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Other scripts have one main function that take a couple basic parameters (like the names of files). Unfortunately, I didn’t yet know how to incorporate command-line options into a python script. At the bottom of the script there’s a long list of strings corresponding to the files on which I had run the code. As I performed different runs of the script, I would comment out previous strings… </span></span></div>
</li>
</ol>
<b style="font-weight: normal;"><span style="font-family: inherit;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">These coding problems had very real effects on my ability to do computational research. It was constantly difficult for me to remember which script I needed to bring up to run a particular analysis. Once I found the code, I often forgot to switch out one or more of the strings in my code, which meant it ran incorrectly and I had to rerun the code. And at the end of the week, I often didn’t remember how I managed to produce the data I had stored.</span></span></div>
<b style="font-weight: normal;"><span style="font-family: inherit;"><br /></span></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">My primary goal for last year was to become comfortable with the Python scientific ecosystem. I’ve devoted a lot of time and effort to finding and exploring new computational tools in order to do so. While I’ve only explored a tiny fraction of all the available resources, I believe I achieved my goal insofar as I can now reliably reproduce my research and I know where to look when I need answers to a new question. Below is a list of tools that have become indispensable, and how they have allowed me to reach specific computational milestones:</span></span></div>
<ol style="margin-bottom: 0pt; margin-top: 0pt;">
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: inherit;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Surprisingly, </span><a href="https://www.reddit.com/r/Python" style="text-decoration: none;"><span style="background-color: transparent; color: #1155cc; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;">https://www.reddit.com/r/Python</span></a><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> has been a great resource. The community is active and new packages, updates, and other resources are constantly posted and discussed. I now have a way to stay up to date with virtually everything Python has to offer as a data analysis tool.</span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Numpy/Scipy/Pandas/Matplotlib/sklearn are now part of my everyday tools. I understand their APIs, documentation, and am generally familiar with their capabilities and limitations. This means that I can much more quickly import, manipulate, analyze, plot, and save large datasets than I could last year. A great example is using Numpy and linear algebra for computing Pearson’s correlation ~500 times faster than I was previously. </span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: inherit;">Discovering the Ipython/Jupyter Notebook has been the biggest game changer for me. Using the notebook allows me to essentially record everything I do in a month. A lot of code that I write has a one-and-done functionality. There’s no reason for me to store it as its own script. Now I don’t have to. I can make notes to myself in the same location as my code, save graphs directly below the code that made them, and section off my projects in a way that makes sense. Basically, I now have a method for reproducibility that has stopped my code directory structure from becoming an incomprehensible disaster. Organization is not my natural forte, so having the capability to use the Notebooks feels like a major accomplishment. </span></span></div>
</li>
<li dir="ltr" style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; list-style-type: decimal; text-decoration: none; vertical-align: baseline;"><div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: inherit;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Another large benefit of the Notebook is that the .py files I </span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: italic; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">do </span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">write are readable and reusable. When I write some code I know I’m going to need again, I take a bit of time and rewrite it in a .py file as a class. I properly break the code up into modular functions and remember to write a docstring for each function. Inevitably, when I go to rerun my code, I’m going to want to try something slightly different than I did the first time. Now, all of my core logic is abstracted away in a .py file. All I have to do is instantiate the class I want inside of the Notebook and choose the functions I want to use this time. All of my slight variations from run to run are immediately saved in the notebook.</span></span></div>
</li>
</ol>
<span style="font-family: inherit;"><br /><span style="font-size: 14.6667px; vertical-align: baseline; white-space: pre-wrap;">While I’m still a long way away from a data analysis expert, I can honestly say that I no longer feel on the brink of disaster like I did this time last year. Improvements can be made in each of the four points listed, but I’m happy to say that I believe I’m on the right track. </span></span>jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-72119698651057225392015-12-28T12:27:00.003-08:002015-12-29T14:31:08.390-08:00Teach Your Fourth Grader Python (Make a Game)Welcome to the second post on introducing your child to Python! You should have Anaconda (or another version of Python) installed on your computer before continuing. As I mentioned before, I wrote this code for and with a class of 4th graders. Did all of them understand all of the concepts? No, of course not; that wasn't really the point. All of the students thought that the game was fun. All of the students gained a little bit of insight into the technology they use everyday. That's the point.<br />
<br />
Similarly, I'm not going to attempt to fully describe everything that's going on in the code here either. The hope is that I can given enough of a description that you'll be able to either guess or google how to change a line if you wanted to do something similar. What if you decided you wanted to do division problems instead? What if you wanted to add a third player? Exercises like these are fun ways to familiarize yourself with what's going on in a script.<br />
<br />
Remember, this is for Python 3 and won't work with Python 2. Leave a comment if you want the 2.7 version for any reason. Here is the code in full:
<br />
<pre class="brush:python;">import time
import random
#Introduction
print("Hello, Players!")
print("Welcome to Multiplication Battles!")
print("")
#Input information
player1 = input("What is your name, Player 1? ")
player1_points = 0
player2 = input("What is your name, Player2? ")
player2_points = 0
length_per_round = int(input("How many seconds do you want each round to be? "))
highest_num = int(input("What's the largest number you want to multiply? "))
#Launch Player1's game
print("")
input("{}! Hit Enter to start your time.".format(player1))
current_time = time.time()
end_time = current_time + length_per_round
while current_time <= end_time:
#Do math
a = random.randint(0, highest_num)
b = random.randint(0, highest_num)
c = a*b
answer = int(input("What is {}x{}? ".format(a,b)))
#Check if right or wrong
if answer == c:
print("You're Correct!")
player1_points += 1
else:
print("Sorry. {}x{}={}.".format(a,b,c))
#Must update the time at the end of each loop.
current_time = time.time()
print("You scored {} points!".format(player1_points))
#Get ready for Player2
print("")
input("{}! Hit Enter to start your time.".format(player2))
current_time = time.time()
end_time = current_time + length_per_round
while current_time <= end_time:
#Do math
a = random.randint(0, highest_num)
b = random.randint(0, highest_num)
c = a*b
#Check if right or wrong
answer = int(input("What is {}x{}? ".format(a,b)))
if answer == c:
print("You're Correct!")
player2_points += 1
else:
print("Sorry. {}x{}={}.".format(a,b,c))
#Must update the time at the end of each loop.
current_time = time.time()
print("You scored {} points!".format(player2_points))
#Decide a winner
print("")
if player1_points > player2_points:
print("{} wins! Good job!".format(player1))
elif player2_points > player1_points:
print("{} wins! Good job!".format(player2))
else:
print("It was a tie! You two should play again!")
</pre>
<br />
Now we'll go through a section by section breakdown. Any line that begins with a # is a comment, and doesn't effect the way the code runs. Think of them as notes to yourself that the computer ignores.
<br />
<pre class="brush:python;">import time
import random
</pre>
These two lines give us access to other pieces of code we'll use later in the script. <a href="https://docs.python.org/3/library/">This page</a> lists all of the 'libraries' that come standard with Python.
<br />
<pre class="brush:python;">#Introduction
print("Hello, Players!")
print("Welcome to Multiplication Battles!")
print("")print ""
</pre>
This is the beginning of the game. The keyword 'print' is how text shows up in the console when running python. Notice that everything being printed in inside of quotation marks. This just indicates that we are printing some normal text, technically called a <a href="https://docs.python.org/3.5/library/stdtypes.html">'string'</a>. Other things, like integers, for example, can also be printed.
<br />
<pre class="brush:python;">#Input information
player1 = input("What is your name, Player 1? ")
player1_points = 0
player2 = input("What is your name, Player 2? ")
player2_points = 0
length_per_round = int(input("How many seconds do you want each round to be? "))
highest_num = int(input("What's the largest number you want to multiply? "))
</pre>
Before launching into questions, the game collects a little bit of information about who's playing. The first thing we do is create 'player1' by asking the game players to input the name of the first player. Whatever the player types in will be stored inside of the variable 'player1'. We need to keep track of how many points the first person has, so we'll create another variable called player1_points. Since the game hasn't started, the first player currently has 0 points. The reason that the words on the left hand side of the equals sign are called variables is because their values can change over the course of the program. When the first player correctly answers a question, they'll gain a point and we'll overwrite the score stored in 'player1_points'. We'll see how this works later. Variables are a pretty complicated concept for 4th graders. The idea was one of the biggest difficult while teaching this course. If anyone has difficulty understanding what's going on here, I highly recommend checking out <a href="https://automatetheboringstuff.com/chapter1/">'How to Automate the Boring Stuff'</a>. <br />
<br />
We then repeat the process for the second player, and collect their information. Lastly, we need to know how long we want each round to last and what the largest number is that we feel comfortable multiplying. Maybe we want to go easy and play a game for 30 seconds only multiplying up to 10. Or we could go for something more challenging and give ourselves a minute to multiply numbers up to 20. Whatever you want to do. Notice the 'int' surrounding the 'input' on the last two lines. 'int' stands for 'integer', and we use this because we want Python to treat our entries in these lines like numbers instead of 'strings'.
<br />
<pre class="brush:python;">#Launch Player1's game
print("")
input("{}! Hit Enter to start your time.".format(player1))
current_time = time.time()
end_time = current_time + length_per_round
</pre>
Line number 3 is a nice way to pause the game until the first player is ready. But what's going on with the '{}'? It's just a placeholder in the text. When it is printed to the console, the first player's name will be displayed in the sentence. So, if I were playing, for example, the prompt would read, 'Jessime! Hit Enter to start your time.' As soon as I hit enter, the next line of code would execute.
<br />
The next line is where one of our imports come in handy. We're just going to access the computer's clock to store the current time. We need to do this because we want the player to answer questions for 30 seconds, or however long was chosen. So we need to know what time the player started. We then calculate when the player's time is up (by adding up our current time and how long we want to play), and store it in the 'end_time' variable.
<br />
<pre class="brush:python;">while current_time <= end_time:
#Do math
a = random.randint(0, highest_num)
b = random.randint(0, highest_num)
c = a*b
answer = int(input("What is {}x{}? ".format(a,b)))
</pre>
This is where the first player begins getting questions. The first line is what's known as a <a href="http://learnpythonthehardway.org/book/ex33.html">while loop.</a> Loops are another tough subject; use the link and other resources on Google to get more information if necessary. What's happening here is quite straightforward though. We're telling Python 'Hey, execute this next bit of code over and over until the first player runs out of time'. The 'next bit of code' means all of the lines which start 4 spaces over. The code that we're going to execute over and over is:<br />
<br />
<ol>
<li>Generate a question</li>
<li>Ask the player the question</li>
<li>Give the player a point if they answer correctly</li>
<li>Tell the player the correct answer if they miss the question</li>
<li>Update the time and see if the 30 seconds is up or not</li>
</ol>
<div>
These five steps will be repeated. Lines 4-7 in the code above knock out the first two steps. We create 'a' and 'b' by using the 'random' library to generate a random integer in the range of 0 to our highest number (12, for example). The correct solution to the question will be 'a' times 'b', which we store as 'c'. Then we ask the question to the player and store their guess as 'answer'.</div>
<div>
<br /></div>
<div>
</div>
<pre class="brush:python;"> #Check if right or wrong
if answer == c:
print("You're Correct!")
player1_points += 1
else:
print("Sorry. {}x{}={}.".format(a,b,c))
</pre>
<b>Note: This should be indented 4 spaces, but the syntax highlighter won't allow is. Look at the whole code or the player2 example for proper indentation. </b><br />
At this point, one of two things can happen. Either the player is right, or they're wrong. Line two says, if the answer the player gave is equivalent to the correct answer, execute the next bit of code. Again, the 'next bit of code' means all of the lines that are indented 4 spaces over. So, if the player get's the question correct, we're going to do two things. We print to the console letting the player know they answered correctly. We then increment 'player1_points' by one. That is, if the question is the first correctly answered, 'player1_points' goes from 0 to 1. If the first player has 4 points already, then 'player1_points' will now be equal to 5. If the player did not correctly answer the question, we print the correct equation.<br />
<br />
<pre class="brush:python;"> #Must update the time at the end of each loop.
current_time = time.time()
</pre>
This line is absolutely key to the while loop. It's the last line of the while loop, which means, since we're in a loop, we're about to jump back up to line 22 (of the whole code). Once we are back at 22, we're going to reevaluate if we have any time left. The only way that the 'current_time' variable will be accurate is if we update it by 'current_time = time.time()'. If we don't have this line, the while condition will always be true, you'll enter an infinite loop, and you'll have to shutdown python manually. Make sure to have this line.<br />
<br />
Once the current time is greater than the end time, we'll exit out of the while loop, and the first player's turn will be over.
<br />
<pre class="brush:python;">print("You scored {} points!".format(player1_points))
</pre>
We can let the first player know how many points they scored. It may not look like it from the line count, but at this point, we're pretty much finished. A majority of the rest of the code is a duplicate of what we just did, but for the second player.
<br />
<pre class="brush:python;">#Get ready for Player2
print("")
input("{}! Hit Enter to start your time.".format(player2))
current_time = time.time()
end_time = current_time + length_per_round
while current_time <= end_time:
#Do math
a = random.randint(0, highest_num)
b = random.randint(0, highest_num)
c = a*b
#Check if right or wrong
answer = int(input("What is {}x{}? ".format(a,b)))
if answer == c:
print("You're Correct!")
player2_points += 1
else:
print("Sorry. {}x{}={}.".format(a,b,c))
#Must update the time at the end of each loop.
current_time = time.time()
print("You scored {} points!".format(player2_points))
</pre>
Literally the only change here is that I've replaced 'player1' with 'player2'. Now that each player has had their turn, the only thing left to do is figure out who the winner is.
<br />
<pre class="brush:python;">#Decide a winner
print("")
if player1_points > player2_points:
print("{} wins! Good job!".format(player1))
elif player2_points > player1_points:
print("{} wins! Good job!".format(player2))
else:
print("It was a tie! You two should play again!")
</pre>
This block of code should look very similar to the part where we decided if the players correctly answered the question or not. The only difference is that there are now three things that can happen:<br />
<br />
<ol>
<li>Player 1 can win.</li>
<li>Player 2 can win.</li>
<li>The players can tie.</li>
</ol>
Only one of these three statements will print, and we make the decision by comparing 'player1_points' to 'player2_points' and responding appropriately. <br />
<br />
And that's it! Once the scripts executes this last line, it will automatically end and the game is over.jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-75223194240045826432015-12-28T12:22:00.000-08:002015-12-28T12:22:00.542-08:00Teach Your Fourth Grader Python (Installing Anaconda)It's really never too early to start teaching your child to code. You may think, "What's the point of teaching my kid to code so long before they have any idea what they want to do with their life?" The topic is worth a post of its own, but here are a couple of articles by <a href="http://www.connectionsacademy.com/blog/posts/2014-12-04/Why-Learning-to-Code-Benefits-Kids-Regardless-of-Future-Career-Choice.aspx" target="_blank">Beth Werrell</a> and <a href="http://www.theguardian.com/technology/2014/feb/07/year-of-code-dan-crow-songkick" target="_blank">Dan Crow</a> that address how useful "computational thinking" is in a world where everything relies on software. Another possible issue that might come to mind is, "How do I teach my child to code when I don't even know how?" Thankfully, there are already some really great resources out there to help you learn and teach at the same time. One of my favorite books is <u><a href="http://inventwithpython.com/chapters/" target="_blank">Invent Your Own Computer Games with Python</a> </u>which is free online. Another resource, which I haven't used at all but generally gets good reviews is <a href="http://www.amazon.com/Teach-Your-Kids-Code-Parent-Friendly/dp/1593276141" style="text-decoration: underline;" target="_blank">Teach Your Kids to Code: A Parent-Friendly Guide to Python Programming</a>.<br />
<div>
<br /></div>
<div>
I had the opportunity earlier this semester to team up with a friend of mine to each a few hours worth of Python to her 4th grade class. Let me point out that this isn't nearly enough time to learn a programming language. It's enough time to see what coding is and complete a small project to get the students interested in coding. In 4th grade kids are still learning/perfecting their multiplication tables, so we decided to make a multiplication 2-player game. </div>
<div>
<br /></div>
<div>
We'll go over two things. First, I'll show you how to easily install Python (it can be a little bit of a challenge on your own). Then, in the next post, I'll present the code that I wrote for class, and describe the basics of what it does. Again, this isn't going to provide enough information for you to "learn how to code". It's a fun first project to show you why learning to code is worthwhile. I would suggest using one of the resources I linked above to figure out all of the details about how the code works.</div>
<div>
<br /></div>
<h2>
Installing Anaconda</h2>
<div>
Anaconda is a version of Python nicely bundled into a convenient package. Here are a list of steps to get up and running </div>
<div>
<br /></div>
<div>
1. Go to <a href="https://www.continuum.io/downloads">https://www.continuum.io/downloads</a> to download the program. </div>
<div>
2. You'll see options for Windows, OSX, and Linux. Choose the one that works for you.</div>
<div>
3. You'll also have the option between Python 2.7 and 3.5. You should choose 3.5 unless you have a very specific reason for choosing 2.7.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGmeZgKnkOmht5sFCdOwdvtgJFESpVj8nil3xUpHbUlfC1nx88j_KY4hFaR3Um5IX2SnAlOIAYf14568S6YstOKFVQAbCaazvqLQ-B_u9iL2bRmwLA4r1lG_JWkT2ShQ4-hgWPMCBDNdvT/s1600/1-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGmeZgKnkOmht5sFCdOwdvtgJFESpVj8nil3xUpHbUlfC1nx88j_KY4hFaR3Um5IX2SnAlOIAYf14568S6YstOKFVQAbCaazvqLQ-B_u9iL2bRmwLA4r1lG_JWkT2ShQ4-hgWPMCBDNdvT/s400/1-1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
4. Begin the download by clicking the 3.5 Graphical Installer I've highlighted in the red rectangle above.</div>
<div class="separator" style="clear: both; text-align: left;">
5. Once the download is complete, open the installer.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDH9HekhPt6p1AgPJKQGHs7Z8XWO4KikukkUFPBnCrnEpOvN4drzo26W58Vi2ouzONmlJlOVTU0FYqNwVHxmkefkYx42hpYxiwBLmNwb2ydV_7lmYywSuH7MKtreBhGp6iOU1UIgB8tF3i/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDH9HekhPt6p1AgPJKQGHs7Z8XWO4KikukkUFPBnCrnEpOvN4drzo26W58Vi2ouzONmlJlOVTU0FYqNwVHxmkefkYx42hpYxiwBLmNwb2ydV_7lmYywSuH7MKtreBhGp6iOU1UIgB8tF3i/s320/2.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
6. Just follow the defaults and walk through the installer. </div>
<div class="separator" style="clear: both; text-align: left;">
7. Agree to the Terms of Service. </div>
<div class="separator" style="clear: both; text-align: left;">
8. Install for Just me.</div>
<div class="separator" style="clear: both; text-align: left;">
9. Accept the default 'Destination Folder'</div>
<div class="separator" style="clear: both; text-align: left;">
10. Click the 'Install' button.</div>
<div>
11. Once the install as been completely finished, search for 'Spyder' in your computer's search. Look for an icon similar to the one below:</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXJtmkc-R5pbBAhl1-uLiV78gA7PNpNPhmLING0Uno6hAiKlPWqQol06qyvAt2Ceh-41vkfcOn9iDkoNl43-ZGdxtuOTprmYdVz-E01j1_ldqx2t8pqWOzyiQRIgiH7R-lL32U4eLp_azQ/s1600/spyder.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXJtmkc-R5pbBAhl1-uLiV78gA7PNpNPhmLING0Uno6hAiKlPWqQol06qyvAt2Ceh-41vkfcOn9iDkoNl43-ZGdxtuOTprmYdVz-E01j1_ldqx2t8pqWOzyiQRIgiH7R-lL32U4eLp_azQ/s1600/spyder.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
12. Note: Ignore that my icon has Python 2.7, it's what I use because of legacy issues.</div>
<div class="separator" style="clear: both; text-align: left;">
13. Select the icon to launch Spyder. It will take a minute to launch. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhmjomqkWqh0JxmaSR-Tnnc4AHUwcSlPDqQTbixiyO8L1sYclWxtJ3dJzeEleDCLJLBS3oPLyqD4D3w2Xx10wuV-chsORPsDay2OPbWfzkrW2BqoMIP_HA9N7mM9VqPRaswU0bFcte_DtH/s1600/spyder2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="225" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhmjomqkWqh0JxmaSR-Tnnc4AHUwcSlPDqQTbixiyO8L1sYclWxtJ3dJzeEleDCLJLBS3oPLyqD4D3w2Xx10wuV-chsORPsDay2OPbWfzkrW2BqoMIP_HA9N7mM9VqPRaswU0bFcte_DtH/s400/spyder2.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
14. Congratulations! You're ready to start coding. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
In case you're wondering Spyder is what's known as an <a href="https://en.wikipedia.org/wiki/Integrated_development_environment" target="_blank">IDE</a>. At its simplest, it is just a place to write and run your code. If yours doesn't look exactly the same as mine, don't worry. It's going to look different depending on whether you're using Windows, OSX or Linux. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div>
<br /></div>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-67718395513882590542015-10-05T19:54:00.000-07:002015-10-05T19:54:06.127-07:00Calculating a Pearson Correlation Matrix One of the great things about graduate school is you get to constantly realize how ignorant you are about how things work. If the domain name weren't already taken, I would think about moving my stuff over to <a href="http://seriously.dontusethiscode.com/" target="_blank">seriously.dontusethiscode.com</a>. It can get a bit depressing thinking about all the stuff there is to know. But if you think about it a bit more, it's really just awesome how exciting our world is. I'm glad I've got this opportunity to learn and explore.<br />
<br />
Anyway, I found a question on <a href="https://www.reddit.com/r/Python/comments/3nbkxa/numpy_best_way_to_speed_up_iteration/" target="_blank">reddit</a> that reminded me of a post I did a while ago. One of the key points of '<a href="http://what-is-bioinformatics.blogspot.com/2015/01/simple-sequence-similarity_15.html" target="_blank">Simple Sequence Similarity</a>' was calculating a Pearson correlation matrix. While I realize that it isn't exactly the same as the problem on the reddit link, the nested iteration made me realize that I should probably show some improved code that I currently use to calculate the correlation matrix. By "improved", I mean ~500x faster.<br />
<br />
Here's a <a href="https://gist.github.com/Jessime/f9320f3e262ae31c1d92" target="_blank">link to the notebook</a>.<br />
<br />
As a fun bonus (which I won't dive into right now) there are at least four different examples of <a href="https://ipython.org/ipython-doc/dev/interactive/tutorial.html" target="_blank">Ipython magic</a> throughout the notebook. As always, I welcome any comments or suggestions!<br />
<br />
Cheers!jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-69517051498058666522015-08-28T21:27:00.000-07:002015-08-28T21:35:25.839-07:00Bot BattleFor those of you who don't program, it may be hard to understand just how slow a process it usually is. Movies and other media don't help this misunderstanding. As Mark Zuckerberg put it, "If they were really making a movie, it would have been of me, sitting at a computer coding for two hours straight". Similarly, here's a <a href="http://imgur.com/gallery/Kgz562w" target="_blank">visual representation of the difference</a>.<br />
<br />
Every once is a while though, it's actually useful to be able to throw together a quick script, or to generate a plot while you're having a discussion with your colleague. It's not something I'm particularly skilled at since I don't do it much. So is there some fun way to practice coding quickly?<br />
<br />
Let's make a bot battle competition!<br />
<br />
I wanted this to be a pretty straightforward weekend project, so I decided to stick with a simple game that I love a lot. <a href="https://en.wikipedia.org/wiki/Reversi" target="_blank">Reversi</a>, also known as Othello is a great game that even little kids can easily understand. The game itself hasn't been solved though, so it's far from trivial. It's the perfect game for this sort of project.<br />
<br />
I'm not going to run through all of the code or anything, but the <a href="https://github.com/Jessime/bot_battle" target="_blank">repo is available</a> if you want to try it out yourself. A more detailed explanation of how to run the code is there, as well as the general rules of the game. If you don't feel like playing yourself, here's a <u>quick</u> clip of what a Series might look like:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /><iframe width="320" height="266" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/MwYgw6hnXYo/0.jpg" src="https://www.youtube.com/embed/MwYgw6hnXYo?feature=player_embedded" frameborder="0" allowfullscreen></iframe></div>
<br />
<br />
If you have any suggestions or need help setting up the game, just let me know!<br />
<br />
Cheers!jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-61058471520595103962015-08-07T20:58:00.000-07:002015-08-07T20:58:37.524-07:00The PerceptronToday in lab meeting, during our bi-weekly "Idea Potluck", I dropped the ball while explaining how perceptrons work. We were running short on time, so I rushed and straight-up got flustered. It was unfortunate, since perceptrons are really cool, and Wikipedia has a great example (<a href="https://en.wikipedia.org/wiki/Perceptron" target="_blank">here</a>).<br />
<br />
To over compensate, I've written a tutorial to go along with the Wikipedia example.<br />
<br />
<a href="http://nbviewer.ipython.org/gist/Jessime/62c2a8a0baa2c0d061b8">http://nbviewer.ipython.org/gist/Jessime/62c2a8a0baa2c0d061b8</a><br />
<br />
The example and the code are really straightforward, so check it out!<br />
<br />
Cheers!jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-4507370739120512152015-08-03T20:45:00.000-07:002016-06-06T18:30:08.679-07:00Bioinformatics Software<div class="tr_bq">
This isn't a long post, but I read something interesting the other day and wanted to repost it. First, here's the link to the blog: </div>
<br />
<a href="http://www.bioinformaticszen.com/post/bioinformatics-software-is-a-disgrace/" target="_blank">http://www.bioinformaticszen.com/</a><br />
<br />
But since the post is so short, here it is in it's entirety:<br />
<span style="color: #444444;"><br /></span>
<blockquote style="box-sizing: border-box; font-family: "open sans", serif; font-size: 16.8px; line-height: 1.8; margin-bottom: 2em;">
<span style="color: #444444;">"Every piece of software written for publication, which then can't be found after publication is grant funding thrown away. Every piece of software that only worked for the author during manuscript preparation is grant money thrown away. Every piece of software reinvented solely for the purpose of adding a new feature and publishing is grant money thrown away.</span></blockquote>
<blockquote class="tr_bq">
<span style="color: #444444; font-family: "open sans" , serif; font-size: 16.8px; line-height: 1.8;">Grants are harder and harder to obtain, yet we fund the current attrition of moving bioinformatics software forward one reinvention at a time. Where else is it acceptable to reinvent a tool rather than try to improve upon an existing one? Count how many types of webservers are commonly used across the web, then count how many different genome assemblers have been published. If we were a company and we behaved this way, we would have gone out of business long ago. We have accepted a state whereby the short-term reward of publication trumps the longer-term goal of maintaining and improving existing open-source software. We now reap the rewards of this every time we can't find stable software to run our analyses."</span></blockquote>
<br />
I think anyone who's tried to learn bioinformatics instinctively knows this is true. Instead of whining about just how true I've found it to be in the past year, I'll offer two high-level solutions. By "high-level", I realize I ignore all of the depressing, nitty-gritty details.<br />
<br />
1. Reproducing computational results must be encouraged and rewarded. Given the current research environment, the rate of independent software validation is unlikely to increase. We as a community must find methods to foster reproducibility; perhaps in ways as simple as offering "bounties" to teams or individuals who validate newly published software.<br />
<br />
2. Guidelines for software publication should become as strict manuscript guidelines. Here's an outline of what's needed to publish to Science:<br />
<a href="http://www.sciencemag.org/site/feature/contribinfo/prep/prep_init.xhtml" target="_blank">http://www.sciencemag.org/site/feature/contribinfo/prep/prep_init.xhtml</a><br />
Where's the equivalent document for software? "Software" isn't even mentioned at all in the guidelines.<br />
<blockquote class="tr_bq">
</blockquote>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-40402998470768539782015-07-13T19:06:00.002-07:002017-07-19T08:26:22.926-07:00Excision WalkthroughI take things too seriously sometimes. As far as I'm aware, I've always been like that. When I was a kid, I knew, deep down, that walkthroughs were bad. Maybe they weren't quite morally wrong, but they were certainly pushing it. You can probably ask my brother how I felt about walkthroughs. He was often on the receiving end of my scorn when he used a website to figure out a particularly difficult puzzle. "That's not the way you're SUPPOSED to do it!" Children can be so vicious. Little did I know I would eventually be publishing my own walkthrough.<br />
<br />
Hopefully I have done my fair share of maturing. Games, I realize almost two decades later than everyone else, are intended to be fun by definition. If utilizing a guide makes the game more entertaining for you, then by all means, use it. Enjoy the little things in life the way you like them, not the way that you're "supposed" to, or the way that others tell you you should. It's better to learn these things late than never, right?<br />
<br />
I've had a tremendous amount of fun putting this game together. That being said, I am still taking things very seriously, and have also viewed this as a learning experience. I've never tried to market anything before. To put it lightly, I failed terribly. Most of the code that I wrote for this game is rather different than the style of code I write for work. Anyone with any web development experience would have a few things to say about my email script.<br />
<br />
"Whatever. This is my first time, and my next one will be better." Tell yourself that and go try something new. Learn something difficult.<br />
<br />
Needless to say, the following link contains spoilers. It also contains a pretty awesome story. While I fully encourage the use of this document, only use it if you know that's what you want to do.<br />
<br />
<b>[This link has been temporarily removed]</b><br />
<b><br /></b>
Until next time,<br />
Cheers!jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-15480591857563254452015-07-08T07:53:00.002-07:002015-07-21T17:49:48.770-07:00Excision Winner AnnouncementCongratulations to Ankur Sundara for being the first person to complete Excision! For his dedication and problem-solving abilities, he's won the first place price of $50! Ankur, a New Hampshire resident, is a rising senior in high school.
Ankur had this to say about the game: "Excision was an awesome competition! It was a fun mix of knowledge of biology, computer security, and programming skills. My prior participation in hacking/programming competitions definitely helped me out a lot. Some of the challenges had me stumped for a while, but they all had pretty elegant solutions. I hope to see a bigger, better sequel to this competition in the future!"
I want to thank everyone who participated in the game or even gave it a glance. Also, for those of you who still want to play, there's an awesome second place price: a sense of adventure and the feeling of a job well done! Until next time!jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-52194191220975917392015-02-21T17:45:00.001-08:002015-06-29T13:47:07.576-07:00Base CampWelcome to <i>Excision.</i><br />
<br />
Before we set off on our adventure, I think it's only fair to give you some provisions for your journey. They come mostly in the form of the basic philosophy of <i>Excision</i>. You're going to be playing the role of an Agent who runs into some unique circumstances which are going to require some equally unique talents. But I'm sure you're up for the job.<br />
<br />
The basic objective of <i>Excision</i> is to complete a number of stages. There will also be an accompanying story, but I'll explain up front that the basic template for each stage is (with some variations):<br />
1. Read the story. It provides important context for the stage, and it’s entertaining!<br />
2. Work through the puzzle at that stage.<br />
3. Uncover the password necessary to unlock the next stage/clue.<br />
4. Find the location of the next stage/clue.<br />
5. Repeat.<br />
<br />
The game itself has a few main themes, which closely echo the themes of this blog. Computers and programming are really exciting subjects, not to mention increasingly ubiquitous in our everyday lives. Unfortunately, they can seem intimidating to learn. I'm hoping these stages can walk you through a few of the basics. Of course, since this is a bioinformatics blog, there's an emphasis on computing in biology, but the skills necessary to complete the stages are useful in any field. There is almost always more than one way to get to the next stage. Think creatively. Think logically. Talk to other people; sometimes people think about things in different ways.<br />
<br />
Of course, what's a game without a prize? The first person to complete the final stage of the puzzle will be the winner of $50! The $50 can be sent directly to you (cash or check) or donated in your name to your favorite charity.<br />
<br />
Additionally, here's a brief reminder that, while anyone can play <i>Excision</i>, to be eligible for the prize you have to like the new Facebook page for the blog: <a href="http://www.facebook.com/WhatIsBioinformatics">www.facebook.com/WhatIsBioinformatics</a><br />
<br />
I'm trying to separate my personal Facebook account from the blog, and this is a good way of doing it. More importantly for the game, the Facebook page is the platform of the referral/reward system.<br />
The Facebook page is how you can earn personalized hints in order to complete Excision more quickly. Games are always more entertaining when played with friends, so invite yours to like the page and help you solve the challenges. Below are the specifics of how to earn and spend hints:<br />
<br />
• If someone mentions your name in a comment or a post on the Facebook page, you earn 1 hint.<br />
• If you share the Facebook page on your Facebook account, you earn 2 hints.<br />
• Special “Bonus Hints” times will give Agents unique ways to earn extra hints.<br />
• You can spend hints by sending a private message to the Facebook page.<br />
• In the message, describe how you earned your hint (Comment/Share/Bonus Hints).<br />
• If you earned your hint via a comment, include the name of the person who mentioned you.<br />
• Include whatever question you want to have answered.<br />
• While responses may not be immediate, one of our team members will get back to you within 24 hours.<br />
• Questions asked can be retracted, for whatever reason, at any point before a clue has been given by sending the message “Please ignore the previous question”.<br />
• Retracted questions will not cost a hint.<br />
• Hints can be stockpiled indefinitely and do not need to be spent any given time, even during Bonus Hints.<br />
<br />
A copy of the official rules for the <i>Excision </i>contest may be found at <a href="http://tinyurl.com/oq3aw4r">http://tinyurl.com/oq3aw4r</a>. Continuing to the first level from this blog post implies that you have read and accepted the rules and that you know what it takes to be eligible for the prize.<br />
<br />
Note that this is Base Camp. A few of the stages are located here, though they're encrypted and password-protected. When you’re not sure where to go next, always try returning here.<br />
<br />
A final tip: a good Agent, like a good scientist, always cHecks their <u><i>source</i></u>, not jusT the <i style="text-decoration: underline;">source</i> of the inforMation he/she is <u><i>currently looking at</i></u> but also aLl the way back to the <u><i>beginning</i></u>.<br />
<br />
Have fun and enjoy <i>Excision</i>!<br />
<br />
<div id="Z8XK471y" title="U2FsdGVkX1+j48ji5LSLrKieeJgYQUdqGG6BFmk4GECgtIAPDgiga4QwxwXhe1HIf8qGJa/tlbPYM8/MxrdPgZq8PE378EkB01mWVrV/DQRqelzf8jQPqmV6BhjhUfxTu/4TxmtS0s4WUkWjxoSI6aAig9HoSnS/DTi60Re0DwPwhAWygFABalE4hx9ehKt4ZMES8GMRV7p+xJnIN/+qnVrfhIa8llqxAk4+cCXtx+nW9N0Y2lOMDgNYX1eT8WvlDK/71yGyUkRDTO4Lj9X7yYJDadiZkamAaOlyfRuZ9LG/hLINPV4PYUPotJJYtRH4bxav9EZajc3raAxSc7ScQLxhxzmeBTYxlsrF0RBKL+owynXH2wkERi+kqCceQgUkYMR2R8nMWa2x7zzCDJ69ZQe+Y8IRUX9dJtIhuzRa81Qvv6l1qRaJDOy99r4FtL7GQGJAfYsECq0lXt2l10V4VNlXthz/Dk1DjOZVM4OT3EyVYbqDt2htiV7oosfraNVL4EvMw3tZzKAYcIyTpp6F9VNOGqDeeNZM7XBwiXVmQsN5iqLEPZZEvCIAk1dugkE1rH73cwgjroAebBs8JBZNMunsLMXJzcFlCN7yP31g3v512/xyudmbkbOV3Hlq5ZzM2XsgOX1RQfyFDiJShr8LAS0RW4FyH+0BtOG/cirRdMTa2mTiDCZTEEVGZuvOX/jXjxwftE05jk/Q1vZX1zLNlLEgOHhylEWbaRk0INBebTJU6hX59zNrjzOEFjH1ENS78CpaxNo6KUTeaAie+XSH+9Wui+b3fzmOJ1cBPw0KbVBqss94yT0wr7FNENETd0MWjN+g2yBMq83863qMknZnlY0iWVHs/CTEaH2F1yDn06XEDvy933exA/vAjeXKe6diGnMqNY0mbut/2Z3sNOjRYzisFQXonUgW6qDiTdr1Vxw4Wynov2Zoy//v3/5vT/2v0sHGSU9KI9/MiSljuFgxf52MzIIE/Wpp1gn1w9ZjpL5Yfvt37FbuimPipD7GaotfA8AGCtWNtGFxDF49m+P/9HbiPAbgOw1I5F3pEJN3u0k7MEhOkcnupeMQCjA2CBP8WcthJ2FPNcxs0Bt/erSuJKBcA92LAWDwThR6ZTCFywyzZT362XX5Nn4khTVraxmeYUwV6rfczer/xVR7o/TazGrfpvuewEEdGwaeVr38g6wD+SRPINw67mSo9OxUmOGmPNEwfkG8tnR84ZLvcPJDh7epKKrxF/93x/vM/23ja6oiAyeJ4RxZ5EDomddnvcqx+3IHR4L6B+OuTRt9mwQOWIF47bJkY6saJsOAfm8HJfY=">
<a href="javascript:decryptText('Z8XK471y')">Who was it?</a>
</div>
<br />
<br />
<div id="izVxsThS" title="U2FsdGVkX18Ph/L999uUYculkZe6DRHze2n+AIlIj3I2UyZVgcKVdt9aKugBl59nZfNo59ti8b0PWCEASp2yDafJlu230ndNY4wDZmr6j8LYnOd/w5gU1aYxEkvdDwAv3Xm4HhhM6UM4XUwLyANL0lB4TmBgYX+A4u17GdKkgUNFU2zZgSE/wUwxFTBgRpbHk4Ob9/pDQxBgfuPmUJlGDaw4/IA7PLZys3GZpAJ6yvNrUbPwU1InRAeyNvZRrCOMLL76BbscJAQwLa2yqNjD3RNnbyjflfUG0p1Yv++WPCH4QiijoYqq6NHKQsjnyrLL4R0lmr5jIlzGc/d7zZf9qyaT8tPSijiTaDFWhbiSTY+l7sASL3neUzUGo/GVHTMVgf7zmuZcs9Q3ka+GX+6sgS08xano7kV94b8MHSj/VU9chejVWrBi1TWXL2pek4RVtS7OrjVB3M4jXBiEdSR882ULu/4iOcCTOdhSZDQgSI0cQXXGqLLUOIu41oT5bEgPcNLrPGUBlvQ1dkHlh7nSKeSU0dh4odjsJUeESfcY5aFSD8+QYvPN0J9DU2GJVzFy/nwnhtg4FRUmAfaFV+Hx8wwK3bqbY5RaNGmo9q99DXPvPzRRlyTAnurCO2qWblR5KhcKyDbwqxxw+SbYApuO80nrYWM6UBgCkVo4z7PnEhLjAG63r6CYaYK56DMgSexoS4IwoTpGXCOvemzvhE2u1CmH3a8YomOHtc+xTeaLlqw5IYpvF8AhsnayC964+ZcRunRWfP8IP+afmPneVTpk6/6pmU4QSV7akTzfR1emhsUjrmbrJKhkWDKdiz7KZFhJ479JVmSUDozKhm3n9gU8fupy11/7FGo8h5itFF4K3G+qUnuhvFaj0sjIj3zKp6eXgxYvZAxUNZuKcwCeEBKSDWvBVD8kn2FyI51cgCpPX0E=">
<a href="javascript:decryptText('izVxsThS')">What COUNTRY *space* STREET ?</a>
</div>
<br />
<br />
<div id="y8FRzSih" title="U2FsdGVkX1/dSY79rnoWOCNKUf/ufu497ILuoc2EBL59lLQ0iYW4o18+UGcqKltL1Hh0P45APF8Xq5Y3do6uPE+Ecv1A2J2L+XqzpjeOc3Y8ofEwc/iNFvCkvMs7qyGJrdJU76Z7MEyeqmuotLIig7O5ELOawc0+/EesHTUwdo+f1pNfO8zGtMGoaBmvidtnJ4Pr5dZ8+NbGPCjlMXWDfmKYPROfv0GwMx3KQrXmfADos/XgjX1kM8L1ryAfIDwcs+03gEZ5PUxSz/UfveEV1sQFRiTwz+sAc0BxiowD8edEn22/ha8dCaGOpxu7qrxQy7snCkKwNtvpB9H5K1XJm/h/M/HnR4WAsbWWkNvhtX4W4UuNQkWXSAW7c0sMgoi4kpEhHVBNFCaZ0ZiS8gYAwTw1qeNsuty9TKoPIhBlCEKWwH7Ia/Y5596WxsOlKKWU7ipf9TFt0IHu/ndY8Jkt2omy2uvRUFBogK9x89V03YZgJLD2toX1cQZgtFWezvr3u0DtVeAIzwXcYKaPCVnsP53ycWOUxdAkOpJhK8GBYDg3BSdqAme4XfdbnJG+wHTrsvQT9NH1mGTHGWh4dF2UkeGoxORucKI+UOiQIi5LoGkTQS0K/kpUhX/ki+veB1GKivTHFBvkPlhpjoSiJ9/6ukQPDtXbVhInS60YpjkOeTx72QJFQB6DxSqwdWVxLg0PwITb8AfGAWYqixLQbKi84RsiPDFlZ1Isnpu+CguLDLp/T7RmsZT6Sg1wO4Fm5E0AtCHPtWm6aNKZ6kCoasO208faFn918l5glTqUEOM8wJJNZMmlxm/4tiX8ttticDcZb+3vrMtXG9X2IjRpcZGRMSgqvD+QDyzXSSKWaHog9h2tj++z6u7WR/pOQh99ZouVW6yzepOgIKq/tOc0hzlZlzLddYZ27tIm7wkj1yT/5MUQ7JFF/q5yHpXcY/kFIkZMfaFG3+h8srO6bNl288fTR+4157YWHIhXP2E3/WDl1WNpznxLZYROonsWEkQ++lWCmf8ZenVESOeZmQlKBBZFrNcVvcJf7iLo8Y2jJKzHDhHQHFyBBT3TGVIhUU/VhFZs+PoeUqX1ZASm9lxxbxI9kkmoi6OlvspzN6EOPM0lDZWtolqsKQgm93quy5RXG8iWfcCqciel6eXYF3/c5hx2l6DbgdmJ89j0ZHWHn8ehvubJsi1SUmfy84+869IU6ZN+dE6wJEYK1uYxE+fL2KZoMikMmslYQnWga0IgfaBiNVsShpy+MltZTHdfgJiHYA2iFLSnppWpxkPCHzwvsY1WaAVlseZVcpxNfU+2DWPeqh8=">
<a href="javascript:decryptText('y8FRzSih')">What is he?</a>
</div>
<br />
<br />
<div id="EMokwVLO" title="U2FsdGVkX19dYS0D22gXDXdMnJd1Yxcm/l03NYS1tCeMh2M2NYORUGPC0S1LuhTATbXL5GBgcexn42bqKKRmCnFdi8ElxTiDr1wgZJ+/mY3nWJJ8SVUaPt/x1+98Myz9pTOoaxbLqDasK4g639OrrIBOF2QBoN7rNUAR3ZdXODQFKd4E11lv834AoReCBH13Uvlq5CmY830OPigp8LUFRCtO25Sy5tjrff2VTAtMIKrWR8LY3t8oR4c3UA19bIgC7aMfXLF2AfTOfRgX/VFejqXN1tjiuQlsM6B9TyUO7G1mYM4RszGrYrqWFXFJp3j9QKVVvUnrTNapiF/SMo4mLbOjfZ021DNE1WY1CFq3hWDEwK0/gr90AiJGzCZ/3KzObIpciHckg5cCWFQFQH6uTwN4NzNx2CI9Xbt29EjGsW4JeSnxMjkqLO5QX1L6YrL0zP6S/5kgAohULbCIbNq+IqfI9mPG8AC2aQwIyAgFNJN2r8mB7HVc3BTV2HIH59isPhoPbXBBih7ZAfK+427NqiGrjjqWlk65IW1sEIPA06q8EgWexqZi+TjNjnkroqqTH4nntGAqbuPhga4BH2r8szG8SrGXjM0p/IplnjcL/rXNspm1TRZRY0ivgVVkfvrhAjSaCfMPSip7G1tCSPJPeoYqaSx5LAk+jwudtOIeNsUyqWMixg5zg0kuTSSormk3xOyGJXV48wUyBnVaXsnnTuUztnsmc3oyr1fcj4pzK0UU004QawracSe46lWkhgdpsen0wXIEN7+6yKpHhBXxCD9qmGqQZHREtsPVMK/OqHs2law4UV2qw9xESgc/3ZXu7Nz0aSuxwhW/NRQEwOXiWQBr8zNdTtxD98lWnq8AqaP/HUd7/AVVLoeunAg0jAX0WCAi/zKCgyR2MB+y7HeEjXYCuEBDsNdRdAAnrRODobRzc2n8EGeAXCGu93tRgJOybRSn9MxRWnr9htNCnLi5NOiopXIehRDc+VyARnhWDcuWNgGz22Ifw1mEY++j9AXDMO1vDXIJFSSPSvG2ROXylQ==">
<a href="javascript:decryptText('EMokwVLO')">Where? xx.xxxxxx *space* xx.xxxxxx</a>
</div>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com1tag:blogger.com,1999:blog-5334665800363991099.post-91931143090961176382015-02-15T21:19:00.000-08:002015-05-02T17:01:07.998-07:00The Protein Folding AnswerI need to issue a disclaimer before anything else. The script below is most definitely NOT the answer to protein folding. In fact, I make no claims at all about the efficacy of this code beyond it's rudimentary ability to fold the beta-hairpin shown here. This code is just a homework assignment and learning experience for me. I believe the code is decently well commented for anyone who's working with PyRosetta themselves. MAYBE this can be used at a starting point.<br />
<br />
I'm also not going to go through the code section by section as I did for the sequence similarity code, but here's a brief discussion of what the script is supposed to accomplish:<br />
<br />
1. First the peptide has to be generated. It's what we are going to fold in this program.<br />
2. Since we know we're making a beta-hairpin, we use knowledge based design to set the basic starting point angles of the backbone.<br />
3. Then we go through a million or so cycles of what amounts to three steps:<br />
i. Randomly shift the peptide by some amount.<br />
ii. Calculate the energy score of the new position compared to the old one. (Since we know we're looking for hydrogen bonds, we add an extra bonus for moves that potentially form h-bonds)<br />
iii. Decide whether to accept the new position of the peptide, or to reject it and keep the old position. This decision is based on the <a href="http://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm">Metropolis Criteria</a>.<br />
4. As the folding simulation progresses we periodically output the energy score to see how things are going.<br />
5. At the end of the run, we save the new peptide so we can view it later.<br />
<br />
In a way, the steps above are deceptively simply. There are only a few processes and they're fairly straightforward. On the other hand, the theory underlying these steps are very powerful. More importantly, the amount of refinement that can be build on top of these steps is enormous.<br />
<br />
At the beginning of the simulation, the peptide is just a straight chain:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFp7RBTrfPKZWGdsL84YUQljgutjRxe4cvqQzrcFWh1eoJvlR7Rv0A5n-XdLmEWEZbpT-fLssJPLtWcgOWdOrgHOnEvqFHSFA7AH7PG7dDmYU0kVMMtWpXoYks2V0EjIfUB2xXMyjOQjat/s1600/straight.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFp7RBTrfPKZWGdsL84YUQljgutjRxe4cvqQzrcFWh1eoJvlR7Rv0A5n-XdLmEWEZbpT-fLssJPLtWcgOWdOrgHOnEvqFHSFA7AH7PG7dDmYU0kVMMtWpXoYks2V0EjIfUB2xXMyjOQjat/s1600/straight.png" height="206" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
By the end, the peptide has folded and formed hydrogen bond. The cartoon representation of the peptide shows that it does appear to be a beta-hairpin. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOzSUh2prX5Mr5wBx5s8bxvWm6Lx0PnqQHCnw-U7kT77X2YPda2xDLu56V03xQzO1CrWPGKM-9awoxqVRtOIkIddT7ayURtdyiqOjdFunOlcTksVbvVqniEPinUuDVXyixgLNKljJ_bOPI/s1600/folded1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOzSUh2prX5Mr5wBx5s8bxvWm6Lx0PnqQHCnw-U7kT77X2YPda2xDLu56V03xQzO1CrWPGKM-9awoxqVRtOIkIddT7ayURtdyiqOjdFunOlcTksVbvVqniEPinUuDVXyixgLNKljJ_bOPI/s1600/folded1.png" height="281" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAkhCtwJ9eTXAGKvcWCIaRIEFS5-jjERLaTwbpskMvipfFWFyitndysMlnvx2ns56Ty7RmJqOBLQF4DjkhP7EjReowukEAagBzhgXAoedws1oEeMqfB6LKIUIwyO3JfdrCIYXJzEhBrOrN/s1600/public_folded2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAkhCtwJ9eTXAGKvcWCIaRIEFS5-jjERLaTwbpskMvipfFWFyitndysMlnvx2ns56Ty7RmJqOBLQF4DjkhP7EjReowukEAagBzhgXAoedws1oEeMqfB6LKIUIwyO3JfdrCIYXJzEhBrOrN/s1600/public_folded2.png" height="280" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Below is dumped the code used to make this transformation. If you have questions about any of the specifics, I'd be happy to try to answer them. For those of you looking for the actual answer to the protein folding problem sorry for the disappointment. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Maybe next time. Cheers!!</div>
<!--You're in the right place if you're looking for a beta-hairpin. Use the one with the cartoon arrow in it to get more information.-->
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<pre class="brush:python;">"""Import necessary libraries and initialize rosetta"""
import random
import math
from rosetta import *
from rosetta.PyMolLink import *
init()
"""Generate the beta-hairpin pose and score it"""
strand = "AAAAA" #alanine end residues
turn = "GG" #glycine turn residues
hairpin = strand+turn+strand #combine to make hairpin
pose = pose_from_sequence(hairpin,"fa_standard") #Create Rosetta pose
fa = get_fa_scorefxn() #Initialize a scoring function
fa(pose) #Score the hairpin
pose.dump_pdb("start1.pdb") #Generate an image of the starting structure
pose.set_psi(5,90) #Set starting angle
pose.set_phi(6,60) #Set starting angle
pose.set_psi(6,-120) #Set starting angle
pose.set_phi(7,-80) #Set starting angle
pose.set_psi(7,0) #Set starting angle
pose.set_phi(8,-120) #Set starting angle
"""Initialize variables"""
old_pose = Pose() #Initialize empty poses for later
low_pose = Pose() #Initialize empty poses for later
max_temp = 100 #Initial temperature for metropolis and annealing
current_temp = max_temp #Current temperature will drop through cycles
max_cycles = 1000000 #How many moves you want to make
low_energy = 10000 #Will store the value of lowest energy conformation
constraint_weight = 0.5 #Parameter for how much h-bond distances matter
ideal_dist = 0.29 #The proper distance for an h-bond between the alanines
"""Begin iterating through moves"""
for i in range(0,max_cycles): #Loop through the all the cycles
"""Update accept flag, and the old pose/energy/score"""
old_pose.assign(pose) #Set the old_pose
fa(old_pose) #Score the old pose
old_energy = fa.score(old_pose) #Define variable for the energy of old pose
old_score = old_energy #Alias old_energy, to use old_score for hbond constraining
"""Move given angle or angles by a chosen amount."""
current_residue = random.randint(1,pose.total_residue()) #Choose the residue to move from a uniform distribution
curr_phi = pose.phi(current_residue) #Set the current phi angle to be moved
curr_psi = pose.psi(current_residue) #Set the current psi angle to be moved
angle_shift = random.gauss(0,25*(float(i)/float(max_cycles))) #As the folding progresses, move the angle(s) by a smaller amount
if(random.random()<(float(i)/float(max_cycles))): #As the folding progresses, make the probability of a shear move increase
pose.set_phi(current_residue,curr_phi+angle_shift) #Set the new phi angle (shear move)
pose.set_psi(current_residue,curr_psi-angle_shift) #Set the new psi angle (shear move)
elif(random.random()<0 data-blogger-escaped--0.01="" data-blogger-escaped--="" data-blogger-escaped-.5="" data-blogger-escaped-0:="" data-blogger-escaped-0="" data-blogger-escaped-1000="" data-blogger-escaped-3="" data-blogger-escaped-a="" data-blogger-escaped-above="" data-blogger-escaped-accept:="" data-blogger-escaped-accept="" data-blogger-escaped-accepted="" data-blogger-escaped-accepting="" data-blogger-escaped-actions="" data-blogger-escaped-addition="" data-blogger-escaped-after="" data-blogger-escaped-alculate="" data-blogger-escaped-and="" data-blogger-escaped-angle="" data-blogger-escaped-angle_shift="" data-blogger-escaped-appropriate="" data-blogger-escaped-are="" data-blogger-escaped-as="" data-blogger-escaped-atom="" data-blogger-escaped-atoms="" data-blogger-escaped-ave="" data-blogger-escaped-bad="" data-blogger-escaped-between="" data-blogger-escaped-bonding="" data-blogger-escaped-change="" data-blogger-escaped-chosen="" data-blogger-escaped-code="" data-blogger-escaped-constraining="" data-blogger-escaped-constraint_weight="" data-blogger-escaped-core="" data-blogger-escaped-criteria="" data-blogger-escaped-cterm="pose.residue(12-2*k)" data-blogger-escaped-cterm_pos="Cterm.xyz(" data-blogger-escaped-curr_phi="" data-blogger-escaped-curr_psi="" data-blogger-escaped-current="" data-blogger-escaped-current_residue="" data-blogger-escaped-current_temp="max_temp*(math.exp(-1*max_cycles**-1))" data-blogger-escaped-delta_e="" data-blogger-escaped-dimentions="" data-blogger-escaped-dist="dist" data-blogger-escaped-distance="" data-blogger-escaped-each="" data-blogger-escaped-ecide="" data-blogger-escaped-edo="" data-blogger-escaped-efine="" data-blogger-escaped-else:="" data-blogger-escaped-end="" data-blogger-escaped-energy:="" data-blogger-escaped-energy="" data-blogger-escaped-epeat="" data-blogger-escaped-eset="" data-blogger-escaped-estore="" data-blogger-escaped-et="" data-blogger-escaped-f="" data-blogger-escaped-fa="" data-blogger-escaped-file="" data-blogger-escaped-final="" data-blogger-escaped-find="" data-blogger-escaped-first="" data-blogger-escaped-folding="" data-blogger-escaped-for="" data-blogger-escaped-hbond="" data-blogger-escaped-hbonding="" data-blogger-escaped-heck="" data-blogger-escaped-here="" data-blogger-escaped-i="" data-blogger-escaped-ideal_dist-old_dist="" data-blogger-escaped-if="" data-blogger-escaped-in="" data-blogger-escaped-inal="" data-blogger-escaped-ind="" data-blogger-escaped-is="" data-blogger-escaped-isn="" data-blogger-escaped-iterations="" data-blogger-escaped-j="" data-blogger-escaped-just="" data-blogger-escaped-k="" data-blogger-escaped-lias="" data-blogger-escaped-low_energy="" data-blogger-escaped-low_pose.assign="" data-blogger-escaped-low_pose.dump_pdb="" data-blogger-escaped-lower="" data-blogger-escaped-lowest="" data-blogger-escaped-math.fabs="" data-blogger-escaped-math.pow="" data-blogger-escaped-max_cycles="" data-blogger-escaped-metropolis="" data-blogger-escaped-move="" data-blogger-escaped-moves="" data-blogger-escaped-new="" data-blogger-escaped-new_dist="math.sqrt(dist)" data-blogger-escaped-new_energy="" data-blogger-escaped-new_score="new_score+math.fabs(ideal_dist-new_dist)*constraint_weight" data-blogger-escaped-not="" data-blogger-escaped-nterm="pose.residue(1+2*k)" data-blogger-escaped-nterm_pos="Nterm.xyz(" data-blogger-escaped-of="" data-blogger-escaped-old="" data-blogger-escaped-old_dist="math.sqrt(dist)" data-blogger-escaped-old_energy="" data-blogger-escaped-old_pose="" data-blogger-escaped-old_score="" data-blogger-escaped-one="" data-blogger-escaped-onte_carlo_2-blog2.pdb="" data-blogger-escaped-or="" data-blogger-escaped-other="" data-blogger-escaped-outcome.="" data-blogger-escaped-pair="" data-blogger-escaped-pdate="" data-blogger-escaped-pdb="" data-blogger-escaped-phi="" data-blogger-escaped-pose.="" data-blogger-escaped-pose.assign="" data-blogger-escaped-pose.set_phi="" data-blogger-escaped-pose.set_psi="" data-blogger-escaped-pose="" data-blogger-escaped-poses="" data-blogger-escaped-pre="" data-blogger-escaped-print="" data-blogger-escaped-probability="" data-blogger-escaped-process="" data-blogger-escaped-progress="" data-blogger-escaped-psi="" data-blogger-escaped-r="" data-blogger-escaped-range="" data-blogger-escaped-residue="" data-blogger-escaped-residues="" data-blogger-escaped-rint="" data-blogger-escaped-runs="" data-blogger-escaped-save="" data-blogger-escaped-score.="" data-blogger-escaped-score="" data-blogger-escaped-script="" data-blogger-escaped-second="" data-blogger-escaped-set="" data-blogger-escaped-shear="" data-blogger-escaped-so="" data-blogger-escaped-spacial="" data-blogger-escaped-statements="" data-blogger-escaped-str="" data-blogger-escaped-structure="" data-blogger-escaped-t="" data-blogger-escaped-take="" data-blogger-escaped-temperature="" data-blogger-escaped-term_pos="" data-blogger-escaped-than="" data-blogger-escaped-the="" data-blogger-escaped-there="" data-blogger-escaped-to="" data-blogger-escaped-until="" data-blogger-escaped-update="" data-blogger-escaped-use="" data-blogger-escaped-utoff="" data-blogger-escaped-value="" data-blogger-escaped-values="" data-blogger-escaped-variable="" data-blogger-escaped-very="" data-blogger-escaped-whether="" data-blogger-escaped-with=""><!--0--></pre>
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-49859481478944761312015-02-06T18:07:00.001-08:002015-04-27T18:17:13.266-07:00Encryptions<div id="m6quQ8L0" title="U2FsdGVkX19nbvLCpoATCU2STG48iu9MRYlIu3NPyJyLfnisttGP3FAONdsh9DHgniNqaybGBVy5wlfSYjXCDzH7ZR0vilX/b1H1+Cxw8gATCtHHYNc6WxVmFVsdIi0YsNkbSZTTQq//cuAwwTrv6YHAMyGqNxh9+VHJZZkDIO9z4MI47HbkIKkiJo2a6IjZDS5L6kTMsLZp0wfCTwaqwA8EIOaPwEZKGOIFKOlqSfIvudoV86cZL5OtKNDUb0yZjOV46QhS4vLF8gerTkVonWPyb12IJ9KnKETUYmo2Dm0Cb5FFDxuiGbdyUYav+whdbNd33JI8d3uI8DAx6Z+CqqqysftI2Dlj+6W9R1Q67zYQrx8KvB0iIIYsfmhNGCQ64/IYwgvV/e1shILYGfvSA6KVc9EocYPKC8uP/hgF3nr7qAW3cVn1JsxQQtVv4fSvAGkmtkrhDeXvDquIgnjQYHVC17KIxN58uxURXcVUq1mXlH89kIbk70c99pWZS/srd7t5veafhI4PZvc4P2EjZrcxc/2PuJbCjX9fAkFOloxeX9SUAmvKFwblXmJCtj4bZos7cyazuweSx7G6bqTiD73ITfDPJabaFMzJ3eh2lfR5YbiSLb4jl4KBCaNa5nk/5HlHpY8FhAb1lKHqxX2M4mglz+Ir1McXhUhbixtJCgR1wZiwdh6ZfjR2XlX63SXhQVK/uD0n3FklF4K9nLGGSKuyfQq5YerlAXBh8bUsNhOji0VuvKGJlfSPW3IVg3+EqGoss4up5ieYWjBv3UnxwuhuHBrePw3oZ6DAXjXbQZa89bAWp8k7SQBaFAotUXl5vlIqOQVBiYkY+p2WI1kqQcYpM32fty0OYdw2k6e6p+O/WP1qDzycZpWBnUFaweeZz8cQmyYkbTAI9LhIObVhuICKmbkcMdnhHFAWe6SO7oPgLleCgrD9JR0D3Wp1NfpeCTILWehiFOSCyfdHCWqMySQope8ESUNVlYed4qw0Mk0CMCkkvyVXEd4SsHOc/LrVU4yem24vV/uZJg0m0QTrueAL3oEQrnvE8ay9VF0ShIVALPXUIxvObjUOyX0GEGs8hNR8VFl1HQqdlva8jwBens2E/OYBKJZW1J9eDSwKy0fpGNbnm2w8eaQWuyN5KBW/MClfkV32EfGyVTkaQzSUHD0jxqznW9mlvXEwztTbz2BHLGY0PxXAou9EZ9Q3cohBJ79S2+hE5WCZnehhYPy4B8DIUjuyj2TvLQtuOA7V8cbRlEDuieL/ysBeuFSInWsN1zb01NZYoSQACDpkApTGCHrlpOKh8QwtZ1DIce6HGXAZj/yZf2Rjv4X+u7qSK16OhdW5PGGlTWqkC9pwkw7xBS9IIlzTL6TBLta6zVF8jMQD+ygaCHiusHRWEaBjBIMR8KzQ1DZa/niG2aImZuLOL1bPpVLrrCtxNxudbxY5KQgYlG7ZSMjw1EVGtGM15oSfL6EH03cAZIkZnO8B+EqwjJjsP1M9PLa9owNTPtXpZliCmsHdH4Lh7PPk+/N1HjbtYXf+jChos38G8XIgqzrKvETnlk4pgQUVcG0SsuhuW2JAMyXYm3/E2cbsMsVoCrYZzqjLuTbgXyVsMPMgdoDEn/T5+IWeSKUEGeKobvcNQQdd4S9cwt6jsUbGmXD6DhTbj0oDaK112ZoveNALPYmsRUCV3UJmKIqypWJDOs8QZGIGs9fJ+byqlx19QmhL7WJDnE/5NRPhjS/8/EosGeDPUqwdB0yp4n4oOnXMLxgHOydAsoVmaENFk4jbRREWkT6gQpCbTV12PVoGJIpNtMzUlrR7NbFDblYT8siQp76vAWuskKDLfAldPxCfhxgMEzFxGOkgr79pWtf3gH6IPZZ1jfV99PV3Snn1lUCvfJfkFDftEEW8R/u3gmrcia5w6GUO">
<a href="javascript:decryptText('m6quQ8L0')">Do you know the answer? Do you know the question?</a>
</div>jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com2tag:blogger.com,1999:blog-5334665800363991099.post-85327589883034586312015-02-05T20:37:00.001-08:002015-02-05T21:29:24.085-08:00The Protein Folding ProblemFirst, if you've never had the opportunity to visit <a href="http://xkcd.com/">xkcd</a>, I highly suggest you do it. It's a wonderful website. My personal favorite is the <a href="http://what-if.xkcd.com/">What If?</a> feature. Read one of them; you'll like it. The comic relevant to this post is:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRPo4ZzA7ddSqfepTSC8R7c7nfQQ7zn-STgSMHBHUVgP_0lyaMaHgFr4oZinc1IOpXQJmpSckUYaOvKjmjPWDOwJEeElyrUUnO3C7ymRYZHOxZQfncWM-9acJCgXJTWbW_4emokA4gmyAw/s1600/xkcd_proteins.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRPo4ZzA7ddSqfepTSC8R7c7nfQQ7zn-STgSMHBHUVgP_0lyaMaHgFr4oZinc1IOpXQJmpSckUYaOvKjmjPWDOwJEeElyrUUnO3C7ymRYZHOxZQfncWM-9acJCgXJTWbW_4emokA4gmyAw/s1600/xkcd_proteins.png" height="110" width="320" /></a></div>
<br />
If you're unfamiliar with the protein folding problem, let me briefly set the stage. Imagine a protein made of 100 amino acids linked together in a chain. The protein has to figure out where to put each of these amino acids relative to each other, in order to work properly. (As an aside, proteins which fail to fold properly have implications to many horrible <a href="http://en.wikipedia.org/wiki/Proteopathy">diseases</a>.) For simplicity, let's also image that each of the amino acids can take one of 2 positions. This implies that the protein can take 2<sup>100</sup> positions. This may or may not seem like a lot of choices to you. Try putting 2<sup>100</sup> into <a href="http://www.wolframalpha.com/">WolframAlpha</a>. It works out to be 1267650600228229401496703205376 different positions, and only one of them is right.<br />
<br />
To think about this number a different way, consider having 100 computers that will each check a trillion of these different possibilities a second. That's pretty good, right? Actually, it's not even close. It's going to take you approximately ~400,000,000 years to be able to look at all possibilities. It's absolutely impossible to fold a protein this way. It's not how nature does it, and it isn't how we attempt to do it either. Instead, the general hypothesis is that as the protein begins to fold into a favorable/proper state, it lowers it's energy, which basically crosses certain possibilities off the list without even having to check. The usual analogy is a <a href="http://www.snipview.com/q/Folding%20funnel">folding funnel</a>:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP5zRcLxLZuEj_yMDx59sCX1tVrDq3qFR1tMyC92xkZree7VPt9FVL5Fq6astVFvprohE_1fCIROlEqeeHcCV20ErR51XsV5wi76dbPOzcYH50QLeXHZLmFj_dkPFjXqX9Zatl3XOjB0RP/s1600/blog_funnel.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP5zRcLxLZuEj_yMDx59sCX1tVrDq3qFR1tMyC92xkZree7VPt9FVL5Fq6astVFvprohE_1fCIROlEqeeHcCV20ErR51XsV5wi76dbPOzcYH50QLeXHZLmFj_dkPFjXqX9Zatl3XOjB0RP/s1600/blog_funnel.jpg" height="336" width="400" /></a></div>
<br />
<br />
So, while all spaces on the funnel are technically possible, the protein is almost always just going to fall down the funnel. When scientist try to fold proteins, they use this funnel analogy as a method for only checking some of the possible conformations. But they check intelligently, mostly looking at the positions that have a high chance of being the natural shape of the protein.<br />
<br />
The specifics of how to implement such a search on a computer can get as technical as you like. But a teaching tool called <a href="http://www.pyrosetta.org/">PyRosetta</a> has been made that allows students like me (and you?) to get a pretty good idea of whats going on and what tools we have available to us. In my next post I'll show you a very simple script written for class that allows for the folding of a short peptide.<br />
<br />
Until next time, cheers.jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-73731557154983861652015-01-15T20:34:00.002-08:002015-01-15T21:35:12.529-08:00Simple Sequence SimilarityI've mostly refrained from posting any of the code that I've been writing in the past months because the code seems scraped together in a "just get it done" method that wouldn't be particularly interesting or useful to anyone but me. The programs are simple scripts only applicable to the single task at hand. But I've finally gained enough confidence to show off a few lines that I've been using recently.<br />
<br />
How similar is the phrase "Get it finished" to "Finished get it"? Or in protein terminology, how homologous is GETITFINISHED to FINISHEDGETIT? Many similarity calculations assume sequence linearity, and therefore would not detect much likeness between these two phrases/sequences. The script below is a very simple way of detecting similarity in these sort of "mixed up" strings.<br />
<br />
<br />
<pre class="brush:python;">import numpy as np
from Bio import SeqIO
from itertools import product
from scipy.stats.stats import pearsonr
def k_mers(data, outfile,k):
def occurrences(s,k1):
dic = {} #Initialize dictionary
c = 0 #Initialize counter
while c+k1 <= len(s): #Iterate through the sequence until the end
k_mer = s[c:c+k1] #Kmer defined as a slice of sequence s and size k
if k_mer not in dic: #If the kmer hasn't been seen before
dic.update({k_mer:1}) #Add the kmer as a key to the dictionary.
elif k_mer in dic: #If the kmer has been seen before
dic[k_mer] += 1 #Increment the kmer's value by one.
c += 1 #Move over one letter in the sequence
return dic #Return the full dictionary
transcripts = SeqIO.parse(open(data, "r"),'fasta') #Open the fasta file
c = 0 #Initialize a counter to determine size of storage array
for i in transcripts: #For each transcript
c+=1 #Add 1 to the counter
transcripts = SeqIO.parse(open(data, "r"),'fasta') #Reopen the fasta file
c_mat = np.zeros([c,4**k]) #Initialize array to store the counts
for i, rna in enumerate(transcripts): #For each transcript
counts = occurrences(str(rna.seq),k) #Get the kmer counts for sequence
counts_ar = np.zeros([4**k]) #Initialize array to store all kmers
for j, sub in enumerate(product("AGTC", repeat=k)): #Generate each kmer
k_mer = "".join(sub) #Turn kmer list into a string
if k_mer in counts: #If the kmer is in the transcript
counts_ar[j] = counts[k_mer] #Add the proper kmer value
c_mat[i] = counts_ar #Add new row of counts to count matrix
np.savetxt(open(outfile, "w"),c_mat, delimiter=",") #Save the matrix
def k_mers_corr(c_mat, outfile):
c_mat = np.genfromtxt(open(c_mat,"r"), delimiter=",") #Open the count matrix
corr_mat = np.zeros([c_mat.shape[0],c_mat.shape[0]]) #Initialize new matrix
for i, row1 in enumerate(c_mat): #For each row in count matrix
for j, row2 in enumerate(c_mat): #For each row in count matrix
dist = pearsonr(row1,row2)[0] #Get the corr coeff between rows
corr_mat[j][i] = dist #Add coeff to matrix
np.savetxt(open(outfile, "w"),corr_mat, delimiter=",") #Save the matrix
p = "A:/Library2/Data/" #My directory containing all my working files
i = p+"gencode_lncRNA_overlap_m.txt" #My transcript file
o1 = p+"blogger1.csv" #Output file for the count data
o2 = p+"blogger2.csv" #Output file for the correlation data
k_mers(i,o1,4) #Call to first function
k_mers_corr(o1,o2) #Call to second function
</pre>
<br />
<br />
Even with the comments, this is a lot to digest at once, so let's go through it section by section.
<br />
<br />
The first section is pretty straightforward. It simply give Python access to the necessary tools that I'm going to need later on in the script.
<br />
<pre class="brush:python;">import numpy as np
from Bio import SeqIO
from itertools import product
from scipy.stats.stats import pearsonr
</pre>
<br />
<br />
The next section defines a couple of functions. "k_mers" takes the name of a data file (currently this must be a FASTA file, but it would be easy to generalize the function to be able to read other strings as well), the name of the file to which you would like to store your data, and the size of the substring/kmer you want to analyze. It will then produce a file telling you how many times each kmer appeared in each of the the sequences you want to compare. Notice that the "occurrences" function is defined exclusively inside of the "k_mers" function. It is the function that actually does the counting. If you know much of anything about Python, you probably want to point out that Python has a built in count method. The count method Python provides, however, does not count overlapping sub-strings. For example if you used the default count method on "AGTC" with a size of 2, it would return "AG" and "TC". "occurrences", on the other hand, will return "AG", "GT", and "TC"'.
<br />
<pre class="brush:python;">def k_mers(data, outfile,k):
def occurrences(s,k1):
dic = {} #Initialize dictionary
c = 0 #Initialize counter
while c+k1 <= len(s): #Iterate through the sequence until the end
k_mer = s[c:c+k1] #Kmer defined as a slice of sequence s and size k
if k_mer not in dic: #If the kmer hasn't been seen before
dic.update({k_mer:1}) #Add the kmer as a key to the dictionary.
elif k_mer in dic: #If the kmer has been seen before
dic[k_mer] += 1 #Increment the kmer's value by one.
c += 1 #Move over one letter in the sequence
return dic #Return the full dictionary
</pre>
<br />
<br />
Next, we need to know how many transcripts we are going to analyze. So, we open the file and read through it with a counter that adds one each time a new transcript is encountered. I'm not going to get into generators here, but Python needs to reopen a file to be able to read through it again, so I have to recall the same line.
<br />
<pre class="brush:python;"> transcripts = SeqIO.parse(open(data, "r"),'fasta') #Open the fasta file
c = 0 #Initialize a counter to determine size of storage array
for i in transcripts: #For each transcript
c+=1 #Add 1 to the counter
transcripts = SeqIO.parse(open(data, "r"),'fasta') #Reopen the fasta file
</pre>
<br />
<br />
Now we can make an 2-by-2 array that's eventually going to be filled with the number of kmers that are present in each transcript and begin cycling through them. For each transcript, we call the "occurrences" function we defined above. We send "occurrences" the current transcript we are working on as well as the size of the kmers we are looking for. It will return with a dictionary of the kmers and their corresponding counts.
<br />
<pre class="brush:python;"> c_mat = np.zeros([c,4**k]) #Initialize array to store the counts
for i, rna in enumerate(transcripts): #For each transcript
counts = occurrences(str(rna.seq),k) #Get the kmer counts for sequence
</pre>
<br />
<br />
The next few lines might make more sense if you've looked ahead to what sort of statistical method we are eventually going to use for comparison of the sequences. But consider the trivial case where we want to compare "AGTA" to "CAAA" using a kmer size of 1. The first transcript is going to produce "A"=2, "G"=1, and "T"=1 while the second will be "A"=4 and "C"=1. But what is needed for "an apples-to-apples" comparison is the first "A"=2, "G"=1, "T"=1, "C"=0 while the second will now be "A"=3, "G"=0, "T"=0, and "C"=1. These next lines are producing those necessary placeholders.
<br />
<pre class="brush:python;"> for j, sub in enumerate(product("AGTC", repeat=k)): #Generate each kmer
k_mer = "".join(sub) #Turn kmer list into a string
if k_mer in counts: #If the kmer is in the transcript
counts_ar[j] = counts[k_mer] #Add the proper kmer value
</pre>
<br />
<br />
The last two lines of this function are pretty self explanatory. It would have been a bit easier to keep the matrix in memory and continue on to the correlation calculations, but here is a natural breaking point which allows the user to do other things with the data if they wish. "k_mers_corr" is a fairly simple function, which takes the names of the file produced in the previous function, as well as another output file to store this new data. The new data will be a symmetric matrix where each transcript is compared to every other transcript in the file, and their similarity are saved. After getting things going by bringing in the data and creating a square matrix of the proper size, we start iterating through the rows of our data.
<br />
<pre class="brush:python;">def k_mers_corr(c_mat, outfile):
c_mat = np.genfromtxt(open(c_mat,"r"), delimiter=",") #Open the count matrix
corr_mat = np.zeros([c_mat.shape[0],c_mat.shape[0]]) #Initialize new matrix
for i, row1 in enumerate(c_mat): #For each row in count matrix
</pre>
<br />
<br />
For each row we go through all of the rows (including the row we are currently on) and compare their similarity via the <a href="http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient">Pearson </a>correlation. Once we have that number, we store it in the proper cell in the matrix we initialized earlier. Once we have filled all of the cells, we save our data.
<br />
<pre class="brush:python;"> for j, row2 in enumerate(c_mat): #For each row in count matrix
dist = pearsonr(row1,row2)[0] #Get the corr coeff between rows
corr_mat[j][i] = dist #Add coeff to matrix
np.savetxt(open(outfile, "w"),corr_mat, delimiter=",") #Save the matrix
</pre>
<br />
<br />
And we're finished! The functions I've walked through here are actually stripped down versions of what I have been using recently (don't want to give away ALL my secrets!), so it would appear that I've made my first real Bioinformatics post. I hope I made it clear but if any clarifications are needed, feel free to ask a question in the comments below. Cheers! jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-90577819255605609162015-01-11T13:26:00.002-08:002015-01-11T14:03:44.663-08:00Syntax HighlightingI had to follow a few different explanations on how to employ syntax highlighting on Blogger before I found a set of instructions that worked. In case anyone else is interested in posting some code onto their site, I would highly recommend checking out <a href="http://oneqonea.blogspot.com/2012/04/how-do-i-add-syntax-highlighting-to-my.html">this blog</a>, which has a nice visual walk through and the necessary code available. It only took me a few minutes to set up. Below are a couple of brief examples (including the one on the post) of what the highlighting looks like.
<pre class="brush:php;"><?php
$example = range(0, 9);
foreach ($example as $value)
{
echo $value;
}
</pre>
<pre class="brush:python;">#Here are some examples of syntax highlighting
"""This is a doc string."""
def Example(name):
for i in range(4):
print "Hello, %s!" %name
Example("Dan")
</pre>jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-25866654215453379472014-12-15T21:30:00.000-08:002014-12-15T21:30:14.616-08:00Be Right BackI'm usually not a huge fan of television, but recently it has been convenient to watch an episode of something or other with my wife after dinner. I reason that it gives me a bit of time to digest and unwind before I start in on homework or whatever project I'm working on. Usually Laura chooses what we watch, since it doesn't matter to me. But after reading <a href="http://www.theverge.com/tldr/2014/12/1/7315405/black-mirror-sci-fi-finally-streaming-netflix">this review</a> of Black Mirror, I suggested we watch it.<br />
<br />
Black Mirror is a <a href="http://en.m.wikipedia.org/wiki/Black_Mirror_%28TV_series%29">British series</a> that actually began airing in 2011. But as uncultured as I am, I hadn't heard about it until it began streaming on Netflix. Each episode is completely independent of the others, though they're very similar in theme and tone. Each episode covers some field of technology (ranging from currently available to fairly futuristic) crashing with the realistic intricacies of humanity. Most episodes focus on computer-centric scenarios, but Be Right Back covers a rather troublesome possibility of computational biology. I'm using the term broadly in this context, but it's fitting.<br />
<br />
I don't want to give away any details, so I'll end by echoing The Verge article: these shows are creepy, and definitely intended for a mature audiance. But they're well worth the watch and deserve the award they won for Best TV Mini-Series.jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-67608534990264338482014-12-04T22:23:00.001-08:002014-12-04T22:23:20.676-08:00Some Ethical Issues of Genomic DataYesterday I spent several hours attending an ethics class as well as a ethics/policy seminary. Both were great, and while I haven't had a large amount of time to process the information myself, I thought it might be useful to reflect on it here and share what I learned. The sessions were on some of the issues and implications of high throughput sequencing and genomic data. While the lecture was interesting, it's the class discussion I've been thinking about most .<br />
<br />
In class we talked about the trade off between privacy and information when dealing with personal genomic data. A few different subjects were covered. The difference in opt-in verses opt-out consent forms and what it means to given "informed" consent was brought up. People in the class thought that it's difficult for a layman to give truly informed consent, simply because the subject matter and background material are too deep to allow an understanding of the implications of genetic data in a few paragraphs. It's analogous to the Terms and Conditions we all blindly accept for using our favorite software and websites. People were also attempting to find the optimum phrasing to ensure that maximum utility of the genomic information could be realized without the phrasing of the consent form becoming vague and open enough that it worried potential subjects. Several people were concerned about data later being abused by researchers as it was in <a href="http://genetics.ncai.org/case-study/havasupai-Tribe.cfm">Arizona</a>. <br />
<br />
Also discussed was de-identifying verses anonymizing data. De-identified data has had the identifications are removed and cryptographically secured, but can be later re-identified by the holder of the encryption keys if necessary. Anonymous data, theoretically, has had the connection between the genome and the person has been completely removed. Most of the time was spent answering questions like, "Is it ethical to re-identify data without explicitly informing the subjects?" or "Who should be given the encryption keys?"<br />
<br />
Overall, I felt like the discussion contained a diversity of opinions and was rather thought provoking. There was one topic, however, that seemed overlooked to me...<br />
<br />
Personally, I'll admit that the issue of privacy has never been a huge concern of mine, but as we have seen recently, ANY digital data is vulnerable to intrusion. It doesn't matter if it's <a href="http://bits.blogs.nytimes.com/2014/09/08/home-depot-confirms-that-it-was-hacked/">credit card</a>, <a href="http://www.bbc.com/news/technology-29076899">personal photo</a>, <a href="http://en.wikipedia.org/wiki/Edward_Snowden">classified</a>, or <a href="http://www.renci.org/wp-content/uploads/2014/02/0313WhitePaper-iRODS.pdf">genomic</a> data. If it's out there, there is the possibility of it being leaked and/or abused. It doesn't even have to be illegal. What are the laws surrounding what the government is able to do with genomic data, and to what extent do organizations like the NSA feel they have to obey those laws? Is the government allowed to re-identify genomic data as evidence against a potential criminal? Say that DNA was found at a crime scene, and it doesn't match to any public database. The police have a suspect in mind, but not enough evidence for an arrest (after the arrest, they can <a href="http://www.cnn.com/2013/06/03/justice/supreme-court-dna-tests/">require </a>DNA swabs). Can they use re-identified data as cause for arrest? Other potential scenarios in which this question matters are distinctly dystopian. And while they may seem sci-fi, programs like PRISM make these topics worth discussing.<br />
<br />
At the end of class my professor asked us if we would/will have our genome sequenced. We unanimously said yes. Because the benefits outweigh the risks, right? But then again, the poll was obviously both biased and homogeneous.<br />
<br />
Would you read your blueprints, even if it meant that others potentially could as well?jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com2tag:blogger.com,1999:blog-5334665800363991099.post-91255993141810927142014-11-24T16:22:00.000-08:002014-11-24T16:22:47.194-08:00My First Rotation I'm giving my first poster talk of my graduate school career tomorrow, along with approximately half of my cohort (the other half had their posters today). We are supposed to present what we accomplished over the past 10 weeks, during our first rotation. Though I understand that the real purpose of this poster session is to practice our communication skills and have the to opportunity to see what our peers have been doing, it's still mildly frustrating to feel like you don't have enough material to work with. Let's be honest, it's basically impossible to do enough novel research, in a field you're new to, in 10 weeks, to adequately fill an entire poster.<br />
<br />
I wanted to upload the entire poster here, but there are probably some issues with that. On going research and all... But, I've gotten a couple of compliments on my poster design, so I'm thinking that I may use it as a template in the future. I've removed most of the text and details from the poster, so you can give me feedback on the visual aspects. A couple of things to take into consideration: there's a difference between an empty and filled poster, and some of the specifics of the current layout are a bit "bloated" to make up for the fact that there wasn't a ton of content (a bit more could be squeezed in, I'm sure).<br />
<br />
Also, check out that QR code. It can take attendees straight to some of my microscopy videos, to help them visualize what I'm talking about. It wasn't my idea, but it's still pretty exciting. Here's the link it takes you to :<br />
<br />
<a href="https://www.youtube.com/user/jessime100">https://www.youtube.com/user/jessime100</a><br />
<br />
You can watch one of the videos here too, if you prefer.<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="350" src="//www.youtube.com/embed/m7IAM10Mjqg" width="590"></iframe><br />
<br />
<br />
But back to the actual poster, I'd gladly take any comments or suggestion about layout, style, design, etc.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV6FUEkwnwxg1zFn0Tx_fQvA9yfF6C5xVp8dNFPOI81n3e0sfKnBtIVKtBbGYavGqi7Ty6C_JAloS4Q0NLew0XHndvwpF-f1az_yQ_VQtUqGmpqgP9HTm41K-a_BnSxrFN_gxb-HFREG2k/s1600/First+Rotation+Poster-Template.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjV6FUEkwnwxg1zFn0Tx_fQvA9yfF6C5xVp8dNFPOI81n3e0sfKnBtIVKtBbGYavGqi7Ty6C_JAloS4Q0NLew0XHndvwpF-f1az_yQ_VQtUqGmpqgP9HTm41K-a_BnSxrFN_gxb-HFREG2k/s1600/First+Rotation+Poster-Template.png" height="240" width="320" /></a></div>
<br />jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com0tag:blogger.com,1999:blog-5334665800363991099.post-68933264626474343852014-11-12T15:43:00.003-08:002015-02-17T11:08:16.958-08:00What is Genomics?I just began my second of three rotations this week, so it's been a busy transition time. But I thought I would share this short genomics video. It's really basic, which may or may not be appealing to you.<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="350" src="//www.youtube.com/embed/mmgIClg0Y1k" width="590"><!--Made by: Arius (with comments)--></iframe>
This video came from the "Education" tab from the website of my new lab. Feel free to check it out (or the rest of the site, for that matter) to get a better idea of what I'm working on at the moment.<br />
<br />
<a href="http://www.med.unc.edu/pharm/calabreselab/education">http://www.med.unc.edu/pharm/calabreselab/education</a><br />
<br />
jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com1tag:blogger.com,1999:blog-5334665800363991099.post-53523319031366344392014-11-06T20:57:00.002-08:002014-11-06T20:57:56.857-08:00The DesktopWith my Birthday, Black Friday, and Christmas all right around the corner, I haven't been able to keep myself from thinking about the possibility of purchasing my first desktop upgrade. It's not that my computer needs work per se, I just built it in July, but I did stay under budget with the idea of upgrading in mind.<br />
<br />
The relevancy of my desktop is complicated by two matters.<br />
<br />
Generally, in the computational biology world, desktops can be a bit of an awkward middleman. For most everyday computing (reading papers, browsing the web, note taking, PowerPoint creation, light scripting, etc.), I am going to be on my laptop. I have to be in lab and class, so portability is necessary. On the other hand, if any real analysis is going to be needed, the lab should have workstations built for their pipeline or access to a cluster. I suppose that between those two things, it's easy to think that a home desktop isn't worth it.<br />
<br />
Specifically, because I'm still rotating, I don't know what my long term computing needs are going to be. The bottlenecks are obviously going to be dependent on the nature of the analysis. Or the data may absolutely require that it be run on a cluster, so as long as I have a functioning terminal, everything is fine. <br />
<br />
In this past rotation, however, having a desktop has been fantastic. I've been generating about 6 GB of image data per experiment-- and already filled 142 GB of my storage drive. Analyzing videos in ImageJ on a laptop with 4 GB of RAM isn't pleasant, and the lab didn't have an open workstation for me at the moment. One particular analysis quickly maxes out the 16 GB I currently have on my desktop. Homework also gets finished a lot faster with the extra screen space. I like the ability to have RStudio, Chrome, and the problem set all open side by side. <br />
<br />
I don't have a particular point I'm trying to make here, I'm just considering the pros and cons of sinking money into what I primarily use as a work machine. Of course, I have made a bit of a hobby out of computer building and component researching, so there's a large amount of enjoyment simply from the process. And I would be lying to myself if I didn't admit a bit of pride in having a (fairly) fancy desktop I built sitting in the living room.<br />
<br />
Anyway, now that the background and situation have been established, I'll leave brief updates as I continue to add and refresh components in the coming months and years. Having a complete history might be quite interesting by graduation if Moore's law keeps up. Here's a link to my current build:<br />
<br />
<a href="http://pcpartpicker.com/user/jessime/saved/kg9nTW">http://pcpartpicker.com/user/jessime/saved/kg9nTW</a><br />
<br />
I'd love to see what everyone else is working with (or dreaming about), so share your build below. Or, if you have suggestions for my first upgrade, post that.<br />
<br />jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com1tag:blogger.com,1999:blog-5334665800363991099.post-866125107307557352014-10-28T19:19:00.000-07:002014-10-28T19:19:57.779-07:00What Did You Accomplish This Week?A few weeks ago I was jokingly asked by a friend (who has never set foot in a lab) if I had made any great discoveries that week. I had just finished confirming a genetic transformation, so I laughed and replied, "Well, I did make a new type of yeast." You may or may not consider that a bit of a stretch, but I thought it was a clever answer to an unexpected question. Apparently my exaggeration was enough to impress my friend, since I found out later that he went on to tell others about my "accomplishment." This brief interaction made me think about a couple things...<br />
<br />
My first thoughts were about how annoying difficult it can seem to have enough things go right in a given week to really feel accomplished. You know those terrible Fridays when you look back on your week and think, "Where did it go, and why haven't I done anything?" Sure you do, we've all had them. But the question I was asking myself at that moment was "Is it unreasonable to consistently expect significant progress on a thesis project each week"? The answer obviously depends on the connotation of 'significant'. You probably won't add a line to your CV every week, and it's easy to default to a, "Well, science is hard and things go wrong," sort of attitude. The best answer I've found is a middle-of-the-road viewpoint is appropriate; I think it would be beneficial to note at least one achievement at the end of the week. This deed isn't to brag about, but to be self motivational.<br />
<br />
I realized later that my friend was actually correct to be impressed with my statement. Not because I had done anything noteworthy, per se, but because the technique and the science behind it IS impressive. After a certain amount of time in the lab it becomes easy to lose sight of how awesome what we get to do is. You get into all of the little gritty details of thinking about the struggle of perfecting your sterile technique and ensuring that your epitubes are all properly labeled in your neatest tiny handwriting. You don't stop to consider that what you're doing. Taking traits from one organism and bestowing them on another could only be called magic a few generations ago. And there are people alive today who were born before this "mundane" task was ever done:<br />
<br />
<a href="http://www.ncbi.nlm.nih.gov/pubmed/8150273">http://www.ncbi.nlm.nih.gov/pubmed/8150273</a>.<br />
<br />
For a slightly more humorous perspective, watch this Jimmy Kimmel clip:<br />
<a href="https://www.youtube.com/watch?v=EzEr23XJwFY">https://www.youtube.com/watch?v=EzEr23XJwFY</a>.<br />
<br />
The point is, even the little things scientists do on a daily basis are awesome. My advice for this week, to myself as much as anyone, is to appreciate the opportunity you have to work in the field you do, and be sure to make the most out it.<br />
<br />
Leave a comment below showcasing the most impressive thing you have accomplished in a week. Exaggerate at your own discretion.<br />
<br />
Cheers jessimehttp://www.blogger.com/profile/14888660153612936987noreply@blogger.com1