Beginning Python for Bioinformatics
This is an RSS file. You can use it to subscribe to this data in your favourite RSS reader, such as GoogleReader, or to display this data on your own website or blog.
Subscribe to this data using MyMedWorm.
Subscribe to this data using GoogleReader.
Subscribe to this data using Bloglines.
Subscribe to this data using MyYahoo.
Get the very latest Swine Flu news via the MedWorm Swine Flu RSS news feed - updated hourly from thousands of authoritative health and news sources.
This page shows you the latest items in this publication.
This is (more or less) the end
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
So, I’m closing the blog, maybe for good, maybe not. I haven’t been updating it and some other responsibilities are consuming my spare time.
I would like to thank everyone that contributed, commented and read it. You have my deepest appreciation. My work is fulfilled if I helped at least one person along the way.
Cheers
Paulo
PS: there’s the wiki, so register and help me improve it.
PS II: sorry that I couldn’t finish the last project. Maybe some other time.
Source: Beginning Python for Bioinformatics - May 23, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: The End fim fin final Source Type: info
Wiki
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
I’m slowly moving the posts from the blog to a wiki. It makes easier to display post series and allows people to modify/enhance/discuss.
The wiki address is http://wiki.genedrift.org.
Source: Beginning Python for Bioinformatics - May 11, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics python wiki Source Type: info
Managing a simple database with Python, SQLite and wxPython, 8
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
Thanks to the comments and suggestions to the last post, it’s possible to make now a more pythonic and clearly generic database update class. Let’s check how the “generic” update/edit entry function is currently:
def update_data(self, values_list):
'''edits and updates fields'''
if sys.platform == 'darwin':
(cursor, database) = link_db(self.db_path)
else:
(cursor, database) = link_db()
cursor.execute("UPDATE bac SET projects = ?, comments = ?, temperature = ?, cell = ?, box = ?, tubes = ?, chromosome = ?, sdate = ...
Source: Beginning Python for Bioinformatics - April 22, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 wxPython bioinformatics SQLite Source Type: info
Managing a simple database with Python, SQLite and wxPython, 7 (includes a question)
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
And we’re back. After a couple of weeks of inactivity we will get back to our small soap-opera pf Python, wxPython and SQLite. Continuing in our database management code let’s check two other functions that changed since our first inception of the code. The first one is the insert_data function that looks like this now
def insert_data(self, values_list, insert_string):
'''inserts data in the database'''
if sys.platform == 'darwin':
(cursor, database) = link_db(self.db_path)
else:
(cursor, database) = link_db()
cursor.execute(insert_string % self.table_n...
Source: Beginning Python for Bioinformatics - April 20, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 wxPython bioinformatics SQLite Source Type: info
Managing a simple database with Python, SQLite and wxPython, 6
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
Let’s get back to our SQLite and wxPython project. We haven’t seen anything on wxPython yet, and we will check the interface only on the next post. For now, let’s see some extra code added to the SQLite access class. Remember that we have a generic class and one class derived from it that would work on accessing specific tables in our database file.
When we last covered the db access routines, there was no search for an entry (the function returned everything in the table no matter what), there was no update function in case someone would want to modify an entry and there was no del...
Source: Beginning Python for Bioinformatics - March 31, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics python SQLite wxPython Source Type: info
RoR commits
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Just illustrating my point (or lack of), an animation about the commits of RoR to its repository. Notice the jump after it was migrated to Github
Ruby on Rails from Ilya Grigorik on Vimeo.
Sorry for the non-Python post.
Source: Beginning Python for Bioinformatics - March 15, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
BioPython and CVS
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
I start this post with an apology. I usually don’t rant or vent here, which are feelings that I usually reserve to my personal blog.
I don’t use BioPython, never used it. I have it installed in my systems, but I never wrote a piece of code importing BioPython routines. But I subscribe to their mailing lists, both user and developer. I maybe have written once to the list, and I just follow the discussions there.
Since last year one of the main topics has been the possibility of moving BioPython from CVS to another version control system. Yes, you read it right. It’s 2009 and BioPyth...
Source: Beginning Python for Bioinformatics - March 13, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic biopython CVS SVN Source Type: info
Managing a simple database with Python, SQLite and wxPython, 5
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
We have seen how to connect, get and insert data (at least theoretically) in the database. Now, a little not about the SQL engine of choice here: SQLite. SQLite databases have the main characteristic that they are self-contained files. Also it does not require an installation, works without a server and works pretty well in most operating systems.
Basically for the type of application we’re developing here, SQLite seems ideal. It eliminates a lot of infrastructure that would be needed if we were working with MySQL or postgresql. We don’t need a server or know how to configure users or manage the databases and ...
Source: Beginning Python for Bioinformatics - March 5, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 wxPython bioinformatics Database SQLite Source Type: info
Managing a simple database with Python, SQLite and wxPython, 4
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
Let’s continue building our small db app. As mentioned in the previous post we need now to instantiate a specific class from our generic SQLite access class. In order to do this we just have to declare a new class and its type will be DB_Generic.
class Bac(DB_Generic)
This new class is called Bac because it’s linked to the bac table in our database file. A side note, bacs are Bacterial Artificial Chromosomes and are used in different molecular biology techniques. Mainly in our case bacs have incorporated human DNA segments and are used as probes for deletion, duplication, etc studies.
...
Source: Beginning Python for Bioinformatics - March 2, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics Programming python SQL SQLite wxPython Source Type: info
Why do I blog. Or: Science Blogging, is it worth?
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
Mirroring the post that appeared on Blind.Scientist
Some time ago there was a meme about science blogging and one of the questions were “why do you blog”. Well, I do it because of the “Nada Surf effect”. You don’t know the “Nada Surf effect”? Pity you weren’t in Washington, DC 2001.
In March or April of 2001, Nada Surf played a concert there. It was a small bar on 14th Street W, close to the more famous Black Cat. It was a spring night, I was with a couple of Dutch friends that had told me about the concert, if I’m not wrong, a couple of days bef...
Source: Beginning Python for Bioinformatics - February 21, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Managing a simple database with Python, SQLite and wxPython, 3
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
In the last post we saw how to connect to a SQLite database file and generate a cursor that would allow us to actually interact with such database. Now we need some functionality that will interact with the data, add, read, delete and search. As was mentioned before the idea is to have a generic database interaction class and have unique instantiated class objects for each database of the project. In the db_obj.py file we have an initial structure set, so let’s check the DB_Generic class.
class DB_Generic():
'''generic class to add DB functionality'''
def __init__(self, table_name)...
Source: Beginning Python for Bioinformatics - February 18, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics Database Programming SQL SQLite Source Type: info
Managing a simple database with Python, SQLite and wxPython, 2
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Let’s continue coding our small Python + SQLite application. The initial idea was to have a file for the interface and another file for the DB access. We will start with the later. If you have access to the repository you will see two Pythonf files, bac_form.py and db_obj.py. At the moment they are not weel commented and have some junk lines at the bottom, legacy from older versions. Take a look on db_obj.py.
It has two class declarations, one called DB_Generic and another one called Bac. Remember in the last post where I mentioned that the idea was to have different simple tables in the same SQLite database and each...
Source: Beginning Python for Bioinformatics - February 17, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics Database Programming python SQL SQLite Source Type: info
Managing a simple database with Python, SQLite and wxPython, 1
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
A little break from reviewing the book, let’s check somne database topics in Python. I was asked to create a simple database to organize wet-lab stuff. No relationships needs, no relational tables required. Just a simple table with determined columns, and a nice GUI to go with it so people can edit, search and use.
My first idea was to use SQLite database, and I stuck with it. After the initial phase of “interviews” to check database requirements, I ended up with a list of tables and decided to start working on the table that organizes the BACs used in the lab. BAC is a DNA vector i...
Source: Beginning Python for Bioinformatics - February 9, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Graphical user interface python SQLite Source Type: info
Expert Python Programming by Tarek Ziadé - a review of Chapter 3
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
The chapter 3 review that I promised for “tomorrow” (last Saturday) was lazily postponed until today. So, let’s get to it. Tarek in this chapter continues with syntax best practices, but at this time at class level. As expected the chapter requires that you have a minimal knowledge of Python classes, so I can say it’s geared to somewhat experienced programmers, and not to newcomers. There is a short explanation on sub-classing that warms up things for the next sections.
Next is the built-in method (type?) super, which was new to me. Basically super gives you access a method or attribute of a class ...
Source: Beginning Python for Bioinformatics - February 9, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic Source Type: info
Expert Python Programming by Tarek Ziadé – a review of Chapter 3
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
The chapter 3 review that I promised for “tomorrow” (last Saturday) was lazily postponed until today. So, let’s get to it. Tarek in this chapter continues with syntax best practices, but at this time at class level. As expected the chapter requires that you have a minimal knowledge of Python classes, so I can say it’s geared to somewhat experienced programmers, and not to newcomers. There is a short explanation on sub-classing that warms up things for the next sections.
Next is the built-in method (type?) super, which was new to me. Basically super gives you access a method or attribute of a class ...
Source: Beginning Python for Bioinformatics - February 9, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic Source Type: info
Expert Python Programming by Tarek Ziadé - a review of Chapter 2
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Cover via Amazon
So we’re up to the second chapter of Tarek’s book. A short disclaimer before diving into it. I started this blog, basically one year after I had started programming with Python. The initial idea was to “convert” the Beginning Perl for Bioinformatics book to Python and see what were the advantages and disadvantages of both languages. I was far from being a advanced Python programmer, and the inception of the blog helped me getting close to that, even though I consider myself far from being an expert programmer in Python. I learned a lot working on converting the Perl and learned a...
Source: Beginning Python for Bioinformatics - February 6, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic expert expert python programming Source Type: info
Expert Python Programming by Tarek Ziadé – a review of Chapter 2
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Cover via Amazon
So we’re up to the second chapter of Tarek’s book. A short disclaimer before diving into it. I started this blog, basically one year after I had started programming with Python. The initial idea was to “convert” the Beginning Perl for Bioinformatics book to Python and see what were the advantages and disadvantages of both languages. I was far from being a advanced Python programmer, and the inception of the blog helped me getting close to that, even though I consider myself far from being an expert programmer in Python. I learned a lot working on converting the Perl and learned a...
Source: Beginning Python for Bioinformatics - February 6, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic expert expert python programming Source Type: info
Expert Python Programming by Tarek Ziadé - a review of Chapter 1
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
I’ve bought (no, Packt Publishing didn’t send me a copy for review) Tarek’s book quite sometime ago, but job changes, and extra-Python issues kept me away from reading it with the attention if fully deserve. When I saw the announcement, I thought that this was the book I wanted in Python. First, a little bit of perspective.
I’m a a biologist, self-taught programmer/coder/you-name-it. I only had a brief course on programming logic with Pascal in 1993 (I think). I first learned Basic on Apple ][, then on PC, then moved to Visual Basic, Pascal, C and C++, most of them with the help of books. About thre...
Source: Beginning Python for Bioinformatics - February 5, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic newtag Source Type: info
Expert Python Programming by Tarek Ziadé – a review of Chapter 1
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
I’ve bought (no, Packt Publishing didn’t send me a copy for review) Tarek’s book quite sometime ago, but job changes, and extra-Python issues kept me away from reading it with the attention if fully deserve. When I saw the announcement, I thought that this was the book I wanted in Python. First, a little bit of perspective.
I’m a a biologist, self-taught programmer/coder/you-name-it. I only had a brief course on programming logic with Pascal in 1993 (I think). I first learned Basic on Apple ][, then on PC, then moved to Visual Basic, Pascal, C and C++, most of them with the help of books. About thre...
Source: Beginning Python for Bioinformatics - February 5, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic expert python programming Source Type: info
BPforB is now PEP 8 compliant!
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
As mentioned in the previous post, Robin Stocker kindly provided a git patch with the required changes to all scripts stored on the repository to be compliant with the PEP 8.
The changes were mainly regarding variable/object names, but they were important as make the code available here more Pythonic following the rules of the Benevolent Dictator for Life.
I would like to thank Robin for spending his time doing this. Much appreciated.
Now, just a quick git tutorial on how to apply patches:
git apply __patch_file__
git commit -a -m “patch applied”
git push
That’s it. Apply, commit, push and you’re do...
Source: Beginning Python for Bioinformatics - February 1, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Finally it’s 2009 …
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia
And … we’re back. The long and cold winter is still out there and January 2009 is almost in the books. After a long period without updating I’ll try to “rush” some posts this week, trying to get back on track. So, a little bit of what’s up and coming:
- a patch provided by Robin Stocker to make all scripts published here (at least the ones on GitHub) PEP 8 compliant.
- using SQLite databases in Python
- developing an interface to access the database
- anything that you might suggest, just leave a comment.
Let’s start 2009 then.
Source: Beginning Python for Bioinformatics - January 31, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Twitter
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
I’m on Twitter, for quite some time. Some Python stuff, some biology, some bioinformatics, and a little bit of everything else.
nuin.
Source: Beginning Python for Bioinformatics - January 31, 2009 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Python Magazine?
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
I have been buying Python Magazine in the last months and I really like it, especially now that I already miss Linux Magazine and have no close source for Linux Journal (I should subscribe, I know). Last week I got an email from Python Magazine that I could use a coupon to buy some issues. Coupon that I used right away. Paid with PayPal and I’m still waiting for my issue to show up. Sent a couple of emails using the contact form and until now, nothing. I’ll wait until next year and see what happened. It’s really sad because this issue covers cloud computing with Python.
Edit: problem solved. Thanks everyone!
Source: Beginning Python for Bioinformatics - December 30, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic Source Type: info
That’s it for 2008
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
The date came and is now gone, and I forgot to “celebrate” two years of Beginning Python for Bioinformatics on December 13th. I would like to thank everyone that commented, helped with posts and suggested anything that would make this website better. Clearly it is far from being what I wanted it to be, but slowly but surely we will get there.
Thanks again and I wish an excellent holiday season and a great 2009 to everyone!
See you in 2009.
Source: Beginning Python for Bioinformatics - December 19, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Scripts and Python 3.0, part 2, using 2to3
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
And we’re back to check our initial scripts to run on Python 3.0. Along with this latest release, a nice tool to parse your scripts is also installed. It’s called 2to3 and it’s available in the Tools/scripts of your Python 3.o installation directory. Basic usage is very similar to any python script:
[sourcecode language='bash']2to3
Source: Beginning Python for Bioinformatics - December 8, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Python 3.0 Source Type: info
Scripts and Python 3.0, part 1
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Yes, Python 3.0 was released earlier than Perl … what version was it? 6? 7? Anyway, I decided to go back to most of the scripts that were posted here. In the github repo we have 50 files in the “original scripts” directory. Let’s check how do they fare on Python 3.0 and what type of changes we need to do in order to make them work. Starting with code_01.py, which is a couple of lines long
myDNA = "ACGTACGTACGTACGTACGTACGT"
print myDNA
Here we have one of the most evident differences between Python 2.x and 3.0. Now print is a function not a statement anymore, so whatever we want to print ...
Source: Beginning Python for Bioinformatics - December 6, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Python 3.0 print python2.x python3.0 Source Type: info
Creating an interface for the motif finding script, final
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
We can say that this would be our final version of the script. There are many nice wxPython programming resources, and one is a very good book called wxPython in Action, which is co-written by Robin Dunn, the wxPython maintainer. Go check it out.
So for the last entry in this series, we just need to add a couple of changes to our interface and motif finding scripts. Basically on the interface script we need to add a line that gets the value entered (or the default one, if not changed) in the motif width input box. And we can do that by including the line below in the run_finder function.
width = self.motif_width.GetValue(...
Source: Beginning Python for Bioinformatics - November 19, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics GUI newtag Source Type: info
Creating an interface for the motif finding script, some corrections
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
We need to pause a bit and do some corrections on our code. First the code I posted on the last entry for the pymotif.py module is wrong. Ok, not wrong, but some of the code I use to test ended up on the blog. Ths first two lines of the calculate_motifs function contained a link to the files I use for testing and should be replaced by
input_seqs = fasta.read_seqs(open(input_seqs).readlines())
input_seqs2 = fasta.read_seqs(open(input_seqs2).readlines())
Also both variables that store the filenames and paths in pymoteGUI.py are declared in the wrong scope. The should have be declared at the pymotGUI class level, so it is a...
Source: Beginning Python for Bioinformatics - November 18, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython newtag Source Type: info
Creating an interface for the motif finding script, part 8
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Let’s see now how do we connect our GUI to the the pymotif file (I changed the name because of some conflicts with the app name [my bad!], the git repo was updated accordingly). And also how to display the results, in a simpler manner.
Ok, first to connecting the script to the function file, pymotif.py. The file is already imported in our script and we have used it before. We need to find the exact point and which parameters to pass. pytmotif.py is a slightly modified version of your command line script, and the code is below.
#!/usr/bin/env python
import fasta
import sys
from collections import defaultdict
def c...
Source: Beginning Python for Bioinformatics - November 13, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Creating an interface for the motif finding script, part 7
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Let’s get back to the last post and check one line we entered
self.motif_width = wx.TextCtrl(panel, -1, '10', (95, 50), (40,18))
There is something in this line that I did not explain. The third parameter in the test box declaration is '10'. How does this affect our box? That’s the default text that will be displayed inside the box as soon as it is created. In our case, 10 is the motif width, and it’s the value we consider to be the most common search width.
Another aspect not explained is the run_finder. We added a line
wx.MessageBox('It should run, eh?')
where we declare a wx.Me...
Source: Beginning Python for Bioinformatics - November 11, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
Creating an interface for the motif finding script, part 6
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Last entry we saw how to allow the user to open a file. Now we need to work on this file and store its path so the script can process it later on. After the file is selected on the file menu, the filename is printed on the label. Let’s think for a second … If we get only the filename from the dialog, the program won’t work, because the file might be located in another directory, partition, you name it. So we need tp get the file’s full path. We need to change the lines
back_file = dialog.GetFilename()
self.fore_label.SetLabel(dialog.GetFilename())
by
back_file = dialog.GetPath()
self.fore_label....
Source: Beginning Python for Bioinformatics - November 4, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics Source Type: info
Motif finding interface on github
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
There has been actual development of the GUI and most of the development is being added simultaneously in the blog and on the code. So, go get a copy of git, install it and play with the BPB repository there.
http://github.com/nuin/beginning-python-for-bioinformatics/tree/master
Source: Beginning Python for Bioinformatics - October 30, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs code Github Source Type: info
Creating an interface for the motif finding script, part 5
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Last time we saw how to bind an interface element to a function. Now we need to make good use of it, and make the script have some actual functionality. First thing we are going to do is to include a label (or static text) on the interface. Remember that initially we added a panel to the frame, so the label should go on the panel. For a label we use a wx.StaticText and has these parameters
(self, parent, id=-1, label=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, name=StaticTextNameStr)
We don’t need all of them, just a couple would be enough. Basically, parent, id, label and pos will do it, as the si...
Source: Beginning Python for Bioinformatics - October 30, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics Source Type: info
Creating an interface for the motif finding script, part 4
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Last time we checked how to add a menu to our simple frame. Unfortunately, just adding it won’t make the menu useful. In order to do that we need to bind some events to it. As any interface framework, wxPython is governed by events generated by the user, being these events mouse clicks on buttons and menus, objects getting/losing focus, etc. In our case, so far, we eveidently need a event called menu event, which will tell the code what path to use when a menu is clicked.
My personal preference for binding an event to menu is to create a separate function to store these procedures, __do_binding. But by using this ro...
Source: Beginning Python for Bioinformatics - October 29, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics Source Type: info
Creating an interface for the motif finding script, part 3
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Today we will add some elements to our interface. Looking at the previous screencap it is easy to conclude that our interface needs a lot of work to be ready. First, it has a dark gray background that does not ressemble the usual window background (it looks more like a MDI frame). We need to change that. Also, there are no menu bars or menus, or tool bars. It’s pretty bare bones, and not exactly good or useful.
There many ways of customizing the look of a window/frame in wxPython, and two of these methods are adding a panel to the frame or adding the so-called sizers. The latter is a difficult method to master, but p...
Source: Beginning Python for Bioinformatics - October 22, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics interface Source Type: info
Creating an interface for the motif finding script, part 2
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Let’s take a deeper look on the code we started yesterday, piece by piece
class pymot(wx.App):
def __init__(self, redirect=False):
wx.App.__init__(self, redirect, filename)
This is the class pymot we derived from wx.App, and this will be the main class for your application. As any other class derived it needs a OnInit or a __init__ function that will take care of initializing things. As usual, we pass self and a redirect parameter, that will tell the application to redirect some output to the command line. We actually don’t need a redirect, but it can be useful in the future to track errors. It’s ...
Source: Beginning Python for Bioinformatics - October 21, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics interface Source Type: info
Creating an interface for the motif finding script, part 1
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
And we are back. After much ado about real life, I am able to “restart” this blog and probably with a good frequency of posts. Last time we saw the final product of our motif finding series. We ended up creating a very elegant script in Python that efficiently counts words in FASTA sequences and then using a basic statistical method, calculates the significance of each word and output the overrepresented ones.
Our script used a little bit less than 50 lines, and if you include the imported fasta module, it won’t top 100. But the number of lines is not important. The efficiency, clarity and speed are key h...
Source: Beginning Python for Bioinformatics - October 20, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: motifs wxPython bioinformatics interface Source Type: info
Git repository updated
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via Wikipedia I just updated the git repository of BPB. Click here to access it. Most of the code presented in the blog is there, some with extra comments, some being updated.
This close another phase in the blog and soon we will check some different aspects of Python programming in Bioinformatics.
Source: Beginning Python for Bioinformatics - September 13, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Programming python Source Type: info
Python, overepresented motifs, the Grand Finale
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
In this final part, let’s do some very simple refactoring and modify the output section to make the result a little bit better. There are not many options about the functions to calculate the binomial expansion. But Andrew posted some opinions on how to slight change the quorum function.
def get_quorums(seqs, mlen):
"""
add seq id_no to a set
use explicit counter to create seq_no
"""
quorum = defaultdict(int)
for seq in seqs:
for n in range(len(seq) - mlen):
quorum[seq[n:n + mlen]] += 1
return quorum
His modifications were small but improved the code a bit, as y...
Source: Beginning Python for Bioinformatics - September 6, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 motifs bioinformatics determination python Source Type: info
Obtaining overrepresented motifs in DNA sequences, final
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
The part 13 of the motifs series is the last one. In a couple of weeks I will post a refactored code, including the suggestions from Andrew in the last post. I will update the blog contents on OWW and commit some of the code to the GitHub repository.
Source: Beginning Python for Bioinformatics - September 4, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics motifs Repository Source Type: info
Obtaining overrepresented motifs in DNA sequences, part 13
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Now that we have the best quorum determination function and the ideal function to calculate the binomial expansions it is easy to program a script to calculate the p value of motifs in DNA sequences. To the script
#!/usr/bin/env python
import fasta
import sys
from collections import defaultdict
def choose(n, k):
if 0 <= k <= n:
ntok = 1
ktok = 1
for t in xrange(1, min(k, n - k) + 1):
ntok *= n
ktok *= t
n -= 1
#print ntok // ktok
return ntok // ktok
else:
return 0
def get_quorums(seqs, mlen):
"""
add seq id_no to a set
use explicit counter...
Source: Beginning Python for Bioinformatics - August 21, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 motifs defaultdict determination dna python Source Type: info
Obtaining overrepresented motifs in DNA sequences, part 12.5
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
So let’s modify a little bit the factorial function and then benchmark both by using timeit. Ideally our factorial function would need to calculate a value similar to the binomial expansion, as we have three factorials to calculate in for each binomial in the Hypergeometric Distribution.
So we can add two extra factorial calculations to our function and perform the multiplication and division to return the equivalent to the binomial calculation. So the function would be
def fac(n, m):
value1 = 1
for i in xrange(2, n + 1):
value1 *= i
value2 = 1
for i in xrange(2, m + 1):
value2 *= i
value3 = 1
f...
Source: Beginning Python for Bioinformatics - August 15, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Section 5 binomial bioinformatics factorial motifs python Source Type: info
Obtaining overrepresented motifs in DNA sequences, part 12
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
So let’s modify a little bit the factorial function and then benchmark both by using timeit. Ideally our factorial function would need to calculate a value similar to the binomial expansion, as we have three factorials to calculate in for each binomial in the Hypergeometric Distribution.
So we can add two extra factorial calculations to our function and perform the multiplication and division to return the equivalent to the binomial calculation. So the function would be
def fac(n, m):
value1 = 1
for i in xrange(2, n + 1):
value1 *= i
value2 = 1
for i in xrange(2, m + 1):
value2 *= i
value3 = 1
f...
Source: Beginning Python for Bioinformatics - August 14, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 binomial bioinformatics factorial motifs python Source Type: info
Obtaining overrepresented motifs in DNA sequences, part 11
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
After a long hiatus we are (almost) back on track in order to get our scripts to determine overrepresented motifs in DNA sequences. Last time we checked we defined the “best” factorial function in Python
def fac_01(n):
result = 1
for i in xrange(2, n+1):
result *= i
return result
and Andrew Dalke sent a couple of links pointing out to a binomial calculation function, one of them is below
# This file contains the Python code from Program 14.10 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Pr...
Source: Beginning Python for Bioinformatics - August 13, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics hypergeometric distribution motifs python Source Type: info
Test from Zoundry Raven
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
I am testing a offline/desktop bloggin tool, called Zoundry Raven. New posts are on the way, as promised.
Source: Beginning Python for Bioinformatics - August 6, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic test zoundry raven Source Type: info
Python for Bioinformatics: a room on FriendFeed
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via WikipediaA couple of days ago a Python for Bioinformatics room was created on FriendFeed. From all the Bioinformatics-related computer languages groups is the one with the highest number of subscribers. Anyone is welcomed to join and contribute to the room. The room has limited resources so far, but we are hoping it grows a lot in the next few days.
Come join us.
Source: Beginning Python for Bioinformatics - July 27, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 bioinformatics FriendFeed python room Source Type: info
BPB on OWW
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via WikipediaThe contents of this site/blog are being (slowly) transferred to a wiki-like page on Open Wet Ware. Thanks to Ricardo Vidal that started including the articles and was the person responsible for this initiative (and a great artist, illustrator).
What is the OWW?
OpenWetWare is an effort to promote the sharing of information, know-how, and wisdom among researchers and groups who are working in biology & biological engineering. Learn more about us.
If you would like edit access, would be interested in helping out, or want your lab website hosted on OpenWetWare, please join us.
Source: Beginning Python for Bioinformatics - July 27, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Phase 2 Source Type: info
New posts
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Image via WikipediaPosts will resume next week. I was off on vacation and then I changed jobs, so there was no time for Python fun.
Source: Beginning Python for Bioinformatics - July 24, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: off topic posts vacation Source Type: info
Bioinformatics career survey
Email this article to a colleague.
Save this article to My Clippings.
Discuss or comment on this article.
Via Bioinformatics Zen:
Loading…
Source: Beginning Python for Bioinformatics - July 2, 2008 Category: Bioinformatics Authors: Paulo Nuin Tags: Uncategorized bioinformatics career survey zen Source Type: info
