2010年7月15日 星期四

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
}}}