December 29, 2013

How to change the limit of uploaded file size in php?

Edit the following configurations in the php.ini file, and then restart webserver (apache).

upload_max_filesize = 10M
post_max_size = 20M

You may find the php.ini file in /etc/php5/apache2 directory of ubuntu. If you forget the location of ini file, you may find it by running a simple php file as below.

<?php
   phpinfo();
?>
 
Note: you will probably require write permission to edit the php.ini file.
 
For more information, you may visit this page. 

December 28, 2013

Automatic mapping (or conversion) among different biological databases

biomaRt is an R package to map among different biological databases. Here is a simple code-snippet to convert human gene id to gene symbol.


library(biomaRt)
ensembl = useMart("ensembl",dataset="hsapiens_gene_ensembl")
symbols = getBM(attributes=c('entrezgene','hgnc_symbol'), filters='entrezgene', values=c("7157","5601"), mart=ensembl) 
 
Installation note:
  • In Ubuntu, you may need to install 'libxml2-dev' and 'libcurl4-openssl-dev'.

November 15, 2013

String Reverse in R

String reversing is a common operation especially in Bioinformatics. However, this function is not provided in R, not even in the "stringr" package. Here you can find the code:


str_reverse <- function(x){
  return(sapply(lapply(strsplit(x, NULL), rev), paste, collapse=""))
}

s <- "abc"
s1 <- str_reverse(s)
print(s1)