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
108 require Bio
::Index
::Fasta
;
109 require Bio
::Index
::EMBL
;
110 require Bio
::Index
::Swissprot
;
111 require Bio
::Index
::GenBank
;
112 require Bio
::Index
::SwissPfam
;
115 # one up from here is Bio directory - we hope!
118 require Bio
::Index
::Fasta
;
119 require Bio
::Index
::EMBL
;
122 print STDERR
("\nbp_index cannot find Bio::Index::Fasta and Bio::Index::EMBL\nbp_index needs to have bioperl installed for it to run.\nBioperl is very easy to install\nSee http://bio.perl.org for more information\n\n");
125 print STDERR
("\nYou are running bp_index.pl without installing bioperl.\nYou have done it from bioperl/scripts, and so we can find the necessary information\nbut it is much better to install bioperl\n\nPlease read the README in the bioperl distribution\n\n");
130 my $dir = $ENV{'BIOPERL_INDEX'};
131 my $type = $ENV{'BIOPERL_INDEX_TYPE'};
136 &GetOptions
("f|fmt=s" => \
$fmt,
138 "t|type=s" => \
$type,
141 exec('perldoc',$0) unless @ARGV;
146 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";
151 # Reset the type if needed
155 $Bio::Index
::Abstract
::USE_DBM_TYPE
= $type;
164 $index = Bio
::Index
::Fasta
->new("$dir/$name", 'WRITE');
168 $index = Bio
::Index
::EMBL
->new("$dir/$name", 'WRITE');
171 /swisspfam|pfam/i && do {
172 $index = Bio
::Index
::SwissPfam
->new("$dir/$name", 'WRITE');
176 $index = Bio
::Index
::Swissprot
->new("$dir/$name", 'WRITE');
180 $index = Bio
::Index
::GenBank
->new("$dir/$name", 'WRITE');
183 die("No index format called $fmt");
186 if( $verbose != 0 ) {
190 $index->make_index(@ARGV);
195 # if you are using this in a script, to
196 # to force deallocation + closing of the index, go