2010年7月26日 星期一

Terminal and window

1. Terminal: 用 ctrl + alt + F1 to F6
2. window: 用 ctrl + alt + F7

2010年7月23日 星期五

Process

1. basic
顯示目前所有程序, 並對 memory 作排序
ps -e o user,pid,size,cmd | sort -k3 -n -r | more

///////////////////////////////////////
ps report a snapshot of the current processes
///////////////////////////////////////
-e Select all identical
-o userdefine output

command:
KEY LONG DESCRIPTION
c cmd simple name of executable
C pcpu cpu utilization
f flags flags as in long format F field
g pgrp process group ID
G tpgid controlling tty process group ID
j cutime cumulative user time
J cstime cumulative system time
k utime user time
m min_flt number of minor page faults
M maj_flt number of major page faults
n cmin_flt cumulative minor page faults
N cmaj_flt cumulative major page faults
o session session ID
p pid process ID
P ppid parent process ID
r rss resident set size
R resident resident pages
s size memory size in kilobytes
S share amount of shared pages
t tty the device number of the controlling tty
T start_time time process was started
U uid user ID number
u user user name
v vsize total VM size in kB
y priority kernel scheduling priority

/////////////////////////////////////////
sort
//////////////////////////////////////////
-k key
-n number sort
-r reverse


/////////////////////////////////
killall
///////////////////////////////////
說明: 可用程序名稱 刪除程序
like: killall /user/httpd

2010年7月22日 星期四

Time

1. In the java you can use

{{{
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); //yyyy-MM-dd HH:mm:ss Z//
Date jobSubmitTime = null;
Date nowTime = new Date();
long timeDifferent = 0;

// Get the job
try {
while (sourceJobIterator.hasNext()) {
logger.info("Enter the resubmit job loop. ");

RecordExpr job = (RecordExpr) sourceJobIterator.next();
logger.info("2");

String jobTime = (new GapJDLParser(job)).getSubmissionTime();
//String jobTime = (new GapJDLParser(job)).get;
logger.info("3");

jobSubmitTime = df.parse(jobTime);

logger.info("4");
logger.info("job: " + (new GapJDLParser(job)).getJobId()
+ ", submit Time: " + jobSubmitTime.getTime()
+ ", current Time: " + nowTime.getTime());


timeDifferent = (nowTime.getTime() - jobSubmitTime.getTime()) / SECONDS_IN_MILLION;
}}}


2. but in sql
{{{
String query = "SELECT b.name,b.vo,b.lsa_host,b.lsa_type,b.lsa_pid,";
query += "b.appid,b.tag,b.nprocs,b.status,";
query += "b.id as jid,b.sub_id,b.qpriority,b.outputs,b.inputs,";
query += "to_char(b.sub_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as sub_dtime,";
query += "to_char(b.run_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as run_dtime,";
query += "to_char(b.done_dtime, 'YYYY-MM-DD HH24:MI:SS TZ') as done_dtime,";
query += "b.timeout,b.trial_count,b.retry_reason,";
query += "b.share_user,b.share_vo,b.share_role,";
query += "a.dn as dn,a.email FROM ";
query += "udb_user as a, jdb_jlist as b, udb_gproxy as c ";
query += "WHERE b.id=? AND b.sub_id=? AND a.dn=b.dn";
}}}

SQL: becareful the time is the automatic build
{{{
CREATE TABLE jdb_jgroup (
id character(256) NOT NULL,
dn character(256) NOT NULL,
vo character(32) NOT NULL REFERENCES vo_list(vo),
adv_appid character(32) NOT NULL,
command_name character(256),
status character(32) NOT NULL,
sub_dtime timestamp with time zone DEFAULT now() NOT NULL,
description text,
command_fqcn character(256) NOT NULL,
success_rate double precision DEFAULT 0.0 NOT NULL,
job_count integer DEFAULT 1 NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (dn) REFERENCES udb_user(dn) ON UPDATE CASCADE ON DELETE CASCADE
);
}}}

2010年7月21日 星期三

Eclipse

匯出與匯入一個專案:
1. 匯出: Export -> Gerneral->ArchieveFile -> zip
2. 匯入: Import -> Existing projects into workspace -> select archieve file

PS. Sometimes you need to set the build path:
project -> java build path -> libaray

2010年7月19日 星期一

Script for wms-glite and ant

Hi guys:
I will teach u how to compiler the LCG-WMS-GLITE job,

1. you can enter gap31Sub1ShellRunRequire dir


2. edit net/asgc/gap/core/lsa/lqs/LCG2.java file
> vim net/asgc/gap/core/lsa/lqs/LCG2.java

3. setting the enviroment variable
> export PATH=$PATH:/home/Andy/apache-ant-1.7.1/bin

4. build the project
> ant fw_core.clean
> ant fw_core.build

5. put the jar file to gap-LCG-GLITE project (you can copy the old jar to temportay)
> cp /home/Andy/tmp/sour/gap31Sub1ShellRunRequire/fw_core/dist/gap-lsa-3.1-0.jar /opt/gap-LCG-GLITE/dist/gap-lsa-3.1-0.jar

6. start the gap-lsa
>/etc/init.d/lsaservice-lcg-glite restart

Build a java to class

1. It need many lib, but we use simple to write

cp.sh
{{{
#!/bin/sh

CP=.

for path in $(find /opt/apache-tomcat-5.5.27/webapps/gcp/WEB-INF/lib/ -name *.jar);
do
#echo $path
CP="$CP:$path";
done

#echo $CP;
#CP="$CP:./tmp/code/datawarehouse/";
javac -classpath $CP GapUserInit.java

}}}

2. A comand that to list all data to as a classpath
{{{
[Andy@localhost lib]$ ls | awk '{home = "/home/Andy/Desktop/GRC/Data/TO_Alang_20110222/UniProt/API/uniprotjapi/src"; classpath = classpath ":" home "/" $1; print classpath; }' | less | tail -n 1
}}}

2010年7月17日 星期六

1. ALU
Alu sequence:

1、分布:

散佈於靈長類,老鼠的genomic DNA。人類的基因組中約有30萬分以上的Alu分散在基因組中,全部Alu佔人類基因組中的5﹪。

2、特性:

a、 約150-300bp DNA,為高度重複(highly repetitive)序列。人類genome有長短不一的Alu形成Alu家族,有些短的序列僅10bp類似Alu存在基因之間或intron內部。

b、 通常具有一段AGCT能被限制脢Alu I認定。

c、 隨種類不同,兩端是7-21bp的直接重複。

d、 Alu也是一種逆轉移子,Alu先轉錄成RNA,真核細胞中能也反轉錄脢,能將Alu RNA轉錄成Alu DNA在插入基因組中。Alu本身不會譯出蛋白質。



Reference:
http://brc.se.fju.edu.tw/nobelist/198x/p1983.htm

生物

1. Primate -靈長類
2. caenorhabditis- 線蟲

2010年7月15日 星期四

防駭

//////////////// 檔 port ///////////////////
說明: 使用 socket 底層去檔
1. /etc/hosts.allow 允許誰能近入
{{{
sshd: 140.109.98.0/255.255.255.0, 117.103.108.0/255.255.255.0 127.0.0.1 114.32.22.27
}}}

2. or /etc/hosts.deny
{{{
sshd: ALL
}}}

//////////////// 使用 iptable 去檔 ////////////////////
1. 只允許 140.109.98.0/24 的人進入 ssh
{{{
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -s ! 140.109.98.0/24 -j DROP
}}}

重啟:
{{{
/etc/init.d/iptables restart
}}}

2. 開放允許的 port
/etc/sysconfig/iptables
{{{
# ssh
#-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -s 140.109.98.0/24 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -s 117.103.108.0/24 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -s 127.0.0.1 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -s 114.32.22.27 -j ACCEPT

}}}

crontab

1. write the crontab
crontab -e

2010年7月14日 星期三

java sign

{{{
#!/bin/bash

JAR_DIR=/home/Andy/apache-tomcat-5.5.27/webapps/gcp/jsp/JWS/JarFiles
keyPath=/home/Andy/portal/script/key_bak

openssl pkcs12 -export -chain \
-inkey $keyPath/hostkey.pem \
-in $keyPath/hostcert.pem \
-out $keyPath/host.p12 \
-CApath /etc/grid-security/certificates/ \
-name "vt-004"

mkdir -p tmp

cp -r $JAR_DIR tmp
cd tmp

mkdir -p signed_jar
cp -r $JAR_DIR/* signed_jar

for jar in $(find JarFiles -name *.jar);
do
echo $jar
echo ${jar/JarFiles/signed_jar}
zip -d $jar META-INF/\*
jarsigner -keystore $keyPath/host.p12 -storetype PKCS12 -signedjar ${jar/JarFiles/signed_jar} $jar vt-004 < ../password
done

/bin/cp -rf signed_jar/* /opt/apache-tomcat-5.5.27/webapps/gcp/jsp/JWS/JarFiles

}}}

2010年7月10日 星期六

gcp_refine 使用 xml parser 和 handler 與 java test

//////////////////////////// 說明 /////////////////////////////
此範例的重點是用到 xml parse 的觀念, 而此文件的 parse
選用 DOM 方式來 parse 一份 xml 文件, Parse 的過程是從
root 開始然後列出它的下一層 Node, 此下一層 Node 再列出下一層 Node,
就可以走到每個節點, 而後讀出它們的值.


一份 xml 文件長的像是如下,
每個 Tag 下的內容都可以自己寫出自己要的名稱,
例如: XXX , 可以是 R, AutoDock4...



R


RScript
R description








///////////////////////// 程式///////////////////////////
GcpXMLParser.java :
{{{
package net.asgc.gap.portal.util;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class GcpXMLParser {
public final static String FILE_NAME = "gcp.xml";
private Document doc;

public GcpXMLParser() throws ParserConfigurationException, SAXException, IOException {

//Create instance of DocumentBuilderFactory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//Get the DocumentBuilder
DocumentBuilder parser = factory.newDocumentBuilder();
//Create blank DOM Document
doc = parser.parse(FILE_NAME);

}

public Map getAppInfo(String appName){
Map appInfo = new HashMap();

NodeList appNameList = doc.getElementsByTagName("appName"); // Get all app Name tage

// for loop to search appName
for(int i = 0; i < appNameList.getLength(); i++){
Node appNameNode = appNameList.item(i);
String name = appNameNode.getTextContent().trim();
System.out.println(name);

if(name.equals(appName)){
System.out.println("haha");

appInfo.put("appName", name);
// Get father to star application root search
Element appNode = (Element)appNameNode.getParentNode();

// Get input field
NodeList inputFilesNodeList = appNode.getElementsByTagName("inputFiles");
for(int j = 0; j < inputFilesNodeList.getLength(); j++){
Node inputFilesNode = inputFilesNodeList.item(i);
NodeList inputNodeList = inputFilesNode.getChildNodes();

// Get Input tag
for(int k = 0; k < inputNodeList.getLength(); k++){
Node inputNode = inputNodeList.item(k);
//System.out.println( "inputNode: " + k + " "+ inputNode.getTextContent());
if(inputNode.getNodeType() == Node.TEXT_NODE)
continue;

Element inputElem = (Element)inputNode;

// Get inptName
NodeList inputNameList = inputElem.getElementsByTagName("inputName");
String inputName = inputNameList.item(0).getTextContent().trim();
System.out.println(inputName);
//System.out.println(inputNameList.getLength());
NodeList descriptionList = inputElem.getElementsByTagName("description");
String description = descriptionList.item(0).getTextContent().trim();
appInfo.put(inputName, description);

}
//System.out.println(inputFilesNode);

}

}

}

return appInfo;

}

public Node getDocumentElement() {
return doc.getDocumentElement();
}

public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException {

GcpXMLParser xmlparse = new GcpXMLParser();


System.out.println(xmlparse.getAppInfo("AutoDock 4"));


}


}




}}}


gcp.xml
{{{



AutoDock 4


Target
Need the *.tar.gz target file consisting of *.maps, *fld, *.xyz, target.pdbqt


Ligand
Need the *.pdbqt file. (i.e ligand.pdbqt)


DPF
Need *.dpf file (Docking Parameter File)





R


RScript
R description




}}}






//////////////////////// 參考 /////////////////////////////
1. Sun java:
Document class
Node class
Element class
NodeList class

2. XML parser tutorial
XML tutorial
DOM XML element

2010年7月4日 星期日

編譯 Phylip 並傳到 Grid

說明:
首先要能 download phylip,
接著 compiler it
then write run.sh to u progam,
final write run.jdl to send to grid.
and check the feedback is the ce enviroment is corrent,
there often have compiler lib problem,
if the make file have solution, you can choose,
otherwise you need to do static bind.


範例:
run.sh
{{{
#!/bin/sh

INPUT=$1
WORK_DIR=`pwd`

compiler() {
PKG=$1
tar xzf $PKG
cd ${PKG%.tar.gz}/src
make install
mv ../exe/* $WORK_DIR
cd $WORK_DIR
rm -rf {PKG%.tar.gz} $PKG
}

run () {
INPUT=$1
./protdist <<-word
$INPUT
Y
word

}

compiler phylip-3.69.tar.gz
run testfile
}}}


run.jdl
{{{
JobType = "Normal";

Executable = "run.sh";
StdOutput = "std.out";
StdError = "std.err";

InputSandBox = {"run.sh", "phylip-3.69.tar.gz", "testfile"};
OutputSandBox = {"std.out", "std.err", "outfile"};
}}}











需要:
1. Bash shell script
2. make

Complier

1. C libaray

glibc:
libc 為連結至 C 主要的函式
libm 数学函数需要用到

2010年7月2日 星期五

書信

4.

本文結束後,再寫上結尾語,如See you (再見)、( With) Best wishes(祝你平安)、Yours always (永遠是你的摯愛)、Yours ever (永遠愛你的)、Your friend (你的友人)、Truly yours (摯友)、Sincerely yours或Yours sincerely或Sincerely (最誠摯的友人)、Love (愛人,避免用在兩個男士間的信件)…等。

注意:
若要針對收信的對象,將結尾語加以區分,則對於比較親密的對方,可 以用Sincerely yours、Yours sincerely或Sincerely;對於一般的朋友可用Your friend;如果是兒女寫給父母,就用Your loving son(daughter);對長輩則寫Respectfully yours,至於生意上的往來就用Faithfully yours。


Best regards,
Andy


參考:
http://home.lsjh.tp.edu.tw/middle/english/handout/b5/01.htm

APPLET

///////////// javaapplet 與 java 溝通 /////////////////////////
1. 說明:
可用 javascript 傳參數到 java applet, 在範例中,

/////////////// 1. 先要 include ///////////////////////


這從 Demo 來, 使用 deployJava.js, 而表示 applet 主要名稱, 和它在的 jstojava.MathApplet, 而 deployJava.runApplet 會作一些 handler, 例如: 幫你 create
applet tag, 最後你可以將參數傳給 java.

//////////////////// 2. 使用 javascript 去呼叫 applet ////////////








2. Reference
sun officer:
http://java.sun.com/docs/books/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html

3. 注意:
a. 在建立 math-applet.jnlp, 要用 jar
b. test.html 要放到 bin 下
{{{
[Andy@t-ap188 bin]$ ls
aaa.html applet_InvokingAppletMethodsFromJavaScript.jar jstojava math-applet.jnlp
[Andy@t-ap188 bin]$ pwd
/home/Andy/Desktop/working/JavaAll/ProjectWEB/DMApplet/bin
}}}

JAR

1. Sign a jar file
若目前目錄有個 bin/jstojava 要 sign, 則可用
{{{
jar cvf applet_InvokingAppletMethodsFromJavaScript.jar jstojava
}}}


參考:
http://www.java-samples.com/showtutorial.php?tutorialid=664

2010年7月1日 星期四

Eating

ur mum cooks for me everyday
i will eat leftover lunch from yesterday

Number Type

//////////////////// 說明 /////////////////
1. 在作科學運算時, 會用到科學計號, 在電腦會用 E+n 表示以 10 為底的幕次,
列如: 1.2E-3 為 0.0012
4.782E+4 為 47820



/////////////////// 原始型態 ///////////////
double 範圍從: 4.94065645841246544e-324d to 1.79769313486231570e+308d
float range: 1.40129846432481707e-45 to 3.40282346638528860e+38


/////////////////////// 參考 ////////////////////////
Java Private typ:
http://www.cafeaulait.org/course/week2/02.html


科學計號介紹:
http://163.19.175.248/teacher/math/index.php?load=read&id=21
http://eason982.blogspot.com/2008/06/blog-post.html

Java Type API:
double: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.html
float: http://www.concentric.net/~Ttwang/tech/javafloat.htm

Standard:
IEEE 854: http://en.wikipedia.org/wiki/IEEE_754-2008

Static paramter

1. E-Value
表示比對的統計數量的相似度, 若 e 越小, 則表式此序列越高.


http://bbsc.imb.sinica.edu.tw/blast/docs/newoptions.html
http://www.ncbi.nlm.nih.gov/Education/BLASTinfo/tut1.html

BLAST command

1. balst
command:
[ui01] /home/dhc00/tmp/0701BLAST > ./blastall --help

blastall 2.2.21 arguments:

-p Program Name [String]
-d Database [String]
default = nr
-i Query File [File In]
default = stdin
-e Expectation value (E) [Real]
default = 10.0
-m alignment view options:
0 = pairwise,
1 = query-anchored showing identities,
2 = query-anchored no identities,
3 = flat query-anchored, show identities,
4 = flat query-anchored, no identities,
5 = query-anchored no identities and blunt ends,
6 = flat query-anchored, no identities and blunt ends,
7 = XML Blast output,
8 = tabular,
9 tabular with comment lines
10 ASN, text
11 ASN, binary [Integer]
default = 0
range from 0 to 11
-o BLAST report Output File [File Out] Optional
default = stdout
-F Filter query sequence (DUST with blastn, SEG with others) [String]
default = T
-G Cost to open a gap (-1 invokes default behavior) [Integer]
default = -1
-E Cost to extend a gap (-1 invokes default behavior) [Integer]
default = -1
-X X dropoff value for gapped alignment (in bits) (zero invokes default behavior)
blastn 30, megablast 20, tblastx 0, all others 15 [Integer]
default = 0
-I Show GI's in deflines [T/F]
default = F
-q Penalty for a nucleotide mismatch (blastn only) [Integer]
default = -3
-r Reward for a nucleotide match (blastn only) [Integer]
default = 1
-v Number of database sequences to show one-line descriptions for (V) [Integer]
default = 500
-b Number of database sequence to show alignments for (B) [Integer]
default = 250
-f Threshold for extending hits, default if zero
blastp 11, blastn 0, blastx 12, tblastn 13
tblastx 13, megablast 0 [Real]
default = 0
-g Perform gapped alignment (not available with tblastx) [T/F]
default = T
-Q Query Genetic code to use [Integer]
default = 1
-D DB Genetic code (for tblast[nx] only) [Integer]
default = 1
-a Number of processors to use [Integer]
default = 1
-O SeqAlign file [File Out] Optional
-J Believe the query defline [T/F]
default = F
-M Matrix [String]
default = BLOSUM62
-W Word size, default if zero (blastn 11, megablast 28, all others 3) [Integer]
default = 0
-z Effective length of the database (use zero for the real size) [Real]
default = 0
-K Number of best hits from a region to keep. Off by default.
If used a value of 100 is recommended. Very high values of -v or -b is also suggested [Integer]
default = 0
-P 0 for multiple hit, 1 for single hit (does not apply to blastn) [Integer]
default = 0
-Y Effective length of the search space (use zero for the real size) [Real]
default = 0
-S Query strands to search against database (for blast[nx], and tblastx)
3 is both, 1 is top, 2 is bottom [Integer]
default = 3
-T Produce HTML output [T/F]
default = F
-l Restrict search of database to list of GI's [String] Optional
-U Use lower case filtering of FASTA sequence [T/F] Optional
-y X dropoff value for ungapped extensions in bits (0.0 invokes default behavior)
blastn 20, megablast 10, all others 7 [Real]
default = 0.0
-Z X dropoff value for final gapped alignment in bits (0.0 invokes default behavior)
blastn/megablast 100, tblastx 0, all others 25 [Integer]
default = 0
-R PSI-TBLASTN checkpoint file [File In] Optional
-n MegaBlast search [T/F]
default = F
-L Location on query sequence [String] Optional
-A Multiple Hits window size, default if zero (blastn/megablast 0, all others 40 [Integer]
default = 0
-w Frame shift penalty (OOF algorithm for blastx) [Integer]
default = 0
-t Length of the largest intron allowed in a translated nucleotide sequence when linking multiple distinct alignments. (0 invokes default behavior; a negative value disables linking.) [Integer]
default = 0
-B Number of concatenated queries, for blastn and tblastn [Integer] Optional
default = 0
-V Force use of the legacy BLAST engine [T/F] Optional
default = F
-C Use composition-based score adjustments for blastp or tblastn:
As first character:
D or d: default (equivalent to T)
0 or F or f: no composition-based statistics
2 or T or t: Composition-based score adjustments as in Bioinformatics 21:902-911,
1: Composition-based statistics as in NAR 29:2994-3005, 2001
2005, conditioned on sequence properties
3: Composition-based score adjustment as in Bioinformatics 21:902-911,
2005, unconditionally
For programs other than tblastn, must either be absent or be D, F or 0.
As second character, if first character is equivalent to 1, 2, or 3:
U or u: unified p-value combining alignment p-value and compositional p-value in round 1 only
[String]
default = D
-s Compute locally optimal Smith-Waterman alignments (This option is only
available for gapped tblastn.) [T/F]
default = F



./blastall -p $prog -d $database -i $infile -o $infile.out -e 10

時間

1. 偶爾 once in a while
2.

運動

1. 羽毛球 badminton
2. 桌球 table tennis
3. 跑步 jogging(running)
4. 游泳 swim
5. 球場 court
6. 棒球 baseball
7. 足球 football