Thursday, May 23, 2013

Biomart 0.8 :: Ant :: Build Failed

$ git clone https://github.com/biomart/biomart-rc6.git
biomart-rc6/
$ cd biomart-rc6/
$ ant
:
[mkdir] Created dir: /home/user/Desktop/biomart-rc6/dist/registry/linkindices
:

BUILD FAILED
/home/user/Desktop/biomart-rc6/build.xml:33: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-7-openjdk-amd64/jre"

On Linux machine when I installed openjdk, it had only installed jre.
To install jdk from openjdk

$ sudo apt-get install openjdk-7-jdk

I rerun the ant command
$ ant
BUILD SUCCESSFUL

Wednesday, May 1, 2013

BioMart 0.8 :: ant :: Build Failed

Follow the step as mentioned in BioMart 0.8 User manual

$ git clone https://github.com/biomart/biomart-rc6.git
biomart-rc6/
$ cd biomart-rc6/
$ ant
:
[mkdir] Created dir: /home/user/Desktop/biomart-rc6/dist/registry/linkindices
:
BUILD FAILED
/home/user/Desktop/biomart-rc6/build.xml:137: /home/user/Desktop/biomart-rc6/registry/linkindices does not exist.

Unable to find a fix on the internet
- Since I know the linkindices directory was created.
- I opened the file build.xml
- Change the entry at line number 138 from
<fileset dir="${basedir}/registry/linkindices" includes="*"/>
- To
<fileset dir="${basedir}/dist/registry/linkindices" includes="*"/>

I rerun the ant command
$ ant
BUILD SUCCESSFUL

It worked

Tuesday, December 4, 2012

GoogleAppEngine :: Ubuntu 12.10

Download Google App Engine.
URL: https://developers.google.com/appengine/downloads
Download: google_appengine_1.7.3.zip

Unzip and move it.
$ cd ~/Desktop/
$ unzip google_appengine_1.7.3.zip
google_appengine/*

Check the command
$ ./dev_appserver.py

Create the required files.
$ cd ~/Desktop
$ mkdir helloworld
$ cd helloworld
$ touch helloworld.py app.yaml

$ cat helloworld.py 
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'

$ cat app.yaml 
application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- uri: /.*
  script: helloworld.py

Run the Application
$ cd ..
$ ~/path/google_appengine/dev_appserver.py helloworld

Visit the browser:
localhost:8080

Its all working good.

To use sqlite instead of MySQL
$ ~/google_appengine/dev_appserver.py --use_sqlite helloworld



Google App Engine :: Mac OS

Download & Install
URL: https://developers.google.com/appengine/downloads
> Download the Google App Engine SDK
> GoogleAppEngineLauncher-1.7.3.dmg
> Double-click on dmg file to install.

Following tutorials at 
https://developers.google.com/appengine/docs/python/gettingstarted/

Created the folder
$ mkdir /path/to/tutorials/helloworld
$ cd /path/to/tutorials/helloworld
$ touch app.yaml helloworld.py

Contents of helloworld.py
print 'Content-Type: text/plain'
print ''
print 'Hello World'

Contents of app.yaml
application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: /.*
  script: helloworld.py

Start Google App Engine.
File > Add Existing Application > helloworld > open > Run

ERROR:
*** Running dev_appserver with the following flags:
    --admin_console_server= --port=8080
Python command: /usr/bin/python
WARNING  2012-12-04 16:23:33,337 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.

Checking Python version
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
$ python --version
Python 2.7

Checking for MySQL
$ mysqladmin -u root -p status
Enter password: 
Uptime: 2627  Threads: 1  Questions: 3  Slow queries: 0  Opens: 33  Flush tables: 1  Open tables: 26  Queries per second avg: 0.001

If you have already install Macports
$ sudo port install py26-mysql

Else, Install Macports
url: https://distfiles.macports.org/MacPorts/
download: MacPorts-2.1.2.tar.gz

On terminal
$ tar zxvf MacPorts-2.1.2.tar.gz
$ cd MacPorts-2.1.2
$ ./configure
$ make
$ sudo make install
/opt/local/bin should be added to my $PATH
$ vim ~/.bashrc
export PATH=$PATH:/opt/local/bin
$ source ~/.bashrc
$ sudo port -v selfupdate
$ sudo port search python | grep mysql
$ sudo port install py26-mysql

Using Macports didnot solve my problem.
So I will use the MySQL-python binaries.
URL: http://sourceforge.net/projects/mysql-python/
Download: MySQL-python-1.2.4b4.tar.gz

Terminal:
$ tar zxvf MySQL-python-1.2.4b4.tar.gz
$ cd MySQL-python-1.2.4b4
$ vim site.cfg
## Comment this line
#mysql_config = /usr/local/bin/mysql_config
## provide path to mysql_config
mysql_config = /usr/local/mysql/bin/mysql_config
$ python setup.py build
$ sudo python setup.py install

Looks good so far. Check if everything works
$ python
Python 2.7 (r27:82508, Jul  3 2010, 21:12:11) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> 

Rerun the Google App Engine.
I was not able to solve the problem. The ERROR message still stays the same.


__END__

Wednesday, August 29, 2012

VIM :: remove lines :: pattern

- To remove lines in a file which matches a pattern
- Open file using VIM
$ vim filename.txt

- To remove lines that has "food101" in it
:g/.*food101.*/d

Monday, January 2, 2012

Phred :: Install


Phred

The installation is in the server
working directory: /bioinfo/packages/Phred

Copy the phred-dist-020425.c-acd.tar.Z to above directory
$ uncompress phred-dist-020425.c-acd.tar.Z
$ tar xvf phred-dist-020425.c-acd.tar

Edit makefile to uncomment lines for 'UNIX specific definitions'
$ make

To set the environment variable
$ export PHRED_PARAMETER_FILE=\usr\local\etc\PhredPar\phredpar.dat

== Now ready to run phred

phd2fasta package
move the package to the working directory
$ uncompress phd2fasta-acd-dist.tar.Z
$ tar xvf phd2fasta-acd-dist.tar
$ make

The program can be executed as ./phd2fasta

Wednesday, December 7, 2011

Ruby :: Gem :: Jeweler

Write a gem in Ruby using Jeweler

Steps.
- Install gem called jeweler
$ gem install jeweler
Fetching: jeweler-1.6.4.gem (100%)
Successfully installed jeweler-1.6.4
1 gem installed
Installing ri documentation for jeweler-1.6.4...
Installing RDoc documentation for jeweler-1.6.4...

To execute the command, first checkout the options
$ jeweler --help

Now generate a new project using the command jeweler.
$ jeweler hello_gem
No github.user found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.user defunkt

ERROR: The above command came up with an error. 

To fix the user
$ git config --global github.user defunkt
$ git config --global github.token 6ef8395fecf207165f1a82178ae1b984
- replace defunkt and 6ef8395fecf207165f1a82178ae1b984
with your user and token respectively.
- To get the token from the Github
On Github > Account Seetings > Account Admin > API token: Your token is ***********

Rerun the jeweler command to create a new project
- By default the test script are generated for shoulda
- I am familiar with Rspec so I chose Rspec for my testing.
$ jeweler hello_gem --rspec
create .gitignore
create Rakefile
create Gemfile
create LICENSE.txt
create README.rdoc
create .document
create lib
create lib/hello_gem.rb
create spec
create spec/spec_helper.rb
create spec/hello_gem_spec.rb
create .rspec
Jeweler has prepared your gem in ./hello_gem

The structure of the directories are
$ tree
.
└── hello_gem
    ├── Gemfile
    ├── lib
    │   └── hello_gem.rb
    ├── LICENSE.txt
    ├── Rakefile
    ├── README.rdoc
    └── spec
        ├── hello_gem_spec.rb
        └── spec_helper.rb

3 directories, 7 files

hello_gem doesnt have the rspec gem yet, so in the Gemfile
group :test do
gem 'rspec', "~> 2.3.0" 
end

Run the bundle install command to install the rspec gem
$ bundle install

To know all the rake commands that can run, 
$ rake -T
rake build               # Build gem into pkg/
rake clobber_rdoc        # Remove rdoc products
rake console[script]     # Start IRB with all runtime dependencies loaded
rake gemcutter:release   # Release gem to Gemcutter
rake gemspec             # Generate and validate gemspec
rake gemspec:debug       # Display the gemspec for debugging purposes, as jeweler knows it (not from the filesystem)
rake gemspec:generate    # Regenerate the gemspec on the filesystem
rake gemspec:release     # Regenerate and validate gemspec, and then commits and pushes to git
rake gemspec:validate    # Validates the gemspec on the filesystem
rake git:release         # Tag and push release to git.
rake install             # Build and install gem using `gem install`
rake rcov                # Run RSpec code examples
rake rdoc                # Build the rdoc HTML Files
rake release             # Release gem
rake rerdoc              # Force a rebuild of the RDOC files
rake spec                # Run RSpec code examples
rake version             # Displays the current version
rake version:bump:major  # Bump the major version by 1
rake version:bump:minor  # Bump the a minor version by 1
rake version:bump:patch  # Bump the patch version by 1
rake version:write       # Writes out an explicit version.

Before we start with the gem we need a version to it.
$ rake version:write MAJOR=0 MINOR=1 PATCH=0
Updated version: 0.1.0

To know the current version
$ rake version
Current version: 0.1.0

Now install the gem 
$ rake install
rake aborted!
"FIXME" or "TODO" is not a description

Tasks: TOP => install => build
(See full trace by running task with --trace)

NOTE: If you get this error, then open the Rakefile
Change the lines from 
  gem.summary = %Q{TODO: one-line summary of your gem}
  gem.description = %Q{longer description of your gem}
to
  gem.summary = "one-line summary of your gem"
  gem.description = "longer description of your gem"

Now try again
$ rake install
  Successfully built RubyGem
  Name: hello_gem
  Version: 0.1.0
  File: hello_gem-0.1.0.gem
Executing "ruby -S gem install ./pkg/hello_gem-0.1.0.gem":
ruby -S gem install ./pkg/hello_gem-0.1.0.gem
Successfully installed hello_gem-0.1.0
1 gem installed
Installing ri documentation for hello_gem-0.1.0...
Installing RDoc documentation for hello_gem-0.1.0...

Now you can push the gem to Github and Rubygems.org
First commit all the changes to Git
$ git add .
$ git commit -am "inital setup"

Second create an repository at github, and call it hello_gem
This will create a repository called hello_gem.git

Run the command
$ rake release
Committing hello_gem.gemspec
Pushing master to origin
Generated: hello_gem.gemspec
hello_gem.gemspec is valid.
  Successfully built RubyGem
  Name: hello_gem
  Version: 0.1.0
  File: hello_gem-0.1.0.gem
Executing "gem push ./pkg/hello_gem-0.1.0.gem":
gem push ./pkg/hello_gem-0.1.0.gem
Pushing gem to https://rubygems.org...
You do not have permission to push to this gem.
rake aborted!
Command failed with status (1): [gem push ./pkg/hello_gem-0.1.0.gem...]

- It generated the gemspec file
- validates the hello_gem.spec
- It pushes the gem to GIT
- ERROR: It fails to push the gem to rubygems.org

Gems are no longer hosted by Github, It has moved to Rubygems.org
- To move gems to Rubygems, use Gemcutter
- To install gemcutter
$ gem update --system

Now install the gem
$ gem install gemcutter

Now stay in the hello_gem folder, and build the gem
$ gem build hello_gem.gemspec 
  Successfully built RubyGem
  Name: hello_gem
  Version: 0.1.0
  File: hello_gem-0.1.0.gem

Now push the gem to rubygems.org
$ gem push hello_gem-0.1.0.gem 
Enter your Gemcutter credentials. Don't have an account yet? Create one at http://gemcutter.org/sign_up
Email:   user@example.com
Password:   
Signed in. Your api key has been stored in ~/.gemrc
Pushing gem to Gemcutter...
Successfully registered gem: hello_gem (0.1.0)

Now gem is part of the Rubygems.

To add Gemcutter support to Jeweler
In the Rakefile, enter the line
Jeweler::GemcutterTasks.new
- This line has to added after the require 'jeweler'

Now check if we have the gemcutter functionality in Jeweler
$ rake -T
rake gemcutter:release   # Release gem to Gemcutter

Now execute the rake command to send the gem to rubygems.org
$ rake gemcutter:release
- This is exactly the same as 'gem push hello_gem-0.1.0.gem'

Now lets look at the current directory
$ tree
.
├── Gemfile
├── Gemfile.lock
├── hello_gem.gemspec
├── lib
│   └── hello_gem.rb
├── LICENSE.txt
├── pkg
│   └── hello_gem-0.1.0.gem
├── Rakefile
├── README.rdoc
├── spec
│   ├── hello_gem_spec.rb
│   └── spec_helper.rb
└── VERSION


3 directories, 11 files

So far the gem is empty so lets write something to it.
Let start writing to it, in the lib/hello_gem.rb
$ cat lib/hello_gem.rb
class HelloGem
  def self.hi
    puts "Hello World!"
  end
end

Now bump the version to a minor release
$ rake version:bump:minor
Current version: 0.1.0
Updated version: 0.2.0

Update the gem in ur local machine
$ rake install
  Successfully built RubyGem
  Name: hello_gem
  Version: 0.2.0
  File: hello_gem-0.2.0.gem
Executing "ruby -S gem install ./pkg/hello_gem-0.2.0.gem":
ruby -S gem install ./pkg/hello_gem-0.2.0.gem
Successfully installed hello_gem-0.2.0
1 gem installed
Installing ri documentation for hello_gem-0.2.0...
Installing RDoc documentation for hello_gem-0.2.0...

Check if the gem is updated.
$ irb
ruby-1.9.2-p290 :001 > require 'hello_gem'
 => true 
ruby-1.9.2-p290 :002 > HelloGem.hi
Hello World!
 => nil 

Modify the gem file to require another file.
- create a directory in the lib with the same name 'hello_gem'
$ mkdir lib/hello_gem

- create a file called translator.rb and write the following
$ cat lib/hello_gem/translator.rb
class Translator
  def initialize(language)
    @language = language
  end


  def hi
    case @language
      when 'spanish'
        "Hola Mundo!"
      when 'english'
        "Hello World!"
      else
        "ERROR !!!"
    end
  end
end


- Modify the gemfile to include this translator
$ cat lib/hello_gem.rb
require 'hello_gem/translator'

class HelloGem
  def self.hi(language = 'english')
    translator = Translator.new(language)
    translator.hi
  end
end

Now update the git repository
$ git add .
$ git commit -am "hello_gem/translator added"
$ rake version:bump:minor
$ rake install
$ irb
> require 'hello_gem'
 => true 
> HelloGem.hi
 => "Hello World!" 
> HelloGem.hi('english')
 => "Hello World!" 
> HelloGem.hi('spanish')
 => "Hola Mundo!" 
> HelloGem.hi('hindi')
 => "ERROR !!!" 

To make the executable
$ mkdir bin
$ touch bin/hello_gem
$ chmod a+x bin/hello_gem

Edit the bin/hello_gem
$ cat bin/hello_gem
#!/usr/bin/env ruby


require 'hello_gem'
puts HelloGem.hi(ARGV[0])

To make this executable, we have include the following line in the gemspec
$ cat hello_gem.gemspec
Gem::Specification.new do |s|
  :
  s.executables << 'hello_gem'
end

Update the git repository and reinstall the gem
On the command line
$ hello_gem english
Hello World!
$ hello_gem spanish
Hola Mundo!

Testing, In the spec folder, edit hello_gem_spec.rb
$ cat spec/hello_gem_spec.rb

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')


describe "HelloGem" do
  it "should return Hello World" do
    HelloGem.hi.should == 'Hello World!'
  end
  it "should return Hello World" do
    HelloGem.hi('english').should == 'Hello World!'
  end
  it "should return Hola mundo" do
    HelloGem.hi('spanish').should == 'Hola Mundo!'
  end
  it "should return error" do
   HelloGem.hi('french').should == 'ERROR !!!'
  end


end

Execute the tests to make sure it passes
$ rspec spec/
....

Finished in 0.0005 seconds
4 examples, 0 failures

Documentation of work.
In the hello_gem.rb
$ cat lib/hello_gem.rb
# The main HelloGem class
class HelloGem
  # Say Hi to the world.
  #
  # Example:
  #   >> HelloGem.hi('spanish')
  #   => Hola Mundo!
  #
  # Arguments:
  #   language: (string)
  
  def self.hi(language = 'english')
  :


Resouces: 
http://guides.rubygems.org/make-your-own-gem/
http://asciicasts.com/episodes/183-gemcutter-jeweler