Tuesday, March 3, 2009

Set up a project managed by SVN

Samuel agreed to help me and get into this project, which makes me so happy. For the sake of teaching me conveniently, he set up a project in sourceforge.net, and told me how to use SVN to manage the project. The name of our project is Biological Network COmparison Toolkit(bnct), and weblink is: https://sourceforge.net/projects/bnct/.

Here is how to set up a project locally managed by SVN.

Firstly, download TortoiseSVN and install it. After the installation, it is integrated into the Windows Explorer. Create an empty folder to hold the coming project,for example, D:\Projects\bnct, and enter it.

Secondly, in this folder, right click and select SVN Checkout, then a property window pop out for setting.

Set the URL repository to: https://bnct.svn.sourceforge.net/svnroot/bnct/trunk, leave others default and click OK to make sure. After this, the fold will contain one gray .svn folder and several folder ticked like this:

Fourthly, right click on bnct, tortoiseSVN -> Settings, go to context menu. In the Cascaded context menu, make these options: Checkout.., Update, Commit.. , Diff and Check for modifications... checked then click OK for sure.

Next, go to Diff Viewer in the settings of TortoiseSVN, configure the program used for comparing different revisions of files as the External program. Here we use WinMerge. Set it like this:
After that, click OK.

TortoiseSVN -> Repo-browser, here is the view of the svn repository in sourceforge. You can check the project in sourceforge conveniently.

Thursday, February 19, 2009

How to debug or run a maven project

Here is the steps to add a tag for running or debugging a maven project. Open "Debug Configurations" by right click on the Eclipse. Also you can open this window by "Run" menu.
1. Give your tag a name, for exmaple, "run App";
2. Use "Browse file system " to fill in the Base directory. For my project, it should be "D:\Projects\netcomp\netcomp", the root path for the project.

3. Fill the blank of Goals by "clean package exec:java";

4. Click Configure at the right side of Maven Runtime and add an external address for the Maven running. It should be the path where your maven installed.

After all the steps, the "run App" tag for running a maven project is built up. When you need to do the debugging, enable the debug configurations window and click debug.

The import of netcomp

"netcomp" is the name of my little project.
Yesterday, after Samuel helped me modified it, I try to update the codes by cover the old files by the new ones. However, because Eclipse has some kind of history record for the old java files, after I re-open Eclipse to see the imported new java files, there are a lot of red crosses on the left side of the new packages and methods. Samuel told me to "Clean ..." and then "Update all the Maven projects" in the project menu of Eclipse. Because I didn't do it in the right order, it seemed useless. So I delete all the projects (there are kegg and netcomp previously) and try to import them in by click "import" and "Maven project". But it's wrong.
The right way to import the maven project to eclipse is,

Step 1. Unzip netcomp to D:\Projects. So now the right path for netcomp is D:\Projects\netcomp.

Step 2. run cmd and cd D:\projects\netcomp. Under this path, run : mvn eclipse:clean

Step 3. cd D:\projects\netcomp\netcomp. Under this path, run: mvn eclipse:eclipse.

Step 4. under D:\projects\netcomp, run: mvn clean install.
Up to now, my own .project for maven is generated.
Note: Run mvn eclipse:eclipse in the child netcomp, the one will be imported in the Eclipse as an existing java project later.

Step 5. In Eclipse, "Import" -> "General" -> "Existing Projects into Workspace" -> "Next" -> "Browse" to select the root directory. When you open "D:\Projects\netcomp" by browse, "netcomp" project will appear in the blank for Projects in this window. Then select it and "finish". If Kegg project appears in this blank too, omit it, it's enough only to import netcomp project.
Attention, in this step, it must be "Existing Projects into Workspace" instead of "Maven project" which is imported. It doesn't mean the option "Maven project" is useless, but since we've already built up the project by (cmd -> mvn eclipse:eclipse) , this project is an Existing project insead of an unbuilt Maven project. If you insist to use "import Maven project", then step 3 should be omitted. Or else, this import can be failed.

The installation of Eclipse and M2Eclipse

Before Eclipse, I've tried JBuilder, Together and MyEclipse. All these are the bundle of Java tools, whose core is Eclipse. They are cracked warez. So when I try to install M2Eclipse, the Maven add-on, various problem occurred. Finally I make up my mind to uninstall them all and turn to the simple Eclipse.

As an open source software, Eclipse is no need to be installed. The version I use now is eclipse-java-ganymede-SR1-win32, the economical version. I copy the unzip folder to C:\. So the installation path is C:\Eclipse.

Step 1. Modify Eclipse.ini and change the target of quick link for eclipse.exe.
I don't know why this file have to be modified. But if not, you will get error report when you run Eclipse with Maven together.
Add the following line in front of -vmargs.
"-vm
C:\Java\jdk1.6.0_10\bin\javaw.exe"
Meanwhile, change the properties of the quick link for Eclipse. The new Target should be "C:\Eclipse\eclipse.exe -vm C:\java\jdk1.6.0_10\bin\javaw.exe".

Note: Here is a bug for JVM. If you add "-vm C:\Java\jdk1.6.0_10\bin\javaw" instead of "-vm C:\Java\jdk1.6.0_10\bin\javaw.exe". It will show a "FATAL ERROR" message after the "BUILD SUCCESSFUL" of Maven information when debugging.

Step 2. Install M2Eclipse for Eclipse. (Note: M2Eclipse means "maven version 2 for eclipse")
In Eclipse, click "Help", then "Software Update", then "Avaliable Software",then "Add site". In the blank for "Location", fill in "http://m2eclipse.sonatype.org/update/ ". After that, the List of avialbe software will include "Maven Integaration for Eclipse Update Site". Make sure it's selected, then click "Install" on the right side. When the installation is finished, then this add-on is installed successfully.

Log4j

Log4j, I think, means "log for java". It is an useful tool to show the list of debugging or running log. Log4j has 6 levels, which are FATAL, ERROR, WARN, INFO, DEBUG and TRACE.
There are two ways to configure log4j. One is with a properties file, named log4j.properties, and the other is with an XML file. Within either these 3 components are necessary: Loggers, Appenders and Layouts. Configuring logging via a file has the advantage of turning logging on or off without modifying the application that uses log4j.
Loggers are logical log file names; The actual outputs are done by Appenders. Appenders use Layouts to format log entries.
To debug a misbehaving configuration use the Java VM Property - Dlog4j.debug which will ouput to standard out. To find out where a log4j.properties was loaded from inspect getClass().getResource("/log4j.properties");
Here is An Example Samuel wrote, which is the content of log4j.properties in /Main/Resource.

# The root logger is assigned priority level info and it's appender is stdout
log4j.rootLogger=info, stdout

# stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd/MM/yy HH:mm:ss} %c{1} %p - %m%n

# limit categories
log4j.logger.com.tt.netcomp=INFO

He said actually he diddn't use log4j directedly, but use Commons Logging(JCL) instead, whose backend includes Log4j.
This sentence, "log4j.appender.stdout=org.apache.log4j.ConsoleAppender" is to write log information out to the console; but if we need to write it out to a certein file instead of console, we can use the following sentence:
log4j.appender.stdout=org.apache.log4j.RollingFileAppender
log4j.appender.stdout.File= filepath

For example, it can be something like this:

# ----------------------log4j.properties -----------------------------------------#
# The root logger is assigned priority level infor and it's appender is fileout;
log4j.rootLogger = INFO, fileout

# fileout
log4j.appender.file out=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=output.log
log4j.appender.fileout.MaxFileSize=100KB
log4j.appender.fileout.MaxBackupIndex=1
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

# limit categories
log4j.logger.com.tt.netcomp = INFO

# --------------------Over----------------------------#

In addition, different package can be set to different limit level. For example,

# limit categories
log4j.logger.com.tt.netcomp. domain = DEBUG
log4j.logger.com.tt.netcomp. service = WARN

In this case, domain package will have the limit level as debug while service package as warn. The other package are set to be info as default since we assign the rootLogger level as INFO in the root setting area.

Sunday, February 15, 2009

What's Maven


These days I learnt a lot on Maven and Java, especially how to use it. I need to record them one by one so as not to forget them soon.

First of all, what's Maven. (Maven in five minutes.)

The most useful two commands:
1.
project_path>mvn clean package, to rebuild
2. project_path>mvn clean package exec:java, to clean, rebuild and run it.

Import Maven add-on to MyEclipse. Since the Together and the JBuilder I used before didn't support this add-on, M2Eclipse, because of their old version, I have to change the work tool to MyEclipse.

Step 1.
Afte
r installation of MyEclipse, click Help, then Software Updates, then Find and install, then Search for new features to install. It will open a new window.

New Remote Site... Then Type M2Eclipse in the name area and copy this line: http://m2eclipse.sonatype.org/update/ to URL. Then finish.Select the options of the M2Eclipse tree which would not fail the update(there are three not to enable)
Step 2.
Winkey + R open
the cmd window. Go to the project folder, here is D:\project\netcomp. Execute this command of mvn:
mvn eclipse:eclipse


Step 3:
Go to Eclipse, import the two projects, kegg and netcomp.

Step 4.
Right click the projects one bye one. There is a maven menu, choose "Enable Dependency Management". Now the projects are managed by Maven dependently.








Wednesday, February 11, 2009

NullPointerException

This sentence:
receivers.addAll( lookupMap.get(it.next() ) );

/* --------------------------------------------------------*/
Please input the name of pathway:
aae00010
Connecting to KEGG...
Connected successfully.
java.lang.NullPointerException
at java.util.AbstractCollection.addAll(AbstractCollection.java:303)
at org.tingting.bn.mn.graphbuilder.test.PathGraphBuilder.main(PathGraphBuilder.java:161)
/*---------------------------------------------------------*/

Now I've found why this problem occurred. NPE(NullPointerExcetion) is caused by Null point of the input variable. Here it is because lookupMap.get( ) returns a Null. I disabled the paragraph to generate the lookupMap for the sake of easy debugging, but I don't notice that this lookupMap is used when enzymerelationshipMap is generated.

Tuesday, February 3, 2009

Hurry Up!!

Only half a year do I have. But there are four papers which are in process. I need another two for the graduation as the request, which should be published on the SCI magazine. Time is so limited. Hurry Up!!

Friday, January 30, 2009

Track a error caused BSOD

This afternoon when I try to open a word file, named as cv_daijingquan.doc, a serious system error occurred, blue screen of death.

Then I entered the safe mode with network service and tried to open it. I opened this troublesome file correctly. At that time I thought maybe the problem was because the file was stored on the damaged disk partition, so I created a new folder in which I also created a new blank word file. I copied the content of the original file to the new one to ensure the new file was located on the different place of the disk. All the operation was done under the safe mode with network service.

Then I quit the safe mode and entered vista normally. When I tried to open the new file the same BSOD appeared again. Then I was sure it was not because of the hard disk error.

This time I entered the safe mode WITHOUT network service.
When I tried to open the original file, a warning message box popped up and asked me if I wanted to continue to open it since it had brought up some system error related to the wrong serial number (I cannot remember the exact message). I clicked yes and then the file was opened as normal. After that I deleted the original folder, including that file. And then I tried to open the new word file which had different name but same content with the original one, the same message box popped up and the file could be right opened then. Here I had the idea that the error must relate to the content of this file. But it's just a very normal word file,no math symbols, no any other sophisticated contents except for characters.

Samuel said it might be caused by the anti-virus tool. Since I'd tested the new file which was impossible to be infected, I was sure it had no business with virus. But I followed his words and forbid all the running service of Symantec. In this case when I was opening the new file, BSOD come again.

Again, he suggested me to clear up the registry. I did it using VistaMaster. But it's useless because BSOD was still there when the file was opened.

The event log of vista was checked too but nothing was found because it was to complicate for me.

Then, maybe I should get the exact prompting message before it could be opened correctly under the safe mode. So I opened the file again to cause another BSOD. After that I entered the safe mode without network service again to recur the popped wrong messge. But this time it's different phenominon.

Under the safe mode, when I tried to open the file, it popped out a warning message box to tell me "Windows cannot find this file. " Meanwhile another error messge box appeared. Here it is:



In order to track this error, I pasted the completed error message in its drop-down text box here:

/***********************************

Problem signature:
Problem Event Name: BlueScreen
OS Version: 6.0.6001.2.1.0.768.3
Locale ID: 1033

Additional information about the problem:
BCCode: 1
BCP1: 00000000
BCP2: 7FFDF000
BCP3: 0000FFFF
BCP4: 00000000
OS Version: 6_0_6001
Service Pack: 1_0
Product: 768_1

Files that help describe the problem:
C:\Windows\Minidump\Mini013009-05.dmp
C:\Users\Ting\AppData\Local\Temp\WER-111774-0.sysdata.xml
C:\Users\Ting\AppData\Local\Temp\WERF842.tmp.version.txt

Read our privacy statement:
http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409

************************************/

After I closed these two warning box, I tried to open the file again. To my surprise, this time it worked. The file was opened as normal correctly. But when I return to the normal mode of vista, its opening caused BSOD again, as above mentioned.

This problem is still unfixed. But this time
I know from the blue screen that it was an error called APC_INDEX_MISMATCH. With google's help I find this useful page which shows more information about this error and the possible solution. Here it is: http://www.geekswhoknow.com/articles/stop-0x00000001-0x0000001-apc_index_mismatch.htm .

I tried to follow its direction to repair my computer (item 10) but failed. This time the computer warned me I couldn't repair it because something wrong with some device.

/****************************************
status: 0xc00000f
Info: The boot selection failed because a required device is inaccessible.
****************************************/

Even the attempt of repair was denied. In this case I have no choice but not touching it any more. Anyway I know there's some problem with my notebook, so I'd better backup my project and files to another safe place in case the system broke down.


Main Tasks of this Year

Today is Jan 30. Time seems so limited. I am not sure it's enough or not for me to complete my graduation in this year. There are four main tasks before I start to compose the dissertation.
First of all, I need to finish my CV today or tomorrow at the latest. Then try to find a job for myself.
Secondly, as the request of my boss, I have to complete another proposal by March. It is for NSFC.
Thirdly, there are three technical report waiting for me to complete. Their contents would be Section 4,5 and 6 in my coming dissertation. Besides, I need to get at least two papers published based on the results of these research.
The last but not the least, compose the dissertation and preparation for the doctoral defense.

Saturday, January 17, 2009

What's a Java Project

Embarrassingly speaking, I don't know what is a Java Project exactly now although I've used it for several months. What's a Java Project? Is one project only set up to do one work? This problem puzzles me all day long.
Suppose here I need to do one work, which can be divided into three steps and conquered. Each step can be regarded as a smaller size work too. In this case, which is better, to set up a huge project to fulfill the overall work, or to set up three small projects for the three sub-tasks and then combined them together?
Samuel said it depended on my problem. Since now what I am touching is some small problem, I may only need to set up one project to include all of my problems as sub-tasks.
Usually a project can be considered as a system, from which a program for application will be generated. A project can have more than one Main function, and be compiled into more than one Jar files according to demand.
A small system can only have one application while a large one can have more. Meanwhile, a huge system can be composed of several smaller system, which in turn have several applications hierarchically.

Friday, January 16, 2009

Sharpen your tools before you are to work well

Don't know why. Jbuider and Together cannot run well on my notebook. I guess it's because the unknown style of Vista's memory allocation. Unfortunately, I have nothing to do with it currently.
In order to go on my work, Prof.Zhu asked Dongsheng help me add another Network Card to the server machine, with which I can write and run my code on the server.
How long I've spent on the setting of the server to make it work as request! However, no one knows it would be out of work so often after everything were ready, at least I thought so. Prof.Zhu said it was no need to get me a desktop, which hurt my pride to some degree.
I don't need such kind of Help with somewhat prejudice. Following Samuel's suggestion, I give up JBuilder and Together, these integrated Java IDEs, and turn to the pure Eclipse, trying to learn how to complete it by adding the necessary add-ons.
If you want to work well, you must sharpen your tools ahead. Keep this lesson in mind.

Monday, January 12, 2009

One-gene-one-enzyme Hypothesis

One gene one enzyme, this is a hypothesis. It believes that one gene only help to generate one enzyme, because of which this gene determines the specificity of this enzyme and influence its phenotype. It comes from a story of G.W.Beadle and E.L.Taum in 1941.
However, there are some enzymes which are aggregated from several different polypeptides and then caused active. Now it is found that one gene can determine more than one polypeptides, and polypeptides can help to form different enzymes or be members of only one enzyme. Thus, one gene should be corresponded to one specific polypeptide, instead of one enzyme.

Friday, January 9, 2009

The classic IO code

Get string from keyboard:

String input;
BufferedReader buf = new BufferedReader(new InputStreamReader(
System.in));
input = buf.readLine();

Write strings to the created file:

File f = new File(outfile);
f.createNewFile();

BufferedWriter output = new BufferedWriter(new FileWriter(f));
String out = "this is for test.";
output.write(out);
output.close();

On "java.lang.ArrayIndexOutOfBoundsException"

I try to assign the organism and pathway through arguments, but unexpectedly I got an exception: java.lang.ArrayIndexOutOfBoundsException. Having searched google I know it's caused because I try to index an empty array.
At first I didn't put in any arguments, so the argument array is empty. But I try to read in the organism name as well as pathway name from the empty arrays, then the exception is caused.

Now I have to try to find a better way to deal with the input arguments.

Highlight:
"java.lang.ArrayIndexOutOfBoundsException" is
Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.

Tips and Tricks on How to Use Eclipse

http://www.javaresearch.org/article/57437.htm

Following these tips posted online, I set my Eclipse on the server. Here is some hotkeys:

1. sysout + shift + space, it will add "System.out.println();" automatically;
2. If you want to comment some blocks, choose these codes and press "ctrl + /" simultaneously. On the contrary, if you want to uncomment it, press "ctrl + \";
3." Ctrl + F8" is used for switching prospective quickly.
4. The hotkey for "Debug Java Application" is "Alt + D";

(To be continue);

System Error 64 occurs when I map a network drive

I mapped the drive of the server used by me, (D:), to a virtual drive in my notebook as (Z:). It worked well all along.
In order to enable all the port of the server, Dongsheng helped to add a netwok card to that server machine meanwhile disabled the original virtual one. Thus, the network address of that machine is changed from an local one to an external. Because of this, the mapped drive is out of work.
When I tried to map the same storage via the new external address, some error occurred. It is "System Error 64:The specified network name is no longer available."
Dongsheng told me the machine had not been recognized as a local one any longer when its virtual NIC was disabled. That's why the mapping doesn't work. Even it is mapped to my notebook successfully, it isn't safe because the address is external, which is easy to attach.
It is a new knowledge to such a green hand like me. So I recode it in detail.
By the way, the command I used to map network drive is "net use * //server/D$ ". Be careful of the blanks before and behind "*".

Thursday, January 8, 2009

Connect to KEGG by KEGGAPI

These two days I spend much time on the codes for connecting KEGG by its API. Fortunately the KEGGAPI is updated to adapt to use AXIS 1.4 version, which means that I don't need to do the pretreatment as described at the website.

Here I write some code according to its Javadoc. Having got all the ports opened, it runs pretty well. Thus I know where the previous problem is: The remote machine doesn't allow the script out because only the port 3128 is open.


package org.tingting.bn.mn.networkbuilder.test;

import org.tingting.bn.mn.networkbuilder.domain.KeggConnector;

import keggapi.Definition;
import keggapi.KEGGPortType;

public class TestKeggConnector {

/**
* @param args
*/

public static void main(String[] args){

KeggConnector conn = new KeggConnector();
KEGGPortType serv;

try{
serv = conn.getServ();
Definition result[] = serv.list_pathways("hsa");

for( int i = 0; i <>

Monday, January 5, 2009

Only One Machine

Share a good essay: "Only One Machine" by Kevin Kelly. Here is the Chinese version translated.
"万器归一"

Sunday, January 4, 2009

Today is my big day

Today is my big day. I'll attend the annual conference of BPRC and give a presentation to sum up my work this year. To say the truth, I am not afraid of the annual report, but of my nominal Big Boss: Fuchu He. He is used to blame his students as far as he doesn't feel happy. The same slides,which got his praise today, is possible be scolded severely tomorrow. Beside, he always don't care the pride of his students. no matter when you are in front of everybody or not, his rebuke comes with no account. Compared to Keith, he is really a harsh supervisor. They are like the two poles of the Earth.
Anyway, I will get myself liberated after the presentation. Don't let his words kill me. God bless me.