5
# the purpose of this script is to make it easier to set up the
6
# Standalone WWW Blast server.
8
# this script accepts as arguments a directory with formatted databases
9
# and a temporary directory (where it will write output files). for example
11
# make_config_files.pl $BLASTDB out
13
# It then creates a blast.rc and a psiblast.rc file in this temporary
14
# directory. It also creates blastdb_options.html and
15
# psiblastdb_options.html files in this directory.
16
# The blast.rc and psiblast.rc files can just replace the ones
17
# in the blast directory. You can then cut and paste the
18
# <option> entries from the html files into the corresponding place
19
# in the blast.html, blast_cs.html, xmlblast.html, megablast.html,
20
# psiblast.html, and psiblast_cs.html
21
# (overwriting the test_aa_db and test_na_db <options>)
23
# you may want to adjust the default number of processors in the rc files.
25
# finally you will probably want to create a symbolic link from the
26
# blast database directory that you passed to this script to the
27
# db directory that currently contains the test_aa_db and test_na_db
28
# files. Assuming you are in the blast directory created by the
29
# blast server distribution, the following should work:
34
# Author: Joseph Ryan <jfryan@nhgri.nih.gov>
38
use vars qw($VERSION);
43
my $blastdb = $ARGV[0] or die "usage: $0 BLASTDB OUTPUT_DIR\n";
44
my $output_dir = $ARGV[1] or die "usage:$0 BLASTDB OUTPUT_DIR\n";
45
unless (-d $output_dir) {
46
mkdir $output_dir, 0755 or die "cannot mkdir $output_dir:$!";
48
my ($ra_nts,$ra_aas) = get_dbs($blastdb);
49
print_blast_html($output_dir,$ra_nts,$ra_aas);
50
print_psiblast_config($output_dir,$ra_aas);
51
print_blast_config($output_dir,$ra_nts,$ra_aas);
52
print_psiblast_html($output_dir,$ra_aas);
53
print "Four files were created in the directory: $output_dir\n";
56
sub print_psiblast_config {
57
my $output_dir = shift;
59
open OUT, ">$output_dir/psiblast.rc"
60
or die "cannot open >$output_dir/psiblast.rc:$!";
61
print OUT "NumCpuToUse 4\n\n";
63
foreach my $aa (@{$ra_aas}) {
69
sub print_blast_config {
70
my $output_dir = shift;
73
open OUT, ">$output_dir/blast.rc"
74
or die "cannot open >$output_dir/blast.rc:$!";
75
print OUT "NumCpuToUse 4\n\n";
76
foreach my $p ("blastn", "tblastn", "tblastx") {
78
foreach my $nt (@{$ra_nts}) {
83
foreach my $p ("blastp", "blastx") {
85
foreach my $aa (@{$ra_aas}) {
92
sub print_psiblast_html {
95
open OUT, ">$dir/psiblastdb_options.html"
96
or die "cannot open >$dir/psiblastdb_options.html:$!";
97
foreach my $aa (@{$ra_aas}) {
98
print OUT " <option>$aa\n";
102
sub print_blast_html {
107
open OUT, ">$dir/blastdb_options.html"
108
or die "cannot open $dir/blastdb_options.html:$!";
109
my @dbs = sort @{$ra_nts}, @{$ra_aas};
110
foreach my $db (@dbs) {
111
next if $redundants{$db};
112
print OUT " <option>$db\n";
122
opendir DIR, $dir or die "cannot open $dir:$!";
123
my @files = grep /\.[np]in$/, readdir DIR;
124
foreach my $f (@files) {
125
$f =~ m/(.*)\.([pn])in$/;
126
push @nts, $1 if ($2 eq 'n');
127
push @aas, $1 if ($2 eq 'p');