Thursday, May 20, 2010

UniFrac :: Setup :: Execution

Download source code from
http://bmf2.colorado.edu/unifrac/about.psp

$ unzip  unifrac.zip
$ cd unifrac.zip

read README.txt
Requirements
- Python
- Python module Numeric
To check if Numeric module is present
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Numeric
>>>
- if the above return error, then
$ sudo apt-get install python-numeric-ext-dbg
- i tried installing only the python-numeric but it gave a error saying that MLab module is missing.
- so i used the above installation set

Steps
>>> from set import Set
- there is some deprecated code, so use this line
>>> from tree_comparison_api import TreeAnalysis
- To start with the analysis
>>> a=TreeAnalysis()
- create object a
>>> print a.__doc__
- lists all the methods along with the parameters required.
session for doing an analysis on a tree
   
Class: TreeAnalysis(interactive=True)

    Usage: session = TreeAnalysis()
        Starts a new session called 'session'.
        Interactive indicates whether the session will be run on the command
            line (True) or from a script (False). By default is True.

    Properties:
        Tree: tree on which all called stats functions are run
        LastSession: saves the current TreeAnalysis object whenever
            the tree is changed
        DataInfo: maps the name of a node (node.Data) to the node object
        Output: records the results of analyses done during a session as a list
        SessionLog: records the steps performed during a session as a list

    Methods:

    To get detailed info on any method type:
    print TreeAnalysis.method_name.__doc__


    ***Loading a Tree:***
   
    loadTreeFromFile(self, file_path, format, tree_name=None)
            loads a tree from a Nexus or Newick from Arb formatted file
    loadTreeFromString(self, input)
            loads a tree from a string or list of strings


    ***Setting the Branch Lengths:***

    setBlFromFile(self, file_path, format='NexLog')
            sets node BranchLengths from info in a file
    setBlToValue(self, value=1.0)
            sets the BranchLengths property of all nodes to value


    ***Loading Environment Information***

    loadEnvs(self, format, file_path=None):
            sets Envs property of nodes


    ***Modifying Tree Contents (taxa represented by tree)***

    pruneTree(self):
        removes terminal descendants that have no environment assigned
    removeNodeByName(name):
        removes a node from the tree identified by name (Data property)
    removeNodeByLCA(self, first_name, second_name):
        removes a node identified as Last Common Ancestor of 2 nodes
    isolateNodeByName(self, name):
        sets the Tree to a node identified by name
    isolateNodeByLCA(self, first_name, second_name):
        sets the Tree to the Last Common Ancestor of 2 nodes
    restoreLastSession(self):
        sets the current TreeAnalysis session to LastSession


    ***Modify Node Names (Data property of nodes in a tree)***

    nameUnnamedNodes(self):
        assigns an arbitrary name to unnamed nodes
    addEnvsToName(self):
        appends the envs to the node name (Data property of node)


    ***Statistical analysis***

    phylogeneticTestP(self, p_output='Tree', pop_size):
        generates p-values for the Tree using the Phylogenetic (P) test
    uniFracP(self, p_output='Tree', pop_size=1000, Weight=False):
        generates p-values for the Tree using the UniFrac metric
    makeEnvDistanceMatrix(self, Weight=False, pad=None, norm=False):
        generates a Distance Matrix for environments in Tree using UniFrac
    clusterEnvs(self, Weight=False, norm=False):
        uses UPGMA to cluster the environments in a tree based on UniFrac
    UniFracPCA(self, Weight=False, norm=False):
        performs principal coordinates analysis on self.Tree using UniFrac
    PD_rarefaction(self, file_path_base='PD_rarefaction_output', env_list=None
        num_reps = 50, stride=1)
        Creates PD rarefaction curves
    G_rarefaction(self, file_path_base='G_rarefaction_output', env_list=None
        num_reps = 50, stride=1)
        Creates G rarefaction curves
       
The exact python code depends on the type of UniFrac analyses that you want to do,  ie;.e UPGMA clustering, PCoA, Pairwise significance testing, whether you want to do  a weighted or unweighted analysis, etc. It also depends on things like the format of  your tree file (it can be in Newick or Nexus format). An example of a list of python  commands that one might type in to do an analysis, however, is below:  
#load the necessary code 
>>> from tree_comparison_api import TreeAnalysis

#make an UniFrac session object
>>>  a = TreeAnalysis()

#load a tree file in Newick format 
>>>  a.loadTreeFromFile('path_to_tree_file.tree', 'NwA') 

#load Environment information that has no abundance information 
>>> a.loadEnvs('TabDel', 'env_file.txt') 

#run unweighted UniFrac pairwise significance test 
>>> a.uniFracP(p_output='Pairwise', Weight=False, pop_size=1000)

Wednesday, May 12, 2010

Rails :: Deploy :: Application

 http://developer.apple.com/tools/deployonrailsleopard.html

First we have go for Software Configuration management.(SCM)
Ex. SVN, but i will use git here

It can be installed using
$ gem install git
or
$ sudo apt-get install git-core git-doc

Create the git repository
$ mkdir -p ~/git/app.git
- where app is the ruby application name
$ cd ~/git/app.git
$ git --bare init
Initialized empty Git repository in /home/kr/REPOSITORY/git/mum.git/

The directories are created here.
$ ls -l 
total 32
drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 branches/
drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 hooks/
drwxr-xr-x 2 kr localuser 4096 2010-05-20 09:30 info/
drwxr-xr-x 4 kr localuser 4096 2010-05-20 09:30 objects/
drwxr-xr-x 4 kr localuser 4096 2010-05-20 09:30 refs/
-rw-r--r-- 1 kr localuser   66 2010-05-20 09:30 config
-rw-r--r-- 1 kr localuser   73 2010-05-20 09:30 description
-rw-r--r-- 1 kr localuser   23 2010-05-20 09:30 HEAD

To setup the ssh key on the server
$ test -e ~/.ssh/id_dsa.pub || ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/kr/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/kr/.ssh/id_dsa.
Your public key has been saved in /home/kr/.ssh/id_dsa.pub.
The key fingerprint is:
so:me:..:fi:ng:er:..:pr:in:t. kr@BIOINFO
The key's randomart image is:
+--[ DSA 1024]----+
|    ..           |
|     o.          |
|    ...          |
|    .. .         |
|. .o+ . S        |
|.+.+o. o         |
|o.. E.=          |
|.   os..         |
|     o+o.        |
+-----------------+

$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2
Setup git subversion
- in the Ruby application directory eg. mum
$ vim .gitignore
db/*.sqlite3
log/*.log
tmp/**/*

Now commit everything to the local repository which was generated above
$ git init
Initialized empty Git repository in /home/kr/Public/mum/.git/
$ git add .
$ git commit -m "initial commit"
[master (root-commit) b3dd69e] initial commit
 Committer: Kashi Revanna
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

    git commit --amend --author='Your Name '

 60 files changed, 9111 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 README
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application.rb
 create mode 100644 app/controllers/mum_controller.rb
 create mode 100644 app/helpers/application_helper.rb
 create mode 100644 app/helpers/mum_helper.rb
 create mode 100644 app/views/mum/index.rhtml
 create mode 100644 config/boot.rb
 create mode 100644 config/database.yml
 create mode 100644 config/environment.rb
 create mode 100644 config/environments/development.rb
 create mode 100644 config/environments/production.rb
 create mode 100644 config/environments/test.rb
 create mode 100644 config/initializers/inflections.rb
 create mode 100644 config/initializers/mime_types.rb
 create mode 100644 config/initializers/new_rails_defaults.rb
 create mode 100644 config/locales/en.yml
 create mode 100644 config/routes.rb
 create mode 100644 doc/README_FOR_APP
 create mode 120000 doc/api
 create mode 100644 public/404.html
 create mode 100644 public/422.html
 create mode 100644 public/500.html
 create mode 100755 public/dispatch.cgi
 create mode 100755 public/dispatch.fcgi
 create mode 100755 public/dispatch.rb
 create mode 100644 public/favicon.ico
 create mode 100644 public/images/rails.png
 create mode 100644 public/index.html
 create mode 100644 public/javascripts/application.js
 create mode 100644 public/javascripts/controls.js
 create mode 100644 public/javascripts/dragdrop.js
 create mode 100644 public/javascripts/effects.js
 create mode 100644 public/javascripts/prototype.js
 create mode 100644 public/robots.txt
 create mode 100755 script/about
 create mode 100755 script/console
 create mode 100755 script/dbconsole
 create mode 100755 script/destroy
 create mode 100755 script/generate
 create mode 100755 script/performance/benchmarker
 create mode 100755 script/performance/profiler
 create mode 100755 script/performance/request
 create mode 100755 script/plugin
 create mode 100755 script/process/inspector
 create mode 100755 script/process/reaper
 create mode 100755 script/process/spawner
 create mode 100755 script/runner
 create mode 100755 script/server
 create mode 100644 test/functional/mum_controller_test.rb
 create mode 100644 test/performance/browsing_test.rb
 create mode 100644 test/test_helper.rb
 create mode 120000 vendor/actionmailer
 create mode 120000 vendor/actionpack
 create mode 120000 vendor/activemodel
 create mode 120000 vendor/activerecord
 create mode 120000 vendor/activeresource
 create mode 120000 vendor/activesupport
 create mode 120000 vendor/rails
 create mode 120000 vendor/railties
To push all the code to the server
$ git remote add origin ssh://user@hostname/~/REPOSITORY/git/mum.git
- shouldnt return any error
$ git push origin master
 The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is
so:me:..:fi:ng:er:..:pr:in:t.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Counting objects: 82, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (82/82), 82.79 KiB, done.
Total 82 (delta 14), reused 0 (delta 0)
To ssh://localhost/~/REPOSITORY/git/mum.git
 * [new branch]      master -> master

Check if this gem is already installed
$ gem list -d capistrano

If not found, install it
 $ gem install capistrano

Check by typing
$ cap
- mine gave error saying it is not found, so
$ sudo apt-get install capistrano


Check again
$ cap
- it should give a list of options.

Steps
$ capify .
[add] writing `./Capfile'
[add] writing `./config/deploy.rb'
[done] capified!


Edit the config/deploy.rb
my file
## Some important information
set :user, "kr"
set :domain, "localhost"
set :application, "mum"

## file paths
set :repository,  "#{user}@#{domain}:/home/../git/#{application}.git"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"
set :deploy_to, "/home/#{user}/Public/#{application}"

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion
set :scm, "git"
set :branch, "master"
set :scm_verbose, true
set :use_sudo, false

## task that causes Passenger to initiate a restart
namespace :deploy do
    task :restart do
        run "touch #{current_path}/tmp/restart.txt"
    end
end

role :app, "localhost"
role :web, "localhost"
role :db,  "localhost", :primary => true

This is how you deploy the server using cap

$ cap deploy:setup
  * executing `deploy:setup'
  * executing "mkdir -p 
/home/kr/Public/mum 
/home/kr/Public/mum/releases 
/home/kr/Public/mum/shared 
/home/kr/Public/mum/shared/system 
/home/kr/Public/mum/shared/log 
/home/kr/Public/mum/shared/pids 
&& chmod g+w 
/home/kr/Public/mum 
/home/kr/Public/mum/releases 
/home/kr/Public/mum/shared 
/home/kr/Public/mum/shared/system 
/home/kr/Public/mum/shared/log 
/home/kr/Public/mum/shared/pids"
    servers: ["localhost"]
    [localhost] executing command
    command finished

$ cap deploy:check
  * executing `deploy:check'
  * executing "test -d /home/krevanna/Public/mum/releases"
    servers: ["localhost"]
    [localhost] executing command
    command finished
  * executing "test -w /home/krevanna/Public/mum"
    servers: ["localhost"]
    [localhost] executing command
    command finished
  * executing "test -w /home/krevanna/Public/mum/releases"
    servers: ["localhost"]
    [localhost] executing command
    command finished
  * executing "which git"
    servers: ["localhost"]
    [localhost] executing command
    command finished
You appear to have all necessary dependencies installed

$ cap deploy:migrations

$ cap deploy
- It shouldnt give errors

Also modify the Apache virtual host as below

From the web-browser, the url is localhost/mum

  ServerAdmin webmaster@localhost
  ServerName localhost
  DocumentRoot /home/kr/Public/mum/public
 
     Options Indexes FollowSymLinks MultiViews
     AllowOverride None
     Order allow,deny
     allow from all
 


This is very educational guide on passenger setup
http://www.modrails.com/documentation/Users%20guide%20Apache.html

More notes on Capistrano
 http://www.capify.org/index.php/Capistrano

Rails :: Apache :: Passenger

Given
- Apache installed
- Rails installed

Rails work independently with Mongrel and can be executed
$ rails server
web address- localhost:3000

To connect apache with Rails we need passenger.

Steps to install passenger
$ sudo gem update
$ sudo gem install passenger
$ sudo passenger-install-apache2-module


ERROR:
If 'sudo gem install passenger' gives an error saying,  "Failed to build gem native extension."
then $ sudo apt-get install ruby1.8-dev
and rerun the install 


This gave me an error
sudo: passenger-install-apache2-module: command not found
Reason: i didnt’t have the gems bin directory in my PATH so do this instead
$ sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module


Press enter after reading information.
It should end with something like this
--------------------------------------------
The Apache 2 module was successfully installed.


Please edit your Apache configuration file, and add these lines:


   LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
   PassengerRoot /var/lib/gems/1.8/gems/passenger-2.2.11
   PassengerRuby /usr/bin/ruby1.8


After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!


Press ENTER to continue.
--------------------------------------------


After you press enter, it gives details on how to use Apache to direct it to the Rails files.
--------------------------------------------
Deploying a Ruby on Rails application: an example


Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:


   <VirtualHost *:80>
      ServerName www.yourhost.com
      DocumentRoot /somewhere/public    # <-- be sure to point to 'public'!
      <Directory /somewhere/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>


And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:


  /var/lib/gems/1.8/gems/passenger-2.2.11/doc/Users guide Apache.html
--------------------------------------------

This finishes the passenger setup.
Edit the file
$ sudo vim /etc/apache2/apache2.conf
At the bottom of the file copy paste the 3 lines.

Restart the apache server
$ sudo /etc/init.d/apache2 restart

To check if the passenger is working
$ sudo /var/lib/gems/1.8/bin/passenger-status
----------- General information -----------
max      = 6
count    = 0
active   = 0
inactive = 0
Waiting on global queue: 0

----------- Domains -----------

To set the Rails folder
Enter
Alias Rails_application /path/to/application
in the /etc/apache2/sites-available/default to point to the public folder in the rails application folder, where Rails_application is the name is the Rails application.

Now access the website using
localhost/<rails_application>

Monday, May 10, 2010

Ubuntu :: Eclipse :: Plugins

EPIC
on Eclipse Galileo

Steps:
Help > Install New Software > Add
Name: EPIC
Location: http://e-p-i-c.sf.net/updates

Next > Next > Finish

RSE
Help > Install New Software > Add
Name: RSE
Location: http://download.eclipse.org/dsdp/tm/updates/3.1/ (or latest)
In the Drop down menu select
- RSE SSH services
- RSE run-time
Next > Next > Finish

To connect to Remote Unix Machine.
Window > Open perspective > Other ... > Remote System Explorer
The Eclipse seems to refresh itself.

File > New > Other > Select a wizard
Select Remote System Explorer > Connection > Linux >
Enter hostname, connection name and description
Finish

Now in the Remote Systems window, there must be hostname listed, below it
Sftp Files
Processes
Ssh Shells
Ssh Terminals

Click on hostname to enter the username and password details.

Friday, May 7, 2010

Domain :: Registration :: Point to server

Steps to register a domain name.

- Go to go-daddy.com
- Register the domain.
- Check if this domain is active by 
$ whois myname.org

- Log into go-daddy
- Domain > Domain manager > click on the domain myname.org
- Look for 'Total DNS' 
- Look for ARecord @ 121.67.78.99 a IP address,
- Click on 'Total DNS Control'
- Look for A(Host) > Host > Points to > Actions > Edit
- Change the IP address to point to your server IP address.

Ubuntu :: Prompt :: Color

Edit file
$ vim ~/.bashrc

Type in the values below
RS="\[\033[0m\]"    # reset
HC="\[\033[1m\]"    # hicolor
FRED="\[\033[31m\]" # foreground red
FBLK="\[\033[30m\]" # foreground black
FMAG="\[\033[35m\]" # foreground magenta

Edit this line:
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$"
and modify it to
PS1="$HC${debian_chroot:+($debian_chroot)}$FRED\u$FBLK@$FMAG\h$FBLK:$FRED\W$FBLK\$ $RS"

Old prompt
username@hostname:~/path/to/dir$

New prompt
username@hostname:dir$

BioStatistics :: DataSet :: Compare

Kolmogorov-Smirnov Test

Summary:
The Kolmogorov-Smirnov test (KS-test) tries to determine if two datasets differ significantly. The KS-test has the advantage of making no assumption about the distribution of data. (Technically speaking it is non-parametric and distribution free.) Note however, that this generality comes at some cost: other tests (for example Student's t-test) may be more sensitive if the data meet the requirements of the test. In addition to calculating the D statistic, this page will report if the data seem normal or lognormal. (If it is silent, assume normal data at your own risk!) It will enable you to view the data graphically which can help you understand how the data is distributed.

In English:
Comparing two data sets, it draws plots to show the difference.

Link:

Thursday, May 6, 2010

Ubuntu :: Create :: Subversion

On Ubuntu
$ sudo apt-get install subversion

Working directory
~/Desktop/TEST

Create a repository
$ svnadmin create svnroot
- creates a directory called svnroot
$ ll svnroot
drwxr-xr-x 2 localuser localuser 4096 2010-05-06 16:22 conf
drwxr-sr-x 6 localuser localuser 4096 2010-05-06 16:22 db
-r--r--r-- 1 localuser localuser    2 2010-05-06 16:22 format
drwxr-xr-x 2 localuser localuser 4096 2010-05-06 16:22 hooks
drwxr-xr-x 2 localuser localuser 4096 2010-05-06 16:22 locks

Files of interest
$ cat conf/passwd
[users]
harry = harryspassword
dolly = dollyspassword

$ cat conf/svnserve.conf
[general]
## restrict access to read, write and none
harry = write
## password-db is the location of the /path/to/passwd file
password-db = passwd

Now create another svn root, this is not req, but same as above
$ svnadmin create projectx
$ mkdir gsv gsv/trunk gsv/branches gsv/tags
$ cd gsv
$ svn import . file:///home/krevanna/Desktop/TEST/SVN/projectx -m 'initial repository structure'
$ cd ..

There are several ways to checkout svn
- using file://
- this will create the folder called trunk if no name is specified in the end.
$ svn checkout file:///home/krevanna/Desktop/TEST/SVN/projectx/trunk .

- using svn ://

This is to access within the same server

It depends upon the projects involved. If the projects are related, and are likely to share data, then it's best to create one repository with several subdirectories like this:
$ svnadmin create /repo/svn
$ svn mkdir file:///repo/svn/projA
$ svn mkdir file:///repo/svn/projB
$ svn mkdir file:///repo/svn/projC
If the projects are completely unrelated, and not likely to share data between them, then it's probably best to create separate and unrelated repositories.
$ mkdir /repo/svn
$ svnadmin create /repo/svn/projA
$ svnadmin create /repo/svn/projB
$ svnadmin create /repo/svn/projC

Reference:

Ubuntu :: Hostname :: Change

Steps to change the computer hostname to BIOINFO-001
Check for current hostname
$ hostname

Simple steps to change hostname
$ hostname BIOINFO-001

If above steps dont work, then
Edit /etc/hostname
Enter BIOINFO-001

Edit /etc/hosts
Enter BIOINFO-001 after 127.0.0.1