Bio::S...::HitI(3pm)
πΈ Bio::S...::HitI(3pm) πΈ
User Contributed Perl Documentation Β· Bio::S...::HitI(3pm)
okay bestie come SIT DOWN because we are about to talk about Bio::Search::Hit::HitI and honestly? she's iconic. she's an interface. she's the blueprint for every "hit" in a similarity search result. let's get into it π
β¨ NAME β¨
Bio::Search::Hit::HitI β the Interface for a hit in a similarity search result π¦
β¨ SYNOPSIS β¨
real talk: Bio::Search::Hit::HitI objects should not be instantiated, because this module defines a pure interface. she's a vibe, not a building. periodt.
but like, given an object that implements the Bio::Search::Hit::HitI interface, you can do all of this with it:
# Bio::Search::Hit::HitI objects should not be instantiated since this #
module defines a pure interface.
# Given an object that implements the Bio::Search::Hit::HitI interface,
# you can do the following things with it:
# Get a HitI object from a SearchIO stream:
use Bio::SeachIO;
my $searchio = Bio::SearchIO->new(-format => 'blast', -file => 'result.bls');
my $result = $searchio->next_result;
my $hit = $result->next_hit;
$hit_name = $hit->name();
$desc = $hit->description();
$len = $hit->length
$alg = $hit->algorithm();
$score = $hit->raw_score();
$significance = $hit->significance();
$rank = $hit->rank(); # the Nth hit for a specific query
while( $hsp = $obj->next_hsp()) { ... } # process in iterator fashion
for my $hsp ( $obj->hsps()()) { ... } # process in list fashion
(yes we are keeping every single line exactly as-is, don't @ me, the typos are part of the lore π«Ά)
β¨ DESCRIPTION β¨
Bio::Search::Hit::* objects are data structures that contain information about specific hits obtained during a library search. some of that info is gonna be algorithm-specific, but the rest is generally defined. lowkey elegant, ngl π
β¨ FEEDBACK β¨
π Mailing Lists
user feedback is an integral part of the evolution of this and other Bioperl modules β like, genuinely, they want to hear from you. send your comments and suggestions preferably to one of the Bioperl mailing lists. your participation is much appreciated π
bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists
π Support
please direct usage questions or support issues to the mailing list:
bioperl-l@bioperl.org
rather than to the module maintainer directly. because bestie, there are so many experienced and reponsive experts who can look at the problem and address it quickly. and 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 so they can keep track of the bugs and their resolution. bug reports can be submitted via the web:
https://github.com/bioperl/bioperl-live/issues
β¨ AUTHOR - Aaron Mackey, Steve Chervitz β¨
email amackey@virginia.edu (original author) email sac@bioperl.org
β¨ COPYRIGHT β¨
copyright (c) 1999-2001 Aaron Mackey, Steve Chervitz. all rights reserved. π
β¨ DISCLAIMER β¨
this software is provided "as is" without warranty of any kind. no cap, that's the whole disclaimer. π
β¨ APPENDIX β¨
the rest of the documentation details each of the object methods. internal methods are usually preceded with a _ π
πΈ name
- Title: name
- Usage:
$hit_name = $hit->name(); - Function: returns the name of the Hit sequence
- Returns: a scalar string
- Args: none
the name of a hit is unique within a Result or within an Iteration. so like, one of a kind β¨
πΈ description
- Title: description
- Usage:
$desc = $hit->description(); - Function: retrieve the description for the hit
- Returns: a scalar string
- Args: none
πΈ accession
- Title: accession
- Usage:
$acc = $hit->accession(); - Function: retrieve the accession (if available) for the hit
- Returns: a scalar string (empty string if not set)
- Args: none
πΈ locus
- Title: locus
- Usage:
$acc = $hit->locus(); - Function: retrieve the locus (if available) for the hit
- Returns: a scalar string (empty string if not set)
- Args: none
πΈ length
- Title: length
- Usage:
my $len = $hit->length - Function: returns the length of the hit
- Returns: integer
- Args: none
πΈ algorithm
- Title: algorithm
- Usage:
$alg = $hit->algorithm(); - Function: gets the algorithm specification that was used to obtain the hit. for BLAST, the algorithm denotes what type of sequence was aligned against what (BLASTN: dna-dna, BLASTP prt-prt, BLASTX translated dna-prt, TBLASTN prt-translated dna, TBLASTX translated dna-translated dna).
- Returns: a scalar string
- Args: none
πΈ raw_score
- Title: raw_score
- Usage:
$score = $hit->raw_score(); - Function: gets the "raw score" generated by the algorithm. what this score is exactly will vary from algorithm to algorithm, returning
undefif unavailable. - Returns: a scalar value
- Args: none
πΈ score
equivalent to raw_score() π«
πΈ significance
- Title: significance
- Usage:
$significance = $hit->significance(); - Function: used to obtain the E or P value of a hit, i.e. the probability that this particular hit was obtained purely by random chance. if information is not available (nor calculatable from other information sources), return
undef. - Returns: a scalar value or
undefif unavailable - Args: none
πΈ bits
- Usage:
$hit_object->bits(); - Purpose: gets the bit score of the best HSP for the current hit.
- Example:
$bits = $hit_object->bits(); - Returns: Integer or double for FASTA reports
- Argument: n/a
- Comments: for BLAST1, the non-bit score is listed in the summary line.
See Also: score()
πΈ next_hsp
- Title: next_hsp
- Usage:
while( $hsp = $obj->next_hsp()) { ... } - Function: returns the next available High Scoring Pair
- Example:
- Returns:
Bio::Search::HSP::HSPIobject or null if finished - Args: none
πΈ hsps
- Usage:
$hit_object->hsps(); - Purpose: get a list containing all HSP objects. get the numbers of HSPs for the current hit.
- Example:
@hsps = $hit_object->hsps();Β·$num = $hit_object->hsps(); # alternatively, use num_hsps() - Returns: Array context: list of
Bio::Search::HSP::BlastHSPobjects. Scalar context: integer (number of HSPs). (Equivalent tonum_hsps()). - Argument: n/a. relies on
wantarray - Throws: Exception if the HSPs have not been collected.
See Also: hsp(), num_hsps()
πΈ num_hsps
- Usage:
$hit_object->num_hsps(); - Purpose: get the number of HSPs for the present Blast hit.
- Example:
$nhsps = $hit_object->num_hsps(); - Returns: Integer
- Argument: n/a
- Throws: Exception if the HSPs have not been collected.
See Also: hsps()
πΈ seq_inds
- Usage:
$hit->seq_inds( seq_type, class, collapse ); - Purpose: get a list of residue positions (indices) across all HSPs for identical or conserved residues in the query or sbjct sequence.
- Example:
@s_ind = $hit->seq_inds('query', 'identical');Β·@h_ind = $hit->seq_inds('hit', 'conserved');Β·@h_ind = $hit->seq_inds('hit', 'conserved', 1); - Returns: Array of integers. may include ranges if
collapseis non-zero. - Argument:
[0] seq_type='query'or'hit'or'sbjct'(default ='query'). ('sbjct'is synonymous with'hit')[1] class='identical'or'conserved'(default ='identical'). (can be shortened to'id'or'cons'). (actually, anything not'id'will evaluate to'conserved').[2] collapse= boolean, if non-zero, consecutive positions are merged using a range notation, e.g.,"1 2 3 4 5 7 9 10 11"collapses to"1-5 7 9-11". this is useful for consolidating long lists. default = no collapse.
- Throws: n/a.
See Also: Bio::Search::HSP::HSPI::seq_inds()
πΈ rewind
- Title: rewind
- Usage:
$hit->rewind; - Function: allow one to reset the HSP iterator to the beginning if possible
- Returns: none
- Args: none
πΈ overlap
- Usage:
$hit_object->overlap( [integer] ); - Purpose: gets/sets the allowable amount overlap between different HSP sequences.
- Example:
$hit_object->overlap(5);Β·$overlap = $hit_object->overlap; - Returns: Integer.
- Argument: integer.
- Throws: n/a
- Status: Experimental β οΈ
- Comments: any two HSPs whose sequences overlap by less than or equal to the
overlap()number of resides will be considered separate HSPs and will not get tiled byBio::Search::BlastUtils::_adjust_contigs().
See Also: Bio::Search::BlastUtils::_adjust_contigs(), BUGS
πΈ n
- Usage:
$hit_object->n(); - Purpose: gets the N number for the current Blast hit. this is the number of HSPs in the set which was ascribed the lowest P-value (listed on the description line). this number is not the same as the total number of HSPs. to get the total number of HSPs, use
num_hsps(). - Example:
$n = $hit_object->n(); - Returns: Integer
- Argument: n/a
- Throws: Exception if HSPs have not been set (BLAST2 reports).
- Comments: note that the N parameter is not reported in gapped BLAST2. calling
n()on such reports will result in a call tonum_hsps(). thenum_hsps()method will count the actual number of HSPs in the alignment listing, which may exceed N in some cases.
See Also: num_hsps()
πΈ p
- Usage:
$hit_object->p( [format] ); - Purpose: get the P-value for the best HSP of the given BLAST hit. (note that P-values are not provided with NCBI Blast2 reports).
- Example:
$p = $sbjct->p;Β·$p = $sbjct->p('exp'); # get exponent only.Β·($num, $exp) = $sbjct->p('parts'); # split sci notation into parts - Returns: Float or scientific notation number (the raw P-value, DEFAULT). Integer if
format == 'exp'(the magnitude of the base 10 exponent). 2-element list (float, int) ifformat == 'parts'and P-value is in scientific notation (See Comments). - Argument: format: string of
'raw'|'exp'|'parts''raw'returns value given in report. Default. (1.2e-34)'exp'returns exponent value only (34)'parts'returns the decimal and exponent as a 2-element list (1.2, -34) (See Comments).
- Throws: Warns if no P-value is defined. Uses expect instead.
- Comments: using the
'parts'argument is not recommended since it will not work as expected if the P-value is not in scientific notation. that is, floats are not converted into sci notation before splitting into parts.
See Also: expect(), signif(), Bio::Search::BlastUtils::get_exponent()
...and that's part 1 bestie, there's more coming so don't go anywhere π
π hsp
okay so this is your go-to for pulling one single HSPI object out of the current HitI object. very demure, very mindful, very slay. β¨
Usage:
$hit_object->hsp( [string] );
Purpose: get a singleHSPIobject for the presentHitIobject.Example:
$hspObj = $hit_object->hsp; # same as 'best'
$hspObj = $hit_object->hsp('best');
$hspObj = $hit_object->hsp('worst');
Returns: object reference for aBio::Search::HSP::HSPIobject.Argument: a string (or no argument at all, bestie, it's chill):- no argument (the default) = highest scoring HSP (same as
'best') 'best'or'first'= highest scoring HSP'worst'or'last'= lowest scoring HSP
- no argument (the default) = highest scoring HSP (same as
Throws: exception if the HSPs have not been collected. also exception if you hand it an argument it does not recognize. π«See Also:hsps(),num_hsps()
𧬠logical_length
lowkey the internal-use girlie of the group, but she's important, trust.
Usage:
$hit_object->logical_length( [seq_type] );
(mostly intended for internal use). π«Ά
Purpose: get the logical length of the hit sequence. if the Blast is aTBLASTNorTBLASTX, the length you get back is the length of the would-be amino acid sequence (length/3). for all other BLAST flavors, this function is literally the same aslength().Example:$len = $hit_object->logical_length();Returns: IntegerArgument:seq_type='query'or'hit'or'sbjct'(default ='query'), and'sbjct'is synonymous with'hit'Throws: n/aComments: this is important for functions likefrac_aligned_query()which need to operate in amino acid coordinate space when dealing with[T]BLAST[NX]type reports. π§See Also:length(),frac_aligned_query(),frac_aligned_hit()
π rank
Title:rankUsage:$obj->rank($newval)Function: get/set the rank of this Hit in the Query search list β i.e. this is the Nth hit for a specific queryReturns: value ofrankArgs:newvalue(optional)
π each_accession_number
Title:each_accession_numberUsage:$obj->each_accession_numberFunction: get each accession number listed in the description of the hit. if there are no alternatives, then only the primary accession will be givenReturns: list of all accession numbers in the descriptionArgs: none
π¦ tiled_hsps
Usage:
$hit_object->tiled_hsps( [integer] );
Purpose: gets/sets an indicator for whether or not the HSPs in this Hit have been tiled. methods that rely on HSPs being tiled should check this and then callSearchUtils::tile_hsps()if not.Example:
$hit_object->tiled_hsps(1);
if( $hit_object->tiled_hsps ) { # do something }
Returns: Boolean (1or0)Argument: integer (optional)Throws: n/a
π strand
okay this one has LORE, bestie, sit down. π
Usage:
$sbjct->strand( [seq_type] );
Purpose: gets the strand(s) for the query, sbjct, or both sequences in the best HSP of the BlastHit object after HSP tiling. only valid forBLASTN,TBLASTX,BLASTX-query,TBLASTN-hit.Example:
$qstrand = $sbjct->strand('query');
$sstrand = $sbjct->strand('hit');
($qstrand, $sstrand) = $sbjct->strand();
Returns:- scalar context: integer
'1','-1', or'0' - array context without args: list of two strings (
queryStrand,sbjctStrand) - array context can be "induced" by providing an argument of
'list'or'array'.
- scalar context: integer
Argument: in scalar context:seq_type='query'or'hit'or'sbjct'(default ='query'), and'sbjct'is synonymous with'hit'Throws: n/aComments:- this method requires that all HSPs be tiled. if they have not already been tiled, they will be tiled first automatically.
- if you don't want the tiled data, iterate through each HSP calling
strand()on each (usehsps()to get all HSPs). - formerly (prior to 10/21/02), this method would return the string
"-1/1"for hits with HSPs on both strands. however, now that strand and frame is properly being accounted for during HSP tiling, it makes more sense forstrand()to return the strand data for the best HSP after tiling. - if you really want to know about hits on opposite strands, you should be iterating through the HSPs using methods on the HSP objects.
- a possible use case where knowing whether a hit has HSPs on both strands would be when filtering via
SearchIOfor hits with this property. however, in this case it would be better to have a dedicated method such as$hit->hsps_on_both_strands(). similarly for frame. this could be provided if there is interest. π
See Also:Bio::Search::HSP::HSPI::strand()
π§ frame
Usage:$hit_object->frame();Purpose: gets the reading frame for the best HSP after HSP tiling. this is only valid forBLASTXandTBLASTN/Xtype reports.Example:$frame = $hit_object->frame();Returns: Integer (-2 .. +2)Argument: n/aThrows: exception if HSPs have not been set.Comments:- this method requires that all HSPs be tiled. if they have not already been tiled, they will be tiled first automatically.
- if you don't want the tiled data, iterate through each HSP calling
frame()on each (usehsps()to get all HSPs).
See Also:hsps()
π
matches
Usage:$hit_object->matches( [class] );Purpose: get the total number of identical or conserved matches (or both) across all HSPs. (note:'conservative'matches are indicated as'positives'in BLAST reports.)Example:
($id,$cons) = $hit_object->matches(); # no argument
$id = $hit_object->matches('id');
$cons = $hit_object->matches('cons');
Returns: Integer or a 2-element array of integersArgument:class='id'|'cons'OR none. if no argument is provided, both identical and conservative numbers are returned in a two element list. (other terms can be used to refer to the conservative matches, e.g.,'positive'. all that is checked is whether or not the supplied string starts with'id'. if not, the conservative matches are returned.)Throws: exception if the requested data cannot be obtained.Comments:- this method requires that all HSPs be tiled. if there is more than one HSP and they have not already been tiled, they will be tiled first automatically.
- if you need data for each HSP, use
hsps()and then interate through the HSP objects. - does not rely on
wantarrayto return a list. only checks for the presence of an argument (no arg = return list).
See Also:Bio::Search::HSP::GenericHSP::matches(),hsps()
π₯ sort_hits
Title:sort_hspsUsage:$result->sort_hsps(\&sort_function)Function: sorts the available HSP objects by a user-supplied function. defaults to sort by descending score.Returns: n/aArgs: a coderef for the sort function. see the documentation on the Perlsort()function for guidelines on writing sort functions.Note: to access the special variables$aand$bused by the Perlsort()function the user function must accessBio::Search::Hit::HitInamespace. for example, use:
$hit->sort_hsps( sub{$Bio::Search::Result::HitI::a->length <=>
$Bio::Search::Result::HitI::b->length});
NOT $hit->sort_hsps($a->length <=> $b->length);
π _default_sort_hsps
Title:_default_sort_hspsUsage: do not call directly. π ββοΈFunction: sort hsps in ascending order by evalueArgs: NoneReturns:1on successNote: used by$hit->sort_hsps()
and that's a wrap on the whole page, bestie π«Ά you just read the perl v5.32.1 release, dated 2021-08-15, and honestly? iconic behavior. go forth and parse some BLAST reports, you absolute legend πβ¨π
π¦ where this page comes from
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms