CGI实现Restrictionmap.pm
CGI实现Restrictionmap.pm
请教一个在CGI 中使用自己改写的Model时的问题 Mastering Perl for Bioinformatics中的例子
先说一下我的调试环境 IIS5.1 XP ActivePerl 5.8.8
自己改写了3个Model 1.Restrictionmap.pm 2. Rebase.pm 3. SeqFileIO.pm (这三个package 我的已经分别在cmd模式下调试过了,都没有问题,而且我都放在IIS5.1的默认的/Inetpub/wwwroot/的文件夹中了 ;在最后面另附model 的用法说明)
然后用main.cgi 实现 (以用 perl -c main.cgi 编译过 syntax ok)
在调试的时候 我自己加了三个标志
1>print "$sequence\n", "one",hr;
2>print "two",hr;
3>print "three",hr;
但在调试时 只能显示第一个标志,第二三个都没有显示(自己怀疑是标志1之后的语句有问题,但用想不明白,请帮忙看看)
另外 还有一个问题 main.cgi可以upload文件 但在选取文件之后
提示:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
CGI open of tmpfile: Permission denied
请问是否和文件夹的权限设置有关? 我该如何设置? 谢谢!
#main.cgi
######################
#!/usr/bin/perl
use Restrictionmap;
use Rebase;
use SeqFileIO;
use CGI qw/:standard/;
use strict;
use warnings;
print header,
start_html('Restriction Maps on the Web'),
h1('<font color=orange>Restriction Maps on the Web</font>'),
hr,
start_multipart_form,
'<font color=blue>',
h3("1) Restriction enzyme(s)? "),
textfield('enzyme'), p,
h3("2) Sequence filename (fasta or raw format): "),
filefield(-name=>'fileseq',
-default=>'starting value',
-size=>50,
-maxlength=>200,
), p,
strong(em("or")),
h3("Type sequence: "),
textarea(
-name=>'typedseq',
-rows=>10,
-columns=>60,
-maxlength=>1000,
), p,
h3("3) Make restriction map:"),
submit, p,
'</font>',
hr,
end_form;
if (param()) {
my $sequence = '';
# must have exactly one of the two sequence input methods specified
if(param('typedseq') and param('fileseq')) {
print "<font color=red>You have given a file AND typed in sequence: do only one!</font>", hr;
exit;
}elsif(not param('typedseq') and not param('fileseq')) {
print "<font color=red>You must give a sequence file OR type in sequence!</font>", hr;
exit;
}elsif(param('typedseq')) {
$sequence = param('typedseq');
}elsif(param('fileseq')) {
my $fh = upload('fileseq');
while (<$fh>) {
/^\s*>/ and next; # handles fasta file headers
$sequence .= $_;
}
}
# strip out non-sequence characters
$sequence =~ s/\s//g;
$sequence = uc ($sequence);
print "$sequence\n", "one",hr;
my $rebase = Rebase->new(
dbmfile => 'BIONET',
bionetfile => 'bionet_705.txt',
mode => '0666',
);
print "two",hr;
my $restrict = Restrictionmap->new(
enzyme => 'EcoRI HindIII',
rebase => $rebase,
sequence => $sequence,
graphictype => 'text',
);
print "three",hr;
print "$sequence\n", hr;
print "Your requested enzyme(s): ",em(param('enzyme')),p,"<code><pre>\n";
hr;
print "Locations are ", join ' ', $restrict->get_enzyme_map('EcoRI'), "\n";
print "\n\n\n";
print $restrict->get_graphic, "</pre></code>\n",hr;
}
print end_html;
########################
# Example for Rebase
use Rebase;
# Use "bionetfile" to create and populate dbm file
my $rebase = Rebase->new(
dbmfile => 'BIONET',
bionetfile => 'bionet.212',
mode => 0644
);
# Use without "bionetfile" to attach to existing dbm file
my $rebase = Rebase->new(
dbmfile => 'BIONET',
mode => 0444
);
my $enzyme = 'EcoRI';
print "Looking up restriction enzyme $enzyme\n";
my @sites = $rebase->get_recognition_sites($enzyme);
print "Sites are @sites\n";
my @res = $rebase->get_regular_expressions($enzyme);
print "Regular expressions are @res\n";
print "DBM file is ", $rebase->get_dbmfile, "\n";
print "Rebase bionet file is ", $rebase->get_bionetfile, "\n";
################
#package Restrictionmap
use Restrictionmap;
use Rebase;
use strict;
use warnings;
my $rebase = Rebase->new(
dbmfile => 'BIONET',
bionetfile => 'bionet.212'
);
my $restrict = Restrictionmap->new(
rebase => $rebase,
enzyme => 'EcoRI HindIII',
sequence => 'ACGAATTCCGGAATTCG',
graphictype => 'text',
);
print "Locations are ", join ' ', $restrict->get_enzyme_map('EcoRI'), "\n";
print $restrict->get_graphic;
#####################