### Install PyHMMER and Run Tests Source: https://github.com/althonos/pyhmmer/blob/master/CONTRIBUTING.md Install the extension locally in editable mode and run Python unit tests. Ensure no build isolation for proper installation. ```bash python -m pip install -e . -v --no-build-isolation python -m unittest pyhmmer.tests -vv ``` -------------------------------- ### Install PyHMMER for Benchmarking Source: https://github.com/althonos/pyhmmer/blob/master/CONTRIBUTING.md Install the extension in release mode for running benchmarks. This requires HMMER binaries in PATH and the 'hyperfine' tool. ```bash python -m pip install . -v --no-build-isolation ``` -------------------------------- ### Install and Run PyHMMER Tests Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/contributing.md Install the extension locally in editable mode and run unit tests using the unittest module. Requires the extension to be built. ```bash $ python -m pip install -e . -v --no-build-isolation $ python -m unittest pyhmmer.tests -vv ``` -------------------------------- ### Install pyhmmer using pip Source: https://github.com/althonos/pyhmmer/blob/master/README.md Install pyhmmer from PyPI using pip. This command installs pre-built wheels for Linux and MacOS or compiles from source with Cython. ```console pip install pyhmmer ``` -------------------------------- ### Build and Install PyHMMER from GitHub source Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/install.md Clone the pyhmmer repository from GitHub and build/install it manually using the 'build' and 'installer' tools. ```console $ git clone --recursive https://github.com/althonos/pyhmmer $ cd pyhmmer $ python -m build . # python -m installer dist/*.whl ``` -------------------------------- ### Project and Language Setup Source: https://github.com/althonos/pyhmmer/blob/master/CMakeLists.txt Initializes the CMake project, specifying the minimum version, project name, version, and programming languages. ```cmake cmake_minimum_required(VERSION 3.20) project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES C) ``` -------------------------------- ### Installing Shared Libraries and Headers Source: https://github.com/althonos/pyhmmer/blob/master/src/easel/CMakeLists.txt Installs the 'libeasel' library and its header files if PYHMMER_INSTALL_LIBS_DIR is defined. Sets runtime path properties for shared libraries on macOS and other Unix-like systems. ```cmake if(DEFINED PYHMMER_INSTALL_LIBS_DIR) install(TARGETS libeasel DESTINATION "${SKBUILD_PLATLIB_DIR}/${PYHMMER_INSTALL_LIBS_DIR}") if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(libeasel PROPERTIES INSTALL_RPATH "@loader_path/") else() set_target_properties(libeasel PROPERTIES INSTALL_RPATH "$ORIGIN/") endif() cmake_path(APPEND SKBUILD_PLATLIB_DIR "${PYHMMER_INSTALL_LIBS_DIR}" "include" "libeasel" OUTPUT_VARIABLE INCLUDE_DEST_FOLDER) foreach(_file IN ITEMS ${EASEL_PATCHED_SOURCES}) cmake_path(GET _file EXTENSION LAST_ONLY _ext) if(_ext STREQUAL ".h") cmake_path(RELATIVE_PATH _file BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" OUTPUT_VARIABLE _local) cmake_path(GET _local PARENT_PATH _dest) install(FILES "${_file}" DESTINATION "${INCLUDE_DEST_FOLDER}/${_dest}") endif() endforeach() endif() ``` -------------------------------- ### Install PyHMMER from GitHub using pip Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/install.md Install the latest version of pyhmmer directly from its GitHub repository using pip. ```console $ pip install -U git+https://github.com/althonos/pyhmmer ``` -------------------------------- ### Install CMake Package Configuration Files Source: https://github.com/althonos/pyhmmer/blob/master/src/cmake/CMakeLists.txt Installs the generated CMake configuration files to the package's installation directory. This makes the package discoverable by other CMake projects. ```cmake install( FILES ${CMAKE_CURRENT_BINARY_DIR}/PyHMMERConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/PyHMMERConfig.cmake DESTINATION ${PYHMMER_INSTALL_LIBS_DIR}/cmake/PyHMMER ) ``` -------------------------------- ### Install PyHMMER from piwheels Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/install.md Install pyhmmer from piwheels.org, which provides pre-built wheels for Raspberry Pi computers. ```console $ pip3 install pyhmmer --extra-index-url https://www.piwheels.org/simple ``` -------------------------------- ### Configure setuptools to include HMM files Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/embed_hmms.md This configuration tells `setuptools` to include all files with the `.hmm` extension from the `redox_detector` package directory into the distribution files. This ensures HMMs are installed alongside your package. ```INI [options.package_data] redox_detector = *.hmm ``` -------------------------------- ### Install PyHMMER using pacman on BioArchLinux Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/install.md Install pyhmmer from the BioArchLinux repository using pacman after adding the repository to pacman.conf. ```ini [bioarchlinux] Server = https://repo.bioarchlinux.org/$arch ``` ```console $ pacman -Sy $ pacman -S python-pyhmmer ``` -------------------------------- ### Installing Platform-Specific Header Files Source: https://github.com/althonos/pyhmmer/blob/master/src/pyhmmer/platform/CMakeLists.txt Installs header files ('linux.h', 'bsd.h', 'util.h') to a specified include directory if the PYHMMER_INSTALL_LIBS_DIR variable is defined. This is used for platform-specific include paths. ```cmake if(DEFINED PYHMMER_INSTALL_LIBS_DIR) cmake_path(APPEND SKBUILD_PLATLIB_DIR "${PYHMMER_INSTALL_LIBS_DIR}" "include" "pyhmmer" "platform" OUTPUT_VARIABLE INCLUDE_DEST_FOLDER) install(FILES "linux.h" "bsd.h" "util.h" DESTINATION "${INCLUDE_DEST_FOLDER}") endif() ``` -------------------------------- ### Include Folder Setup Source: https://github.com/althonos/pyhmmer/blob/master/CMakeLists.txt Defines the directory for Cython headers. This is used to ensure that generated header files are found during the build process. ```cmake set(CYTHON_HEADERS_DIR ${CMAKE_CURRENT_LIST_DIR}/include) ``` -------------------------------- ### Install PyHMMER using AUR helper (aura) Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/install.md Install the python-pyhmmer package from the Arch User Repository using the 'aura' AUR helper. ```console $ aura -A python-pyhmmer ``` -------------------------------- ### Run Benchmarks Source: https://github.com/althonos/pyhmmer/blob/master/docs/guide/contributing.md Execute the benchmark suite using the provided UNIX shell script. Assumes HMMER binaries and 'hyperfine' are in the PATH and the extension is installed. ```bash $ ./benches/run.sh ``` -------------------------------- ### Run Benchmarks Source: https://github.com/althonos/pyhmmer/blob/master/CONTRIBUTING.md Execute the benchmark suite using the provided shell script. This assumes the PyHMMER extension is installed and dependencies are met. ```bash ./benches/run.sh ``` -------------------------------- ### Install Shared Libraries and Headers Source: https://github.com/althonos/pyhmmer/blob/master/src/hmmer/CMakeLists.txt This conditional block handles the installation of the 'libhmmer' library and its headers if the 'PYHMMER_INSTALL_LIBS_DIR' variable is defined. It sets the runtime path for shared libraries on macOS and other systems. ```cmake if(DEFINED PYHMMER_INSTALL_LIBS_DIR) install(TARGETS libhmmer DESTINATION "${SKBUILD_PLATLIB_DIR}/${PYHMMER_INSTALL_LIBS_DIR}") if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(libhmmer PROPERTIES INSTALL_RPATH "@loader_path/") else() set_target_properties(libhmmer PROPERTIES INSTALL_RPATH "$ORIGIN/") endif() cmake_path(APPEND SKBUILD_PLATLIB_DIR "${PYHMMER_INSTALL_LIBS_DIR}" "include" "libhmmer" OUTPUT_VARIABLE INCLUDE_DEST_FOLDER) foreach(_file IN ITEMS ${HMMER_PATCHED_SOURCES}) cmake_path(GET _file EXTENSION LAST_ONLY _ext) if(_ext STREQUAL ".h") cmake_path(RELATIVE_PATH _file BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" OUTPUT_VARIABLE _local) cmake_path(GET _local PARENT_PATH _dest) install(FILES "${_file}" DESTINATION "${INCLUDE_DEST_FOLDER}/${_dest}") endif() endforeach() endif() ``` -------------------------------- ### Import PyHMMER and Check Version Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/msa_to_hmm.ipynb Imports the pyhmmer library and displays its version. Ensure pyhmmer is installed. ```python import pyhmmer pyhmmer.__version__ ``` -------------------------------- ### Running a HMM Search with a Bitscore Cutoff Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/hmmer/profile.md Example of how to run `hmmsearch` using a bitscore cutoff (T=5) instead of the default E-value cutoff. This requires passing the `T` keyword argument. ```python >>> hits = next(hmmsearch(thioesterase, proteins, T=5)) >>> hits[0].score 8.601... ``` -------------------------------- ### Match Emissions Example Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/hmms.md Illustrates the structure of the match emissions matrix. The first row corresponds to entry probabilities and is conventionally set with 1 probability for the first symbol. ```python >>> hmm = HMM(easel.Alphabet.dna(), 100, "test") >>> hmm.match_emissions MatrixF([[1.0, 0.0, 0.0, 0.0], ...]) ``` -------------------------------- ### Install pyhmmer using conda Source: https://github.com/althonos/pyhmmer/blob/master/README.md Install pyhmmer from the bioconda channel using conda. This is an alternative installation method for users of the conda package manager. ```console conda install -c bioconda pyhmmer ``` -------------------------------- ### Initialize and Search with Pipeline Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/results.md Demonstrates initializing a Pipeline and performing a search to obtain TopHits. Shows how to check if the results are sorted by key. ```default >>> abc = thioesterase.alphabet >>> hits = Pipeline(abc).search_hmm(thioesterase, proteins) >>> hits.is_sorted(by="key") True ``` -------------------------------- ### Initialize and Configure Plan7 Builder Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/pli.md Demonstrates initializing a Plan7 Builder with a specific alphabet and background, setting the score matrix, and then building an HMM from a protein sequence. ```python alphabet = easel.Alphabet.amino() background = plan7.Background(alphabet) builder = plan7.Builder(alphabet, popen=0.05) builder.score_matrix = "BLOSUM90" hmm, _, _ = builder.build(proteins[0], background) ``` -------------------------------- ### Client Initialization and Connection Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/daemon/client.md Instantiate a Client and establish a connection to the HMMER daemon server. The client can also be used as a context manager. ```APIDOC ## 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`](../easel/seq.md#pyhmmer.easel.Sequence), [`MSA`](../easel/msa.md#pyhmmer.easel.MSA) or [`HMM`](../plan7/hmms.md#pyhmmer.plan7.HMM). It must first connect to the server with the [`connect`](#pyhmmer.daemon.Client.connect) method: ```default >>> client = daemon.Client("127.0.0.1", 51371) >>> client.connect() ``` Afterwards, the client can be used to run pipelined searches, returning a [`TopHits`](../plan7/results.md#pyhmmer.plan7.TopHits): ```default >>> client.search_hmm(thioesterase) ``` Additional keyword arguments can be passed to customize the pipelined search. All parameters from [`Pipeline`](../plan7/pli.md#pyhmmer.plan7.Pipeline) are supported: ```default >>> client.search_hmm(thioesterase, F1=0.02, E=1e-5) ``` #### HINT [`Client`](#pyhmmer.daemon.Client) implements the context manager protocol, which can be used to open and close a connection to the server within a context: ```default >>> with daemon.Client() as client: ... client.search_hmm(thioesterase) ``` #### Versionadded Added in version 0.6.0. #### __init__(address='127.0.0.1', port=51371) Create a new [`Client`](#pyhmmer.daemon.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. ``` -------------------------------- ### pyhmmer.plan7.HMM.__init__ Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/hmms.md Creates a new HMM from scratch with a specified alphabet, length, and name. ```APIDOC ## pyhmmer.plan7.HMM.__init__ ### Description Create a new HMM from scratch. ### Method `__init__(alphabet, M, name)` ### Parameters #### Parameters - **alphabet** (`Alphabet`) - The alphabet of the model. - **M** (`int`) - The length of the model (i.e. the number of nodes). - **name** (`str`) - The name of the model. ``` -------------------------------- ### __init__ Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/misc.md Creates a new SSI file writer for the specified file location. It can optionally create the file if it doesn't exist. ```APIDOC ## __init__ ### Description Create a new SSI file write for the file at the given location. ### Parameters #### Path Parameters * **file** (str, bytes or os.PathLike) – The path to a sequence/subsequence index file to write. * **exclusive** (bool) – Whether or not to create a file if one does not exist. ### Raises * **FileNotFoundError** – When the path to the file cannot be resolved. * **FileExistsError** – When the file exists and `exclusive` is `True`. ``` -------------------------------- ### Pipeline Initialization Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/pli.md Instantiate and configure a new accelerated comparison pipeline with various biological and statistical parameters. ```APIDOC ## Pipeline( alphabet, background=None, *, bias_filter=True, null2=True, seed=42, Z=None, domZ=None, F1=0.02, F2=0.001, F3=1e-05, E=10.0, T=None, domE=10.0, domT=None, incE=0.01, incT=None, incdomE=0.01, incdomT=None, bit_cutoffs=None ) ### Description Instantiate and configure a new accelerated comparison pipeline. ### Parameters #### Positional Parameters: * **alphabet** ([`Alphabet`](../easel/alphabet.md#pyhmmer.easel.Alphabet)) – The biological alphabet of the HMMs and sequences to be compared. Used to build the background model. * **background** ([`Background`](#pyhmmer.plan7.Background), optional) – The background model to use with the pipeline, or `None` to create and use a default one. The pipeline needs ownership of the background model, so any background model passed will be copied. #### Keyword Arguments: * **bias_filter** (`bool`) – Whether or not to enable composition bias filter. Defaults to `True`. * **null2** (`bool`) – Whether or not to compute biased composition score corrections. Defaults to `True`. * **seed** (`int`, optional) – The seed for the random number generator. Pass `0` to use a one-time arbitrary seed, or `None` to keep the default seed from HMMER. * **Z** (`int`, optional) – The effective number of comparisons done, for E-value calculation. Leave as `None` to auto-detect by counting the number of sequences queried. * **domZ** (`int`, optional) – The number of significant sequences found, for domain E-value calculation. Leave as `None` to auto-detect by counting the number of sequences reported. * **F1** (`float`) – The MSV filter threshold. * **F2** (`float`) – The Viterbi filter threshold. * **F3** (`float`) – The uncorrected Forward filter threshold. * **E** (`float`) – The per-target E-value threshold for reporting a hit. * **T** (`float`, optional) – The per-target bit score threshold for reporting a hit. If given, takes precedence over `E`. * **domE** (`float`) – The per-domain E-value threshold for reporting a domain hit. * **domT** (`float`, optional) – The per-domain bit score threshold for reporting a domain hit. If given, takes precedence over `domE`. * **incE** (`float`) – The per-target E-value threshold for including a hit in the resulting [`TopHits`](results.md#pyhmmer.plan7.TopHits). * **incT** (`float`, optional) – The per-target bit score threshold for including a hit in the resulting [`TopHits`](results.md#pyhmmer.plan7.TopHits). If given, takes precedence over `incE`. * **incdomE** (`float`) – The per-domain E-value threshold for including a domain in the resulting [`TopHits`](results.md#pyhmmer.plan7.TopHits). * **incdomT** (`float`, optional) – The per-domain bit score thresholds for including a domain in the resulting [`TopHits`](results.md#pyhmmer.plan7.TopHits). If given, takes precedence over `incdomE`. * **bit_cutoffs** (`str`, optional) – The model-specific thresholding option to use for reporting hits. With `None` (the default), use global pipeline options; otherwise pass one of ` ``` ```APIDOC ## Pipeline.arguments() ### Description Generate an `argv`-like list with pipeline options as CLI flags. ### Versionadded Added in version 0.6.0. ``` ```APIDOC ## Pipeline.clear() ### Description Reset the pipeline to its default state. ``` -------------------------------- ### Install Shared Libraries Source: https://github.com/althonos/pyhmmer/blob/master/CMakeLists.txt Conditionally installs shared library objects to a specific directory (`pyhmmer.libs`) if the `PYHMMER_INSTALL_LIBS` variable is set. This is useful for packaging tools like auditwheel. ```cmake if(PYHMMER_INSTALL_LIBS) set(PYHMMER_INSTALL_LIBS_DIR "${CMAKE_PROJECT_NAME}.libs") message(STATUS "Installing shared libraries to ${PYHMMER_INSTALL_LIBS_DIR}") install(DIRECTORY "${CYTHON_HEADERS_DIR}" DESTINATION "${PYHMMER_INSTALL_LIBS_DIR}/cython") endif() ``` -------------------------------- ### Using HMMFile with a context manager Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/parsers.md Demonstrates how to open and read an HMM from a file using the HMMFile class within a 'with' statement, ensuring automatic resource cleanup. ```python >>> with HMMFile("tests/data/hmms/bin/Thioesterase.h3m") as hmm_file: ... hmm = hmm_file.read() ``` -------------------------------- ### to_profile(background=None, L=400, multihit=True, local=True) Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/hmms.md Creates a new profile configured for this HMM, serving as a shortcut for initializing and configuring a Profile object. ```APIDOC ## to_profile(background=None, L=400, multihit=True, local=True) ### Description Create a new profile configured for this HMM. This method is a shortcut for creating a new [`Profile`](#pyhmmer.plan7.Profile) and calling [`configure`](#pyhmmer.plan7.Profile.configure) for a given HMM. Prefer manually calling [`configure`](#pyhmmer.plan7.Profile.configure) to recycle the profile buffer when running inside a loop. ### Parameters #### Path Parameters - **background** ([`Background`](pli.md#pyhmmer.plan7.Background), optional) – The null background model. In `None` given, create a default one for the HMM alphabet. - **L** (`int`) – The expected target sequence length. - **multihit** (`bool`) – Whether or not to use multihit mode. - **local** (`bool`) – Whether to use local or global mode. ``` -------------------------------- ### Background.__init__ Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/pli.md Creates a new background model for the given alphabet. ```APIDOC ## Background.__init__(alphabet, uniform=False) ### Description Create a new background model for the given `alphabet`. ### Parameters #### Path Parameters * **alphabet** (`Alphabet`) – The alphabet to create the background model with. * **uniform** (`bool`) – Whether or not to create the null model with uniform frequencies. Defaults to `False`. ### Method POST ### Endpoint /background ``` -------------------------------- ### DigitalSequence.source Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the source of the sequence, if any. ```APIDOC ## DigitalSequence.source ### Description The source of the sequence, if any. ### Type `str` ### Versionchanged Changed in version 0.12.0: Property is now a `str` instead of `bytes`. ``` -------------------------------- ### Building the Easel Library Source: https://github.com/althonos/pyhmmer/blob/master/src/easel/CMakeLists.txt Creates a static library named 'libeasel' using the processed source files. It also sets public include directories for the library. ```cmake add_library(libeasel ${EASEL_PATCHED_SOURCES}) target_include_directories(libeasel PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(libeasel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) ``` -------------------------------- ### DigitalSequence.name Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the name of the sequence. ```APIDOC ## DigitalSequence.name ### Description The name of the sequence. ### Type `str` ### Versionchanged Changed in version 0.12.0: Property is now a `str` instead of `bytes`. ``` -------------------------------- ### DigitalSequence.description Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the description of the sequence. ```APIDOC ## DigitalSequence.description ### Description The description of the sequence. ### Type `str` ### Versionchanged Changed in version 0.12.0: Property is now a `str` instead of `bytes`. ``` -------------------------------- ### DigitalSequence.accession Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the accession of the sequence. ```APIDOC ## DigitalSequence.accession ### Description The accession of the sequence. ### Type `str` ### Versionchanged Changed in version 0.12.0: Property is now a `str` instead of `bytes`. ``` -------------------------------- ### Load NCBI Taxonomy Database with taxopy Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/iterative_search.ipynb Initializes the taxopy database for taxonomic lookups. Set keep_files=False to avoid saving temporary files. ```python import taxopy taxdb = taxopy.TaxDb(keep_files=False) ``` -------------------------------- ### DigitalSequence.length Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the length of the sequence. ```APIDOC ## DigitalSequence.L ### Description The length of the sequence. ### Type `int` ### Versionadded Added in version 0.12.1. ``` -------------------------------- ### DigitalSequence.sequence Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the raw sequence letters as a Python string. ```APIDOC ## DigitalSequence.sequence ### Description The raw sequence letters, as a Python string. ### Type `str` ``` -------------------------------- ### DigitalSequence.alphabet Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets the biological alphabet used to encode this sequence to digits. ```APIDOC ## DigitalSequence.alphabet ### Description The biological alphabet used to encode this sequence to digits. ### Type [`Alphabet`](alphabet.md#pyhmmer.easel.Alphabet), *readonly* ### HINT Use the `sequence` property to access the sequence digits as a memory view, allowing to access the individual bytes. This can be combined with `numpy.asarray` to get the sequence as an array with zero-copy. ### Versionadded Added in version 0.10.4: `pickle` protocol support. ``` -------------------------------- ### Create and Access MatrixD Elements Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/linalg.md Demonstrates creating a MatrixD, setting individual elements using indexing, and accessing rows as VectorD objects. Also shows conversion to a NumPy array and performing NumPy operations. ```python >>> m = MatrixD.zeros(2, 2) >>> m[0, 0] = 3.0 >>> m MatrixD([[3.0, 0.0], [0.0, 0.0]]) ``` ```python >>> m = MatrixD([ [1.0, 2.0], [3.0, 4.0] ]) >>> m[0] VectorD([1.0, 2.0]) ``` ```python >>> m = MatrixD([ [1.0, 2.0], [3.0, 4.0] ]) >>> numpy.asarray(m) array([[1., 2.], [3., 4.]]) ``` ```python >>> m = MatrixD([ [1.0, 2.0], [3.0, 4.0] ]) >>> numpy.log2(m) array([[0. , 1. ], [1.5849625, 2. ]]) ``` -------------------------------- ### rewind() Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/parsers.md Rewinds the file back to the beginning, allowing profiles to be read again from the start. ```APIDOC ## rewind() ### Description Rewinds the file back to the beginning, allowing profiles to be read again from the start. ``` -------------------------------- ### Download PKSI-AT HMM profile Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/active_site.ipynb Download the PKSI-AT HMM file from the AntiSMASH GitHub repository using urllib.request and save it locally. This requires shutil for file copying. ```python import shutil from urllib.request import urlopen with urlopen('https://raw.githubusercontent.com/antismash/antismash/refs/heads/8-0-stable/antismash/modules/active_site_finder/data/PKSI-AT.hmm2') as src: with open("PKSI-AT.hmm2", "wb") as dst: shutil.copyfileobj(src, dst) ``` -------------------------------- ### DigitalSequence.residue_markups Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/seq.md Gets extra residue markups, mapping information to each position. Keys and values are not decoded. ```APIDOC ## DigitalSequence.residue_markups ### Description Extra residue markups, mapping information to each position. Keys and values are not decoded, since they are not necessarily valid UTF-8 bytestrings. ### Type `dict` ### Versionadded Added in version 0.4.6. ``` -------------------------------- ### Traces.__init__ Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/traces.md Creates a new Traces block, which is a collection of Trace objects. ```APIDOC ## __init__() ### Description Create a new trace block from an iterable of [`Trace`](#pyhmmer.plan7.Trace) objects. ``` -------------------------------- ### Using HMMPressedFile with a context manager Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/parsers.md Shows how to open and read an optimized profile from a pressed HMM database file using HMMPressedFile within a 'with' statement for automatic closing. ```python >>> with HMMPressedFile("tests/data/hmms/db/Thioesterase.hmm") as hmm_db: ... optimized_profile = hmm_db.read() ``` -------------------------------- ### Accessing TopHits Information Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/plan7/results.md Shows how to get the number of top hits using len() and access individual hits by index. ```default >>> len(hits) 1 >>> hits[0].name '938293.PRJEB85.HG003687_113' ``` -------------------------------- ### Extract HMM from Iterations Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/iterative_search.ipynb Extracts the HMM object from the last iteration of a search. This HMM can then be modified, for example, to set cutoffs. ```python hmm = iterations[-1].hmm ``` -------------------------------- ### Get HMM Consensus Sequence Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/msa_to_hmm.ipynb Retrieves the consensus sequence of the built HMM. This provides a summary of the conserved residues across the alignment. ```python hmm.consensus ``` -------------------------------- ### View pyhmmer.plan7 documentation Source: https://github.com/althonos/pyhmmer/blob/master/README.md Access the pyhmmer.plan7 module documentation directly from the command line using pydoc. This provides an API reference for plan7 objects, including results. ```console pydoc pyhmmer.plan7 ``` -------------------------------- ### Compare HMM File Loading Times Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/performance_tips.ipynb Demonstrates the performance difference between loading HMMs from text (.hmm) and binary (.h3m) files. Binary files are significantly faster to load. ```python import pyhmmer %timeit list(pyhmmer.plan7.HMMFile("data/hmms/txt/RREFam.hmm")) %timeit list(pyhmmer.plan7.HMMFile("data/hmms/bin/RREFam.h3m")) ``` -------------------------------- ### AlphabetMismatch Example Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/errors/value.md This error is raised when arguments to a function have mismatching alphabets, such as passing a DigitalSequence with a DNA alphabet to a Builder expecting an amino alphabet. ```python >>> seq = easel.DigitalSequence(easel.Alphabet.dna()) >>> builder = plan7.Builder(easel.Alphabet.amino()) >>> builder.build(seq, plan7.Background(seq.alphabet)) Traceback (most recent call last): ... pyhmmer.errors.AlphabetMismatch: Expected amino alphabet, found DNA alphabet ``` -------------------------------- ### Plot Score Differences Source: https://github.com/althonos/pyhmmer/blob/master/docs/examples/iterative_search.ipynb Plots the calculated score differences to visualize the distribution and aid in identifying optimal cutoff points. Requires matplotlib to be installed. ```python import matplotlib.pyplot as plt plt.plot(diff) plt.ylabel("dscore") plt.xlabel("Hit rank") plt.show() ``` -------------------------------- ### VectorU8 Initialization and Operations Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/easel/linalg.md Methods for creating and operating on VectorU8, which stores byte-sized unsigned integers. ```APIDOC ## VectorU8 ### __init__(iterable=()) Create a new byte vector from the given data. ### argmax() Return index of the maximum element in the vector. * **Raises:** **ValueError** – When called on an empty vector. ### argmin() Return index of the minimum element in the vector. * **Raises:** **ValueError** – When called on an empty vector. ### copy() Create a copy of the vector, allocating a new buffer. ### max() Return value of the maximum element in the vector. * **Raises:** **ValueError** – When called on an empty vector. ### min() Return value of the minimum element in the vector. * **Raises:** **ValueError** – When called on an empty vector. ### reverse() Reverse the vector, in place. ### sum() Returns the scalar sum of all elements in the vector. ``` -------------------------------- ### Connect to HMMER Daemon Client Source: https://github.com/althonos/pyhmmer/blob/master/docs/api/daemon/client.md Instantiate and connect a client to the HMMER daemon server. The client can also be used as a context manager. ```python >>> client = daemon.Client("127.0.0.1", 51371) >>> client.connect() ``` ```python >>> with daemon.Client() as client: ... client.search_hmm(thioesterase) ```