Monday, November 7, 2011

close file handler in java while operating on files

I just bumped into one of the error with file io. if you dont close fie handler, it wont write anything into file.
import java.io.*;
class FileWrite 
{
 public static void main(String args[])
  {
  try{
  // Create file 
  FileWriter fstream = new FileWriter("out.txt");
  BufferedWriter out = new BufferedWriter(fstream);
  out.write("Hello Java");
  //Close the output stream
  out.close();
  }catch (Exception e){//Catch exception if any
  System.err.println("Error: " + e.getMessage());
  }
  }
}

executing external process using java

Runtime rt=Runtime.getRuntime();
  Process x= rt.exec("ls -l");
  BufferedReader stdInput = new BufferedReader(new 
                InputStreamReader(x.getInputStream()));
  String s;
  while ((s = stdInput.readLine()) != null) {
            System.out.println(s);
        }

Adding new elements to arraylist in java while using iterator

today i had a problem with usage of arraylist along side of iterator. the problem was that i was unable to add elements to the arraylist. it gives you an error java.util.ConcurrentModificationException this is because u cant add elements to an arraylist while using an iterator. so i had used listiterator as below.

import java.util.ArrayList;
import java.util.ListIterator;
public class Test 
{
 public static void main(String args[])
 {
  ArrayList array_test= new ArrayList();
  array_test.add("a");
  array_test.add("k");
  array_test.add("d");
  array_test.add("s");
  array_test.remove("d");
  int i=1;
  for(ListIterator it=array_test.listIterator();it.hasNext();)
  { 
   String link=it.next(); 
   if(i==1)
   {  
    it.add("r");
    it.previous();
    it.add("kk");
    it.previous();
   i++;
   }
   System.out.println(link);
   
  } 
   
  System.out.println("Contents of arrays list "+array_test);
 }
 

}

In the above code i had used it.previous whenever i used it.add. this is because i want to use the added value in the loop again. while the addition of new element in array is added just before next element in arraylist.

Thursday, October 6, 2011

perl object oriented tutorial
http://www.tutorialspoint.com/perl/perl_oo_perl.htm

Wednesday, September 28, 2011

collections in java
array list algorithm (dynamic array)
map
hashmap ( unordered data)
linkedhashmap ( ordered data)
- treemap are type of linked hash map better in implementation
java iterators for getting next element link
mutable and imutable onbjects link

sql query to find data between an interval.. something like getting data for each week

SELECT MAX( STR_TO_DATE( CONVERT( `PurchaseDt`

USING utf8 ) , '%m-%d-%Y' ) ) AS maxdate, MIN( STR_TO_DATE( CONVERT( `PurchaseDt`

USING utf8 ) , '%m-%d-%Y' ) ) AS mindate

FROM `MemberEarnings`

WHERE STR_TO_DATE( CONVERT( `PurchaseDt`

USING utf8 ) , '%m-%d-%Y' )

BETWEEN STR_TO_DATE( '08-01-2011', '%m-%d-%Y' )

AND STR_TO_DATE( '08-21-2011', '%m-%d-%Y' )

GROUP BY DATE_SUB( STR_TO_DATE( CONVERT( `PurchaseDt`

USING utf8 ) , '%m-%d-%Y' ) , INTERVAL DAYOFWEEK( STR_TO_DATE( CONVERT( `PurchaseDt`

USING utf8 ) , '%m-%d-%Y' ) ) -1

DAY )

Thursday, September 15, 2011

scala (new programming language)

data types

def to define objects
val final variables
var which can be changed...

peano Axioms

http://jim-mcbeath.blogspot.com/2008/11/practical-church-numerals-in-scala.html

99 scala problems

Thursday, June 9, 2011

adding users in ubuntu

sudo useradd -d /home/testuser -m testuser

sudo passwd testuser


make him sudoer my tweaking the following file

/etc/sudoers

when auto filling doesnt work using tab.....

It is likely your default shell for adding users is Bourne shell, not bash.

Look at /etc/defaults/useradd, and change:

SHELL=/bin/sh

to

SHELL=/bin/bash

So that future user adds will default to bash.

For your current user, you should change their login shell to bash.

chsh -s /bin/bash user_name

installing mysql

sudo apt-get install mysql-server



sudo netstat -tap | grep mysql
When you run this command, you should see the following line or something similar:

tcp 0 0 localhost.localdomain:mysql *:* LISTEN -
If the server is not running correctly, you can type the following command to start it:

sudo /etc/init.d/mysql restart

Saturday, April 16, 2011

mongodb and nodejs

to install express framework for nodejs

http://www.giantflyingsaucer.com/blog/?p=1688

Friday, March 25, 2011

mummer

url: http://sourceforge.net/projects/mummer/files/
Download MUMmer3.22.tar.gz


Installation

Follow these instructions only if you downloaded the package.
$ tar zxvf MUMmer3.22.tar.gz
$ cd MUMmer3.22
$ make
When i ran make make check, it gave a error saying
$ make check
csh: not found
ERROR: 'csh' C-shell not found
check complete
Follow the steps below only if u get the above error.
$ sudo apt-get install csh
Now continue with the installation
$ make check
$ sudo make install
Testing

All the commands below must be present
$ mummer
$ nucmer
$ promer
$ run-mummer1
$ run-mummer3

Saturday, March 19, 2011

esprit

ESPRIT :: Installation :: Cluster
Obtain the source code


On *nix, Steps to install ESPRIT
$ unzip ESPRIT_distribution.zip
$ cd ESPRIT_distribution


Read, esprit_user_guide.pdf and README.txt
$ cd source
$ vim Makefile
Choose the platform by uncomment/comment


To make the package
$ make esprit_cc


Its always better to
$ make clean
$ make esprit_cc


Precaution:
- make sure that the fasta file has header in one and the sequence in one line
- if the sequence is in multiple lines, convert the file to contain just one line of sequence


Pseudocode is followed here using shell scripting and clusterjobmanager
Copy the sequence file here, If you have more than one than group them.
$ cp /path/to/sequence.fas .


To run preproc
$ /path/to/ESPRIT_distribution/source/preproc -f sequence.fas
160794 Seqs Match Primer
160794 Seqs Valid Len


31072 Seqs After Process
1.63 secs in Purging Strings.


flag:
-f this prevents the program from trimming.


Files created:
sequence_Clean.fas
sequence_Clean.frq


To check
$ awk -F' ' '{ s+=$2 } END { print s }' sequence_Clean.frq
160794
$ grep -c '>' sequence.fas
160794
- Make sure that these numbers are same.


To run kmerdist_par
$ cat submit_kmer_jobs.sh
for i in $(seq 1 10)
do
for j in $(seq $i 10)
do
job="/path/to/ESPRIT_distribution/source/kmerdist_par sequence_Clean.fas 10 $i $j\n ";
RANDOM=10
num=$RANDOM
echo -e $job > kmer_job_$num.clusterJob
clusterJobSubmission < kmer_job_$num.clusterJob done done - where clusterJobSubmission is your cluster job submission manager - the extension .clusterJob can be replaced with the extension required - variable job can include other details if required. $ cat jobs.clusterJob ## .. sh submit_kmer_jobs.sh $ jobsubmit < jobs. clusterJob - this will submit the job. Output: sequence_Clean_[*]_[*].dist - make sure that numbers are 1_[1-10], 2_[2-10], 3_[3-10], 4_[4-10], 5_[5-10], 6_[6-10], 7_[7-10], 8_[8-10], 9_[9-10], 10_10 Merge all the .dist files $ cat sequence_Clean_*.dist >> kmer.dist


Split the kmer files into 100 files
$ /path/to/ESPRIT_distribution/source/splitdist -s 100 kmer.dist
Counting Total Records....
71249223 Records Found, Splitting...


Output:
kmer.dist_[0-99]


Submit parallel jobs for needle_dist
$ cat submit_needle_job.sh
for i in $(seq 0 99)
do
job="/path/to/ESPRIT_distribution/source/needledist sequence_Clean.fas kmer.dist\_$i needle.dist\_$i\n ";
RANDOM=10
num=$RANDOM
echo -e $job > needle_job_$num.clusterJob
clusterJobSubmission < needle_job_$num.clusterJob done Output needle.dist_[0-99] Group all the needle.dist files $ cat needle.dist_* >> sequence.ndist


To run hcluster
$ /path/to/ESPRIT_distribution/source/hcluster -t 15000 sequence.ndist sequence_Clean.frq
- flag -t is used to increase the size of the linked table, default is 10000


Output
sequence.ndist_sort
sequence.OTU
sequence.Outliers
sequence.Rarefaction
sequence.Cluster
sequence.Cluster_List
sequence.ACE
sequence.CHAO1

Monday, February 14, 2011

ruby on rails

http://www.techrepublic.com/blog/programming-and-development/learn-ruby-with-these-10-books-and-other-resources/3886?tag=nl.e108

Friday, February 11, 2011

arb installation

download arb software from the following link.

choose the downloadable file based on your system os.

http://download.arb-home.de/release/arb_5.2/

extract the download in a folder

get into the folder and execute the file ./arb_install.sh

after executing that it will ask some questions.. press enter and atlast it would give you options.. 1,2 or 3

enter 1 for bash

it would provide some path and paste that path in ./bashrc or profile files..

than go to the sh folder in /usr/arb

there execute the arb_installubu..* file..

it should be given with parameter. if you execute without parameter it would provide some standard output error .. we can make that as base to provide parameters.

after installing all of them depending on opengl or non opengl version....


enter arb..

the software would be started..

Monday, January 31, 2011

present problem with swarm

Downloading: http://repo1.maven.org/maven2/Swarm/Swarm/0.9/Swarm-0.9.pom
[INFO] Unable to find resource 'Swarm:Swarm:pom:0.9' in repository central (http://repo1.maven.org/maven2)
[INFO] [compiler:compile {execution: default-compile}]

Wednesday, January 26, 2011

swarm probs

[INFO] [jar:jar {execution: default-jar}]
[INFO] Preparing exec:java
[WARNING] Removing: java from forked lifecycle, to prevent recursive invocation.
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default}]
11:05:36,441 DEBUG JobClient2:134 - 2011-01-26 11:05:36 JavaDaemonTest started
11:05:36,443 DEBUG JobClient2:134 - 2011-01-26 11:05:36 2011-01-26 11:05:36 This is output to StdErr...
11:05:36,906 DEBUG PropertyUtil:33 - L1
11:05:36,914 DEBUG PropertyUtil:35 - L2
11:05:36,914 DEBUG PropertyUtil:39 - L3
11:05:45,709 DEBUG JobManager:742 - Job Submission Thread is running...
11:05:45,807 DEBUG Programs:32 - Getting the list of jobs waiting to be submitted
11:06:21,839 DEBUG JobManager:289 - Submitting 8 jobs
11:06:21,843 DEBUG SwarmUtil:156 - Requesting ticket now
11:06:21,870 DEBUG SwarmUtil:162 - org.apache.axis2.rpc.client.RPCServiceClient@1
11:06:28,330 DEBUG SwarmUtil:166 - Ticket request result: Username: qdong
Email: Default email address
Project: GSA Project
Organization: default organization
Group Job Title: default job title
Group Job Descriptiondefault job description
Expected Number of Jobs130000
Timestamp: Wed Jan 26 11:06:27 CST 2011
TicketID-743724069
Current number of jobs submitted0
11:06:28,357 DEBUG JobManager:258 - ticketID : -743724069
11:06:28,742 DEBUG JobManager:204 - 1017 RepeatMasker
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. org/biojava/bio/BioException

org.biojava.bio.BioException
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 minutes 22 seconds
[INFO] Finished at: Wed Jan 26 11:06:28 CST 2011
[INFO] Final Memory: 17M/42M
[INFO] ------------------------------------------------------------------------
11:06:30,704 DEBUG JobClient2:134 - 2011-01-26 11:06:30 ShutdownHook started
11:06:31,204 DEBUG JobClient2:134 - 2011-01-26 11:06:31 shutdown
11:06:31,706 DEBUG JobClient2:134 - 2011-01-26 11:06:31 shutdown
11:06:32,207 DEBUG JobClient2:134 - 2011-01-26 11:06:32 shutdown
11:06:32,707 DEBUG JobClient2:134 - 2011-01-26 11:06:32 ShutdownHook completed