2012年11月29日 星期四

Top Field


1.

VIRT: Total amount of virtual memory used by the process
RES: physical memory which the process has used 
S - Process status - Possible values:
  • R - Running
  • S - Sleeping (may be interrupted)



Reference:
Top_field

2012年11月28日 星期三

illumina rna-seq insert size discussion

1. illumina say insert using 200-500 bp insert. Reference: illumina office

2. Someone say the peak of 180~190bp and (means the inserts shall be 60~70bp, Pair-End). Reference: Seq_Answer

3. a simple clear answer: Reference Biostart

2012年11月27日 星期二

Human sequence reference

1. Current there a human project hg19 and mean the grch37

2. As I found in google the hg19 is equal the grch37,
    but the hg19 is develop in UCSC
    Reference: UCSC hg19, UCSC_hg19_Statistic

3. And grch37 is develop in the genome reference consortium
    Reference: GRCH37

4.  Ensembl is a European project, but the version I didn't clear
        *Ensembl_Human_Annotation Genbank
        *EnsemblJ_Human_Annotation_GTF
        *Ensembl_FTP_Download_include_FASTA

2012年11月26日 星期一

How to set Java memory size

1.  What is the heap function in java ?
Java heap is the heap size allocated to JVM applications which takes care of the new objects being created. If the objects being created exceed the heap size, it will throw an error saying memoryOutof Boun.


2. Problem:
How to set the java memory? to avoid the OutOfMemoryException.
and how much is fit?


3. Solution:
A.How to set java memory
Memory usage = Stack Size + Heap Size + Code Size
  
-Xmsinitial java heap size
-Xmxmaximum java heap size


-Xssset thread stack size




B. How much is fit on your application?
IBM technical report say about head size

Size your Java heap so that your application runs with a minimum heap usage of 40%, and a maximum heap usage of 70%.


Reference:
IBM heap size advice
How to set java memory and debug
Java Memory Talk
what_is_java_heap_size

2012年11月21日 星期三

Boost Error boost/thread/detail/thread.hpp:43: undefined reference to `boost::detail::thread_data_base::~thread_data_base()'

1. Problem:
My boost version is boost_1_49_0, and System is Centos6.3
its build step is following and
it will auto create the library in the /usr/local/lib,
and the include files in /usr/local/include/boost:
  • su -
  • ./bootstrap.sh
  • ./b2
  • ./b2 link=static runtime-link=static stage install

But when I use this information to compile my project,
it is happen the following error
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:4926: undefined reference to `boost::thread::join()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:4927: undefined reference to `boost::thread::~thread()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:5003: undefined reference to `boost::thread::join()'
/home/Andy/IBMS/Software/tophat/develop/tophat-2.0.4/src/segment_juncs.cpp:5004: undefined reference to `boost::thread::~thread()'


It seems like the thread error.



2. Solution:
I find the google and the key point is
add the
 -lboost_thread-mt
to my gcc,
and then it will pass the problem.



Reference:
Boost Error Undefined


2012年11月16日 星期五

Struts 1.3 redirect function in login page

1. Problem: 

In my application,
I have a login.jsp and
authorize page need the user to login through this login,
then he will get the content of authorize page.

A general method
in struts-config.xml  file
<action path="/login" type="struts.action.LoginAction" scope="session" name="loginForm">

            <forward name="login" path="/login" />   
            <forward name="success" path="/loginSuccessPage" />
</action>
<action path="/anyAuthorizePage" type="struts.action.AuthorizeAction" scope="request" >
            <forward name="login" path="/login" />
            <forward name="anyAuthorizePageSuccess" path="/anyAuthorizePageSuccessPage" />
 </action>


And long as you type following page, and assuming session is timeout
                     http://localhost/anyAuthorizePage
the action is AuthorizeAction and because not login,
user will receive the login.jsp.

But when the user login,
according to the login action,
user will receive the loginSuccessPage,
not user expected the anyAuthorizePageSucccessPage.



2. Solution:

My solution conception is
let client way provide redirect url to LoginAction, 
and LoginAction use this redirect url to perform the redirection page.

The key point in my solution is client way, therefore I don't handle any session  this in anyAuthorizeAction. I only focus on the client way and LoginAction.
Another reason why I solve in client way is me observe that the



3. Example:

The technique contains the javascript to get the browseURL, struts action of redirect attribute. The following simple step is following:

A. Adding the webbrowse url filed on login.jsp

 
<script type="text/javascript">

/*將 user browserID */
function loginOnload() {
    writeBrowseUrlToForms();
}


/* 寫入 browse URL 到欄位中 */
function writeBrowseUrlToForms() {
   
    // 取得所有表單的 form, 因為 tagname 會回傳 array 
    elementsForms = document.getElementsByTagName("form");
   
    // 進入個別 form 取得個別欄位
    for (var intCounter = 0; intCounter < elementsForms.length; intCounter++)
    {
           writeBrowseUrlToForm(elementsForms[intCounter]);
    }
}

/*單一 URL */
function writeBrowseUrlToForm(currentForm) {

     var elementsInputs;
     var browseurl = document.location.href;
    
     // 取得所有輸入欄位 input, 但只在意 formposition 與 endPosition 兩個欄位
     elementsInputs = currentForm.getElementsByTagName("input");

     for (var intCounter = 0; intCounter < elementsInputs.length; intCounter++)
     {
           var inputFieldName = elementsInputs[intCounter].name;
           var inputFieldValue = elementsInputs[intCounter].value;
          
           if (inputFieldName == "browseurl")
           {
              elementsInputs[intCounter].value = browseurl;
           }
     }

}

/* 加入 Layout Onload 到事件中*/
// Namespace of login content
var login;

if (!login) {
    login = {};
}

login.oldOnload = window.onload || function() {};
window.onload = function () {
    login.oldOnload();
    loginOnload();
};

</script>
<html:form action="/login" >

<%-- hidden the url redirect, and on submit send to user --%>
<table id="login_table" style="border-collapse: collapse">
      
    <tr>
    <td>User Name</td>
    <td><html:text name="loginForm" property="name" size="20" /></td>
    </tr>
    
    <tr>
    <td>Password</td>
    <td> <html:password name="loginForm" property="password" size="21" /></td>
    </tr>
    
        
    <%-- Hiden redirect page --%>
    <tr>
     <html:hidden property="browseurl" value=""/>
    </tr>
    
    <tr> <td colspan="2" align="right">    <html:submit value="login"/></td>
    </tr>
    
    
    
</table>

</html:form>



 B. And LoginAction adding sendRedirect() method in LoginAction

public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
 
if (verifyUser(username, password)) {
           
          ....
       
            // 如果需要重導入功能
            ActionRedirect redirect = null;
            if ( (redirect = sendRedirect(request, loginForm.getBrowseurl(), mapping)) != null) {
                return redirect;
            }else {
                return mapping.findForward("success");
            }
        } 

}

}


    protected ActionRedirect sendRedirect(HttpServletRequest req, String needLoginPageURL, ActionMapping mapping) {
        ActionRedirect redirect = null;
       
        if (req == null || needLoginPageURL == null || needLoginPageURL.equals("")) {
            return redirect;
        }
        logger.info(needLoginPageURL);
       
        // 比對是否相同 host not by hack
         if (equalsHost(getThisFormUrl(req), needLoginPageURL)) {
           
             String contextPath = getContextPath(needLoginPageURL);
           
             if (contextPath != null) {
               
                 // 手動加入想要 login 內容
                 if (contextPath.contains("/authorizePage.do")) {
                     redirect = new ActionRedirect(mapping.findForward("
authorizePage"));
                 }
               
             } // end if path
         }
        return redirect;
    }



/** 需要 URL 網址 */
    protected String getThisFormUrl(HttpServletRequest req) {
        String reqUrl = req.getRequestURL().toString();
        String queryString = req.getQueryString();  
        if (queryString != null) {
            reqUrl += "?"+queryString;
        }
        return reqUrl;
    }



C. LoginForm.class add the browseurl

public class LoginForm extends ActionForm{
    private static final long serialVersionUID = 1L;
    private String name;
    private String password;
    private String browseurl;        // 如果需要從新導入可以使用
   
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getBrowseurl() {
        return browseurl;
    }
    public void setBrowseurl(String browseurl) {
        this.browseurl = browseurl;
    }
     
}

D. Setting the struts.xml Action
<action path="/login" type="struts.action.LoginAction" scope="session" name="loginForm">
            <forward name="login" path="/login" />   
            <forward name="success" path="/successLogin" />           
           <forward name="authorizePage" path="/authorizePaget.do" redirect="true" />
</action>



Reference
Struts_Action_Redirct
GET_Browse_URL
web_GET_URL

2012年11月13日 星期二

JSP or Struts simply show error page and exception inforamtion

1. Problem
In develop the web application by struts or jsp,
it has the requirement to show the error message,
but use the struts default exception handler method is complex to show data,
because it involve the bean, action setting for exception type.

I study the inline error page show and share it.


2. Solution
I use simple jsp handle object,
pageContext.exception and
pageContext.errorData


3. Example

Notice: if you use struts,
don't write the <global-exceptions> tag,
we will transfer the exception to the tomcat handle

A. in web.xml write
=============================================
<error-page>
        <error-code>404</error-code>
        <location>/error.jsp</location>
</error-page>
 
<error-page>
     <exception-type>java.lang.Throwable</exception-type>
      <location>/error.jsp</location>
</error-page>
=============================================



B. error.jsp
=============================================

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isErrorPage="true" %>
<html>
<head>
<title>Error Page</title>

 <style type="text/css">
h2{background:darkblue;color:white}
h3{background:darkblue;color:white}
.style1 {
    color: #66CCFF;
    font-size: x-large;
    font-weight: bold;
}
</style>


</head>
<body>
<span class="style1">Oops...</span><br>
<div>
A system error has occured. <br>
If the
problem persists, please report this information to the System Administrator.
</div>

<br/>
[<a href="./index.jsp">GoGack to index</a>]
[<a href="javascript:showDetails()">Show details</a> ]
[<a href="javascript:hideDetails()">Hide details</a> ]
<br/>


<table id="showDetailsLinkDiv" style="{display:none}"   cellspacing="0" width="100%" border="1">
 
    <tr valign="top">
        <td width="40%"><b>Error:</b></td>
        <td>${pageContext.exception}</td>
    </tr>
 
    <tr valign="top">
        <td><b>URI:</b></td>
        <td>${pageContext.errorData.requestURI}</td>
    </tr>
 
    <tr valign="top">
        <td><b>Status code:</b></td>
        <td>${pageContext.errorData.statusCode}</td>
    </tr>
 
    <tr valign="top">
    <td><b>Stack trace:</b></td>
    <td>
        <c:forEach var="trace"
                 items="${pageContext.exception.stackTrace}">
        <p>${trace}</p>
    </c:forEach>
    </td>
    </tr>

</table>

<script language="javascript">
   function showDetails() {
     document.getElementById("showDetailsLinkDiv").style.display = "inline";
   }
   function hideDetails() {
     document.getElementById("showDetailsLinkDiv").style.display = "none";
   }
</script>
</body>
</html>


=============================================


Reference:
http://geekexplains.blogspot.tw/2008/06/errorexception-handling-in-jsp-using.html