tag:blogger.com,1999:blog-80427767317145693142024-03-13T19:22:52.259-07:00code.ex(python)Python, PostgreSQL, R, sundry computer geek stuff, etc.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-8042776731714569314.post-53852214011044873582017-06-15T17:41:00.004-07:002017-06-15T17:41:46.109-07:00Dealing with Postgres "/tmp/.s.PGSQL.5432" errorI have dealt with this error quite a few times, but so infrequently that I forget the solution. When upgrading or wiping and reinstalling PostgreSQL via Homebrew, sometimes a few things get dropped by the scripts for some reason.<br />
<br />
Situation: Postgres is running, database has been created, I can log in via psql and interact with the database just fine. Even Django, running via the development runserver, can interact with the database fine. However, when you try to test the production server on Apache, you get the dreaded error:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">could not connect to server: No such file or directory</span><br />
<span style="font-family: Courier New, Courier, monospace;"> Is the server running locally and accepting</span><br />
<span style="font-family: Courier New, Courier, monospace;"> connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?</span><br />
<br />
Here is the solution:<br />
Quick check to see if /var/pgsql_socket exists:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">ls /var/ # nope, nothing here</span><br />
<br />
So then just make one, per the instructions found <a href="http://fullybaked.co.uk/articles/getting-postgresql-running-on-osx-mountain-lion">here</a><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo mkdir /var/pgsql_socket/</span><br />
<span style="font-family: Courier New, Courier, monospace;">ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/</span><br />
<br />
Reload your apache page and voila, it works.<br />
<br />
System config: OSX 10.12.5 (Sierra), httpd24, postgresql@9.5 (9.5.7), django 1.9.2Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-9496567587935297092016-09-27T10:53:00.000-07:002016-09-27T10:53:39.882-07:00How to convert PatentIn Sequence listing file back to FASTAI wrote this up as a wiki on my github site. Click the <a href="https://github.com/talonsensei/codex-python/wiki/How-to-parse-PatentIn-Format-back-to-FASTA">link</a> to visit.<br />
<br />
-MarkAnonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-88674405419193642512016-02-01T13:28:00.000-08:002016-02-01T13:28:48.590-08:00Problems starting MySQLUsing MySQL 14.14 distrib 5.7.9 for osx10.11 on El Capitan 10.11.3<br />
<br />
An existing MySQL database suddenly stopped running after a restart. When I tried to connect I first got this error:<br />
<br />
<pre class="lang-sql prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; margin: 0px; padding: 0px; white-space: inherit;"><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">Can</span><span class="str" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">'t connect to local MySQL server through socket '</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">/</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">tmp</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">/</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">mysql</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">.</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;">sock</span><span class="str" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">'</span><span class="pln" style="border: 0px; color: black; margin: 0px; padding: 0px;"> </span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">(</span><span class="lit" style="border: 0px; color: maroon; margin: 0px; padding: 0px;">2</span><span class="pun" style="border: 0px; color: black; margin: 0px; padding: 0px;">)</span></code></pre>
So tried to run mysql.server start and got this error:<div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">ERROR! The server quit without updating PID file (/usr/local/var/mysql/Honshu.local.pid)</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Tried using sudo but that did not change anything.</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Went to install location and removed the *.err file (which was 53Mb!?)</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">sudo rm /usr/local/var/mysql/Honshu.local.err</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1">Then ran mysql.server start and it started up just fine.</span></div>
</div>
Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-65479039439156455272014-02-20T15:38:00.001-08:002014-02-20T15:41:53.974-08:00How to Install Shiny Server on OSXI want to set up the <code style="background-color: #eeeeee;">shiny-server</code> to run on an iMac at work so that we can run multiple R-apps over the intranet. According to the <a href="https://github.com/rstudio/shiny-server">docs</a> for Shiny server, OSX is not supported yet (version 1.1.0) so we are going to build it from source and hope for the best! <br />
<br />
Instructions for building from source are <a href="https://github.com/rstudio/shiny-server/wiki/Building-Shiny-Server-from-Source">here</a>. We follow them pretty closely but there are a few gotchas.<br />
<br />
The full HowTo is on our GitHub Wiki, <a href="https://github.com/talonsensei/codex-python/wiki/Howto-Install-Shiny-Server-on-OSX">here</a>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-17703311588454403312013-09-16T11:40:00.000-07:002013-09-16T11:40:44.035-07:00Creating a Mountain Lion development environmentSo I had to set up a new dev environment at work on Mountain Lion. It uses the following components<br />
<br />
<ul>
<li>Hombrew</li>
<li>Python 2.7.5</li>
<li>Django 1.5.2</li>
<li>Apache 2.2.25</li>
<li>Postgres 9.2.4</li>
<li>R 3.0.1</li>
<li>Virtualenv</li>
</ul>
and a bunch of other python libraries and stuff. This system is set up for Bioinformatics development, so there are things that are specific to that. The build is documented on our internal wiki, but I copied the build instructions to the *new* <a href="http://github.com/talonsensei/codex-python/wiki/">code.ex(python) wiki</a> in my personal github account. The direct link to the build instructions is <a href="http://github.com/talonsensei/codex-python/wiki/Setup-development-environment-on-mountain-lion">here</a>.Anonymoushttp://www.blogger.com/profile/06969404015538154322noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-63806291802521065992013-09-13T13:06:00.000-07:002013-09-13T13:09:20.110-07:00Understanding Django static filesIn struggling to setup a new development/production server on Mountain Lion, I came across this good explanation of django static files and how to configure them.<br />
<br />
<a href="http://bitsoul.com/2012/10/04/understanding-django-static-files-for-beginners/">http://bitsoul.com/2012/10/04/understanding-django-static-files-for-beginners/</a><br />
<br />
Also, this link was also helpful in setting up the environment<br />
<br />
<a href="http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/">http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/</a><br />
<br />
Cheers.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-24765005456974754132013-08-28T12:00:00.001-07:002013-08-28T12:01:15.554-07:00Zipping a python dict of listsHave a python dictionary containing lists. Want to zip the lists together, but don't know the keys. Solution provided from Stackoverflow<br />
<br />
http://stackoverflow.com/questions/9828072/zipping-a-python-dict-of-lists<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/06969404015538154322noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-55395270016313827012013-08-20T10:27:00.000-07:002013-08-20T10:27:38.003-07:00How to install mod_wsgi on Mountain Lion<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;">There are apparently changes Apple made in XCode between Lion and Mountain Lion that cause the standard install method to fail. The conventional fix that comes up most often in a Google search at the time of this writing is to create a symlink between the new name of a Toolchain folder and the old name that the installer is supposedly looking for, like this </span><br />
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><b>sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain</b> </span><br />
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;">I did this and tried to make mod_wsgi using Homebrew but it throws a cryptic apxs error. Long story short, I eventually compiled mod_wsgi from source myself, but it continued to through various errors, even though things seemed to be configured properly. I went back to a different Mountain Lion machine I had configured earlier using MacPorts. When I did that machine, I had no problems with mod_wsgi or the need for this toolchain symlink. Examining the Portfile for mod_wsgi gives the key. The missing element is adding the <b>--disable-framework</b> flag to the config file. After that, everything works fine. </span><br />
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;">This flag should be added to the Homebrew Formula for mod_wsgi. I have never made a Formula before, but maybe one day I will do it. Below is the Gist showing what I did and how it worked.</span><script src="https://gist.github.com/talonsensei/6284446.js"></script><br />
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>
<span style="background-color: white; color: #666666; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 19px;"><br /></span>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-19625472363379044972013-08-12T14:11:00.000-07:002013-08-12T14:11:55.659-07:00Fix locate command on Mountain LionSo apparently upgrading to the Macintosh system Mountain Lion (10.8) breaks the unix "locate" command because it deletes the "nobody" user that was used to own the database.
I found this <a href="https://gist.github.com/zbowling/3318310"><b>gist</b></a> that gives instructions how to get it working again. However, in my case I also had to enable the root user and then log in as root in Terminal and run the command
/usr/libexec/locate.updatedb
as root. Then it finally worked. Sheesh.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-47723588831963682092013-07-25T13:34:00.000-07:002013-07-25T13:34:16.110-07:00Understanding R plot marginsCame across <b>this<a href="http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/"></a></b> great VISUAL explanation of the differences between margins (mar) and outer margin (oma) regions. This is very helpful.
Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-2128037596390627182013-07-25T10:36:00.002-07:002013-07-25T10:40:59.919-07:00How to subset RPy2 dataframeThis example demonstrates how to create subsets of RPy2 data frames using single or multiple criteria. I also wanted to test if using Github Gist is a better way the display code snippets on this blog than using Bloggers formatting tools.<br />
<br />
<script src="https://gist.github.com/talonsensei/6081973.js"></script>
And linked gist is <a href="https://gist.github.com/talonsensei/6081973">here</a>
<br />Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-48893340629841001912013-04-04T10:47:00.002-07:002013-04-04T10:48:12.352-07:00How to remap Home/End key bindings in Mac OSX Mountain LionThis is taken straight from <a href="http://mwholt.blogspot.nl/2012/09/fix-home-and-end-keys-on-mac-os-x.html">here</a>. Content is copied in case the link dies. I needed to redo the key bindings for Sublime after I upgraded the OS to 10.8. So here it is:<br />
<br />
<span style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;">To get your Home and End keys working </span><i style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;">properly</i><span style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"> on Mac OS X (in my case, Mountain Lion, although this should work in prior versions back to at least Tiger), simply open the Terminal and do this:</span><br />
<br style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;" />
<b style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"><span style="font-family: 'Courier New', Courier, monospace;">$ cd ~/Library</span></b><br />
<b style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"><span style="font-family: 'Courier New', Courier, monospace;">$ mkdir KeyBindings</span></b><br />
<b style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"><span style="font-family: 'Courier New', Courier, monospace;">$ cd KeyBindings</span></b><br />
<b style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"><span style="font-family: 'Courier New', Courier, monospace;">$ nano DefaultKeyBinding.dict</span></b><br />
<b style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;"><br /></b><span style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;">Put these lines in that file, including the curly braces:</span><br />
<br style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;" />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">{</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">/* Remap Home / End keys to be correct</span><span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;"> */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"\UF729" = "moveToBeginningOfLine:"; /* Home */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"\UF72B" = "moveToEndOfLine:"; /* End */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;">}</span><br />
<span style="background-color: white; color: #333333; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 13px; line-height: 24px; text-align: justify;"><br /></span><span style="background-color: white; color: #333333; font-family: 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 19px; text-align: justify;">Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit. Restart your computer to have it take full effect.</span>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-51553089350724961502012-07-11T14:22:00.002-07:002012-07-11T14:22:56.537-07:00Finding values in one table that are not in anotherThis site has a very good explanation of NOT IN, LEFT JOIN,where NULL, and NOT EXISTS statements for <a href="http://explainextended.com/2009/09/16/not-in-vs-not-exists-vs-left-join-is-null-postgresql/">Finding values in one table that are not in another</a>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-21108801080269339022012-05-02T11:08:00.000-07:002012-05-02T11:08:30.567-07:00Matching limited elements using Postgres IN clauseSo you have two tables, one a sequence table holds unique sequence ids. The other table hold sequence mutations and has a 1 to many relationship with the sequence table. So for a given sequence id in the mutation table, there are many records, one for each mutation.<br />
<br />
Now you have two sets of mutations you are interested in, a primary set A and a secondary set B. You want to know how many sequences contain 1 and only 1 mutation from set A and 1 and only 1 from set B. <br />
<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>select count(*) from (</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>SELECT distinct a.seq_id</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>FROM sequence a</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>JOIN seq_mutations b ON b.seq_id = a.seq_id</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>JOIN seq_mutations c ON c.seq_id = a.seq_id</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>WHERE b.mutation IN ('mutA','mutB','mutC')</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>AND c.mutation IN ('mut1', 'mut2', 'mut3', 'mut4', 'mut5')</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>GROUP BY a.seq_id</b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>HAVING </b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b> count(distinct b.mutation) = 1 </b></span><br />
<span style="font-family: 'Courier New', Courier, monospace;"><b> AND count(distinct c.mutation) = 1) a</b></span><br />
<br />
This query gives you exact, fine control over the conditions you want to test for. If you then want to test for 1 and only 1 mutation in set A and 2 and only 2 mutations in set B, just change<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>count(distinct c.mutation) = 2</b></span><br />
<br />
in the HAVING clause. This also lets you use > and <, so you can ask for 3 or more mutations by using<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"><b>count(distinct c.mutation) >= 3</b></span><br />
<br />
You can also vary the count for b.mutation to adjust the number of mutations allowed from set A, so any combination can now be extracted.<br />
<br />
Thanks to Jake for the code help.<br />Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-58110554656429352682012-04-30T12:01:00.002-07:002012-04-30T12:02:35.906-07:00Convert Postgres column from text to numeric typeALTER TABLE foo ALTER COLUMN col TYPE NUMERIC USING col::numeric<br />
<br />
You can use this with data in the table. All data must be convertable (no alpha chars). You can also specify numeric formatting here if you like.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com1tag:blogger.com,1999:blog-8042776731714569314.post-51920693791158492652011-10-05T14:32:00.000-07:002011-10-05T14:32:49.836-07:00cron HellFinally solved a nightmare trying to get a python script to execute properly (at all!) under crontab on Linux 64-bit machine.<br />
<br />
Things I learned:<br />
<br />
1. cron executes using /bin/sh so if you want to execute a bash script, you need to call it explicitly in crontab like this */1 * * * * root /bin/bash /opt/bin/hcv_update.cron<br />
<div>
<br /></div>
<div>
2. cron does not have it's own environment variables, so you need to figure out how to get it to see those for the user you want to run as (root). The easiest way to do this is to make a shell script that calls your python script. You have more control over what is going on. Also, you can source your .bash_profile so that the variables are now inherited.</div>
<div>
<br /></div>
<div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">#!/bin/bash</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">source /root/.bash_profile</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># calls python update script</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">/usr/local/bin/python2.7 /opt/bin/hcv_comm_query.py</span></b></div>
</div>
<div>
<br /></div>
<div>
3. If you have more than one version of python on the system (RedHat always has 2.4 present), make sure you explicitly call the right one.</div>
<div>
<br /></div>
<div>
4. In this case, was using cx_Oracle as well, so explicitly defined the Oracle paths in the python script just in case. This shouldn't be necessary though if they are already present in the .bash_profile</div>
<div>
<br /></div>
<div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import os</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">os.environ["LD_LIBRARY_PATH"]="/usr/lib/oracle/11.2/client64/lib"</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">os.environ["ORACLE_HOME"]="/usr/lib/oracle/11.2/client64"</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">os.environ["TNS_ADMIN"]="/usr/lib/oracle/11.2/client64"</span></b></div>
<div>
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import cx_Oracle as cxo</span></b></div>
</div>
<div>
<br /></div>
<div>
This should solve the problem.</div>
Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-45467788170006959012011-09-29T15:01:00.000-07:002011-10-05T14:34:24.901-07:00Django, Apache 2 and mod_wsgiA pain in the neck to set up, but nice to have.<br />
<br />
1. Follow installation instructions for mod_wsgi and django<br />
2. Add to httpd.conf<br />
<br />
<span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> <b># ----------- Django / WSGI Configuration ----------</b></span><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> WSGIDaemonProcess processes=2 threads=15</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> </span></b><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> WSGIScriptAlias /mgrm "/home/django/var/www/mgrm/apache/django.wsgi"</span></b><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> <Directory "/home/django/var/www/mgrm/"></span></b><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> Order allow,deny</span></b><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> Allow from all</span></b><br />
<b><span class="Apple-style-span" style="background-color: white; font-family: 'Courier New', Courier, monospace;"> </Directory></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> </span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> Alias "/static/admin" "/opt/python2.7/lib/python2.7/site-packages/django/contrib/admin/media/"</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> <Directory "/opt/python2.7/lib/python2.7/site-packages/django/contrib/admin/media/"></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> Order allow,deny</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> Allow from all</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> </Directory></span></b><br />
<div>
<br /></div>
<br />
*Note that the alias for "static/admin" must match whatever alias and path are in the main settings.py file in your Django project directory<br />
<br />
3. Create a django.wsgi file in the place that is specified by the path you used in the WSGIScriptAlias that contains the following:<br />
<br />
<br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import os</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import sys</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># Option one</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">#sys.path.append('/home/django/var/www')</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">#sys.path.append('/home/django/var/www/mgrm')</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">#os.environ['DJANGO_SETTINGS_MODULE'] = 'mgrm.settings'</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">#os.environ['DJANGO_ENV'] = 'PRODUCTION'</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># Option two</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># from http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">sys.path.insert(0,'/home/django/var/www/mgrm')</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import settings</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import django.core.management</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">django.core.management.setup_environ(settings)</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">utility = django.core.management.ManagementUtility()</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">command = utility.fetch_command('runserver')</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">command.validate()</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import django.conf</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import django.utils</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"># Common to both options</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">import django.core.handlers.wsgi</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">application = django.core.handlers.wsgi.WSGIHandler()</span></b><br />
<br />
<br />
*Note that this file goes inside your django project folder, preferably in an apache folder.<br />
<br />
5. Edit main urls.py so that you can use files with both the django server and apache like this:<br />
<br />
<br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">urlpatterns = patterns('',</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # mod_wsgi does NOT pass the '/mgrm' mount point to this application. However,</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # the django development server does. So in order to get these urls.py to</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # work correctly with both, I created a match group that doesn't create a </span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # back reference. That match group is this: (?:mgrm/)?</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> url(r'^(?:mgrm/)?polls/',include('polls.urls')),</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> </span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # Admin sites are doing some reverse url lookup, and the match group trick</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # doesn't work with them. To resolve this issue we create two references:</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> # one for mod_wsgi, and the other for the development server.</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> url(r'^admin/',include(admin.site.urls)),</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> url(r'^mgrm/admin/', include(admin.site.urls)),</span></b><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">)</span></b><br />
<br />
<br />
6. May need to edit templates to add the application name to each url in the template.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-32320054742786529732011-09-14T11:58:00.000-07:002011-09-14T11:58:02.602-07:00How to get Django to see multiple PostgreSQL schemasTook awhile to figure this out, so here goes.<br />
<br />
First create a PostgreSQL user that will be used by Django to connect to the database. This is the user that will be included in the settings.py file for the database connection section.<br />
<br />
Log into PostgreSQL as admin/superuser and issue the following command:<br />
<br />
<b style="background-color: #cccccc;">GRANT USAGE SCHEMA foo TO django_user;</b><br />
<b style="background-color: #eeeeee;"><br /></b><br />
<span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;">(Or GRANT USAGE to any role which has django_user as a (direct or indirect) member.)<br />(Or GRANT ALL ... if that is what you want.)</span><br />
<br />
The next step is to change the default schema search path. To make a permanent change, do the following:<br />
<br />
<b style="background-color: #cccccc;">ALTER ROLE django_user SET SEARCH_PATH to "$user",public,your_schema;</b><br />
<br />
Log out and log back in for the change to take effect. You can test the outcome by doing a <b style="background-color: #cccccc;">\dt</b> and you should see all table from all schemas that the role has been granted access to.<br />
<br />
You can now run <b style="background-color: #cccccc;">manage.py inspectdb</b> and it will see all tables in all schemas. Don't know yet how it will treat tables with the same name in different schemas, as it is no longer required to prefix the schema name in a query, although it can still be done.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-18209815223445568222011-07-29T16:02:00.001-07:002011-07-29T16:07:34.700-07:00ClustalW2 Command line ArgumentsCLUSTAL 2.0.12 Multiple Sequence Alignments<br />
<br />
<br />
DATA (sequences)<br />
<br />
-INFILE=file.ext :input sequences.<br />
-PROFILE1=file.ext and -PROFILE2=file.ext :profiles (old alignment).<br />
<br />
<br />
VERBS (do things)<br />
<br />
-OPTIONS :list the command line parameters<br />
-HELP or -CHECK :outline the command line params.<br />
-FULLHELP :output full help content.<br />
-ALIGN :do full multiple alignment.<br />
-TREE :calculate NJ tree.<br />
-PIM :output percent identity matrix (while calculating the tree)<br />
-BOOTSTRAP(=n) :bootstrap a NJ tree (n= number of bootstraps; def. = 1000).<br />
-CONVERT :output the input sequences in a different file format.<br />
<br />
<br />
PARAMETERS (set things)<br />
<br />
***General settings:****<br />
-INTERACTIVE :read command line, then enter normal interactive menus<br />
-QUICKTREE :use FAST algorithm for the alignment guide tree<br />
-TYPE= :PROTEIN or DNA sequences<br />
-NEGATIVE :protein alignment with negative values in matrix<br />
-OUTFILE= :sequence alignment file name<br />
-OUTPUT= :GCG, GDE, PHYLIP, PIR or NEXUS<br />
-OUTORDER= :INPUT or ALIGNED<br />
-CASE :LOWER or UPPER (for GDE output only)<br />
-SEQNOS= :OFF or ON (for Clustal output only)<br />
-SEQNO_RANGE=:OFF or ON (NEW: for all output formats)<br />
-RANGE=m,n :sequence range to write starting m to m+n<br />
-MAXSEQLEN=n :maximum allowed input sequence length<br />
-QUIET :Reduce console output to minimum<br />
-STATS= :Log some alignents statistics to file<br />
<br />
***Fast Pairwise Alignments:***<br />
-KTUPLE=n :word size<br />
-TOPDIAGS=n :number of best diags.<br />
-WINDOW=n :window around best diags.<br />
-PAIRGAP=n :gap penalty<br />
-SCORE :PERCENT or ABSOLUTE<br />
<br />
<br />
***Slow Pairwise Alignments:***<br />
-PWMATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or filename<br />
-PWDNAMATRIX= :DNA weight matrix=IUB, CLUSTALW or filename<br />
-PWGAPOPEN=f :gap opening penalty <br />
-PWGAPEXT=f :gap opening penalty<br />
<br />
<br />
***Multiple Alignments:***<br />
-NEWTREE= :file for new guide tree<br />
-USETREE= :file for old guide tree<br />
-MATRIX= :Protein weight matrix=BLOSUM, PAM, GONNET, ID or filename<br />
-DNAMATRIX= :DNA weight matrix=IUB, CLUSTALW or filename<br />
-GAPOPEN=f :gap opening penalty <br />
-GAPEXT=f :gap extension penalty<br />
-ENDGAPS :no end gap separation pen.<br />
-GAPDIST=n :gap separation pen. range<br />
-NOPGAP :residue-specific gaps off <br />
-NOHGAP :hydrophilic gaps off<br />
-HGAPRESIDUES= :list hydrophilic res. <br />
-MAXDIV=n :% ident. for delay<br />
-TYPE= :PROTEIN or DNA<br />
-TRANSWEIGHT=f :transitions weighting<br />
-ITERATION= :NONE or TREE or ALIGNMENT<br />
-NUMITER=n :maximum number of iterations to perform<br />
-NOWEIGHTS :disable sequence weighting<br />
<br />
<br />
***Profile Alignments:***<br />
-PROFILE :Merge two alignments by profile alignment<br />
-NEWTREE1= :file for new guide tree for profile1<br />
-NEWTREE2= :file for new guide tree for profile2<br />
-USETREE1= :file for old guide tree for profile1<br />
-USETREE2= :file for old guide tree for profile2<br />
<br />
<br />
***Sequence to Profile Alignments:***<br />
-SEQUENCES :Sequentially add profile2 sequences to profile1 alignment<br />
-NEWTREE= :file for new guide tree<br />
-USETREE= :file for old guide tree<br />
<br />
<br />
***Structure Alignments:***<br />
-NOSECSTR1 :do not use secondary structure-gap penalty mask for profile 1<br />
-NOSECSTR2 :do not use secondary structure-gap penalty mask for profile 2<br />
-SECSTROUT=STRUCTURE or MASK or BOTH or NONE :output in alignment file<br />
-HELIXGAP=n :gap penalty for helix core residues<br />
-STRANDGAP=n :gap penalty for strand core residues<br />
-LOOPGAP=n :gap penalty for loop regions<br />
-TERMINALGAP=n :gap penalty for structure termini<br />
-HELIXENDIN=n :number of residues inside helix to be treated as terminal<br />
-HELIXENDOUT=n :number of residues outside helix to be treated as terminal<br />
-STRANDENDIN=n :number of residues inside strand to be treated as terminal<br />
-STRANDENDOUT=n:number of residues outside strand to be treated as terminal<br />
<br />
<br />
***Trees:***<br />
-OUTPUTTREE=nj OR phylip OR dist OR nexus<br />
-SEED=n :seed number for bootstraps.<br />
-KIMURA :use Kimura's correction. <br />
-TOSSGAPS :ignore positions with gaps.<br />
-BOOTLABELS=node OR branch :position of bootstrap values in tree display<br />
-CLUSTERING= :NJ or UPGMA<br />
<div><br />
<span class="Apple-style-span" style="font-family: 'Segoe UI', Calibri, 'Myriad Pro', Myriad, 'Trebuchet MS', Helvetica, Arial, sans-serif; font-size: 15px; line-height: 22px;"></span><br />
<div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">>> HELP 0 << Help for tree output format options</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Four output formats are offered: 1) Clustal, 2) Phylip, 3) Just the distances<br />
4) Nexus</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">None of these formats displays the results graphically. Many packages can<br />
display trees in the the PHYLIP format 2) below. It can also be imported into<br />
the PHYLIP programs RETREE, DRAWTREE and DRAWGRAM for graphical display.<br />
NEXUS format trees can be read by PAUP and MacClade.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">1) Clustal format output.<br />
This format is verbose and lists all of the distances between the sequences and<br />
the number of alignment positions used for each. The tree is described at the<br />
end of the file. It lists the sequences that are joined at each alignment step<br />
and the branch lengths. After two sequences are joined, it is referred to later<br />
as a NODE. The number of a NODE is the number of the lowest sequence in that<br />
NODE.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">2) Phylip format output.<br />
This format is the New Hampshire format, used by many phylogenetic analysis<br />
packages. It consists of a series of nested parentheses, describing the<br />
branching order, with the sequence names and branch lengths. It can be used by<br />
the RETREE, DRAWGRAM and DRAWTREE programs of the PHYLIP package to see the<br />
trees graphically. This is the same format used during multiple alignment for<br />
the guide trees.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Use this format with NJplot (Manolo Gouy), supplied with Clustal W. Some other<br />
packages that can read and display New Hampshire format are TreeView (Mac/PC),<br />
TreeTool (UNIX), and Phylowin.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">3) The distances only.<br />
This format just outputs a matrix of all the pairwise distances in a format<br />
that can be used by the Phylip package. It used to be useful when one could not<br />
produce distances from protein sequences in the Phylip package but is now<br />
redundant (Protdist of Phylip 3.5 now does this).</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">4) NEXUS FORMAT TREE. This format is used by several popular phylogeny programs,<br />
including PAUP and MacClade. The format is described fully in:<br />
Maddison, D. R., D. L. Swofford and W. P. Maddison. 1997.<br />
NEXUS: an extensible file format for systematic information.<br />
Systematic Biology 46:590-621.</div><div style="border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: inherit; font-size: 15px; font-style: inherit; font-weight: inherit; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">5) TOGGLE PHYLIP BOOTSTRAP POSITIONS<br />
By default, the bootstrap values are placed on the nodes of the phylip format<br />
output tree. This is inaccurate as the bootstrap values should be associated<br />
with the tree branches and not the nodes. However, this format can be read and<br />
displayed by TreeTool, TreeView and Phylowin. An option is available to<br />
correctly place the bootstrap values on the branches with which they are<br />
associated.</div></div>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-18477421133401921332011-07-29T12:03:00.000-07:002011-07-29T12:03:02.274-07:00Setting up X Windows on MacFor Snow Leopard. <br />
<br />
First check<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b> /usr/etc/sshd_config</b></span> and make sure that "<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>X11 Forwarding yes</b></span>" has been set.<br />
<br />
Then login to remote server with <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>ssh -X user@remote.server</b></span><br />
<br />
Start remote desktop (e.g. gnome) with <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><b>gnome-session</b></span>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-87619944487679511742011-03-29T13:29:00.000-07:002011-03-29T13:29:44.680-07:00Adding PHP module to default OS 10.6.1 PHP stackThe current system is Snow Leopard 10.6.1 and I want to add PostgreSQL support to the default PHP installation. Snow Leopard comes with PHP 5.3.4 already installed in Apple's weird, distributed way. However, the current distro for PHP is 5.3.6 at the time of this writing, so what to do? I found the solution scattered across many different blogs, so I am synthesizing it here. None of this was my own creation.<br />
<br />
First, grab a copy of the source code that matches what is already installed. Probably won't find it on PHP.net, so try this link: <a href="http://us.php.net/get/php-5.3.4.tar.gz/from/a/mirror">php-5.3.4</a><br />
<br />
I created a /src directory to store source code in. Copy the tar file into here or a similar directory and unpack it.<br />
<br />
Change to that directory:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><b></b></span><br />
<b><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>cd /src/php-5.3.4</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;">Set some environment variables before doing the configuration</span></span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;"><br />
</span></span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>export MACOSX_DEPLOYMENT_TARGET=10.6.7</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>export CFLAGS="-arch x86_64"</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>export CXXFLAGS="-arch x86_64"</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>export LDFLAGS="-arch x86_64"</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-weight: normal;">Go to the pgsql source directory in php ext folder</span></span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small;"><span class="Apple-style-span" style="font-weight: normal;"><br />
</span></span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>cd ext/pgsql</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">Compile the extension module</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><br />
</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>phpize</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>./configure</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>make</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">The extension will be found here</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>cd /src/php-5.3.4/ext/pgsql/.libs/</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>ls</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">-rwxr-xr-x 1 Bali admin 154K Mar 29 12:41 pgsql.so</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">Copy the extension to the extensions library and make sure it is executable</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><br />
</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>sudo cp pgsql.so </span><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">/usr/lib/php/extensions/no-debug-non-zts-20090626/</span></div></b></span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>cd </span><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">/usr/lib/php/extensions/no-debug-non-zts-20090626/</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>sudo chmod +x pgsql.so</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">Create a copy of the php.ini file if one does not already exist</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><br />
</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>sudo cp /etc/php.ini.default /etc/php.ini</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">Edit the php.ini file and add the following two lines:</span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">extension_dir="/usr/lib/php/extensions/no-debug-non-zts-20090626/"</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">extension=pgsql.so</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-weight: normal;"><span class="Apple-style-span" style="font-size: small;">Save and then test that the extension is loaded properly by running the following at the command line:</span></span></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>php -m</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">You should see a list of installed modules, including pgsql. Then go back and restart Apache</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><br />
</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: xx-small;"><b><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">>/usr/sbin/apachectl graceful</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-weight: normal;"><b><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: x-small;"><br />
</span></div></b></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">Run phpinfo to verify the module has been loaded. You may have to scroll down to see it.</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;"><br />
</span></span></div></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><div style="color: black; display: inline !important; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-size: small; font-weight: normal;">That is it.</span></span></div></div></b></span></span></span></div></div></b>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-46802223095843898212011-02-04T16:01:00.000-08:002011-02-24T13:49:40.975-08:00Installing libsvm-3.0 for Python on OSX 10.6This was very frustrating to solve and I eventually had to get my friend Kieran (thanks Kieran!) to help me. Basically the vanilla installation instructions that come with are insufficient (at least for me) to get a working module. Here are the steps that were required to get everything to work.<br />
<br />
1. Run '<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b>make</b></span>' in the libsvm-3.0 directory<br />
<br />
2. Run '<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b>make</b></span>' in the libsvm-3.0/python directory<br />
<br />
In the libsvm-3.0 directory there now should be a .so2 file<br />
<br />
3. Create a new directory in your site-packages directory (your pythonpath) called libsvm<br />
<br />
4. Copy the .so2 file from libsvm-3.0 and the svm.py, svm.pyc, svmutil.py files from libsvm-3.0/python to site-packages/libsvm<br />
<br />
There are a couple things that are missing so now we need to make them.<br />
<br />
5. In site-packages/libsvm create a file called __init__.py. This is an empty file, but it is necessary to get the directory recognized as a python module.<br />
<br />
6. Edit svm.py and add the following two lines after the other import statements at the top of the file:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b>import os.path</b></span><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"></span></b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> _PATH = os.path.join( *os.path.split(__file__)[:-1] )</b></span><br />
<br />
<br />
7. At around line 7 you will see this statement<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;">#<b> For unix the prefix 'lib' is not considered.</b></span><br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> if find_library('svm'):</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> libsvm = CDLL(find_library('svm'))</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> elif find_library('libsvm'):</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> libsvm = CDLL(find_library('libsvm'))</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> else:</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> if sys.platform == 'win32':</b></span><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"></span></b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> libsvm = CDLL('../windows/libsvm.dll')</b></span><br />
<b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"></span></b><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> else:</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> libsvm = CDLL('../libsvm.so.2')</b></span><br />
<br />
8. Change this to look like this:<br />
<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> <b># For unix the prefix 'lib' is not considered.</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> if find_library('svm'):</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>libsvm = CDLL(find_library('svm'))</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> elif find_library('libsvm'):</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>libsvm = CDLL(find_library('libsvm'))</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b> else:</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>if sys.platform == 'win32':</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>libsvm = CDLL(os.path.join(_PATH,'windows','libsvm.dll'))</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>else:</b></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><span class="Apple-style-span" style="white-space: pre;"><b> </b></span><b>libsvm = CDLL(os.path.join(_PATH,'libsvm.so.2'))</b></span><br />
<br />
9. Once you save svm.py, you should be able to fire up a python interpreter and do<span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"> <b>'from libsvm </b></span><span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b>import svm</b></span>'. If that works, and a <span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"><b>dir(svm)</b></span> shows you a ton of functions, then you are good to go.Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com5tag:blogger.com,1999:blog-8042776731714569314.post-79924132860185459492011-01-19T16:00:00.000-08:002011-01-19T16:50:16.526-08:00Generate all possible proteins from ambiguous DNAThis had me stumped for awhile, but this works pretty well. Does NOT handle stop codons or gap characters like '-'. Requires BioPython<br />
<br />
<span class="Apple-style-span" style="color: #404040; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"></span><br />
<pre class="prettyprint" style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><span class="Apple-style-span" style="color: darkblue;"><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="font-size: x-small;"><b><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">import itertools</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">from Bio.Seq import Seq</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">from Bio.Data import CodonTable</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">from Bio.Data import IUPACData</pre></span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"># Takes Bio.Seq.Seq object as input</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"># Returns list of all possible proteins</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"># Assumes sequence is in frame +1</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">def generateProtFromAmbiguousDNA(s):</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> std_nt = CodonTable.unambiguous_dna_by_name["Standard"]</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> nonstd = IUPACData.ambiguous_dna_values</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> aa_trans = []</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> for i in range(0,len(s),3):</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> codon = s.tostring()[i:i+3]</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> aa = CodonTable.list_possible_proteins(codon,std_nt.forward_table,nonstd) </span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> aa_trans.append(aa)</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> proteins = list(itertools.product(*aa_trans))</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> possible_proteins = []</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> for x in proteins:</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> possible_proteins.append("".join(x))</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> return possible_proteins</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">def main():</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> a = Seq('ATGGCARTTGTAHAC')</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> print "DNA: ",a.tostring()</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> print "Proteins:"</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> foo = generateProtFromAmbiguousDNA(a)</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> for s in foo: print s</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">
</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">if __name__ == '__main__':</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;"> main()</span></div></b></span></span></div></span></pre>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-12799529019213561912011-01-19T10:35:00.000-08:002011-01-19T10:35:37.765-08:00Creating a quick codon tableI didn't think this up, the code comes from Peter Collingridge <a href="http://petercollingridge.co.uk/blog/python-codon-table">here</a>. But it is rather elegant.<br />
<br />
<span class="Apple-style-span" style="color: #404040; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px;"></span><br />
<pre class="prettyprint" style="background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; margin-bottom: 10px; margin-left: 0px; margin-right: 0px; margin-top: 0px; max-height: 600px; overflow-x: auto; overflow-y: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; vertical-align: baseline; width: auto;"><span class="Apple-style-span" style="color: darkblue;"><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="font-size: x-small;"><b></b></span></span>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><span class="Apple-style-span" style="font-size: x-small;"><b><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">bases = ['t', 'c', 'a', 'g']</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">codons = [a+b+c for a in bases for b in bases for c in bases]</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">amino_acids = "F F L L S S S S Y Y stop stop C C stop W L L L L P P P P H H Q Q R R R R I I I M T T T T N N K K S S R R V V V V A A A A D D E E G G G G".split(' ')</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"><span class="Apple-style-span" style="font-size: small;">codon_table = dict(zip(codons, amino_acids))</span></div><div style="color: black; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; white-space: normal;"></div></b></span></span></div></span></pre>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0tag:blogger.com,1999:blog-8042776731714569314.post-85714322539213360512011-01-13T15:39:00.000-08:002011-01-13T15:39:31.974-08:00Update the locate database on the MacThis is the command for updating the locate database on the OSX system. <br />
<br />
<span class="Apple-style-span" style="color: #666666; font-family: Verdana, sans-serif; font-size: 14px; line-height: 22px;">sudo /usr/libexec/locate.updatedb</span><br />
<span class="Apple-style-span" style="color: #666666; font-family: Verdana, sans-serif; font-size: 14px; line-height: 22px;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif; font-size: medium;"><span class="Apple-style-span" style="font-size: 14px; line-height: 22px;">I should figure out how to make this run everyday.</span></span>Anonymoushttp://www.blogger.com/profile/03579522812057768523noreply@blogger.com0