SmartThresholds - Index smart.thresholds file
use Index::SmartThresholds;
This package is used to index smart.thresholds file (not public). It indexes the file by the accession number (SM00002).
#Acc Domain Family DB size mu lamda cutoff cut_low family repeats repeat_cut # #SM00002 PLP PLP 258281 -53.973225 0.271322 3.70e-02 8.80e+00 - - - #SM00003 NH NH 258281 -82.877457 0.202168 1.00e+00 5.80e+00 - - - #SM00004 NL NL 258281 -44.927269 0.281190 2.70e-04 2.00e-01 - - - #SM00005 DEATH DEATH 200456 -47.930714 0.225013 1.40e-07 5.60e+00 - - - #SM00173 RAS small_GTPase 260388 -159.772034 0.183040 2.60e-41 1.30e-02 1.20e-02 - - #SM00174 RHO small_GTPase 260388 -175.865631 0.184573 1.50e-31 1.50e+00 1.30e+00 - - #SM00175 RAB small_GTPase 260388 -169.925217 0.184361 1.30e-43 3.30e-01 2.90e-02 - - #SM00176 RAN small_GTPase 260388 -111.837875 0.168917 5.30e-39 1.10e+01 1.00e+01 - - #SM00177 ARF small_GTPase 260388 -91.930550 0.197962 1.60e-30 5.10e-01 4.80e-01 - - # ...
# examples here use Index::SmartThresholds;
my($res, $msg, $index); ($res, $index) = new Index::SmartThresholds($file); #Smart file to index die $index unless $res;
($res, $msg) = $index->setRecDel('dumper', '\n'); die($msg) unless($res);
($res, $r_inx) = $index->buildIndex(['ac', 'name']); #list of entries you want to index. $regexp in this module for allowing rules. die($r_inx) unless($res); #if no argument given, will build the index with all the rules describe in $regexp.
#or you can build the index on your own key-value pairs based on regular expression. Only the first match is taken into account. #so if you want to index multiple things based on the same line, you need to create another key-value pair. ($res, $r_inx) = $index->builIndex({ 'id' => '>(\S+)', 'name' => '^\s+\w+\s+(\S+)' }); die $r_inx unless $res;
($res, $mess) = $index->indexOut($r_inx); #need a reference to hash table. die $mess unless $res;
my $id = 'SM00177'; my ($res, $pos) = $index->getIndex($id); #return the position in the file for this $id. die $pos unless $res;
#getEntry returns a reference to an array in case of multiple entries found. my ($res, $entry) = $index->getEntry($id); #return the complete entry. die $entry unless $res; $entry = $entry->[0] if($entry);
#Either (parsing once the whole entry) my($res, $msg) = $index->parseFields(\$entry); die $msg unless $res;
my ($res, $name) = $index->getField('name'); #return the name of this entry. $name = $name->[0] if $name; my ($res, $name) = $index->getField(['ac', 'name', 'desc']); #return the ac, name and description of this entry. if($name){ my $nm = $name->[0]; my $ac = $name->[1]; my $de = $name->[2]; }
.... # see below for fields you can retrieve. my ($res, $name) = $index->get_name(); #return the name of this smart entry. $name = $name->[0] if $name; #or simplier my ($res, $name) = $index->getField('name', \$entry); #return the name of this smart entry by parsing it on the fly $name = $name->[0] if $name;
$Id: SmartThresholds.pm.html,v 1.1.1.1 2005/08/18 13:18:25 hunter Exp $
Copyright (c) European Bioinformatics Institute 2002
Emmanuel Quevillon <tuco@ebi.ac.uk>
Description: Create a new object Index::SmartThresholds.
Arguments: $file a file to index $tool Do you want to use Dispatcher::Tool to use index.conf values? (optional)
Returns: 1, $self on success 0, msg on failure
Description: Initialize record delimiter, file and parse configuration file from index configuration file. Argument: Returns: 1, '' on success 0, msg on error