2009-09-14

Setting Perforce API

Installing P4C/C++ API
Check the P4C/C++ API notes.
Check the P4C/C++ API documentation.
&] sudo cp ~/Downloads/p4api.tgz /opt ; cd /opt
&] sudo tar -zxf p4api.tgz
&] sudo ln -s p4api-2009.1.205670 p4api
&] sudo chmod -R +x *4*

Installing P4Perl API
Check the P4Perl API notes.
Check the P4Perl API documentation.
&] sudo cp ~/Downloads/p4perl.tgz /opt ; cd /opt
&] sudo tar -zxf p4perl.tgz
&] sudo ln -s p4perl-2009.1.GA p4perl
&] sudo chmod -R +x *4* ; cd p4perl
&] perl -MP4 -e "print P4::Identify()"
&] sudo perl Makefile.PL --apidir /opt/p4api
&] sudo make # in xp nmake
&] sudo make test # in xp namke test
&] sudo make install # in xp nmake install
&] perl -MP4 -e "print P4::Identify()"

Installing P4Ruby API
Check the P4Ruby API notes.
Check the P4Ruby API documentation.
&] sudo cp ~/Downloads/p4ruby.tgz /opt ; cd /opt
&] sudo tar -zxf p4ruby.tgz
&] sudo ln -s p4ruby-2009.1 p4ruby
&] sudo chmod -R +x *4*
&] cd p4ruby
&] ruby -rP4 -e "puts P4.identify"
&] sudo ruby p4conf.rb --apidir /opt/p4api
&] sudo make # in xp nmake
&] sudo ruby test.rb
&] sudo make install # in xp nmake install
&] ruby -rP4 -e "puts P4.identify"

Installing P4Python API
Check the P4Python API notes.
Check the P4Python API documentation.
&] sudo cp ~/Downloads/p4python.tgz /opt ; cd /opt
&] sudo tar -zxf p4python.tgz
&] sudo ln -s P4Python-2009.1 p4python
&] sudo chmod -R +x *4*
&] cd p4python
# update P4API in setup.cfg as: p4_api=/opt/p4api
&] python
>>> import P4
>>> print P4.P4.identify()
&] sudo python setup.py build
&] sudo python p4test.py
&] sudo python setup.py install
&] python
>>> import P4
>>> print P4.P4.identify()

Installing P4PHP
Check the P4PHP API notes.
Check the P4PHP API documentation.
&] sudo cp ~/Downloads/p4php.tgz /opt ; cd /opt
&] sudo tar -zxf p4php.tgz
&] sudo ln -s p4php-2009.1 p4php
&] sudo chmod -R +x *4*

Installing P4Java API
Check the P4Java API notes.
Check the P4Java API documentation.
&] sudo cp ~/Downloads/p4java.zip /opt ; cd /opt
&] sudo mkdir p4java/ ; sudo mv p4java.zip p4java/ ; cd p4java
&] sudo unzip p4api.zip
&] sudo ln -s p4java_2009.1.211156.jar p4java.jar
Then add /opt/p4java to your CLASSPATH

Installing P4WSAD
Check the P4WSAD API notes.
Check the P4WSAD API documentation.
&] sudo cp ~/Downloads/p4wsad.zip /opt ; cd /opt
&] sudo mkdir p4wsad/ ; sudo mv p4wsad.zip p4wsad/ ; cd p4wsad
&] sudo unzip p4wsad.zip

Installing P4Objective-C API
Check the P4ObjC API notes.
Check the P4ObjC API documentation.
&] sudo cp ~/Downloads/p4objc.tgz /opt ; cd /opt
&] sudo tar -zxf p4objc.tgz
&] sudo ln -s p4objc-2009.1.205670 p4objc
&] cd p4objc/doc ; sudo doxygen
&] cd /opt/p4objc

Installing P4COM Windows C++ API
Check the P4COM Windows C++ notes.
Check the P4COM Windows C++ documentation.

Setting Perforce

To install the Perforce Command-Line Client (p4) on a UNIX or Linux or Macintosh OS X machine, perform the following steps:
1. Download p* from http://www.perforce.com/perforce/downloads/index.html
2.
Copy it to /usr/local/bin/
3. Make the p* files executables (p4 p4d p4ftpd p4p p4sql p4web p4broker perfmerge)
4. Configure the server port setting, client workspace name, and user name. You can specify these settings by configuring the P4PORT, P4CLIENT, and P4USER environment variables. (For details, see Chapter 2, Configuring P4.)
&] sudo cp ~/Downloads/p* /usr/local/bin
&] sudo chmod +x /usr/local/bin/p*
&] sudo chmod -R +x p*

Other P4 environment variables:
  1. P4DIFF -default-
  2. P4MERGE -default-
  3. P4PASSWD
  4. P4CLIENT
  5. P4EDITOR
  6. P4PORT
  7. P4USER
  8. P4CONFIG export $HOME/.p4config or export %USERPROFILE%\p4config.txt
  9. P4TICKETS export $HOME/.p4tickets or export %USERPROFILE%\p4tickets.txt
To install the Perforce P4V Client:
1. Download p4v.tgz from http://www.perforce.com/perforce/downloads/index.html
2.
Copy it to /Applications
3. Decompress with tar -zxf
4. Make the p4v* executable
&] sudo cp p4v.tgz /Applications/ ; cd /Applications
&] sudo tar -zxf p4v.tgz ; sudo chmod -R +x p4v* ; sudo rm -rf p4v.tgz
&] sudo ln -s p4v-2009.1.212209 p4v

Installing P4Thumb on UNIX, Linux and OS X
To install the Perforce P4Thumb:
1. Download p4thumb.tgz from http://www.perforce.com/perforce/downloads/index.html
2.
Copy it to /Applications
3. Decompress with tar -zxf
4. Make the p4thumb* executable
&] sudo cp p4thumb.tgz /Applications/ ; cd /Applications
&] sudo tar -zxf p4thumb.tgz ; sudo chmod -R +x p4thumb* ; sudo rm -rf p4thumb.tgz
&] sudo ln -s p4thumb-2009.1.210672 p4thumb

Installing P4DTG on UNIX, Linux and OS X
To install the Perforce P4DTG:
1. Download p4dtg.tgz from http://www.perforce.com/perforce/downloads/index.html
2.
Copy it to /Applications
3. Decompress with tar -zxf
4. Make the p4dtg* executable
&] sudo cp p4dtg.tgz /Applications/ ; cd /Applications
&] sudo tar -zxf p4dtg.tgz ; sudo chmod -R +x p4dtg* ; sudo rm -rf p4dtg.tgz
&] sudo ln -s p4dtg-2009.1.209672 p4dtg
&] cd p4dtg
&] ./p4dtg-test
> LL ./plugins/p4jobdt.so
Loading module: [./plugins/p4jobdt.so]
Module loaded: ./plugins/p4jobdt.so
> LT
Module tests passed
> LF
Module freed
> Q
To install the Perforce Command-Line Client (p4.exe) on Windows, download and run the Perforce Windows installer (perforce.exe) from the Downloads page of the Perforce web site:

2009-09-09

Using rsruby in RubyOnRails

  1. Create your Rails application
  2. Let’s call it Plotter. Usual procedure:
    rails Plotter
    cd Plotter
    rake db:create
    We won’t use the database (default sqlite3) in this example, but you may use it later on.
  3. Tell the application about R_HOME
  4. RSRuby will fail unless the environment variable R_HOME is set.
    To tell Plotter that R_HOME is /usr/lib/R, I put this in the file app/helpers/application_helper.rb:
    module ApplicationHelper
    # set R_HOME if not set
    if ENV['R_HOME'].nil?
    ENV['R_HOME'] = "/usr/lib/R"
    end
    end
  5. Make an instance of RSRuby available to all controllers
  6. RSRuby works by providing an instance of an “R object”, on which you call R functions as methods.
    I provided the object by editing app/controllers/application_controller.rb to include a method named InitR:
    class ApplicationController < r =" RSRuby.instance">
    
  7. Create a sample controller and view
  8. For testing purposes, I created a controller named Home with a single view named index:
    ./script/generate controller Home index
    rm public/index.html
    I edited config/routes.rb so as the root of the application is the index view for the home controller:
    ActionController::Routing::Routes.draw do |map|
    map.root      :controller => "home"  #default view is app/views/home/index.html.erb
    map.connect  ':controller/:action/:id'
    map.connect  ':controller/:action/:id.:format'
    end
    Now we can get to work on the file app/controllers/home_controller.rb. I wrote a sample method, show_image to plot a histogram using R via RSRuby:
      def show_image
    # next 6 lines use R to plot a histogram
    @r = InitR()
    @d = @r.rnorm(1000)
    @l = @r.range(-4,4,@d)
    @r.png "/tmp/plot.png"
    @r.par(:bg => "cornsilk")
    @r.hist(@d, :range => @l, :col => "lavender", :main => "My Plot")
    @r.eval_R("dev.off()")  #required for png output
    # then read the png file and deliver it to the browser
    @g = File.open("/tmp/plot.png", "rb") {|@f| @f.read}
    send_data @g, :type=>"image/png", :disposition=>'inline'
    end
    Not the prettiest code, but you get the idea. Obviously the owner of the HTTP daemon (www-data on Ubuntu) must have write permission to the location of the PNG file; /tmp in this case.
  9. Create the view
  10. All that remains is to edit app/views/home/index.html.erb so as it displays the image:

    Home#index

    Find me in app/views/home/index.html.erb <%= image_tag(url_for(:controller => "home", :action => "show_image")) %>
    Which just says “wrap whatever comes out of the method show_image in an IMG SRC tag”.

Installing BioRails

"BioRails":http:/projects/show/core is a commercially backed, open-source biological information management system designed specifically for pharmaceutical discovery research. BioRails core version is available free to use and the source code is available for download under the GNU Public License. Support services are available from "The Edge Software Consultancy Ltd":http//edgesoftwareconsultancy.com


This is a new BioRails Release Version at BioRails.org .

There is an example chemreg .

All support is now on BioRails.com .

You can start setting your development installation.

&] sudo apt-get install build-essential mysql-server mysql-client subversion ruby libzlib-ruby rdoc eruby irb libsvn-ruby ri libmysql-ruby libdbd-mysql-ruby imagemagick libmagick9-dev librmagick-ruby graphviz ruby1.8-dev libmysqlclient15-dev openssl htmldoc gnuplot rake zip sqlite3 libsqlite3-dev mongrel libruby-extras libxml2 libxml2-dev libxslt1-dev openoffice.org python-uno unoconv openoffice.org-dev

OpenOffice is needed so you can install the following packages:

&] sudo apt-get install openoffice.org openoffice.org-base openoffice.org-base-core openoffice.org-calc openoffice.org-common openoffice.org-core openoffice.org-dev openoffice.org-draw openoffice.org-filter-binfilter openoffice.org-mobiledev unoconv python-uno openoffice.org-headless

Gems is needed:

&] sudo gem install archive-tar-minitar builder chronic crypt fastercsv gnuplot hpricot htmldoc icalendar json mime-types mocha mongrel mongrel_cluster mysql ntp rcov rmagick mini_magick roodi rspec ruby-net-ldap rubyzip ruport sqlite3-ruby tidy transaction-simple tzinfo uuid uuidtools ZenTest

&] gem sources -a http://gems.github.com

&] sudo gem install mislav-will_paginate

&] gem list --local

&] sudo gem update

It is time to install source code.

For development:

&] mkdir trunk; svn co http://biorails.org/svn/biorails/core/trunk trunk/

For snapshot:

&] wget http://redmine.biorails.org/attachments/download/221?filename=biorails-3.0-2772.tar.gz ; tar -zvxf biorails-3.0-2772.tar.gz

Database connection:

&] cp config/database_template.yml config/database.yml ; nano config/database.yml

development:
adapter: mysql
database: biorails_development
username: biorails
password: moose
host: localhost

test:
adapter: mysql
database: biorails_test
username: biorails
password: moose
host: localhost

production:
adapter: oracle
database: localhost
username: biorails_validation
password: moose


/* Will need to login to mysql as root to initial run this script eg.
* mysql -u root -p
*/
create user biorails identified by 'moose';
create user 'biorails'@'localhost' identified by 'moose';

create database biorails_development;
grant all on biorails_development.* to 'root'@'localhost';
grant all on biorails_development.* to 'biorails'@'localhost';

create database biorails_test;
grant all on biorails_test.* to 'root'@'localhost';
grant all on biorails_test.* to 'biorails'@'localhost';

create database biorails_production;
grant all on biorails_production.* to 'root'@'localhost';
grant all on biorails_production.* to 'biorails'@'localhost';


&] mysql -u root -p < db/create_databases.mysql
grant all on biorails_production.* to 'biorails'@'localhost';

Create schema:

&] rake db:schema:load ; rake -T

Quick check:

&] rake biorails:check:all

Test preparation:

&] unoconv -l

Full test:

&] export RAILS_ENV=test
&] rake biorails:ferret_start
&] rake test

Bootstrap:

&] rake biorails:db:bootstrap
&] ruby script/server


Lighthttpd web server:

&] sudo apt-get install lighttpd
&] nano config/lighttpd-template.conf
########################################################################
# lighttpd configuration file
#
# use it as a base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $
#
############ Options you really have to take care of ####################
server.modules = ("mod_rewrite", "mod_access", "mod_redirect", "mod_proxy", "mod_compress", "mod_accesslog")
server.document-root = "/home/biorails/enterprise/trunk/public/"
server.errorlog = "/var/log/lighttpd/error_log"
server.dir-listing = "disable"

## files to check for if .../ is requested
server.indexfiles = ("index.html", "index.htm", "index.rb")

&] sudo cp config/lighttpd-template.conf /etc/lighttpd/lighttpd.conf
&] sudo /etc/init.d/lighttpd stop
&] sudo lighttpd -f /etc/lighttpd/lighttpd.conf

Performance upgrade:
&] export RAILS_ENV=production
&] rake asset:packager:build_all
&] rake biorails:start


Installing R from CRAN, Bioconductor and Related Interfaces

Use the following link to fetch the last stable version from CRAN .

R for All
Choose the last universal tar.gz file.

R for Windows
Choose the last installable file.
We can use R in the CommandPrompt if we add Path=Path;%R_PATH%

RDCOMServer: Look for other software and install R(D)COM Interface as DCOMServer usig R\DCOMServer and the variable RDCOM_PATH=D:\GNU\R\DCOMServer\bin. But you need rscproxyand rcom installed on R.
RExcel: Look for this link.

R for MacOS X
Choose the last dmg file.

R for Ubuntu
Choose the last binary file in /bin/linux/ubuntu or
&] sudo apt-get -y install r-*

R for fedora
Choose the last rpm file in /bin/linux/redhat/fedora1*/{i386,x86_64,src) or
&] sudo yum -y install R-*

RStudio (R multiform IDE)
Choose the last version of R to install in your machine (multiple version are allowed) and install IDE from their site.

GGobi for R

iPlots for R

iPlots eXtreme for R

ReShape for R

Plyr for R

R-commander from R
Read the documentation.
You can choose your packages to install from repository or to do it directly from R CMD
&] sudo R
&] install.packages("Rcmdr", dependencies=TRUE)
] install.packages(c("car","MASS","nnet","XLConnect"))

Bioconductor from R
Read the documentation.
You can choose your packages to install from repository or to do it directly from R CMD
&] sudo R
> source("http://bioconductor.org/biocLite.R") ; biocLite()
> source("http://bioconductor.org/getBioC.R") ; getBioC()

R Environment Variable
Windows:
R_HOME=D:\GNU\R\R-2.10.1
Ubuntu:
R_HOME=/usr/lib/R
OSX:
R_HOME=/Library/Frameworks/R.framework/Resources
At the end:
RHOME=$R_HOME
R_PATH=$R_HOME/bin
R_PATH=D:\GNU\R\R-2.10.1\bin
R_LIBS=$R_HOME/library

Windows R(D)COM interface for R using CSharp
Read the documentation.

RPy interface for R
Read the documentation.
&] sudo yum install rpy.i686 #in fedora
The steps are:
  1. Check that you have built R with the configure option '--enable-R-shlib' to make R as a shared library
  2. &]cd $R_HOME
  3. &]make distclean
  4. &]./configure --enable-R-shlib
  5. &]make
  6. &] make install 
The 2 following steps are optional:
  1. make a link to RHOME/bin/libR.so in /usr/local/lib or /usr/lib, then run 'ldconfig'
  2. or put the following line in your .bashrc (or equivalent) &] export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:RHOME/bin
  3. or edit the file /etc/ld.so.conf and add the following line RHOME/bin, then run 'ldconfig'.
  4. &] python setup.py install

RPy2 interface for R
Read the documentation.
The steps are:
  1. &] easy_install rpy2
  2. &] tar -zxf rpy2_package.tar.gz
  3. &] cd rpy2_package
  4. &] python setup.py install
Test:
import rpy2.tests
import unittest

# the verbosity level can be increased if needed
tr = unittest.TextTestRunner(verbosity = 1)
suite = rpy2.tests.suite()
tr.run(suite)

RSPython interface for R
Read the documentation.
The steps:
  1. &] sudo cp ~/Downloads/RSPython_0.7-1.tar.gz /opt ; cd /opt
  2. &] sudo chmod -R +x RS*
  3. &] sudo R CMD INSTALL -c RSPython_0.7-1.tar.gz

RSPerl interface for R
The steps:
  1. &] sudo cp ~/Downloads/RSPerl_0.92-1.tar.gz /opt ; cd /opt
  2. &] sudo chmod -R +x RS*
  3. &] sudo R CMD INSTALL -c -l --configure-args='--with-in-perl' RSPerl_0.92-1.tar.gz # -l is option for PERL5LIB
Rserve interface for R
You can try another mirror to fetch the file.
Read the documentation.
In R, sudo R
> install.packages(Rserve)

RRuby interface for R
You can try another mirror to fetch the file.
Read the documentation.
&] sudo gen install rinruby

RinRuby interface for R
You can try another mirror to fetch the file.
Read the documentation.

RSRuby interface for R
You can try another mirror to fetch the file.
Read the documentation.

First option:
  1. &] sudo cp ~/Downloads/rsruby*{gem,tgz} /opt ; cd /opt
  2. &] sudo chmod -R +x rs*
  3. &] sudo gem install rsruby-0.5.1.1.gem --with-R-dir=$R_HOME
Second option:
  1. &] sudo tar -zxf rsruby-0.5.tgz
  2. &] sudo chmod -R +x rs*
  3. &] cd rsruby
  4. &] ruby setup.rb config -- --with-R-dir=$R_HOME
  5. &] ruby setup.rb setup
  6. &] ruby setup.rb test
  7. &] sudo ruby setup.rb install
This is a new Ruby interface for R/S found at RubyForge .
Note that you’ll need to set the R_HOME and RHOME environment variable prior to installation.
On MacOX, RHOME=R_HOME=/Library/Frameworks/R.framework/Resources.
On Ubuntu, when installed from source, RHOME=R_HOME=/usr/local/lib/R. It is useful to just drop this into /etc/environment so that this variable is set upon login.
Otherwise update /etc/bash_profile .

&] export R_HOME=/path/to/R/for/your/OS
&] export RHOME=/path/to/R/for/your/OS
&] sudo gem install rsruby -- --with-R-dir=$R_HOME
On Ubuntu
&] sudo gem install rsruby -- --with-R-home=/usr/lib/R --with-R-include=/usr/share/R/include

You may try to install it from source. Compile and install the Ruby library using setup.rb as shown. You need to supply
the location of your R installation for the libR shared library. This will usually be
the same as R_HOME.

&] cd rsruby
&] ruby setup.rb config -- --with-R-dir=/usr/lib/R
&] ruby setup.rb setup
&] sudo ruby setup.rb install

You may test it
&] ruby setup.rb test


&] irb -rrsruby
>> @R = RSRuby.instance
>> @R.wilcox_test([1,2,3],[4,5,6])
>> foo = @R.as_data_frame(1)



2009-09-04

Discovering new Tools

Today is a very special day, because I will start maintaining a long time needed blog...

HTMLCode

HTMLCode Content