Client#
- class pyhmmer.daemon.Client#
A
socket
-based client to communicate with a HMMER daemon server.This class implements the client-side protocol to query a database with a
Sequence
,MSA
orHMM
. It must first connect to the server with theconnect
method:>>> client = daemon.Client("127.0.0.1", 51371) >>> client.connect()
Afterwards, the client can be used to run pipelined searches, returning a
TopHits
:>>> client.search_hmm(thioesterase) <pyhmmer.plan7.TopHits object at 0x...>
Additional keyword arguments can be passed to customize the pipelined search. All parameters from
Pipeline
are supported:>>> client.search_hmm(thioesterase, F1=0.02, E=1e-5) <pyhmmer.plan7.TopHits object at 0x...>
Hint
Client
implements the context manager protocol, which can be used to open and close a connection to the server within a context:>>> with daemon.Client() as client: ... client.search_hmm(thioesterase) <pyhmmer.plan7.TopHits object at 0x...>
Caution
Hits returned by the server will not have corresponding hit names, but only numerical identifiers. It is up to the client user to map these to the actual target names, often using an external file or database. If the database is small and several queries are made, it is feasible to parse the database from the client side to extract identifiers of the target HMMs or sequences.
Added in version 0.6.0.
- __init__(address='127.0.0.1', port=51371)#
Create a new
Client
connecting to the given HMMER daemon server.
- close()#
Close the connection to the HMMER daemon server.
- connect()#
Connect the client to the HMMER daemon server.
- iterate_hmm(query, db=1, ranges=None, builder=None, select_hits=None, **options)#
Search iteratively against the daemon database with a query HMM.
- Parameters:
query (
HMM
) – The HMM object to use to query the server-side sequence database.db (
int
) – The index of the sequence database to query.ranges (
list
oftuple
, optional) – A list of ranges of target sequences to query inside the database.builder (
Builder
, optional) – A builder instance to use to convert theMSA
objects obtained during each iteration intoHMM
objects.select_hits (callable, optional) – A function or callable object for manually selecting hits during each iteration. It should take a single
TopHits
argument and change the inclusion of individual hits with theHit.include
andHit.drop
methods.
- Returns:
IterativeSearch
– An iterator object yielding the hits, sequence alignment, and HMM for each iteration.
Hint
This method corresponds to running
jackhmmer
with thequery
HMM against the sequence database loaded on the server side.Caution
Default values used for
jackhmmer
do not correspond to the default parameters used for creating a pipeline in the other cases. This method will use default values ofincE=0.001
andincdomE=0.001
unless other values are given as keyword arguments.
- iterate_seq(query, db=1, ranges=None, builder=None, select_hits=None, **options)#
Search iteratively against the daemon database with a query sequence.
- Parameters:
query (
Sequence
) – The sequence object to use to query the server-side sequence database.db (
int
) – The index of the sequence database to query.ranges (
list
oftuple
, optional) – A list of ranges of target sequences to query inside the database.builder (
Builder
, optional) – A builder instance to use to convert theMSA
objects obtained during each iteration intoHMM
objects.select_hits (callable, optional) – A function or callable object for manually selecting hits during each iteration. It should take a single
TopHits
argument and change the inclusion of individual hits with theHit.include
andHit.drop
methods.
- Returns:
IterativeSearch
– An iterator object yielding the hits, sequence alignment, and HMM for each iteration.
Hint
This method corresponds to running
jackhmmer
with thequery
sequence against the sequence database loaded on the server side.Caution
Default values used for
jackhmmer
do not correspond to the default parameters used for creating a pipeline in the other cases. This method will use default values ofincE=0.001
andincdomE=0.001
unless other values are given as keyword arguments.
- scan_seq(query, db=1, **options)#
Search the HMMER daemon database with a query sequence.
- Parameters:
- Returns:
TopHits
– The hits found in the target sequences.
Hint
This method corresponds to running
hmmscan
with thequery
sequence against the HMM database loaded on the server side.
- search_hmm(query, db=1, ranges=None, **options)#
Search the HMMER daemon database with a query HMM.
- Parameters:
- Returns:
TopHits
– The hits found in the target sequences.
Hint
This method corresponds to running
hmmsearch
with thequery
HMM against the sequence database loaded on the server side.
- search_seq(query, db=1, ranges=None, **options)#
Search the HMMER daemon database with a query sequence.
- Parameters:
- Returns:
TopHits
– The hits found in the target sequences.
Hint
This method corresponds to running
phmmer
with thequery
sequence against the sequence database loaded on the server side.
- class pyhmmer.daemon.IterativeSearch#
A helper class for running iterative queries against a HMMER daemon.
See
Client.iterate_seq
andClient.iterate_hmm
for more information.- builder#
The builder object for converting multiple sequence alignments obtained after each run to a
HMM
.- Type:
- query#
The query object to use for the first iteration.
- Type:
- Yields:
IterationResult
– A named tuple containing the hits, multiple sequence alignment and HMM for each iteration, as well as the iteration index and a flag marking whether the search converged.
References
Johnson, Steven L., Eddy, Sean R. & Portugaly, Elon. Hidden Markov model speed heuristic and iterative HMM search procedure. BMC Bioinformatics 11, 431 (18 August 2010). doi:10.1186/1471-2105-11-431.
Added in version 0.6.0.
- __init__(client, query, db, builder, ranges=None, select_hits=None, options=None)#
Create a new iterative search against the HMMER daemon.
Hint
Use the
Client.iterate_hmm
method instead of creating this object directly.