Bio::S...::HitI(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

🌸 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 (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 undef if 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 undef if 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::HSPI object 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::BlastHSP objects. Scalar context: integer (number of HSPs). (Equivalent to num_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 collapse is 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 by Bio::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 to num_hsps(). the num_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) if format == '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 single HSPI object for the present HitI object.
  • Example:
$hspObj  = $hit_object->hsp;  # same as 'best'
$hspObj  = $hit_object->hsp('best');
$hspObj  = $hit_object->hsp('worst');
  • Returns: object reference for a Bio::Search::HSP::HSPI object.
  • 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
  • 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 a TBLASTN or TBLASTX, 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 as length().
  • Example: $len = $hit_object->logical_length();
  • Returns: Integer
  • Argument: seq_type = 'query' or 'hit' or 'sbjct' (default = 'query'), and 'sbjct' is synonymous with 'hit'
  • Throws: n/a
  • Comments: this is important for functions like frac_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: rank
  • Usage: $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 query
  • Returns: value of rank
  • Args: newvalue (optional)

πŸŽ€ each_accession_number

  • Title: each_accession_number
  • Usage: $obj->each_accession_number
  • Function: get each accession number listed in the description of the hit. if there are no alternatives, then only the primary accession will be given
  • Returns: list of all accession numbers in the description
  • Args: 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 call SearchUtils::tile_hsps() if not.
  • Example:
$hit_object->tiled_hsps(1);
if( $hit_object->tiled_hsps ) { # do something }
  • Returns: Boolean (1 or 0)
  • 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 for BLASTN, 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'.
  • Argument: in scalar context: seq_type = 'query' or 'hit' or 'sbjct' (default = 'query'), and 'sbjct' is synonymous with 'hit'
  • Throws: n/a
  • 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 strand() on each (use hsps() 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 for strand() 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 SearchIO for 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 for BLASTX and TBLASTN/X type reports.
  • Example: $frame = $hit_object->frame();
  • Returns: Integer (-2 .. +2)
  • Argument: n/a
  • Throws: 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 (use hsps() 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 integers
  • Argument: 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 wantarray to 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_hsps
  • Usage: $result->sort_hsps(\&sort_function)
  • Function: sorts the available HSP objects by a user-supplied function. defaults to sort by descending score.
  • Returns: n/a
  • Args: a coderef for the sort function. see the documentation on the Perl sort() function for guidelines on writing sort functions.
  • Note: to access the special variables $a and $b used by the Perl sort() function the user function must access Bio::Search::Hit::HitI namespace. 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_hsps
  • Usage: do not call directly. πŸ™…β€β™€οΈ
  • Function: sort hsps in ascending order by evalue
  • Args: None
  • Returns: 1 on success
  • Note: 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