Web interface: GC shift mapping

From Augix' Wiki

Jump to: navigation, search

GC_shift_mapping.cgi

#!/usr/bin/perl
$TITLE =     'No title';
$WEBMASTER = 'Any problems or suggestions please contact <img src="http://www.augix.com/html/img/Gmail.png">';
alarm(600); # Timeout: generate SIGALRM after 10 min.
$SIG{'INT'} = $SIG{'TERM'} = 
    $SIG{'STOP'} = $SIG{'QUIT'} = $SIG{'ALRM'} = '&stop';
if ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    %FORM = &parse($buffer);
    &run;
} else {
    &print_form;
}
exit;
sub parse { # parse parameters
    local(%form, @pairs, $name, $value);
    @pairs = split(/&/,$_[0]);
    foreach (@pairs) {
	($name, $value) = split /=/;
	$value =~ tr/\+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$form{$name} = $value;
    }
    return %form;
}
sub run {
    $|=1; 			# force flush buffer
    print "Content-Type: text/html\n\n";
    print "<title>$TITLE</title>\n";
    print "<body bgcolor=\"#eeeeee\">\n";
    print "<pre>";
#	if ($FORM{'times'}=~/\D/) { print 'Go back! Check the "time(s)" value !'; &stop; }
#	if ($FORM{'signal'}=~/[^ACGTacgt]/) { print "Go back! Check your signal. [ACGT] allowed only!"; &stop; }
#	if (!$FORM{'sequence'}) { print 'Go back! Paste your data (FASTA format) and try again!'; &stop; }
	($r_species,$r_chr,$r_draw,$c_species,$c_chr,$c_draw)=($FORM{'$r_species'},$FORM{'$r_chr'},$FORM{'$r_draw'},$FORM{'$c_species'},$FORM{'$c_chr'},$FORM{'$c_draw'});
 
	$draw_par="
plot( 0, xlim=c(0,250000000), ylim=c(1,22), xlab= 'position', ylab= '', )\n
title(main = list("no title", cex=1.5, col="red", font=3))\n
 
segments( 0, 0, chr.length.$r_species[$r_chr,2], 0 )\n
text(-2000000,0,labels=as.character(chr.length.$r_species[$r_chr,1]))\n
";
 
 
	if ($r_draw eq "shift") { $draw_r="
ref_plus  <- subset(ref, shift.$r_species > 0)\n
ref_moins <- subset(ref, shift.$r_species < 0)\n
segments( ref_plus$inf.$r_species, ref_plus$chr.$r_species, ref_plus$sup.$r_species, 0 + ref_plus$shift.$r_species, col='red' )\n
segments( ref_moins$inf.$r_species, ref_moins$chr.$r_species, ref_moins$sup.$r_species, 0 + ref_moins$shift.$r_species, col='blue' )\n
";}
 
	if ($r_draw eq "gc3") {	$draw_r="
segments( ref$inf.$r_species, ref$chr.$r_species, ref$sup.$r_species, 0 + 0.5, col=ref$gc3.$r_species*100 )\n
";}
 
	if ($r_draw eq "pos") { $draw_r="
centro.$r_species <- read.table('/bge/augix/minorshift/etape5/$r_species Centromeres.txt')\n
telo.$r_species <- read.table('/bge/augix/minorshift/etape5/$r_species Telomeres.txt')\n
 
arm_p.$r_species <- subset(ref, inf.$r_species < centro.$r_species[shift$chr.$r_species,2])\n
arm_q.$r_species <- subset(ref, inf.$r_species > centro.$r_species[shift$chr.$r_species,3])\n
 
if (length(arm_p.$r_species$inf.$r_species)>0) arm_p.$r_species$col= (centro.$r_species[arm_p.$r_species$chr.$r_species,2] - arm_p.$r_species$inf.$r_species)*100 / centro.$r_species[arm_p.$r_species$chr.$r_species,2]\n 
if (length(arm_p.$r_species$inf.$r_species)>0) segments(arm_p.$r_species$inf.$r_species, 0, arm_p.$r_species$sup.$r_species,0+0.5,col= arm_p.$r_species$col )\n
 
if (length(arm_q.$r_species$inf.$r_species)>0) arm_q.$r_species$col=(arm_q.$r_species$inf.$r_species-centro.$r_species[arm_q.$r_species$chr.$r_species,3])*100/(telo.$r_species[arm_q.$r_species$chr.$r_species,3]-centro.$r_species[arm_q.$r_species$chr.$r_species,3])\n
if (length(arm_q.$r_species$inf.$r_species)>0) segments(arm_q.$r_species$inf.$r_species,0 ,arm_q.$r_species$sup.$r_species,0+0.5,col=arm_q.$r_species$col)\n
";}
 
 
print <<"HTML";
Content-Type: text/html
 
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$TITLE</title></head>
<body bgcolor="#eeeeee">
<h1 align="left"><font size="7" color="#000080">$TITLE</font></h1>
<h4 align="center">$WEBMASTER<br></h4>
 
<br>
<form action="http://www.augix.com/cgi-bin/Bioinfo/shift_karyotype.cgi" method="POST" name="Microsatellites" class="style2">
 
<center>
 
<FORM onSubmit = "return checkData(this)" action="http://pbil.univ-lyon1.fr/cgi-bin/Rweb/Rweb.cgi" enctype="multipart/form-data" method="post">
<TEXTAREA NAME="Rcode" ROWS=5 COLS=80>
 
chr.length.homo <- read.table("/bge/augix/minorshift/etape5/chr.length.homo")
chr.length.mus <- read.table("/bge/augix/minorshift/etape5/chr.length.mus")
shift <- read.table("/bge/augix/minorshift/etape5/shift")
cl <- rainbow(100,s=1,v=1,start=0.6,end=1,gamma=1)
palette(cl)
 
r_species <- $r_species
r_chr <- $r_chr
r_draw <- $r_draw
c_species <- $c_species
c_chr <- $c_chr
c_draw <- $c_draw
 
r_chr <- $r_chr
ref <- subset(shift, chr.$r_species == r_chr)
 
$draw_par
$draw_r
 
 
 
 
 
</TEXTAREA><br>
<INPUT TYPE="submit" VALUE="Plot it"></FORM>
 
<hr>
</center>
 
HTML
 
}
 
 
sub stop { exit 1; }
 
 
 
sub print_form {
print <<"HTML";
Content-Type: text/html
 
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$TITLE</title></head>
<body bgcolor="#eeeeee">
<h1 align="left"><font size="7" color="#000080">$TITLE</font></h1>
<h4 align="center">$WEBMASTER<br></h4>
 
<br>
<form action="http://www.augix.com/cgi-bin/Bioinfo/shift_karyotype.cgi" method="POST" name="Microsatellites" class="style2">
 
<p>
Reference Chromosome:<br>
Species :&nbsp <input name="r_species" size="6" value="mus"> Chromosome <input name="r_chr" size="6" value="1">, draw <select name="r_draw">
  <option value="shift">	1. shift
  <option value="gc3">	2. GC3
  <option value=pos"> 3. position between telo and centromere
</select>
<br>
<br>
<br>
Compared Chromosome:
Species :&nbsp <input name="c_species" size="6" value="homo"> Chromosome <input name="c_chr" size="30" value="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24">, draw <select name="c_draw">
  <option value="shift">	1. shift
  <option value="gc3">	2. GC3
  <option value=pos"> 3. position between telo and centromere
</select>
<br><br>
 
 
 
<input TYPE=submit VALUE="Run">	  <input TYPE=reset VALUE="Clear Input">
</form>
<br>
</body>
</html>
 
HTML
}

simple.php

<!--
Title: GC shift mapping
Author: Augix G.H. Xu
-->
<?PHP
$TITLE =     'GC shift mapping';
$Description = 'This program allows user to retrieve the information of GC content and GC change for vertebrate orthologous genes, and to map these information on the chromosomes according to the gene position.';
$WEBMASTER = 'Any problems or suggestions please contact <img src="/~augix/img/Gmail.png">';
?>
<html><head>
<title><?php print $TITLE;?></title>
</head>
<body bgcolor="#eeeeee">
<h1 align="left"><font size="7" color="#000080"><?php print $TITLE;?></font></h1>
<h4 align="left"><?php print $Description;?><br></h4>
<h4 align="center"><?php print $WEBMASTER;?><br></h4>
 
<form method="POST" action=""<? print $_SERVER["PHP_SELF"]; ?>"">
<p>
Reference Chromosome:<br>
Species :&nbsp <input name="r_species" size="6" value="mus"> Chromosome <input name="r_chr" size="6" value="1">, draw <select name="r_draw">
  <option value="shift">	1. shift
  <option value="gc3">	2. GC3
  <option value="pos"> 3. position between telo and centromere
</select>
<br>
<br>
<br>
Compared Chromosome:<br>
Species :&nbsp <input name="c_species" size="6" value="homo"> Chromosome <input name="c_chr" size="30" value="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24">, draw <select name="c_draw">
  <option value="shift">	1. shift
  <option value="gc3">	2. GC3
  <option value=pos"> 3. position between telo and centromere
</select>
<br><br>
<input TYPE=submit VALUE="Run">	  <input TYPE=reset VALUE="Clear Input">
</form>
 
<?php
if ($_POST) {
 
$r_chr=$_POST["r_chr"];
 
print <<<END
<FORM onSubmit = "return checkData(this)" action="http://pbil.univ-lyon1.fr/cgi-bin/Rweb/Rweb.cgi" enctype="multipart/form-data" method="post">
<TEXTAREA NAME="Rcode" ROWS=10 COLS=80>
 
chr.length.homo <- read.table("/bge/augix/minorshift/etape5/chr.length.homo")
chr.length.mus <- read.table("/bge/augix/minorshift/etape5/chr.length.mus")
shift <- read.table("/bge/augix/minorshift/etape5/shift")
cl=rainbow(105,s=1,v=1,start=0.6,end=1,gamma=1)
palette(cl)
species="mus"
chr=$r_chr
 
 
series1 <- subset(shift, shift\$chr.mus==chr)
plot( 0, xlim=c(0,250000000), ylim=c(0,max(series1\$chr.homo)), xlab= 'position', ylab= '',cex=0.1 )
title(main = list(paste(species,' chromosome ',chr), cex=1.5, col="red", font=3))
 
segments(0,0,chr.length.mus[chr,2],0)
segments( 0,series1\$chr.homo,chr.length.homo[series1\$chr.homo,2],series1\$chr.homo)
 
$draw_in
 
 
centro.homo <- read.table("/bge/augix/minorshift/etape5/Human Centromeres.txt")
telo.homo <- read.table("/bge/augix/minorshift/etape5/Human Telomeres.txt")
arm_p.homo <- subset(series1, inf.homo < centro.homo[shift\$chr.homo,2])
arm_q.homo <- subset(series1, inf.homo > centro.homo[shift\$chr.homo,3])
 
if (length(arm_p.homo\$inf.homo)>0) arm_p.homo\$col= (centro.homo[arm_p.homo\$chr.homo,2] - arm_p.homo\$inf.homo)*100 / centro.homo[arm_p.homo\$chr.homo,2] 
if (length(arm_p.homo\$inf.homo)>0) segments(arm_p.homo\$inf.homo,arm_p.homo\$chr.homo,arm_p.homo\$sup.homo,arm_p.homo\$chr.homo+0.5,col= arm_p.homo\$col )
 
if (length(arm_q.homo\$inf.homo)>0) arm_q.homo\$col=(arm_q.homo\$inf.homo-centro.homo[arm_q.homo\$chr.homo,3])*100/(telo.homo[arm_q.homo\$chr.homo,3]-centro.homo[arm_q.homo\$chr.homo,3])
if (length(arm_q.homo\$inf.homo)>0) segments(arm_q.homo\$inf.homo,arm_q.homo\$chr.homo,arm_q.homo\$sup.homo,arm_q.homo\$chr.homo+0.5,col=arm_q.homo\$col)
 
text( -2000000,c(1:(length(chr.length.homo[,1]))),labels=as.character(chr.length.homo[,1]))
 
###relationship
segments(series1\$inf.mus,0.8,series1\$inf.homo,series1\$chr.homo,lty=3,lwd=0.5)
 
</TEXTAREA><br>
<INPUT TYPE="submit" VALUE="Plot it"></FORM>
 
<hr>
</center>
END;
}
 
?>
 
<br>
</body>
</html>
Personal tools