[Bio] / FigWebServices / align_DNA.cgi Repository:
ViewVC logotype

View of /FigWebServices/align_DNA.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Sat Oct 1 19:20:54 2005 UTC (14 years, 8 months ago) by overbeek
Branch: MAIN
add align_DNA.cgi

# -*- perl -*-

use URI::Escape;  # uri_escape()
use HTML;
use strict;
use tree_utilities;

use CGI;

my $cgi = new CGI;
if (0)
{
    my $VAR1;
    eval(join("",`cat /tmp/align_dna_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);
}

if (0)
{
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params)
    {
	print "$_\t:",join(",",$cgi->param($_)),":\n";
    }

    if (0)
    {
	if (open(TMP,">/tmp/align_dna_parms"))
	{
	    print TMP &Dumper($cgi);
	    close(TMP);
	}
    }
    exit;
}

use FIG;
my $fig = new FIG;

my $html = [];
push @$html, "<TITLE>SEED Align DNA</TITLE>\n"; 

#
# parameters: @ids        = $cgi->param('peg')        are the ids of the relevant PEGs
#             $upstream   = $cgi->param('upstream')   # of characters upstream (default = 0)
#             $gene       = $cgi->param('gene')       # of characters of gene (defaults to all)
#                                                    

my $upstream   = $cgi->param('upstream');
$upstream      = $upstream ? $upstream : 0;

my $gene       = $cgi->param('gene');

my $seqF = "$FIG_Config::temp/dna$$.fasta";
open(SEQ,">$seqF") || die "could not open $seqF";

my $peg;
my $n = 0;
foreach $peg (grep { $_ =~ /^fig\|/ } $cgi->param('peg'))
{

    my $coding;
    if (! defined($gene))
    {
	$coding = $fig->dna_seq(&FIG::genome_of($peg),$fig->feature_location($peg));
    }
    elsif ($gene > 0)
    {
	$coding = substr($fig->dna_seqa(&FIG::genome_of($peg),$fig->feature_location($peg)),0,$gene);
    }
    else
    {
	$coding = "";
    }

    my $upstream_seq = "";
    if ($upstream)
    {
	$upstream_seq = $fig->upstream_of($peg,$upstream,0);
    }
    my $seq = $upstream_seq . $coding;
    print SEQ ">$peg\n$seq\n";
    $n++;
}
close(SEQ);

if ($n > 1)
{
    $/ = "\n>";
    my @tmp = `$FIG_Config::bin/align_fasta < $seqF`;

    push(@$html,"<table border>\n");
    while (defined($_ = shift @tmp))
    {
	chomp;
	if ($_ =~ /^>?(\S+)[^\n]*\n(.*)/s)
	{
	    my $peg  =  $1;
	    my $seq =  $2;
	    $seq =~ s/\s//gs;
	    push(@$html,"<tr><td>$peg</td>");
	    my $c;
	    foreach $c (split("",$seq))
	    {
		my $color;
		if     ($c =~ /a/i)        { $color = 'red' }
		elsif  ($c =~ /c/i)        { $color = 'green' }
		elsif  ($c =~ /g/i)        { $color = 'blue' }
		elsif  ($c =~ /[tu]/i)     { $color = 'yellow' }
		push(@$html,"<td bgcolor=$color>$c</td>\n");
	    }
	    push(@$html,"</tr>");
	}
    }
    push(@$html,"</table>\n");
    $/ = "\n";
}
else
{
    push(@$html,$cgi->h1("Less than 2 sequences defined -- alignment failed"));
}
unlink $seqF;
&HTML::show_page($cgi, $html);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3