#!/usr/bin/env perl use strict; use Carp; use Pod::Usage; =head1 NAME cgiUniprotEntry.pl - cgi scripts to grep a uniprot AC and print a fasta with derivated sequence =head1 DESCRIPTION get a uniprot Entry in .dat format and display the derived sequence =head1 ARGUMENTS =head3 ac=string A uniprot accession code (to be retieved from http://www.expasy.org/uniprot/yourac.txt =head3 outputformat=(dat|fasta|html) The output format in which the entry is printed =head1 COPYRIGHT Copyright (C) 2004-2005 Geneva Bioinformatics www.genebio.com This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =head1 AUTHORS Alexandre Masselot, www.genebio.com =cut $|=1; # flush immediately; BEGIN{ eval{ require DefEnv; DefEnv::read(); }; } END{ } my $isCGI; use CGI qw(:standard); if($isCGI){ use CGI::Carp qw(fatalsToBrowser warningsToBrowser); warningsToBrowser(1); } BEGIN{ $isCGI=$ENV{GATEWAY_INTERFACE}=~/CGI/; sub carp_error{ my $msg=shift; if ($isCGI){ my $q=new CGI; error($q, $msg); }else{ print STDERR $msg; } } CGI::Carp::set_message(\&carp_error) if $isCGI; sub error(){ my($q, $msg)=@_; # $q->header; print $q->start_html(-title=>"$0", -author=>'alexandre.masselot@genebio.com', -BGCOLOR=>'white'); print "

$0

\n"; print "
$msg
\n"; $q->end_html; exit; } } use InSilicoSpectro::Databanks::DBEntryUniprot; use File::Basename; use CGI qw(:standard); my $query = new CGI; if($query->param('doc')){ print $query->header; while(){ print $_; } exit(0); } my $script=basename($0); my $help=$query->param('help'); if(defined $help){ print $query->header(-type=>'text/plain'); pod2usage(-verbose=>2, -exitval=>2, -output=>\*STDOUT); exit(0); } unless($query->param('ac')){ my %cookies=$query->cookie($script); my $outputformat=$cookies{outputformat}; my $ac=$cookies{ac}; print $query->header; # print $query->start_html(-title=>"$script", # -author=>'alexandre.masselot@genebio.com', # -script=>[ # { # -src => 'elementControl.js', # -language=> 'JavaScript', # } # ] # ); print < $script

$script

Uniprot entry viewer (?)

AC
Output format
EOT print $query->end_html; exit(0); } my $query = new CGI; my $ac=$query->param('ac')||die "must provide an ac"; my $outputFormat=$query->param('outputformat')||die "must provide output format"; my %cookies; $cookies{ac}=$ac; $cookies{outputformat}=$outputFormat; my $cookie=cookie(-name=>$script, -value=>\%cookies, -expires=>'+100d' ); if($outputFormat=~/^(dat|fasta)$/i){ print $query->header(-type=>'text/plain', -cookie=>$cookie, ); }else{ print $query->header( -cookie=>$cookie, ); } use File::Basename; use LWP::Simple; my $url="http://www.expasy.org/uniprot/$ac.txt"; my $contents=LWP::Simple::get($url) or die "cannot get url $url: $!"; if($outputFormat=~/^(dat)$/i){ print $contents; exit(0); }else{ my $dbu=new InSilicoSpectro::Databanks::DBEntryUniprot; $dbu->readDat($contents); my @derived=$dbu->generateDerivedForms(); if($outputFormat=~/^(fasta)$/i){ $dbu->printFasta; foreach (@derived){ $_->printFasta; } exit(0); }else{ my $ac=$dbu->AC; print <
$ac
EOT print "

$ac

ID".$dbu->ID."
description".$dbu->description."
"; $dbu-> printHtml; foreach (@derived){ $_->printHtml; } print <
visit http://insilicospectro.vital-it.ch or download the soft from CPAN EOT } }