Sunday, October 1, 2017

Simple WebServer using PHP

It Works!

This is a simple example to design your own PHP web server used for application development or testing PHP script and should not be used on a public network. It works similar to the Apache web server with limited functionalities and not intended to be a full-featured web server. This tutorial demonstrates just to activate the built-in web server through a batch file.

Instructions

For designing a PHP web server, we simply need PHP software alone. The batch file(.bat) was created to activate the built-in web server, automatically open the default web browser with custom folder as root directory (www), and minimize the command line window while running the PHP script.

Step 1: Download and extract compresed file (.zip) formatted PHP software according to your system platform. I have downloaded VC14 x64 Thread Safe (2017-Sep-26 23:04:10) for 64-bit Windows 10 OS.

PHP 7.1

Step 2: Create a new folder www in the extracted folder. Also, create a new file index.html in the www folder with the following line “<h1>It Works!</h1>” and save it.

Step 3: Create an batch file PHPServer.bat in the extracted folder using any ASCII text editor and enter the following commands.

START /min php -S localhost:88 -t www/ START "" http://localhost:88

Step 4: Double-click PHPServer.bat file to run web server and launch the web browser.

It Works!

Frequency Plot of Protein Sequence using PHP and R

Frequenc Plot

About Protein Frequency Plot

A frequency plot is a graphical data analysis technique for summarizing the distributional information of a variable. The response variable is divided into equal sized intervals (or bins). The number of occurrences of the response variable is calculated for each bin. In this tutorial, the number of occurrences of each amino acids in the protein sequence (response variable) is calculated and sorted in ascending order.

The frequency plot then consists of:

Vertical Axis = Amino acids
Horizontal Axis = Frequencies of the amino acids

There are 4 types of frequency plots:

  1. Frequency plot (absolute counts);
  2. Relative frequency plot (convert counts to proportions);
  3. Cumulative frequency plot;
  4. Cumulative relative frequency plot.

The frequency plot and the histogram have the same information except the frequency plot has lines connecting the frequency values, whereas the histogram has bars at the frequency values.

Frequency plot using PHP and R

In this tutorial, the programming language R, PHP, and BioConductor packages SeqinR & Biostrings are used to generate a frequency plot from the protein sequence. SeqinR is used to read or manipulate sequences, and Biostrings is used to convert sequence to array. The PHP language is used to execute Rscript at background using exec() function of PHP and the image generated through R (Rscript) is retrieved and displayed through the IMG HTML tag. The execution process acts similar to PHP/CGI or Perl/CGI. For generating a frequency plot, we need a protein sequence in .fasta|.fas file format as input. A simple protocol for generating a frequency plot is given below:

Step 1: Download and install R software according to your system platform.

Step 2: Download SeqinR and Biostrings module from CRAN and install. The brief explanations for Step (1) & (2) can be downloaded from http://www.biogem.org/downloads/notes/Installing%20R.pdf

Step 3: Create an R script as given bellow using an ASCII editor (Eg. Notepad) and save it with .R file extension. Here args function is used to get path of the FASTA file formatted protein sequence through command line.

R Source Code (Freq.R)

args <- commandArgs(TRUE) fas_file <- args[1] library("seqinr") library("Biostrings") seqfile <- read.fasta(file = fas_file) fastaseq <- seqfile[[1]] seqstring <- c2s(fastaseq) seqstring <- toupper(seqstring) seqchar <- s2c(seqstring) tab <- table(seqchar) taborder <- tab[order(tab)] names(taborder) <- aaa(names(taborder)) png(filename="freq.png", width=500, height=500) dotchart(taborder, pch=19, main="Frequency of Amino Acids", xlab="Frequency", ylab="Amino Acid") dev.off()

Step 4: Create an PHP program to get protein sequence and execute the Rscript in commandline using exec() function. Example, exec("\"C:\Program Files\R\R-3.3.1\bin\Rscript.exe\" Freq.R $input");

FreqPlot PHP/R Input

PHP Source Code (Freq.PHP)

<!DOCTYPE html"> <html xmlns="https://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Frequency Plot using PHP and R</title> <style type="text/css"> html { box-sizing: border-box; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; } html, body { height: 100%; margin: 0px; padding: 0px; } .form{ position: absolute; top: 50%; left: 50%; width: 510px; height: 320px; margin-top: -160px; /* Half the height */ margin-left: -255px; /* Half the width */ vertical-align: middle; border: 1px solid blue; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset; border-radius: 2px; font-family: "Times New Roman", Georgia, Serif; } .output{ position: absolute; top: 50%; left: 50%; width: 512px; height: 584px; margin-top: -292px; /* Half the height */ margin-left: -256px; /* Half the width */ vertical-align: middle; border: 1px solid blue; font-size: 12px; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset; border-radius: 2px; } .space { padding: 10px; } .effect { border: 1px solid #aaa; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset; border-radius: 2px; } .heffect { border: 0; height: 1px; background: blue; } a { text-decoration: none; } </style> </head> <body> <?php if(isset($_POST['submit'])) { function img2data($image) { $type = pathinfo($image, PATHINFO_EXTENSION); $data = file_get_contents($image); return 'data:image/' . $type . ';base64,' . base64_encode($data); } $input = pathinfo($_FILES['seqfile']['tmp_name'], PATHINFO_FILENAME) . ".fasta"; move_uploaded_file($_FILES['seqfile']['tmp_name'], $input); exec("\"C:\Program Files\R\R-3.3.1\bin\Rscript.exe\" Freq.R $input"); $s = img2data("freq.png"); unlink("freq.png"); unlink($input); ?> <div class='output'> <h2 style="text-align: center;">Frequency Plot using PHP and R</h2> <hr class='heffect' /> <div class='space'><?php print "<img src='" . $s . "' />"; ?></div> </div> <?php } else { ?> <div class="form"> <h3 style="text-align: center;">Frequency Plot using PHP and R</h3> <hr class="heffect" /> <form action="" method="post" name="freqform" enctype= "multipart/form-data"> <p style="padding: 0 10px 0 10px;"> Upload protein sequence (<i>fasta file</i>) <input class="effect" type="file" name="seqfile" /> </p> <p style="padding: 0 10px 0 10px;"> <input class="effect" type="reset" name="reset" value="Reset" /> <input class="effect" type="submit" name="submit" value="Generate Plot" /> </p> </form> </div> <?php } ?> </body> </html>

Program Output

FreqPlot PHP/R Output

Friday, September 29, 2017

Local NCBI BLAST+ in WebServer - Easy Steps

locBLAST Input

This is a simple tutorial which explains how to design your own web interface for NCBI BLAST+ to perform local and online database search using PHP in webserver. The PHP library locBLAST executes the NCBI BLAST+ programs using exec() function through passing parameters from the HTML form fields. In locBLAST, two list boxes were used to select program & database, and text area & file upload is used to input query sequence in the FASTA file format. A FASTA file validation function is included to validate the query sequence before executing the BLAST programs. The locBLAST PHP library and test database files were freely available at GitHub.

Requirements for locBLAST Setup

In this tutorial, I have given a brief explanation about embedding the latest NCBI BLAST+ (the latest version of NCBI BLAST+ as on September 29, 2017 is 2.60.) in any PHP enabled web server. The latest version of NCBI BLAST+ (standalone command-line BLAST programs) can be downloaded from the FTP server of NCBI (ftp://ftp.ncbi.nih.gov/blast/executables/blast+/LATEST). A simple PHP supporting web server is enough to run the local BLAST program through the web browser. Follow the steps given below to setup and run the locBLAST program.

1. Download the compressed NCBI BLAST+ software (I have downloaded ncbi-blast-2.6.0+-x64-win64.tar.gz for Windows 64-bit OS) from the NCBI FTP server.

2. Create a folder named locBLAST in the web directory (usually named htdocs, www, or wwwroot).

3. Decompress ncbi-blast-2.6.0+-x64-win64.tar.gz file and copy all the files present in the bin folder to locBLAST directory.

4. Download index.php and db folder from GitHub and copy to locBLAST directory.

5. Open the URL http://localhost/locBLAST in the web browser to run locBLAST program.

locBLAST in Browser

6. Click the hyperlink DEMO and Search button to test local database search. The default parameters will generate an HTML file formatted BLAST search report.

locBLAST Output

The form fields in locBLAST program can be extended with custom form fields to perform advanced search. Moreover, desired database files can be downloaded from the NCBI FTP directory (ftp://ftp.ncbi.nih.gov) and copied to the db directory to perform offline database search.

Custom Database Creation

We can also create custom database using makeblastdb program present in the locBLAST directory. To create a custom database, copy the FASTA file formatted multiple sequence file to the db directory. Then open the db directory and press ALT key + Right mouse click to open command-line window directing to the current directory. Enter the command “makeblastdb.exe -in db/pdt.fas -out db/pdt -dbtype prot -title PDTDB” to create a custom database named PDTDB (already included in the db folder).

The FASTA file formatted multiple sequence file (pdt.fas)is given below:
>pdt|pdtdbt00001|pdb|1OKE|A/B
MRCIGISNRDFVEGVSGGSWVDIVLEHGSCVTTMAKNKPTLDFELIKTEAKQPATLRKYC
IEAKLTNTTTESRCPTQGEPTLNEEQDKRFVCKHSMVDRGWGNGCGLFGKGGIVTCAMFT
CKKNMEGKIVQPENLEYTVVITPHSGEEHAVGNDTGKHGKEVKITPQSSITEAELTGYGT
VTMECSPRTGLDFNEMVLLQMKDKAWLVHRQWFLDLPLPWLPGADTQGSNWIQKETLVTF
KNPHAKKQDVVVLGSQEGAMHTALTGATEIQMSSGNLLFTG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PTLEWFAALGLRWYALPAVSNMLLEIGGLEFPAAPFSGWYMSTEIGTR
NLCDPHRYNILEDVAVCMDLDTRTTSSLWKDKAAVEINVAVLHSYQLAKVTIVDHHAATA
SFMKHLENEQKARGGCPADWAWIVPPISGSLTPVFHQEMVNYFLSPAFRYQPDPWKGSAA
KGTGITR
>pdt|pdtdbt00008|pdb|4PQE|A
EGREDAELLVTVRGGRLRGIRLKTPGGPVSAFLGIPFAEPPMGPRRFLPPEPKQPWSGVV
DATTFQSVCYQYVDTLYPGFEGTEMWNPNRELSEDCLYLNVWTPYPRPTSPTPVLVWIYG
GGFYSGASSLDVYDGRFLVQAERTVLVSMNYRVGAFGFLALPGSREAPGNVGLLDQRLAL
QWVQENVAAFGGDPTSVTLFGESAGAASVGMHLLSPPSRGLFHRAVLQSGAPNGPWATVG
MGEARRRATQLAHLVGCPPGGTGGNDTELVACLRTRPAQVLVNHEWHVLPQESVFRFSFV
PVVDGDFLSDTPEALINAGDFHGLQVLVGVVKDEGSYFLVYGAPGFSKDNESLISRAEFL
AGVRVGVPQVSDLAAEAVVLHYTDWLHPEDPARLREALSDVVGDHNVVCPVAQLAGRLAA
QGARVYAYVFEHRASTLSWPLWMGVPHGYEIEFIFGIPLDPSRNYTAEEKIFAQRLMRYW
ANFARTGDPNEPRDPKAPQWPPYTAGAQQYVSLDLRPLEVRRGLRAQACAFWNRFLPKLL
SAT

Brief Video Tutorial

Tuesday, September 26, 2017

Extracting Multiple FASTA Sequences using PHP

cPanel Domain

This is a simple tutorial which explains how to safely extract multiple sequences from a FASTA file using PHP script. I have used four functions to perform different tasks: read_fas_file() - to check invalid file, fas_check() - to check FASTA file format, get_seq() - to retrieve sequence and sequence name pairs, and fas_get() - to extract and display multiple FASTA file formatted sequences. The full source code and multiple protein sequences in FASTA file format used in this tutorial is given below.

Source Code

function read_fas_file($x) { // Check for Empty File
 if (!file_exists($x)) {
  print "File Not Exist!!";
  exit();
 } else {
  $fh = fopen($x, 'r');
  if (filesize($x) == 0) {
   print "File is Empty!!";
   fclose($fh);
   exit();
  } else {
   $f = fread($fh, filesize($x));
   fclose($fh);
   return $f;
  }
 }
}

function fas_check($x) { // Check FASTA File Format
 $gt = substr($x, 0, 1);
 if ($gt != ">") {
  print "Not FASTA File!!";
  exit();
 } else {
  return $x;
 }
}

function get_seq($x) { // Get Sequence and Sequence Name
 $fl = explode(PHP_EOL, $x);
 $sh = trim(array_shift($fl));
 if($sh == null) {
  $sh = "UNKNOWN SEQUENCE";
 }
 $fl = array_filter($fl);
 $seq = "";
 foreach($fl as $str) {
  $seq .= trim($str);
 }
 $seq = strtoupper($seq);
 $seq = preg_replace("/[^ACDEFGHIKLMNPQRSTVWY]/i", "", $seq);
 if ((count($fl) < 1) || (strlen($seq) == 0)) {
  print "Sequence is Empty!!";
  exit();
 } else {
  return array($sh, $seq);
 }
}

function fas_get($x) { // Read Multiple FASTA Sequences
 $gtr = substr($x, 1);
 $sqs = explode(">", $gtr);
 if (count($sqs) > 1) {
  foreach ($sqs as $sq) {
   $spair = get_seq($sq);
   $spairs[$spair[0]] = $spair[1];
  }
  return $spairs;
 } else {
  $spair = get_seq($gtr);
  return array($spair[0] => $spair[1]);
 }
}

$file = "pdt.fas";
$content = read_fas_file($file);
$fasta = fas_check($content);
$seq = fas_get($fasta);
foreach($seq as $x => $y) {
 print $x . "\n" . $y;
 print "\n\n";
}

FASTA File (pdt.fas)

>pdt|pdtdbt00001|pdb|1OKE|A/B
MRCIGISNRDFVEGVSGGSWVDIVLEHGSCVTTMAKNKPTLDFELIKTEAKQPATLRKYC
IEAKLTNTTTESRCPTQGEPTLNEEQDKRFVCKHSMVDRGWGNGCGLFGKGGIVTCAMFT
CKKNMEGKIVQPENLEYTVVITPHSGEEHAVGNDTGKHGKEVKITPQSSITEAELTGYGT
VTMECSPRTGLDFNEMVLLQMKDKAWLVHRQWFLDLPLPWLPGADTQGSNWIQKETLVTF
KNPHAKKQDVVVLGSQEGAMHTALTGATEIQMSSGNLLFTGHLKCRL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AALGLRWYALPAVSNMLLEIGGLEFPAAPFSGWYMSTEIGTR
NLCDPHRYNILEDVAVCMDLDTRTTSSLWKDKAAVEINVAVLHSYQLAKVTIVDHHAATA
SFMKHLENEQKARGGCPADWAWIVPPISGSLTPVFHQEMVNYFLSPAFRYQPDPWKGSAA
KGTGITR
>pdt|pdtdbt00008|pdb|4PQE|A
EGREDAELLVTVRGGRLRGIRLKTPGGPVSAFLGIPFAEPPMGPRRFLPPEPKQPWSGVV
DATTFQSVCYQYVDTLYPGFEGTEMWNPNRELSEDCLYLNVWTPYPRPTSPTPVLVWIYG
GGFYSGASSLDVYDGRFLVQAERTVLVSMNYRVGAFGFLALPGSREAPGNVGLLDQRLAL
QWVQENVAAFGGDPTSVTLFGESAGAASVGMHLLSPPSRGLFHRAVLQSGAPNGPWATVG
MGEARRRATQLAHLVGCPPGGTGGNDTELVACLRTRPAQVLVNHEWHVLPQESVFRFSFV
PVVDGDFLSDTPEALINAGDFHGLQVLVGVVKDEGSYFLVYGAPGFSKDNESLISRAEFL
AGVRVGVPQVSDLAAEAVVLHYTDWLHPEDPARLREALSDVVGDHNVVCPVAQLAGRLAA
QGARVYAYVFEHRASTLSWPLWMGVPHGYEIEFIFGIPLDPSRNYTAEEKIFAQRLMRYW
ANFARTGDPNEPRDPKAPQWPPYTAGAQQYVSLDLRPLEVRRGLRAQACAFWNRFLPKLL
SAT

Friday, September 15, 2017

Simple Show/Hide Text using JavaScript

cPanel Domain

This is a simple tutorial which explains how to show or hide lines in a paragraph using JavaScript. The concept is to split the lines in the paragraph into two sections and show/hide the second section by clicking a hyperlinked text (to create a toggle effect). By default, the first section in the paragraph is set to always visible, and a hyperlink at the end of the line with onclick action to display the second section. Similarly, a hyperlink at the end of the line of the second section with onclick action is displayed after a mouse click event to hide the second section.

Example

This is a simple tutorial which explains how to show or hide lines in a paragraph using JavaScript. <a style='text-decoration: none' id='show_line' href='javascript:void(0)' onclick="document.getElementById('more').style.display = 'inline'; document.getElementById('hide_line').style.display = 'inline'; document.getElementById('show_line').style.display = 'none';">show more</a><span id='more' style='display: none;'>The concept is to split the lines in the paragraph into two sections and show/hide the <i>second section</i> by clicking a hyperlinked text (to create a toggle effect). By default, the <i>first section</i> in the paragraph is set to always visible, and a hyperlink at the end of the line with <kbd>onclick</kbd> action to display the <i>second section</i>. Similarly, a hyperlink at the end of the line of the <i>second section</i> with <kbd>onclick</kbd> action is displayed after a mouse click event to hide the <i>second section</i>. </span><a style='text-decoration: none; display: none' id='hide_line' href='javascript:void(0)' onclick="document.getElementById('more').style.display = 'none'; document.getElementById('show_line').style.display = 'inline'; document.getElementById('hide_line').style.display = 'none';">hide less</a>

Demo

This is a simple tutorial which explains how to show or hide lines in a paragraph using JavaScript. show more

Monday, November 7, 2016

Pointing Subdomain to another Domain through cPanel

cPanel Domain

Pointing Subdomain to another Domain

Pointing a subdomain to another domain is a challenging task for those who shift to another hosting provider. The problem is, old domain must point to the new domain properly for all sub-directories (Eg. https://sub.site1.com/article/introduction.html to https://www.site2.com/article/introduction.html). If the subdomain does not properly points to the new domain, the link may get broken. We can point a subdomain to another domain through cPanel, Zone Editor, or .htaccess file. In this tutorial, I have used cPanel version 66.0.14 to take screenshot.

cPanel Method

It is an easy method to point a subdomain to another domain. In this method, we can simply set both domains in cPanel to perform the task. In the Domains section of cPanel, click the Redirects link. In the Redirects page, enter the old subdomain and the new domain as shown in the screenshot below. Select the Wild Card Redirect box to redirect all files within a directory with the same filename in the redirected directory. But, you cannot use a Wild Card Redirect to redirect your main domain to a different directory on your site.

cPanel Redirect

The list of redirections can be viewed from the Subdomains page in the cPanel. To open the Subdomains page, click the Subdomains link present in the Domains section in the cPanel.

cPanel Subdomains

Zone Editor Method

It is a little difficult method to point a subdomain to another domain. In this method, we must specify the IP address of the new domain in “A” record in the Zone Editor. The correct IP address of the new domain must be carefully entered to point to the new domain properly. Click the + Add Record drop down menu and select Add A Record list. In the Name column, enter the old subdomain sub.site1.com and the IP address in the Record column. Press Add Record button to save the record.

cPanel Redirect

.htaccess Method

It is a difficult and complicated method to point a subdomain to another domain. In this method, we must enter the Apache handler command in the .htaccess file which is located in the www or htdocs directory, to redirect the URL. Incorrect commands may bisbehave the site's functionality. The Apache handler command for URL redirection is Redirect 301 /sub http://site2.com/$1.