5 bp_index.pl - indexes files for use by bp_fetch.pl
9 bp_index.pl index_name file1 file2 etc.
13 bp_index.pl builds a bioperl index for the sequence files given in the
14 argument list, under the index name. For example
16 bp_index.pl nrdb /data/nrdb/nrdb.fasta
18 would build an index called 'nrdb' as the index name for the file
21 bp_index.pl -fmt EMBL swiss /data/swiss/*.dat
23 would build an index called swiss for all the files in /data/swiss
24 which end in .dat which are in EMBL format.
26 The indexes are built using the Bio/Index/* modules, in particular,
27 Bio::Index::EMBL and the Bio::Index::Fasta modules. Any script which
28 uses these modules can use the index. A good example script is bp_fetch
29 which fetches sequences and pipes them to STDOUT, for example
31 bp_fetch swiss:ROA1_HUMAN
33 gets the ROA1_HUMAN sequence from the swiss index and writes it as
34 fasta format on STDOUT.
38 -fmt <format> - Fasta (default), swiss or EMBL
39 -dir <dir> - directory where the index files are found
40 (overrides BIOPERL_INDEX environment variable)
42 Options for expert use
44 -type <db_type> - DBM_file type.
45 (overrides BIOPERL_INDEX_TYPE environment variable)
46 -v - report every index addition (debugging)
50 bp_index and bp_fetch coordinate where the databases lie using the
51 environment variable BIOPERL_INDEX. This can be overridden using the
52 -dir option. There is no default value, so you must use the -dir option
55 The DB type is coordinated with BIOPERL_INDEX_TYPE which if it
56 is not there, defaults to whatever the bioperl modules have installed,
57 which itself defaults to SDBM_File.
59 =head1 USING IT YOURSELF
61 bp_index.pl is a script that drives the Index modules. If you want to
62 use this script heavily in your work, if it is Perl based, it is
63 almost certainly better to look at the code in this script and copy
64 it across (probably you will be more likely to want to use the bp_fetch
69 bp_index is just a wrapper around James Gilbert's excellent Index modules
76 User feedback is an integral part of the evolution of this and other
77 Bioperl modules. Send your comments and suggestions preferably to
78 the Bioperl mailing list. Your participation is much appreciated.
80 bioperl-l@bioperl.org - General discussion
81 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
85 Report bugs to the Bioperl bug tracking system to help us keep track
86 of the bugs and their resolution. Bug reports can be submitted via the
89 https://github.com/bioperl/bioperl-live/issues
91 =head1 AUTHOR - Ewan Birney
93 Ewan Birney E<lt>birney@ebi.ac.ukE<gt>
102 # Doofus catcher for people who are trying this script without
106 use Bio
::Index
::Fasta
;
107 use Bio
::Index
::EMBL
;
108 use Bio
::Index
::Swissprot
;
109 use Bio
::Index
::GenBank
;
110 use Bio
::Index
::SwissPfam
;
112 my $dir = $ENV{'BIOPERL_INDEX'};
113 my $type = $ENV{'BIOPERL_INDEX_TYPE'};
118 &GetOptions
("f|fmt=s" => \
$fmt,
120 "t|type=s" => \
$type,
123 exec('perldoc',$0) unless @ARGV;
128 print STDERR
"\nNo directory specified for index\nDirectory must be specified by the environment variable BIOPERL_INDEX or -dir option\ngo bp_index with no arguments for more help\n\n";
133 # Reset the type if needed
137 $Bio::Index
::Abstract
::USE_DBM_TYPE
= $type;
146 $index = Bio
::Index
::Fasta
->new("$dir/$name", 'WRITE');
150 $index = Bio
::Index
::EMBL
->new("$dir/$name", 'WRITE');
153 /swisspfam|pfam/i && do {
154 $index = Bio
::Index
::SwissPfam
->new("$dir/$name", 'WRITE');
158 $index = Bio
::Index
::Swissprot
->new("$dir/$name", 'WRITE');
162 $index = Bio
::Index
::GenBank
->new("$dir/$name", 'WRITE');
165 die("No index format called $fmt");
168 if( $verbose != 0 ) {
172 $index->make_index(@ARGV);
177 # if you are using this in a script, to
178 # to force deallocation + closing of the index, go