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 or HMM. It must first connect to the server with the connect 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.

Parameters:
  • address (str) – The address of the HMMER daemon server.

  • port (int) – The port over which the HMMER daemon server performs client/server communication.

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 of tuple, optional) – A list of ranges of target sequences to query inside the database.

  • builder (Builder, optional) – A builder instance to use to convert the MSA objects obtained during each iteration into HMM 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 the Hit.include and Hit.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 the query 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 of incE=0.001 and incdomE=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 of tuple, optional) – A list of ranges of target sequences to query inside the database.

  • builder (Builder, optional) – A builder instance to use to convert the MSA objects obtained during each iteration into HMM 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 the Hit.include and Hit.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 the query 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 of incE=0.001 and incdomE=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:
  • query (Sequence) – The sequence object to use to query the HMM database.

  • db (int) – The index of the HMM database to query.

Returns:

TopHits – The hits found in the target sequences.

Hint

This method corresponds to running hmmscan with the query 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:
  • query (MSA) – The profile HMM object to use to query the sequence database.

  • db (int) – The index of the sequence database to query.

  • ranges (list of tuple) – A list of ranges of target sequences to query inside the database.

Returns:

TopHits – The hits found in the target sequences.

Hint

This method corresponds to running hmmsearch with the query 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:
  • query (Sequence) – The sequence object to use to query the sequence database.

  • db (int) – The index of the sequence database to query.

  • ranges (list of tuple) – A list of ranges of target sequences to query inside the database.

Returns:

TopHits – The hits found in the target sequences.

Hint

This method corresponds to running phmmer with the query 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 and Client.iterate_hmm for more information.

client#

The HMMER daemon client to use to get hits on each iteration.

Type:

Client

db#

The index of the database to query for hits on each iteration.

Type:

int

builder#

The builder object for converting multiple sequence alignments obtained after each run to a HMM.

Type:

Builder

query#

The query object to use for the first iteration.

Type:

DigitalSequence or HMM

converged#

Whether the iterative search already converged or not.

Type:

bool

ranking#

A mapping storing the rank of hits from previous iterations.

Type:

KeyHash

iteration#

The index of the last iteration done so far.

Type:

int

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.