NAME
Bio::Index::Abstract - Abstract interface for indexing a flat file
SYNOPSIS
You should not be using this module directly
USING DB_FILE
To use DB_File and not SDBM for this index, pass the value:
-dbm_package => 'DB_File'
to new (see below).
DESCRIPTION
This object provides the basic mechanism to associate positions in files with names. The position and filenames are stored in DBM which can then be accessed later on. It is the equivalent of flat file indexing (eg, SRS or efetch).
This object is the guts to the mechanism, which will be used by the specific objects inheriting from it.
FEEDBACK
Mailing Lists
User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably to one of the Bioperl mailing lists. Your participation is much appreciated.
[email protected] - General discussionhttp://bioperl.org/wiki/Mailing_lists - About the mailing lists
Support
Please direct usage questions or support issues to the mailing list:
rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.
Reporting Bugs
Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
AUTHOR - Ewan Birney, James Gilbert
Email - [email protected], [email protected]
APPENDIX
The rest of the documentation details each of the object methods. Internal methods are usually preceded with an "_" (underscore).
new
Usage : $index = Bio::Index::Abstract->new(-filename => $dbm_file,-write_flag => 0,-dbm_package => 'DB_File',-verbose => 0);Function: Returns a new index object. If filename isspecified, then open_dbm() is immediately called.Bio::Index::Abstract->new() will usually be calleddirectly only when opening an existing index.Returns : A new index objectArgs : -filename The name of the dbm index file.-write_flag TRUE if write access to the dbm file isneeded.-dbm_package The Perl dbm module to use for theindex.-verbose Print debugging output to STDERR ifTRUE.
filename
Title : filenameUsage : $value = $self->filename();$self->filename($value);Function: Gets or sets the name of the dbm index file.Returns : The current value of filenameArgs : Value of filename if setting, or none ifgetting the value.
write_flag
Title : write_flagUsage : $value = $self->write_flag();$self->write_flag($value);Function: Gets or sets the value of write_flag, whichis whether the dbm file should be opened withwrite access.Returns : The current value of write_flag (default 0)Args : Value of write_flag if setting, or none ifgetting the value.
dbm_package
Usage : $value = $self->dbm_package();$self->dbm_package($value);Function: Gets or sets the name of the Perl dbm module used.If the value is unset, then it returns the value ofthe package variable $USE_DBM_TYPE or if that isunset, then it chooses the best available dbm type,choosing 'DB_File' in preference to 'SDBM_File'.Bio::Abstract::Index may work with other dbm filetypes.Returns : The current value of dbm_packageArgs : Value of dbm_package if setting, or none ifgetting the value.
db
Title : dbUsage : $index->dbFunction: Returns a ref to the hash which is tied to the dbmfile. Used internally when adding and retrievingdata from the database.Example : $db = $index->db();$db->{ $some_key } = $data$data = $index->db->{ $some_key };Returns : ref to HASHArgs : NONE
get_stream
Title : get_streamUsage : $stream = $index->get_stream( $id );Function: Returns a file handle with the file pointerat the approprite placeThis provides for a way to get the actualfile contents and not an objectWARNING: you must parse the record deliminter*yourself*. Abstract won't do this for youSo this code$fh = $index->get_stream($myid);while( <$fh> ) {# do something}will parse the entire file if you don't put ina last statement in, likewhile( <$fh> ) {/^\/\// && last; # end of record# do something}Returns : A filehandle objectArgs : string represents the accession numberNotes : This method should not be used without forethought
cachesize
Usage : $index->cachesize(1000000)Function: Sets the dbm file cache size for the index.Needs to be set before the DBM file gets opened.Example : $index->cachesize(1000000)Returns : size of the curent cache
ffactor
Usage : $index->ffactor(1000000)Function: Sets the dbm file fill factor.Needs to be set before the DBM file gets opened.Example : $index->ffactor(1000000)Returns : size of the curent cache
open_dbm
Usage : $index->open_dbm()Function: Opens the dbm file associated with the indexobject. Write access is only given if explicitlyasked for by calling new(-write => 1) or having setthe write_flag(1) on the index object. The type ofdbm file opened is that returned by dbm_package().The name of the file to be is opened is obtained bycalling the filename() method.Example : $index->_open_dbm()Returns : 1 on success
_version
Title : _versionUsage : $type = $index->_version()Function: Returns a string which identifes the version of anindex module. Used to permanently identify an indexfile as having been created by a particular versionof the index module. Must be provided by the sub classExample :Returns :Args : none
_code_base
Title : _code_baseUsage : $code = $db->_code_base();Function:Example :Returns : Code package to be used with thisArgs :
_type_and_version
Title : _type_and_versionUsage : Called by _initalizeFunction: Checks that the index opened is made by the same indexmodule and version of that module that made it. If theindex is empty, then it adds the information to thedatabase.Example :Returns : 1 or exceptionArgs : none
_check_file_sizes
Title : _check_file_sizesUsage : $index->_check_file_sizes()Function: Verifies that the files listed in the databaseare the same size as when the database was built,or throws an exception. Called by the new()function.Example :Returns : 1 or exceptionArgs :
make_index
Title : make_indexUsage : $index->make_index( FILE_LIST )Function: Takes a list of file names, checks that they areall fully qualified, and then calls _filename() oneach. It supplies _filename() with the name of thefile, and an integer which is stored with each recordcreated by _filename(). Can be called multiple times,and can be used to add to an existing index file.Example : $index->make_index( '/home/seqs1', '/home/seqs2', '/nfs/pub/big_db' );Returns : Number of files indexedArgs : LIST OF FILES
pathtype
Title : pathtypeUsage : $index->pathtype($pathtype)Function: Set the type of the file pathOnly two values are supported, 'relative' or 'absolute'.If the user does not give any value, it is set toabsolute by default. Thus it mimics the defaultbehavior of Bio::Index::Abstract module.Example : my $index = Bio::Index::Abstract->(-pathtype => 'relative',-file => $file.inx,);or$index->pathtype('relative');Returns : Type of the path.Args : String (relative|absolute)
_filename
Title : _filenameUsage : $index->_filename( FILE INT )Function: Indexes the fileExample :Returns :Args :
_file_handle
Title : _file_handleUsage : $fh = $index->_file_handle( INT )Function: Returns an open filehandle for the fileindex INT. On opening a new filehandle itcaches it in the @{$index->_filehandle} array.If the requested filehandle is already open,it simply returns it from the array.Example : $first_file_indexed = $index->_file_handle( 0 );Returns : ref to a filehandleArgs : INT
_file_count
Title : _file_countUsage : $index->_file_count( INT )Function: Used by the index building sub in a sub class totrack the number of files indexed. Sets or getsthe number of files indexed when called with orwithout an argument.Example :Returns : INTArgs : INT
add_record
Title : add_recordUsage : $index->add_record( $id, @stuff );Function: Calls pack_record on @stuff, and adds the resultof pack_record to the index database under key $id.If $id is a reference to an array, then a new entryis added under a key corresponding to each elementof the array.Example : $index->add_record( $id, $fileNumber, $begin, $end )Returns : TRUE on success or FALSE on failureArgs : ID LIST
pack_record
Title : pack_recordUsage : $packed_string = $index->pack_record( LIST )Function: Packs an array of scalars into a single stringjoined by ASCII 034 (which is unlikely to be usedin any of the strings), and returns it.Example : $packed_string = $index->pack_record( $fileNumber, $begin, $end )Returns : STRING or undefArgs : LIST
unpack_record
Title : unpack_recordUsage : $index->unpack_record( STRING )Function: Splits the sting provided into an array,splitting on ASCII 034.Example : ( $fileNumber, $begin, $end ) = $index->unpack_record( $self->db->{$id} )Returns : A 3 element ARRAYArgs : STRING containing ASCII 034
count_records
Title : count_recordsUsage : $recs = $seqdb->count_records()Function: return count of all recs in the indexExample :Returns : a scalarArgs : none
DESTROY
Title : DESTROYUsage : Called automatically when index goes out of scopeFunction: Closes connection to database and handles tosequence filesReturns : NEVERArgs : NONE