make test pass for multicat parsing with two xlsx files for testing.
[sgn.git] / cgi-bin / scraps / fasta.pl
blob41620524a8e6dc13a2b473bb1c208a099b64d21b
1 #!/usr/bin/perl
2 use CXGN::Scrap::AjaxPage;
3 use CXGN::DB::Connection;
4 use CXGN::UserList::Hotlist;
5 #use CXGN::Login;
7 my $page = CXGN::Scrap::AjaxPage->new();
8 my %args = $page->get_all_encoded_arguments();
10 $page->send_http_header;
11 print $page->header();
13 print "<caller>Fasta</caller>\n";
15 # Test high-latency conditions for AJAX:
16 # system("sleep 3");
18 my $type = $args{type} or $page->throw("Type must be specified");
19 $type =~ /(protein)|(genomic)|(cdna)|(cds)/ or $page->throw("Invalid sequence type: $type");
21 my $agi_list = $args{agi_list} or $page->throw("Agi list must be sent");
23 my $fasta = "";
25 my $dbh = CXGN::DB::Connection->new("public");
27 my $sth = $dbh->prepare("SELECT $type FROM ara_sequence WHERE agi=?");
29 my @agis = split /::/, $agi_list;
31 foreach(@agis){
32 $sth->execute($_);
33 my $row = $sth->fetchrow_hashref;
34 my $seq = $row->{$type};
35 $seq =~ s/(\w{60})/$1\n/g;
36 $fasta .= ">$_ | " . $type . "\n$seq\n";
38 print "<type>$type</type>\n";
39 print "<fasta>$fasta\n</fasta>";
41 print $page->footer();