#!/usr/bin/perl use strict; use warnings; use Adrian::Goodies ':dirs'; use File::Temp; use File::Spec::Functions; use Env::Path 'PATH'; PATH->Append(BLAST_BIN_DIR) if BLAST_BIN_DIR; #my %VALID_PROGS = (blastn => 'allnucl', tblastn => 'allnucl', tblastx => 'allnucl', # blastp => 'allprot', blastx => 'allprot'); #my %VALID_DBS = (allnucl => 'allnucl', nucl => 'allnucl', allflanks => 'allnucl', # flanks => 'allnucl', allprot => 'allprot', prot => 'allprot'); my $cgi = CGI->new(); my ($title, $prog, $db, $seq) = ($cgi->param('title') || "notitle" . time(), $cgi->param('prog'), $cgi->param('db'), $cgi->param('sequence')); $title =~ s/\s/ /g; $title = "notitle" . time() if $title eq ''; $seq =~ s/[^A-Za-z]//g; if ($cgi->request_method() eq 'POST' #and exists $VALID_PROGS{$prog} and #exists $VALID_DBS{$db} and $seq) { my $seqfile = File::Temp->new(); open (my $fh, '>', $seqfile); print $fh ">$title\n"; print $fh $seq, "\n"; close $fh; my $execstring; # currently is secure if ($prog eq "blastp" and $db eq "allnucl"){ $execstring = "/home/groupii/ncbi-blast/bin/$prog -db \"" . catfile(BLAST_DB_DIR, "allprot") . "\" -max_target_seqs 10 -word_size 5 -evalue 100 -query \"$seqfile\""; } elsif ($prog eq "blastx" and $db eq "allnucl"){ $execstring = "/home/groupii/ncbi-blast/bin/$prog -db \"" . catfile(BLAST_DB_DIR, "allprot") . "\" -max_target_seqs 10 -word_size 5 -evalue 100 -query \"$seqfile\""; } elsif ($prog eq "blastn") { $execstring = "/home/groupii/ncbi-blast/bin/$prog -db \"" . catfile(BLAST_DB_DIR, $db) . "\" -max_target_seqs 10 -word_size 5 -penalty -3 -reward 2 -task blastn -evalue 100 -query \"$seqfile\""; } else { $execstring = "/home/groupii/ncbi-blast/bin/$prog -db \"" . catfile(BLAST_DB_DIR, $db) . "\" -max_target_seqs 10 -word_size 5 -evalue 100 -query \"$seqfile\""; } print $cgi->header('text/plain'); print qx{$execstring}; } else { print $cgi->redirect('../blast.html'); } exit;