SmartDesc - Index smart.desc file
use Index::SmartDesc;
This package is used to index smart.desc file (not public). It indexes the file by the accession number (SM00002).
#SM00004 NL NL.HMM Domain found in Notch and Lin-12 #SM00005 DEATH DEATH.HMM DEATH domain, found in proteins involved in cell death (apoptosis). #SM00006 A4_EXTRA A4_EXTRA.HMM amyloid A4 #SM00008 HormR HormR.HMM Domain present in hormone receptors #SM00013 LRRNT LRRNT.HMM Leucine rich repeat N-terminal domain #SM00014 acidPPc acidPPc.HMM Acid phosphatase homologues #SM00015 IQ IQ.HMM Short calmodulin-binding motif containing conserved Ile and Gln residues. #SM00017 OSTEO OSTEO.HMM Osteopontin #SM00018 PD PD.HMM P or trefoil or TFF domain #SM00019 SF_P SF_P.HMM Pulmonary surfactant proteins #SM00020 Tryp_SPc Tryp_SPc.HMM Trypsin-like serine protease
# examples here use Index::SmartDesc;
my($res, $msg, $index); ($res, $index) = new Index::SmartDesc($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 = 'SM00135'; 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: SmartDesc.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::SmartDesc.
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