| Trees | Indices | Help |
|
|---|
|
|
object --+
|
_base._BaseSearchObject --+
|
Hit
Class representing a single database hit of a search result.
Hit objects are the second-level container in the SearchIO module. They
are the objects contained within a QueryResult (see QueryResult). They
themselves are container for HSP objects and will contain at least one
HSP.
To have a quick look at a Hit and its contents, invoke `print` on it:
>>> from Bio import SearchIO
>>> qresult = SearchIO.parse('Blast/mirna.xml', 'blast-xml').next()
>>> hit = qresult[3]
>>> print hit
Query: 33211
mir_1
Hit: gi|301171322|ref|NR_035857.1| (86)
Pan troglodytes microRNA mir-520c (MIR520C), microRNA
HSPs: ---- -------- --------- ------ --------------- ---------------------
# E-value Bit score Span Query range Hit range
---- -------- --------- ------ --------------- ---------------------
0 8.9e-20 100.47 60 [1:61] [13:73]
1 3.3e-06 55.39 60 [0:60] [13:73]
You can invoke `len` on a Hit object to see how many HSP objects it contains:
>>> len(hit)
2
Hit objects behave very similar to Python lists. You can retrieve the HSP
object inside a Hit using the HSP's integer index. Hit objects can also be
sliced, which will return a new Hit objects containing only the sliced HSPs:
# HSP items inside the Hit can be retrieved using its integer index
>>> hit[0]
HSP(hit_id='gi|301171322|ref|NR_035857.1|', query_id='33211', 1 fragments)
# slicing returns a new Hit
>>> hit
Hit(id='gi|301171322|ref|NR_035857.1|', query_id='33211', 2 hsps)
>>> hit[:1]
Hit(id='gi|301171322|ref|NR_035857.1|', query_id='33211', 1 hsps)
>>> print hit[1:]
Query: 33211
mir_1
Hit: gi|301171322|ref|NR_035857.1| (86)
Pan troglodytes microRNA mir-520c (MIR520C), microRNA
HSPs: ---- -------- --------- ------ --------------- ---------------------
# E-value Bit score Span Query range Hit range
---- -------- --------- ------ --------------- ---------------------
0 3.3e-06 55.39 60 [0:60] [13:73]
Hit objects provide `filter` and `map` methods, which are analogous to
Python's built-in `filter` and `map` except that they return a new Hit
object instead of a list.
Here is an example of using `filter` to select for HSPs whose e-value is
less than 1e-10:
>>> evalue_filter = lambda hsp: hsp.evalue < 1e-10
>>> filtered_hit = hit.filter(evalue_filter)
>>> len(hit)
2
>>> len(filtered_hit)
1
>>> print filtered_hit
Query: 33211
mir_1
Hit: gi|301171322|ref|NR_035857.1| (86)
Pan troglodytes microRNA mir-520c (MIR520C), microRNA
HSPs: ---- -------- --------- ------ --------------- ---------------------
# E-value Bit score Span Query range Hit range
---- -------- --------- ------ --------------- ---------------------
0 8.9e-20 100.47 60 [1:61] [13:73]
There are also other methods which are counterparts of Python lists' methods
with the same names: `append`, `index`, `pop`, and `sort`. Consult their
respective documentations for more details and examples of their usage.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from Inherited from |
|||
|
|||
_NON_STICKY_ATTRS =
|
|||
|
|||
|
description Hit description |
|||
|
query_description Description of the query that produced the hit |
|||
|
id Hit ID string. |
|||
|
query_id ID string of the query that produced the hit |
|||
|
hsps HSP objects contained in the Hit |
|||
|
fragments HSPFragment objects contained in the Hit |
|||
|
Inherited from |
|||
|
|||
Initializes a Hit object. Arguments: hsps -- List containing HSP objects. Hit objects must be initialized with a list containing at least one HSP object. If multiple HSP objects are used for initialization, they must all have the same `query_id`, `query_description`, `hit_id`, and `hit_description` properties.
|
repr(x)
|
str(x)
|
Validates an HSP object. Valid HSP objects have the same hit_id as the Hit object ID and the same query_id as the Hit object's query_id. |
Adds a HSP object to the end of Hit. Parameters hsp -- HSP object to append. Any HSP object appended must have the same `hit_id` property as the Hit object's `id` property and the same `query_id` property as the Hit object's `query_id` property. |
Creates a new Hit object whose HSP objects pass the filter
function.
Arguments:
func -- Callback function that accepts a HSP object as its parameter,
does a boolean check, and returns True or False.
`filter` is analogous to Python's built-in `filter` function, except
that instead of returning a list it returns a `Hit` object. Here is an
example of using `filter` to select for HSPs having bitscores bigger
than 60:
>>> from Bio import SearchIO
>>> qresult = SearchIO.parse('Blast/mirna.xml', 'blast-xml').next()
>>> hit = qresult[3]
>>> evalue_filter = lambda hsp: hsp.bitscore > 60
>>> filtered_hit = hit.filter(evalue_filter)
>>> len(hit)
2
>>> len(filtered_hit)
1
>>> print filtered_hit
Query: 33211
mir_1
Hit: gi|301171322|ref|NR_035857.1| (86)
Pan troglodytes microRNA mir-520c (MIR520C), microRNA
HSPs: ---- -------- --------- ------ --------------- ---------------------
# E-value Bit score Span Query range Hit range
---- -------- --------- ------ --------------- ---------------------
0 8.9e-20 100.47 60 [1:61] [13:73]
|
Returns the index of a given HSP object, zero-based. Arguments: hsp -- HSP object to be looked up. |
Creates a new Hit object, mapping the given function to its HSPs.
Arguments:
func -- Callback function that accepts a HSP object as its parameter and
also returns a HSP object.
`map` is analogous to Python's built-in `map` function. It is applied to
all HSPs contained in the Hit object and returns a new Hit object.
|
Removes and returns the HSP object at the specified index. Arguments: index -- Integer denoting the index of the HSP object to remove. |
Sorts the HSP objects.
Arguments:
key -- Function used to sort the HSP objects.
reverse -- Boolean, whether to reverse the sorting or not.
in_place -- Boolean, whether to perform sorting in place (in the same
object) or not (creating a new object).
`sort` defaults to sorting in-place, to mimick Python's `list.sort`
method. If you set the `in_place` argument to False, it will treat
return a new, sorted Hit object and keep the initial one unsorted
|
|
|||
descriptionHit description
|
query_descriptionDescription of the query that produced the hit
|
idHit ID string.
|
query_idID string of the query that produced the hit
|
hspsHSP objects contained in the Hit
|
fragmentsHSPFragment objects contained in the Hit
|
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Feb 5 18:02:51 2013 | http://epydoc.sourceforge.net |