Hidden Markov Model profile tools (reader/writer/data structures)
Hidden Markov Model profile toolkit.
Written in the base of HMMER User's Guide p.107.
With my package you can read and write hmm profile files. It's easy to use and easy to read - the best documentation is a well-written code itself, so don't be scared about reading source code.
Read all hmm from file
read_all function returns generator to optimise memory usage -
it's a common pattern that one file contains many profiles.
from hmm_profile import reader with open('/your/hmm/profile/file.hmm') as f: model_generator = reader.read_all(f) # IMPORTANT: returns generator profiles = list(model_generator)
Read single model
If you have only single model files, you can use this method. It will return
models.HMM ready to use.
from hmm_profile import reader with open('/your/hmm/profile/file.hmm') as f: model = reader.read_single(f)
Write multiple profiles to single file
from hmm_profile import writer profiles = [...] path = '/your/hmm/profile/file.hmm' writer.save_many_to_file(hmms=profiles, output=path)
Write single model to file
from hmm_profile import writer model = ... path = '/your/hmm/profile/file.hmm' writer.save_to_file(hmm=model, output=path)
Get file content without saving
from hmm_profile import writer model = ... lines = writer.get_lines(model) # IMPORTANT: returns generator content = ''.join(lines)
If you have a file that is not readable or has some glitches on save, please crate the issue and attach this file. Bug reports without files (or good examples if you can't provide full file) will be ignored.
Above you can see if all hmm profiles from Pfam works. Test are running every day.
- Download all hmm profiles from Pfam.
- Load profiles sequentially.
- Write model to file.
- Load saved model from file.
- Check if both loaded profiles are equals.
For this test the latest version of
hmm_profile from pypi is used.
Full DB test also runs before each release, but badge above shows only periodic tests results.
Whole package is written in pure Python, without C extensions.
You can treat full DB test as benchmark.
Benchmark should be depended mainly on single core of CPU and secondarily on storage and eventually on RAM. Storage is used only for read from then files will be saved to "in-memory file" (StringIO).
Remember: Results may vary when CPU is under load. Also, hmm profiles in db can be modified in future or some profiles may be added/removed from DB.
|Intel Core i7-4702MQ||Crucial MX500 500 GB||342||17928||2020.02.22||0.0.9||3.7|
|Intel Core i7-4702MQ||Crucial MX500 500 GB||322||17928||2020.02.22||0.0.9||3.6|
|Intel Core i7-4702MQ||GoodRAM Iridium Pro240 GB||TBA||TBA||TBA||TBA||3.6|
To run benchmark:
pip install . export HMM_PROFILE_RUN_INTEGRITY_TESTS=TRUE python setpu.py test --addopts -s
Run test at least 3 times if you want to share results (last line) and close as much process as possible. Important: do not run tests inside so-called terminal in IDE - it will do much more job with output and benchmark result will be affected.
As you can see python 3.6 is a little faster, probably due to different implementation of backported dataclasses, but I'm not sure.
- Change version in setup.py to
x.y.z.dev0and ensure changelog is up to date.
- Tag head of master branch with
Important: release ALWAYS is from master branch! So keep master untouched when you want to release.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size hmm_profile-0.0.11-py3-none-any.whl (9.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size hmm_profile-0.0.11.tar.gz (10.6 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for hmm_profile-0.0.11-py3-none-any.whl