├── .coveragerc ├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── main.yml ├── .gitignore ├── .readthedocs.yml ├── CHANGELOG.rst ├── CONTRIB.rst ├── LICENSE.txt ├── MANIFEST.in ├── README.rst ├── bin └── README.md ├── conkit ├── __init__.py ├── applications │ ├── __init__.py │ ├── bbcontacts.py │ ├── ccmpred.py │ ├── cdhit.py │ ├── hhblits.py │ ├── hhfilter.py │ ├── jackhmmer.py │ ├── map_align.py │ └── psicov.py ├── command_line │ ├── README.md │ ├── __init__.py │ ├── conkit_convert.py │ ├── conkit_msatool.py │ ├── conkit_plot.py │ ├── conkit_precision.py │ ├── conkit_predict.py │ └── conkit_validate.py ├── core │ ├── __init__.py │ ├── contact.py │ ├── contactfile.py │ ├── contactmap.py │ ├── distance.py │ ├── distancefile.py │ ├── distogram.py │ ├── entity.py │ ├── ext │ │ ├── __init__.py │ │ ├── c_contactmap.pyx │ │ └── c_sequencefile.pyx │ ├── mappings.py │ ├── sequence.py │ ├── sequencefile.py │ ├── struct.py │ └── tests │ │ ├── test_contact.py │ │ ├── test_contactfile.py │ │ ├── test_contactmap.py │ │ ├── test_distance.py │ │ ├── test_distancefile.py │ │ ├── test_distogram.py │ │ ├── test_entity.py │ │ ├── test_mappings.py │ │ ├── test_sequence.py │ │ └── test_sequencefile.py ├── io │ ├── __init__.py │ ├── _cache.py │ ├── _iotools.py │ ├── _parser.py │ ├── a2m.py │ ├── a3m.py │ ├── aleigen.py │ ├── alphafold.py │ ├── bbcontacts.py │ ├── bclcontact.py │ ├── casp.py │ ├── caspmode2.py │ ├── ccmpred.py │ ├── clustal.py │ ├── comsat.py │ ├── epcmap.py │ ├── evfold.py │ ├── fasta.py │ ├── freecontact.py │ ├── gremlin.py │ ├── mapalign.py │ ├── mappred.py │ ├── membrain.py │ ├── ncont.py │ ├── pcons.py │ ├── pdb.py │ ├── plmdca.py │ ├── psicov.py │ ├── rosetta.py │ ├── rosetta_npz.py │ ├── stockholm.py │ └── tests │ │ ├── __init__.py │ │ ├── helpers.py │ │ ├── test__cache.py │ │ ├── test__iotools.py │ │ ├── test__parser.py │ │ ├── test_a2m.py │ │ ├── test_a3m.py │ │ ├── test_aleigen.py │ │ ├── test_alphafold.py │ │ ├── test_bbcontacts.py │ │ ├── test_bclcontact.py │ │ ├── test_casp.py │ │ ├── test_caspmode2.py │ │ ├── test_ccmpred.py │ │ ├── test_clustal.py │ │ ├── test_comsat.py │ │ ├── test_epcmap.py │ │ ├── test_evfold.py │ │ ├── test_fasta.py │ │ ├── test_freecontact.py │ │ ├── test_gremlin.py │ │ ├── test_mapalign.py │ │ ├── test_mappred.py │ │ ├── test_membrain.py │ │ ├── test_ncont.py │ │ ├── test_pcons.py │ │ ├── test_pdb.py │ │ ├── test_plmdca.py │ │ ├── test_psicov.py │ │ ├── test_rosetta_npz.py │ │ └── test_stockholm.py ├── misc │ ├── __init__.py │ ├── bandwidth.py │ ├── distances.py │ ├── energyfunction.py │ ├── ext │ │ ├── __init__.py │ │ └── c_bandwidth.pyx │ ├── selectalg.py │ ├── selector.py │ ├── standard_scaler.joblib │ ├── tests │ │ ├── test___init__.py │ │ ├── test_bandwidth.py │ │ ├── test_distances.py │ │ ├── test_energyfunction.py │ │ └── test_selectalg.py │ └── trained_classifier.joblib ├── plot │ ├── __init__.py │ ├── contactdensity.py │ ├── contactmap.py │ ├── contactmapchord.py │ ├── contactmapmatrix.py │ ├── distogramheatmap.py │ ├── figure.py │ ├── modelvalidation.py │ ├── precisionevaluation.py │ ├── sequencecoverage.py │ ├── tests │ │ └── test_tools.py │ └── tools.py └── version.py ├── docs ├── Makefile ├── _static │ ├── custom.css │ ├── favicon.ico │ ├── logo_conkit.svg │ ├── plot_cdens_4p9g.png │ ├── plot_distogram_simple.png │ ├── plot_model_validation.png │ ├── plot_peval_toxd.png │ └── plot_scov_toxd.png ├── _templates │ ├── layout.html │ └── navbar.html ├── api │ ├── applications.rst │ ├── command_line.rst │ ├── core.rst │ ├── io.rst │ ├── misc.rst │ └── plot.rst ├── conf.py ├── contents.rst ├── contrib.rst ├── examples.rst ├── examples │ ├── analysis.rst │ ├── applications.rst │ ├── code │ │ ├── plot_cdens.py │ │ ├── plot_chord_simple.py │ │ ├── plot_distogram_simple.py │ │ ├── plot_map_reference.py │ │ ├── plot_map_simple.py │ │ ├── plot_mat_simple.py │ │ ├── plot_peval.py │ │ └── predict_pipeline.py │ ├── core.rst │ ├── io.rst │ ├── plot.rst │ ├── rst │ │ ├── python_analyse_conpred.rst │ │ ├── python_analyse_msa.rst │ │ ├── python_convert_conpred.rst │ │ ├── python_convert_distpred.rst │ │ ├── python_convert_msa.rst │ │ ├── python_create_contactfile.rst │ │ ├── python_create_sequencefile.rst │ │ ├── python_plot_cdens.rst │ │ ├── python_plot_chord.rst │ │ ├── python_plot_distogram.rst │ │ ├── python_plot_map.rst │ │ ├── python_plot_mat.rst │ │ ├── python_plot_peval.rst │ │ ├── python_plot_scov.rst │ │ ├── python_predict_pipeline.rst │ │ ├── script_analyse_msa.rst │ │ ├── script_convert_conpred.rst │ │ ├── script_convert_distpred.rst │ │ ├── script_convert_msa.rst │ │ ├── script_model_validation.rst │ │ ├── script_plot_cdens.rst │ │ ├── script_plot_chord.rst │ │ ├── script_plot_distogram.rst │ │ ├── script_plot_map.rst │ │ ├── script_plot_mat.rst │ │ ├── script_plot_peval.rst │ │ ├── script_plot_scov.rst │ │ └── script_predict_pipeline.rst │ └── validation.rst ├── figures.py ├── formats.rst ├── index.rst ├── install.rst ├── requirements.txt └── sphinxext │ ├── __init__.py │ └── math_symbol_table.py ├── pyproject.toml ├── requirements.txt ├── setup.cfg └── setup.py /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | source = conkit 4 | 5 | [report] 6 | exclude_lines = 7 | if self.debug: 8 | raise NotImplementedError 9 | if __name__ == .__main__.: 10 | ignore_errors = True 11 | omit = 12 | conkit/tests/* 13 | conkit/*/tests/* 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## General Information 2 | 3 | 4 | - ConKit version: 5 | - Python version: 6 | - Environment (if applicable): 7 | 8 | 9 | ## Example 10 | 11 | A minimal example to reproduce the error: 12 | ``` 13 | 14 | ``` 15 | 16 | ## Traceback 17 | 18 | The Python traceback 19 | ``` 20 | 21 | ``` 22 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | 13 | unittests: 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest, macos-latest, windows-latest] 18 | python-version: [3.7, 3.8, 3.9] 19 | 20 | steps: 21 | - uses: actions/checkout@v1 22 | - name: Set up Python ${{ matrix.python-version }} 23 | uses: actions/setup-python@v1 24 | with: 25 | python-version: ${{ matrix.python-version }} 26 | architecture: 'x64' 27 | - name: Install dependencies 28 | run: | 29 | python -m pip install --upgrade pip 30 | python -m pip install . 31 | - name: Run Tests 32 | run: | 33 | python -m pip install --upgrade pip 34 | python -m pip install . 35 | python setup.py test 36 | 37 | codecov: 38 | runs-on: ubuntu-latest 39 | needs: unittests 40 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} 41 | steps: 42 | - uses: actions/checkout@v1 43 | - name: Setup Python 44 | uses: actions/setup-python@v1 45 | with: 46 | python-version: '3.8' 47 | architecture: 'x64' 48 | - name: Install dependencies 49 | run: | 50 | python -m pip install --upgrade pip 51 | python -m pip install . 52 | - name: Run Tests 53 | run: | 54 | python -m pip install --upgrade pip 55 | python -m pip install . 56 | python setup.py test 57 | - name: Upload coverage to Codecov 58 | uses: codecov/codecov-action@v1.0.2 59 | with: 60 | token: ${{secrets.CODECOV_TOKEN}} 61 | file: ./coverage.xml 62 | flags: unittests 63 | name: codecov-umbrella 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | bin/* 3 | !bin/REAME.md 4 | docs/api/generated/*.rst 5 | docs/examples/images/*.png 6 | 7 | 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | *.c 16 | 17 | # Distribution / packaging 18 | .Python 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | MANIFEST 35 | 36 | # PyInstaller 37 | # Usually these files are written by a python script from a template 38 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 39 | *.manifest 40 | *.spec 41 | 42 | # Installer logs 43 | pip-log.txt 44 | pip-delete-this-directory.txt 45 | 46 | # Unit test / coverage reports 47 | htmlcov/ 48 | .tox/ 49 | .coverage 50 | .coverage.* 51 | .cache 52 | nosetests.xml 53 | coverage.xml 54 | *.cover 55 | .hypothesis/ 56 | .pytest_cache/ 57 | 58 | # Translations 59 | *.mo 60 | *.pot 61 | 62 | # Django stuff: 63 | *.log 64 | local_settings.py 65 | db.sqlite3 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | target/ 79 | 80 | # Jupyter Notebook 81 | .ipynb_checkpoints 82 | 83 | # pyenv 84 | .python-version 85 | 86 | # celery beat schedule file 87 | celerybeat-schedule 88 | 89 | # SageMath parsed files 90 | *.sage.py 91 | 92 | # Environments 93 | .env 94 | .venv 95 | env/ 96 | venv/ 97 | ENV/ 98 | env.bak/ 99 | venv.bak/ 100 | 101 | # Spyder project settings 102 | .spyderproject 103 | .spyproject 104 | 105 | # Rope project settings 106 | .ropeproject 107 | 108 | # mkdocs documentation 109 | /site 110 | 111 | # mypy 112 | .mypy_cache/ 113 | /.pip/ 114 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | sphinx: 4 | configuration: docs/conf.py 5 | 6 | python: 7 | version: 3.7 8 | install: 9 | - requirements: requirements.txt 10 | - requirements: docs/requirements.txt 11 | -------------------------------------------------------------------------------- /CONTRIB.rst: -------------------------------------------------------------------------------- 1 | 2 | Contributors 3 | ============ 4 | 5 | This is a list of people who have made contributions to ConKit. 6 | 7 | - `Adam Simpkin `_ 8 | - `Felix Simkovic `_ 9 | - `Jens Thomas `_ 10 | - `Stefan Seemayer `_ 11 | - `Chunan Liu `_ 12 | - `Filomeno Sanchez `_ 13 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2016-21, University of Liverpool 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include LICENSE.txt 3 | include CONTRIB.rst 4 | include CHANGELOG.rst 5 | include requirements.txt 6 | include setup.cfg 7 | include pyproject.toml 8 | recursive-include conkit/misc/ *.joblib 9 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. 2 | 3 | ************************** 4 | Contact Prediction ToolKit 5 | ************************** 6 | 7 | **A Python Interface to Contact Predictions** 8 | 9 | .. image:: https://img.shields.io/badge/DOI-10.1093%2Fbioinformatics%2Fbtx148-blue.svg 10 | :target: https://doi.org/10.1093/bioinformatics/btx148 11 | :alt: DOI Status 12 | 13 | .. image:: https://img.shields.io/pypi/v/conkit.svg 14 | :target: https://pypi.python.org/pypi/conkit 15 | :alt: PyPi Package 16 | 17 | .. image:: https://img.shields.io/pypi/pyversions/conkit.svg 18 | :target: https://pypi.python.org/pypi/conkit 19 | :alt: Python Versions 20 | 21 | .. image:: https://readthedocs.org/projects/conkit/badge/?version=latest 22 | :target: https://conkit.readthedocs.io/en/latest/ 23 | :alt: Documentation Status 24 | 25 | .. image:: https://github.com/rigdenlab/conkit/workflows/Build/badge.svg 26 | :alt: Build Status 27 | 28 | **NEW: Now ConKit is also compatible with residue-residue distance predictions** 29 | 30 | ConKit is a Python library to provide a data object hierarchy and associated routine operations to 31 | work and manipulate residue-residue contact prediction data. Main features shipped with this library 32 | include: 33 | 34 | - Parsers for Multiple Sequence Alignment, contact prediction and residue distance prediction files 35 | - Analysis functions for Multiple Sequence Alignment, contact prediction data and residue distance prediction data 36 | - Visualisation of Multiple Sequence Alignment, contact prediction data and residue distance prediction data 37 | - Validation of models based on residue distance predictions 38 | - Python wrappers for the contact-prediction-related software 39 | 40 | For a general overview of ConKit, watch `this video `_. 41 | 42 | For an overview of model validation with ConKit, watch this `video `_. 43 | 44 | .. CHECKPOINT FOR READTHEDOCS 45 | 46 | Installation & Usage 47 | ++++++++++++++++++++ 48 | Please refer to `ConKit's documentation `_. 49 | 50 | Contributing 51 | ++++++++++++ 52 | There are two ways by which you can contribute to ConKit: 53 | 54 | 1. Submit any suggestions to the `GitHub Issue Tracker`_, or 55 | 2. Fork this repository, commit your changes and submit a pull request. 56 | 57 | Found a Bug? 58 | ++++++++++++ 59 | Please use the `GitHub Issue Tracker`_. 60 | 61 | .. _GitHub Issue Tracker: https://github.com/rigdenlab/conkit/issues 62 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | ## WARNING 2 | 3 | This folder is and remains empty. It is only used during the installation where it places temporary scripts in here. 4 | 5 | **Do not delete, move or modify this folder** 6 | 7 | -------------------------------------------------------------------------------- /conkit/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | ConKit is a Python interface for handling and manipulating 32 | contact predictions obtained from a variety of different 33 | sources. 34 | """ 35 | 36 | import conkit.version 37 | 38 | __author__ = "Felix Simkovic" 39 | __contributing_authors__ = "Jens Thomas & Adam Simpkin" 40 | __credits__ = "Stefan Seemayer" 41 | __version__ = conkit.version.__version__ 42 | -------------------------------------------------------------------------------- /conkit/applications/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Python wrappers for common command line applications""" 33 | 34 | __author__ = "Felix Simkovic" 35 | __date__ = "20 Oct 2016" 36 | __version__ = "0.13.3" 37 | 38 | 39 | def BbcontactsCommandline(*args, **kwargs): 40 | from conkit.applications.bbcontacts import BbcontactsCommandline 41 | 42 | return BbcontactsCommandline(*args, **kwargs) 43 | 44 | 45 | def CCMpredCommandline(*args, **kwargs): 46 | from conkit.applications.ccmpred import CCMpredCommandline 47 | 48 | return CCMpredCommandline(*args, **kwargs) 49 | 50 | 51 | def CdhitCommandline(*args, **kwargs): 52 | from conkit.applications.cdhit import CdhitCommandline 53 | 54 | return CdhitCommandline(*args, **kwargs) 55 | 56 | 57 | def HHblitsCommandline(*args, **kwargs): 58 | from conkit.applications.hhblits import HHblitsCommandline 59 | 60 | return HHblitsCommandline(*args, **kwargs) 61 | 62 | 63 | def HHfilterCommandline(*args, **kwargs): 64 | from conkit.applications.hhfilter import HHfilterCommandline 65 | 66 | return HHfilterCommandline(*args, **kwargs) 67 | 68 | 69 | def JackhmmerCommandline(*args, **kwargs): 70 | from conkit.applications.jackhmmer import JackhmmerCommandline 71 | 72 | return JackhmmerCommandline(*args, **kwargs) 73 | 74 | 75 | def PsicovCommandline(*args, **kwargs): 76 | from conkit.applications.psicov import PsicovCommandline 77 | 78 | return PsicovCommandline(*args, **kwargs) 79 | 80 | 81 | def MapAlignCommandline(*args, **kwargs): 82 | from conkit.applications.map_align import MapAlignCommandline 83 | 84 | return MapAlignCommandline(*args, **kwargs) 85 | -------------------------------------------------------------------------------- /conkit/applications/map_align.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """ 33 | Command line object for map_align contact map alignment application 34 | """ 35 | 36 | from Bio.Application import _Option 37 | from Bio.Application import AbstractCommandline 38 | 39 | 40 | class MapAlignCommandline(AbstractCommandline): 41 | """ 42 | Command line object for map_align [#]_ [#]_ 43 | 44 | https://github.com/sokrypton/map_align 45 | 46 | 47 | Examples 48 | -------- 49 | >>> from conkit.applications import MapAlignCommandline 50 | >>> mapalign_cline = MapAlignCommandline(map_a='cmap_1.mapalign', map_b='cmap_2.mapalign') 51 | >>> print(mapalign_cline) 52 | map_align cmap_1.mapalign cmap_2.mapalign 53 | 54 | You would typically run the command line with :func:`mapalign_cline` or via 55 | the :mod:`~subprocess` module. 56 | 57 | """ 58 | 59 | def __init__(self, cmd="map_align", **kwargs): 60 | self.parameters = [ 61 | _Option( 62 | ["-a", "contact_map_a"], 63 | "contact map A", 64 | filename=True, 65 | equate=False, 66 | is_required=True, 67 | ), 68 | _Option( 69 | ["-b", "contact_map_b"], 70 | "contact map B", 71 | filename=True, 72 | equate=False, 73 | is_required=True, 74 | ), 75 | _Option(["-gap_o", "gap_opening_penalty"], "Gap opening penalty [default=-1]", equate=False), 76 | _Option(["-gap_e", "gap_extension_penalty"], "Gap extension penalty [default=-0.01]", equate=False), 77 | _Option(["-sep_cut", "seq_separation_cutoff"], "Sequence separation cutoff [default=3]", equate=False), 78 | _Option(["-iter", "n_iterations"], "Number of iterations [default=20]", equate=False), 79 | ] 80 | AbstractCommandline.__init__(self, cmd, **kwargs) 81 | -------------------------------------------------------------------------------- /conkit/command_line/README.md: -------------------------------------------------------------------------------- 1 | # Script instructions 2 | 3 | If you want to add a new command-line script, please follow these instructions. 4 | 5 | 1. Start all scripts with the word "conkit" 6 | 2. Avoid using non-standard characters to separate words, please only use "_" or "." 7 | 8 | If you follow the above steps, then re-running the "python setup.py install" command will automatically place a new script in your bin directory. Note, "_" and "." characters will be converted to a dash, i.e. the "conkit_convert.py" file will be installed as "conkit-convert" script. 9 | 10 | -------------------------------------------------------------------------------- /conkit/command_line/conkit_convert.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """This script provides direct access to ConKit's conversion algorithms. 33 | 34 | This script can convert either contact prediction files or sequence files. 35 | In case of the latter, a file with a single or multiple sequences can be 36 | converted. 37 | 38 | !!! IMPORTANT 39 | ============= 40 | Do not attempt to mix formats, i.e. convert from a contact file format 41 | to a sequence file format. 42 | 43 | """ 44 | 45 | __author__ = "Felix Simkovic" 46 | __date__ = "01 Oct 2016" 47 | __version__ = "0.13.3" 48 | 49 | import argparse 50 | 51 | import conkit.command_line 52 | import conkit.io 53 | 54 | logger = None 55 | 56 | 57 | def main(): 58 | parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) 59 | parser.add_argument("infile") 60 | parser.add_argument("informat") 61 | parser.add_argument("outfile") 62 | parser.add_argument("outformat") 63 | args = parser.parse_args() 64 | 65 | global logger 66 | logger = conkit.command_line.setup_logging(level="info") 67 | 68 | if args.outformat == "rosetta": 69 | raise NotImplementedError("This conversion is not yet supported") 70 | 71 | msg = "Converting file{nline}{tab}{infile} of format {informat}{nline}" 72 | msg += "to file{nline}{tab}{outfile} of format {outformat}" 73 | msg = msg.format( 74 | infile=args.infile, informat=args.informat, outfile=args.outfile, outformat=args.outformat, nline="\n", tab="\t" 75 | ) 76 | logger.info(msg) 77 | conkit.io.convert(args.infile, args.informat, args.outfile, args.outformat) 78 | 79 | return 80 | 81 | 82 | if __name__ == "__main__": 83 | import sys 84 | import traceback 85 | 86 | try: 87 | main() 88 | sys.exit(0) 89 | except Exception as e: 90 | if not isinstance(e, SystemExit): 91 | msg = "".join(traceback.format_exception(*sys.exc_info())) 92 | logger.critical(msg) 93 | sys.exit(1) 94 | -------------------------------------------------------------------------------- /conkit/command_line/conkit_msatool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """This script analyses a Multiple Sequence Alignment. 33 | 34 | It provides you estimates about the quality, which will allow 35 | you to determine its usefulness for covariance-based contact 36 | prediction. 37 | 38 | """ 39 | 40 | __author__ = "Felix Simkovic" 41 | __date__ = "21 Nov 2016" 42 | __version__ = "0.13.3" 43 | 44 | import argparse 45 | 46 | import conkit.command_line 47 | import conkit.io 48 | import conkit.plot 49 | import conkit.plot.tools 50 | 51 | logger = None 52 | 53 | 54 | def main(): 55 | parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) 56 | parser.add_argument("msafile", help="Multiple Sequence Alignment file") 57 | parser.add_argument("msaformat", help="Multiple Sequence Alignment format") 58 | args = parser.parse_args() 59 | 60 | global logger 61 | logger = conkit.command_line.setup_logging(level="info") 62 | 63 | msa = conkit.io.read(args.msafile, args.msaformat) 64 | 65 | plot = args.msafile.rsplit(".", 1)[0] + ".png" 66 | figure = conkit.plot.SequenceCoverageFigure(msa, legend=True) 67 | figure.ax.set_aspect(conkit.plot.tools.get_adjusted_aspect(figure.ax, 0.3)) 68 | figure.savefig(plot) 69 | 70 | logger.info("Input MSA File: %s", args.msafile) 71 | logger.info("Input MSA Format: %s", args.msaformat) 72 | logger.info("Length of the Target Sequence: %d", msa.top_sequence.seq_len) 73 | logger.info("Total Number of Sequences: %d", msa.nseq) 74 | logger.info("Number of Effective Sequences: %d", msa.meff) 75 | logger.info("Sequence Coverage Plot: %s", plot) 76 | 77 | 78 | if __name__ == "__main__": 79 | import sys 80 | import traceback 81 | 82 | try: 83 | main() 84 | sys.exit(0) 85 | except Exception as e: 86 | if not isinstance(e, SystemExit): 87 | msg = "".join(traceback.format_exception(*sys.exc_info())) 88 | logger.critical(msg) 89 | sys.exit(1) 90 | -------------------------------------------------------------------------------- /conkit/core/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Core entities for hierarchy construction""" 33 | 34 | __author__ = "Felix Simkovic" 35 | __contributing_authors__ = "Jens Thomas" 36 | __date__ = "03 Aug 2016" 37 | __version__ = "0.13.3" 38 | 39 | 40 | def Contact(*args, **kwargs): 41 | """:obj:`Contact ` instance""" 42 | from conkit.core.contact import Contact 43 | 44 | return Contact(*args, **kwargs) 45 | 46 | 47 | def Distance(*args, **kwargs): 48 | """:obj:`Contact ` instance""" 49 | from conkit.core.distance import Distance 50 | 51 | return Distance(*args, **kwargs) 52 | 53 | 54 | def DistanceFile(*args, **kwargs): 55 | """:obj:`Contact ` instance""" 56 | from conkit.core.distancefile import DistanceFile 57 | 58 | return DistanceFile(*args, **kwargs) 59 | 60 | 61 | def Distogram(*args, **kwargs): 62 | """:obj:`Contact ` instance""" 63 | from conkit.core.distogram import Distogram 64 | 65 | return Distogram(*args, **kwargs) 66 | 67 | 68 | def ContactMap(*args, **kwargs): 69 | """:obj:`ContactMap ` instance""" 70 | from conkit.core.contactmap import ContactMap 71 | 72 | return ContactMap(*args, **kwargs) 73 | 74 | 75 | def ContactFile(*args, **kwargs): 76 | """:obj:`ContactFile ` instance""" 77 | from conkit.core.contactfile import ContactFile 78 | 79 | return ContactFile(*args, **kwargs) 80 | 81 | 82 | def Sequence(*args, **kwargs): 83 | """:obj:`Sequence ` instance""" 84 | from conkit.core.sequence import Sequence 85 | 86 | return Sequence(*args, **kwargs) 87 | 88 | 89 | def SequenceFile(*args, **kwargs): 90 | """:obj:`SequenceFile ` instance""" 91 | from conkit.core.sequencefile import SequenceFile 92 | 93 | return SequenceFile(*args, **kwargs) 94 | -------------------------------------------------------------------------------- /conkit/core/distancefile.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Distance prediction file container used throughout ConKit""" 33 | 34 | from conkit.core.contactfile import ContactFile 35 | 36 | 37 | class DistanceFile(ContactFile): 38 | """A distance file object representing a single distance prediction file. This class inherits methods and attributes 39 | from :obj:`~conkit.core.contactfile.ContactFile` 40 | 41 | 42 | Examples 43 | -------- 44 | >>> from conkit.core import Distogram, DistanceFile 45 | >>> distance_file = DistanceFile("example") 46 | >>> distance_file.add(Distogram("foo")) 47 | >>> distance_file.add(Distogram("bar")) 48 | >>> print(distance_file) 49 | DistanceFile(id="example" ndistograms=2) 50 | 51 | Attributes 52 | ---------- 53 | author : str 54 | The author of the :obj:`~conkit.core.contactfile.ContactFile` 55 | method : list, str 56 | The :obj:`~conkit.core.contactfile.ContactFile`-specific method 57 | remark : list, str 58 | The :obj:`~conkit.core.contactfile.ContactFile`-specific remarks 59 | target : str 60 | The target name 61 | top_map : :obj:`~conkit.core.contactmap.ContactMap` 62 | The first :obj:`~conkit.core.contactmap.ContactMap` entry in :obj:`~conkit.core.contactfile.ContactFile` 63 | original_file_format : str 64 | The original file format used to create the :obj:`~conkit.core.distogram.Distogram` instance 65 | 66 | """ 67 | 68 | __slots__ = ["author", "target", "_method", "_remark", "_original_file_format"] 69 | 70 | def __init__(self, id): 71 | """Initialise a new distance file""" 72 | self._original_file_format = None 73 | super(DistanceFile, self).__init__(id) 74 | 75 | def __repr__(self): 76 | return '{}(id="{}" ndistograms={})'.format(self.__class__.__name__, self.id, len(self)) 77 | 78 | @property 79 | def original_file_format(self): 80 | """The original file format used to create the :obj:`~conkit.core.distancefile.DistanceFile` instance""" 81 | return self._original_file_format 82 | 83 | @original_file_format.setter 84 | def original_file_format(self, value): 85 | self._original_file_format = value 86 | 87 | def add(self, entity): 88 | entity.original_file_format = self.original_file_format 89 | super(ContactFile, self).add(entity) 90 | -------------------------------------------------------------------------------- /conkit/core/ext/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Extensions to conkit.core package""" 33 | 34 | __author__ = "Felix Simkovic" 35 | __date__ = "03 May 2018" 36 | __version__ = "0.13.3" 37 | -------------------------------------------------------------------------------- /conkit/core/ext/c_contactmap.pyx: -------------------------------------------------------------------------------- 1 | #cython: boundscheck=False, wraparound=False 2 | 3 | cimport cython 4 | import numpy as np 5 | cimport numpy as np 6 | 7 | from libc.stdlib cimport abs 8 | 9 | np.import_array() 10 | 11 | 12 | def c_singletons(np.ndarray[np.int64_t, ndim=2] X, double threshold, np.ndarray[np.uint8_t, ndim=1, cast=True] throwables): 13 | cdef Py_ssize_t i, j 14 | for i in xrange(X.shape[0]): 15 | for j in xrange(i + 1, X.shape[0]): 16 | if throwables[j]: 17 | continue 18 | if abs(int(X[j, 0] - X[i, 0])) <= threshold and abs(int(X[j, 1] - X[i, 1])) <= threshold: 19 | throwables[i] = True 20 | throwables[j] = True 21 | -------------------------------------------------------------------------------- /conkit/core/ext/c_sequencefile.pyx: -------------------------------------------------------------------------------- 1 | #cython: boundscheck=False, cdivision=True, wraparound=False 2 | 3 | cimport cython 4 | import numpy as np 5 | cimport numpy as np 6 | 7 | from cython.parallel import prange 8 | 9 | np.import_array() 10 | 11 | 12 | def c_get_frequency(np.ndarray[np.int64_t, ndim=2] X, Py_ssize_t symbol, np.ndarray[np.int64_t, ndim=1] frequencies): 13 | cdef Py_ssize_t i, j 14 | for j in prange(X.shape[1], nogil=True): 15 | for i in xrange(X.shape[0]): 16 | frequencies[j] += X[i, j] == symbol 17 | 18 | 19 | def c_get_weights(np.ndarray[np.int64_t, ndim=2] X, double identity, np.ndarray[double, ndim=1] hamming): 20 | cdef Py_ssize_t i, j, k 21 | cdef double threshold, dist 22 | threshold = (1.0 - identity) * X.shape[1] 23 | for i in prange(X.shape[0], nogil=True): 24 | for j in xrange(X.shape[0]): 25 | dist = 0.0 26 | for k in xrange(X.shape[1]): 27 | dist += X[i, k] != X[j, k] 28 | hamming[i] += dist < threshold 29 | hamming[i] = 1.0 / hamming[i] 30 | 31 | 32 | def c_filter(np.ndarray[np.int64_t, ndim=2] X, double min_id, double max_id, np.ndarray[np.uint8_t, ndim=1, cast=True] throwables): 33 | cdef Py_ssize_t i, j, k 34 | cdef double dist 35 | for i in xrange(X.shape[0]): 36 | for j in xrange(i + 1, X.shape[0]): 37 | if not throwables[j]: 38 | dist = 0 39 | for k in xrange(X.shape[1]): 40 | dist += X[i, k] != X[j, k] 41 | ident = 1.0 - dist / X.shape[1] 42 | throwables[j] = (ident < min_id) or (ident > max_id) 43 | 44 | 45 | def c_filter_symbol(np.ndarray[np.int64_t, ndim=2] X, double min_prop, double max_prop, Py_ssize_t symbol, np.ndarray[np.uint8_t, ndim=1, cast=True] throwables): 46 | cdef Py_ssize_t i, k 47 | cdef double prop 48 | for i in xrange(X.shape[0]): 49 | prop = 0 50 | for k in xrange(X.shape[1]): 51 | prop += X[i, k] == symbol 52 | prop /= X.shape[1] 53 | throwables[i] = (prop < min_prop) or (prop > max_prop) 54 | -------------------------------------------------------------------------------- /conkit/core/mappings.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Mappings required for the core functionality""" 33 | 34 | from __future__ import division 35 | from __future__ import print_function 36 | 37 | __author__ = "Felix Simkovic" 38 | __date__ = "03 Aug 2016" 39 | __version__ = "0.13.3" 40 | 41 | from enum import Enum, unique 42 | 43 | 44 | class AminoAcidMapping(Enum): 45 | """Amino acid mapping to encode an alignment""" 46 | 47 | A = 1 48 | C = 2 49 | D = 3 50 | E = 4 51 | F = 5 52 | G = 6 53 | H = 7 54 | I = 8 55 | K = 9 56 | L = 10 57 | M = 11 58 | N = 12 59 | P = 13 60 | Q = 14 61 | R = 15 62 | S = 16 63 | T = 17 64 | V = 18 65 | W = 19 66 | X = 21 67 | Y = 20 68 | 69 | 70 | class AminoAcidOneToThree(Enum): 71 | """Amino acid mapping to convert one-letter codes to three-letter codes""" 72 | 73 | A = "ALA" 74 | C = "CYS" 75 | B = "ASX" 76 | E = "GLU" 77 | D = "ASP" 78 | G = "GLY" 79 | F = "PHE" 80 | I = "ILE" 81 | H = "HIS" 82 | K = "LYS" 83 | J = "XLE" 84 | M = "MET" 85 | L = "LEU" 86 | O = "PYL" 87 | N = "ASN" 88 | Q = "GLN" 89 | P = "PRO" 90 | S = "SER" 91 | R = "ARG" 92 | U = "SEC" 93 | T = "THR" 94 | W = "TRP" 95 | V = "VAL" 96 | Y = "TYR" 97 | X = "XAA" 98 | Z = "GLX" 99 | 100 | 101 | class AminoAcidThreeToOne(Enum): 102 | """Amino acid mapping to convert three-letter codes to one-letter codes""" 103 | 104 | ALA = "A" 105 | ARG = "R" 106 | ASN = "N" 107 | ASP = "D" 108 | CME = "C" 109 | CYS = "C" 110 | GLN = "Q" 111 | GLU = "E" 112 | GLY = "G" 113 | HIS = "H" 114 | ILE = "I" 115 | LEU = "L" 116 | LYS = "K" 117 | MET = "M" 118 | MSE = "M" 119 | PHE = "F" 120 | PRO = "P" 121 | PYL = "O" 122 | SER = "S" 123 | SEC = "U" 124 | THR = "T" 125 | TRP = "W" 126 | TYR = "Y" 127 | VAL = "V" 128 | ASX = "B" 129 | GLX = "Z" 130 | XAA = "X" 131 | UNK = "X" 132 | XLE = "J" 133 | 134 | 135 | @unique 136 | class ContactMatchState(Enum): 137 | """Enumerated class to store state constants for each contact""" 138 | 139 | unknown = 0 140 | true_positive = 1 141 | true_negative = 2 142 | false_positive = 3 143 | false_negative = 4 144 | 145 | 146 | @unique 147 | class SequenceAlignmentState(Enum): 148 | """Alignment states""" 149 | 150 | unknown = 0 151 | unaligned = 1 152 | aligned = 2 153 | -------------------------------------------------------------------------------- /conkit/core/struct.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Internal classes required by ConKit defining some sort of internal structure""" 31 | 32 | from __future__ import division 33 | from __future__ import print_function 34 | 35 | __author__ = "Felix Simkovic" 36 | __date__ = "03 Aug 2016" 37 | __version__ = "0.13.3" 38 | 39 | from collections import namedtuple 40 | 41 | Residue = namedtuple("Residue", ["res_seq", "res_altseq", "res_name", "res_chain"]) 42 | 43 | 44 | class Gap(namedtuple("Gap", Residue._fields)): 45 | IDENTIFIER = -999999 46 | 47 | 48 | Gap.__new__.__defaults__ = (Gap.IDENTIFIER, Gap.IDENTIFIER, "X", "") 49 | -------------------------------------------------------------------------------- /conkit/core/tests/test_distancefile.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.core.DistanceFile""" 2 | 3 | 4 | import unittest 5 | 6 | from conkit.core.distogram import Distogram 7 | from conkit.core.distancefile import DistanceFile 8 | 9 | 10 | class TestDistanceFile(unittest.TestCase): 11 | 12 | def test_original_file_format(self): 13 | distance_file = DistanceFile("test") 14 | distance_file.original_file_format = "pdb" 15 | distogram = Distogram("test") 16 | distance_file.add(distogram) 17 | self.assertTrue(distogram in distance_file.child_list) 18 | self.assertEqual("pdb", distogram.original_file_format) 19 | -------------------------------------------------------------------------------- /conkit/core/tests/test_mappings.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.core.mappings""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "16 Mar 2018" 5 | 6 | import unittest 7 | 8 | from conkit.core.mappings import AminoAcidMapping, AminoAcidThreeToOne, AminoAcidOneToThree 9 | 10 | 11 | class AminoAcidMappingTest(unittest.TestCase): 12 | def test_A_1(self): 13 | self.assertEqual(1, AminoAcidMapping["A"].value) 14 | 15 | def test_C_1(self): 16 | self.assertEqual(2, AminoAcidMapping["C"].value) 17 | 18 | def test_D_1(self): 19 | self.assertEqual(3, AminoAcidMapping["D"].value) 20 | 21 | def test_E_1(self): 22 | self.assertEqual(4, AminoAcidMapping["E"].value) 23 | 24 | def test_F_1(self): 25 | self.assertEqual(5, AminoAcidMapping["F"].value) 26 | 27 | def test_G_1(self): 28 | self.assertEqual(6, AminoAcidMapping["G"].value) 29 | 30 | def test_H_1(self): 31 | self.assertEqual(7, AminoAcidMapping["H"].value) 32 | 33 | def test_I_1(self): 34 | self.assertEqual(8, AminoAcidMapping["I"].value) 35 | 36 | def test_K_1(self): 37 | self.assertEqual(9, AminoAcidMapping["K"].value) 38 | 39 | def test_L_1(self): 40 | self.assertEqual(10, AminoAcidMapping["L"].value) 41 | 42 | def test_M_1(self): 43 | self.assertEqual(11, AminoAcidMapping["M"].value) 44 | 45 | def test_N_1(self): 46 | self.assertEqual(12, AminoAcidMapping["N"].value) 47 | 48 | def test_P_1(self): 49 | self.assertEqual(13, AminoAcidMapping["P"].value) 50 | 51 | def test_Q_1(self): 52 | self.assertEqual(14, AminoAcidMapping["Q"].value) 53 | 54 | def test_R_1(self): 55 | self.assertEqual(15, AminoAcidMapping["R"].value) 56 | 57 | def test_S_1(self): 58 | self.assertEqual(16, AminoAcidMapping["S"].value) 59 | 60 | def test_T_1(self): 61 | self.assertEqual(17, AminoAcidMapping["T"].value) 62 | 63 | def test_V_1(self): 64 | self.assertEqual(18, AminoAcidMapping["V"].value) 65 | 66 | def test_W_1(self): 67 | self.assertEqual(19, AminoAcidMapping["W"].value) 68 | 69 | def test_X_1(self): 70 | self.assertEqual(21, AminoAcidMapping["X"].value) 71 | 72 | def test_Y_1(self): 73 | self.assertEqual(20, AminoAcidMapping["Y"].value) 74 | 75 | def test_Z_1(self): 76 | self.assertEqual(21, getattr(AminoAcidMapping, "Z", AminoAcidMapping.X.value)) 77 | 78 | 79 | class AminoAcidThreeToOneTest(unittest.TestCase): 80 | def test_single_1(self): 81 | self.assertTrue("ALA" in AminoAcidThreeToOne.__members__) 82 | 83 | def test_single_2(self): 84 | self.assertFalse("ala" in AminoAcidThreeToOne.__members__) 85 | 86 | def test_single_3(self): 87 | self.assertFalse("Ala" in AminoAcidThreeToOne.__members__) 88 | 89 | def test_single_4(self): 90 | self.assertEqual("A", AminoAcidThreeToOne.ALA.value) 91 | 92 | def test_single_5(self): 93 | self.assertEqual("A", AminoAcidThreeToOne["ALA"].value) 94 | 95 | 96 | class AminoAcidOneToThreeTest(unittest.TestCase): 97 | def test_single_1(self): 98 | self.assertTrue("A" in AminoAcidOneToThree.__members__) 99 | 100 | def test_single_2(self): 101 | self.assertFalse("a" in AminoAcidOneToThree.__members__) 102 | 103 | def test_single_3(self): 104 | self.assertEqual("ALA", AminoAcidOneToThree.A.value) 105 | 106 | def test_single_4(self): 107 | self.assertEqual("ALA", AminoAcidOneToThree["A"].value) 108 | 109 | 110 | if __name__ == "__main__": 111 | unittest.main(verbosity=2) 112 | -------------------------------------------------------------------------------- /conkit/io/_parser.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parent classes for all parser classes 32 | """ 33 | 34 | __author__ = "Felix Simkovic" 35 | __date__ = "04 Oct 2016" 36 | __version__ = "0.13.3" 37 | 38 | import abc 39 | 40 | ABC = abc.ABCMeta("ABC", (object,), {}) 41 | 42 | from conkit.core.contact import Contact 43 | from conkit.core.contactmap import ContactMap 44 | from conkit.core.contactfile import ContactFile 45 | from conkit.core.sequence import Sequence 46 | from conkit.core.sequencefile import SequenceFile 47 | 48 | 49 | class Parser(ABC): 50 | """Abstract class for all parsers 51 | 52 | """ 53 | 54 | @abc.abstractmethod 55 | def read(self): 56 | pass 57 | 58 | @abc.abstractmethod 59 | def write(self): 60 | pass 61 | 62 | @classmethod 63 | def _reconstruct(cls, hierarchy): 64 | """Wrapper to re-construct full hierarchy when parts are provided""" 65 | if isinstance(hierarchy, ContactFile): 66 | h = hierarchy 67 | elif isinstance(hierarchy, ContactMap): 68 | h = ContactFile("conkit") 69 | h.add(hierarchy) 70 | elif isinstance(hierarchy, Contact): 71 | h = ContactFile("conkit") 72 | m = ContactMap("1") 73 | m.add(hierarchy) 74 | h.add(m) 75 | elif isinstance(hierarchy, SequenceFile): 76 | h = hierarchy 77 | elif isinstance(hierarchy, Sequence): 78 | h = SequenceFile("conkit") 79 | h.add(hierarchy) 80 | return h 81 | 82 | 83 | class ContactFileParser(Parser): 84 | """General purpose class for all contact file parsers""" 85 | 86 | pass 87 | 88 | 89 | class DistanceFileParser(Parser): 90 | """General purpose class for all distance prediction file parsers""" 91 | 92 | pass 93 | 94 | 95 | class BinaryDistanceFileParser(Parser): 96 | """General purpose class for all binary distance prediction file parsers""" 97 | 98 | pass 99 | 100 | 101 | class SequenceFileParser(Parser): 102 | """General purpose class for all sequence file parsers""" 103 | 104 | pass 105 | -------------------------------------------------------------------------------- /conkit/io/a2m.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to HH-suite A2M sequence files 32 | 33 | """ 34 | 35 | __author__ = "Felix Simkovic" 36 | __date__ = "30 Jul 2018" 37 | __version__ = "0.13.3" 38 | 39 | from conkit.io._parser import SequenceFileParser 40 | from conkit.core.sequence import Sequence 41 | from conkit.core.sequencefile import SequenceFile 42 | 43 | 44 | class A2mParser(SequenceFileParser): 45 | """Parser class for A2M sequence files 46 | 47 | """ 48 | 49 | def __init__(self): 50 | super(A2mParser, self).__init__() 51 | 52 | def read(self, f_handle, f_id="a2m"): 53 | """Read a sequence file 54 | 55 | Parameters 56 | ---------- 57 | f_handle 58 | Open file handle [read permissions] 59 | f_id : str, optional 60 | Unique sequence file identifier 61 | 62 | Returns 63 | ------- 64 | :obj:`~conkit.core.sequencefile.SequenceFile` 65 | 66 | """ 67 | hierarchy = SequenceFile(f_id) 68 | for i, line in enumerate(f_handle): 69 | line = line.strip() 70 | if line: 71 | for j, char in enumerate(line): 72 | if char.isalpha() or char == "-": 73 | continue 74 | indicator = ["-"] * len(line) 75 | indicator[j] = "^" 76 | msg = "Unknown character in line {0}:{1}{1}{2}{1}{3}" 77 | msg = msg.format(i + 1, "\n", line, "".join(indicator)) 78 | raise ValueError(msg) 79 | sequence = Sequence("seq_{}".format(i), line) 80 | hierarchy.add(sequence) 81 | return hierarchy 82 | 83 | def write(self, f_handle, hierarchy): 84 | """Write a sequence file instance to to file 85 | 86 | Parameters 87 | ---------- 88 | f_handle 89 | Open file handle [write permissions] 90 | hierarchy : :obj:`~conkit.core.sequencefile.SequenceFile` or :obj:`~conkit.core.sequence.Sequence` 91 | 92 | """ 93 | sequence_file = self._reconstruct(hierarchy) 94 | content = "" 95 | for sequence_entry in sequence_file: 96 | content += sequence_entry.seq + "\n" 97 | f_handle.write(content) 98 | -------------------------------------------------------------------------------- /conkit/io/aleigen.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to al-eigen map files 32 | """ 33 | 34 | from conkit.io._parser import ContactFileParser 35 | from conkit.core.contact import Contact 36 | from conkit.core.contactmap import ContactMap 37 | from conkit.core.contactfile import ContactFile 38 | 39 | 40 | class AleigenParser(ContactFileParser): 41 | """Class to parse a al-eigen map file 42 | """ 43 | 44 | def read(self, f_handle, f_id="map_align"): 45 | """Read a contact file 46 | 47 | Parameters 48 | ---------- 49 | f_handle 50 | Open file handle [read permissions] 51 | f_id : str, optional 52 | Unique contact file identifier 53 | Returns 54 | ------- 55 | :obj:`~conkit.core.contactfile.ContactFile` 56 | """ 57 | 58 | hierarchy = ContactFile(f_id) 59 | _map = ContactMap("map_1") 60 | hierarchy.add(_map) 61 | 62 | for line in f_handle: 63 | line = line.strip().split() 64 | 65 | if len(line) == 2 and line[0].isdigit() and line[1].isdigit(): 66 | # Al-eigen has no score field so we assume score=0.5 67 | _contact = Contact(int(line[0]), int(line[1]), 0.5) 68 | _map.add(_contact) 69 | 70 | hierarchy.method = "Contact map compatible with Al-Eigen" 71 | 72 | return hierarchy 73 | 74 | def write(self, f_handle, hierarchy): 75 | """Write a contact file instance to a file 76 | 77 | Parameters 78 | ---------- 79 | f_handle 80 | Open file handle [write permissions] 81 | hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap` 82 | or :obj:`~conkit.core.contact.Contact` 83 | Raises 84 | ------ 85 | :exc:`RuntimeError` 86 | More than one contact map in the hierarchy 87 | """ 88 | contact_file = self._reconstruct(hierarchy) 89 | if len(contact_file) > 1: 90 | raise RuntimeError("More than one contact map provided") 91 | cmap = contact_file.top_map 92 | content = "{}\n".format(cmap.highest_residue_number) 93 | line_template = "{} {}\n" 94 | for contact in cmap: 95 | content += line_template.format(contact.res1_seq, contact.res2_seq) 96 | f_handle.write(content) 97 | -------------------------------------------------------------------------------- /conkit/io/alphafold.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to AF2 distance predictions 32 | """ 33 | 34 | import numpy as np 35 | from scipy.special import softmax 36 | from conkit.io._parser import BinaryDistanceFileParser 37 | from conkit.core.distance import Distance 38 | from conkit.core.distogram import Distogram 39 | from conkit.core.distancefile import DistanceFile 40 | 41 | 42 | class AlphaFold2Parser(BinaryDistanceFileParser): 43 | """Parser class for AF2 distance prediction file""" 44 | 45 | def read(self, f_handle, f_id="alphafold2"): 46 | """Read a distance prediction file 47 | 48 | Parameters 49 | ---------- 50 | f_handle 51 | Open file handle [read permissions] 52 | f_id : str, optional 53 | Unique contact file identifier 54 | 55 | Returns 56 | ------- 57 | :obj:`~conkit.core.distancefile.DistanceFile` 58 | 59 | """ 60 | 61 | hierarchy = DistanceFile(f_id) 62 | hierarchy.original_file_format = "alphafold2" 63 | _map = Distogram("distogram_1") 64 | hierarchy.add(_map) 65 | 66 | prediction = np.load(f_handle, allow_pickle=True) 67 | predicted_distogram = prediction['distogram'] 68 | probs = softmax(predicted_distogram['logits'], axis=-1) 69 | bin_edges = predicted_distogram['bin_edges'] 70 | 71 | distance_bins = [(0, bin_edges[0])] 72 | distance_bins += [(bin_edges[idx], bin_edges[idx + 1]) for idx in range(len(bin_edges) - 1)] 73 | distance_bins.append((bin_edges[-1], np.inf)) 74 | distance_bins = tuple(distance_bins) 75 | L = probs.shape[0] 76 | for i in range(L): 77 | for j in range(i, L): 78 | _distance = Distance(i + 1, j + 1, tuple(probs[i, j, :].tolist()), distance_bins) 79 | _map.add(_distance) 80 | 81 | return hierarchy 82 | 83 | def write(self, f_handle, hierarchy): 84 | """Write a distance file instance to a file 85 | 86 | Raises 87 | ------ 88 | :exc:`NotImplementedError` 89 | Write function not available 90 | 91 | """ 92 | raise NotImplementedError("Write function not available yet") 93 | -------------------------------------------------------------------------------- /conkit/io/bclcontact.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to BCL::Contact predictions 32 | """ 33 | 34 | __author__ = "Felix Simkovic" 35 | __date__ = "12 Dec 2016" 36 | __version__ = "0.13.3" 37 | 38 | import re 39 | 40 | from conkit.io._parser import ContactFileParser 41 | from conkit.core.contact import Contact 42 | from conkit.core.contactmap import ContactMap 43 | from conkit.core.contactfile import ContactFile 44 | 45 | RE_SPLIT = re.compile(r"\s+") 46 | 47 | 48 | class BCLContactParser(ContactFileParser): 49 | """Class to parse a BCL::Contact contact file 50 | """ 51 | 52 | def __init__(self): 53 | super(BCLContactParser, self).__init__() 54 | 55 | def read(self, f_handle, f_id="bclcontact"): 56 | """Read a contact file 57 | 58 | Parameters 59 | ---------- 60 | f_handle 61 | Open file handle [read permissions] 62 | f_id : str, optional 63 | Unique contact file identifier 64 | 65 | Returns 66 | ------- 67 | :obj:`~conkit.core.contactfile.ContactFile` 68 | 69 | """ 70 | 71 | hierarchy = ContactFile(f_id) 72 | contact_map = ContactMap("map_1") 73 | hierarchy.add(contact_map) 74 | 75 | for line in f_handle: 76 | line = line.rstrip() 77 | if line: 78 | res1_seq, res1, res2_seq, res2, _, _, _, _, _, raw_score = RE_SPLIT.split(line) 79 | contact = Contact(int(res1_seq), int(res2_seq), float(raw_score)) 80 | contact.res1 = res1 81 | contact.res2 = res2 82 | contact_map.add(contact) 83 | 84 | hierarchy.method = "Contact map predicted using BCL::Contact" 85 | return hierarchy 86 | 87 | def write(self, f_handle, hierarchy): 88 | """Write a contact file instance to to file 89 | 90 | Parameters 91 | ---------- 92 | f_handle 93 | Open file handle [write permissions] 94 | hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap` 95 | or :obj:`~conkit.core.contact.Contact` 96 | 97 | Raises 98 | ------ 99 | :exc:`NotImplementedError` 100 | Write function not available 101 | 102 | """ 103 | raise NotImplementedError("Write function not available") 104 | -------------------------------------------------------------------------------- /conkit/io/mapalign.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to map_align map files 32 | """ 33 | 34 | from conkit.io._parser import ContactFileParser 35 | from conkit.core.contact import Contact 36 | from conkit.core.contactmap import ContactMap 37 | from conkit.core.contactfile import ContactFile 38 | 39 | 40 | class MapAlignParser(ContactFileParser): 41 | """Class to parse a map_align map file 42 | """ 43 | 44 | def read(self, f_handle, f_id="map_align"): 45 | """Read a contact file 46 | 47 | Parameters 48 | ---------- 49 | f_handle 50 | Open file handle [read permissions] 51 | f_id : str, optional 52 | Unique contact file identifier 53 | 54 | Returns 55 | ------- 56 | :obj:`~conkit.core.contactfile.ContactFile` 57 | 58 | """ 59 | 60 | hierarchy = ContactFile(f_id) 61 | _map = ContactMap("map_1") 62 | hierarchy.add(_map) 63 | 64 | for line in f_handle: 65 | line = line.strip().split() 66 | 67 | if line[0] == "CON" and line[1].isdigit() and line[2].isdigit(): 68 | _contact = Contact(int(line[1]), int(line[2]), float(line[3])) 69 | _map.add(_contact) 70 | 71 | hierarchy.method = "Contact map compatible with map_algin" 72 | 73 | return hierarchy 74 | 75 | def write(self, f_handle, hierarchy): 76 | """Write a contact file instance to a file 77 | 78 | Parameters 79 | ---------- 80 | f_handle 81 | Open file handle [write permissions] 82 | hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap` 83 | or :obj:`~conkit.core.contact.Contact` 84 | 85 | Raises 86 | ------ 87 | :exc:`RuntimeError` 88 | More than one contact map in the hierarchy 89 | 90 | """ 91 | contact_file = self._reconstruct(hierarchy) 92 | if len(contact_file) > 1: 93 | raise RuntimeError("More than one contact map provided") 94 | cmap = contact_file.top_map 95 | content = "LEN {}\n".format(cmap.highest_residue_number) 96 | line_template = "CON {} {} {:.6f}\n" 97 | for contact in cmap: 98 | content += line_template.format(contact.res1_seq, contact.res2_seq, contact.raw_score) 99 | f_handle.write(content) 100 | -------------------------------------------------------------------------------- /conkit/io/rosetta.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | # 3 | # Copyright (c) 2017-18 Felix Simkovic 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | __author__ = "Felix Simkovic" 24 | __date__ = "13 Aug 2018" 25 | __version__ = "0.13.3" 26 | 27 | from conkit.io._parser import ContactFileParser 28 | from conkit.misc.distances import DynamicDistances 29 | from conkit.misc.energyfunction import RosettaFunctionConstructs 30 | 31 | 32 | class RosettaParser(ContactFileParser): 33 | """Implementation of a ROSETTA restraint file parser""" 34 | 35 | def read(self, f_handle, f_id="rosetta"): 36 | """Read a contact file into a :obj:`~conkit.core.contactfile.ContactFile` instance 37 | 38 | Parameters 39 | ---------- 40 | f_handle 41 | Open file handle [read permissions] 42 | f_id : str, optional 43 | Unique contact file identifier 44 | 45 | Returns 46 | ------- 47 | :obj:`~conkit.core.contactfile.ContactFile` 48 | 49 | Raises 50 | ------ 51 | :exc:`NotImplementedError` 52 | 53 | """ 54 | raise NotImplementedError 55 | 56 | def write(self, f_handle, hierarchy, efunc="FADE"): 57 | """Write a contact file instance to to file 58 | 59 | Parameters 60 | ---------- 61 | f_handle 62 | Open file handle [write permissions] 63 | hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap` 64 | or :obj:`~conkit.core.contact.Contact` 65 | efunc : str, optional 66 | The output format 67 | 68 | """ 69 | if not hasattr(RosettaFunctionConstructs, efunc): 70 | raise ValueError("Unknown Rosetta energy function: {}".format(efunc)) 71 | contact_file = self._reconstruct(hierarchy) 72 | construct = getattr(RosettaFunctionConstructs, efunc).fget(RosettaFunctionConstructs) 73 | for contact in contact_file.top: 74 | contact_dict = contact._to_dict() 75 | contact_dict["atom1"] = "CA" if contact.res1 == "G" else "CB" 76 | contact_dict["atom2"] = "CA" if contact.res2 == "G" else "CB" 77 | contact_dict["energy_bonus"] = contact.weight * 15.00 78 | contact_dict["scalar_score"] = contact.scalar_score * contact.weight 79 | contact_dict["sigmoid_cutoff"] = DynamicDistances.cutoff(contact.res1, contact.res2) 80 | contact_dict["sigmoid_slope"] = 1.0 / DynamicDistances.percentile(contact.res1, contact.res2) 81 | f_handle.write(construct.format(**contact_dict) + "\n") 82 | -------------------------------------------------------------------------------- /conkit/io/rosetta_npz.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | Parser module specific to rosetta NPZ distance predictions 32 | """ 33 | 34 | import numpy as np 35 | from conkit.io._parser import BinaryDistanceFileParser 36 | from conkit.core.distance import Distance 37 | from conkit.core.distogram import Distogram 38 | from conkit.core.distancefile import DistanceFile 39 | 40 | DISTANCE_BINS = ((0, 2), (2, 2.5), (2.5, 3), (3, 4), (4, 4.5), (4.5, 5), (5, 5.5), (5.5, 6), (6, 6.5), (6.5, 7), 41 | (7, 7.5), (7.5, 8), (8, 8.5), (8.5, 9), (9, 9.5), (9.5, 10), (10, 10.5), (10.5, 11), (11, 11.5), 42 | (11.5, 12), (12, 12.5), (12.5, 13), (13, 13.5), (13.5, 14), (14, 14.5), (14.5, 15), (15, 15.5), 43 | (15.5, 16), (16, 16.5), (16.5, 17), (17, 17.5), (17.5, 18), (18, 18.5), (18.5, 19), (19, 19.5), 44 | (19.5, 20), (20, np.inf)) 45 | 46 | 47 | class RosettaNpzParser(BinaryDistanceFileParser): 48 | """Parser class for rosetta NPZ distance prediction file""" 49 | 50 | def read(self, f_handle, f_id="rosettanpz"): 51 | """Read a distance prediction file 52 | 53 | Parameters 54 | ---------- 55 | f_handle 56 | Open file handle [read permissions] 57 | f_id : str, optional 58 | Unique contact file identifier 59 | 60 | Returns 61 | ------- 62 | :obj:`~conkit.core.distancefile.DistanceFile` 63 | 64 | """ 65 | 66 | hierarchy = DistanceFile(f_id) 67 | hierarchy.original_file_format = "rosettanpz" 68 | _map = Distogram("distogram_1") 69 | hierarchy.add(_map) 70 | 71 | prediction = np.load(f_handle, allow_pickle=True) 72 | probs = prediction['dist'] 73 | # Bin #0 corresponds with d>20A & bins #1 ~ #36 correspond with 2Aheader1 39 | GSMFTPKPPQDSAVI--GYCVKQGAVMKNWKRRY--LDENTIGYF 40 | >header2 41 | EVHK--ECKQSDIMMRD--FEIVTTSRTFYVQADSPEEMHSWIKA 42 | >header3 43 | EVHKVQECK--DIMMRDNLFEI--TSRTFWKRRY--LDENTIGYF 44 | >header4 45 | EVHKVQECK--DIMMRDNLFEI--TSRTF--RRY--LDENTIGYF 46 | """ 47 | f_name = self.tempfile(content=msa) 48 | with open(f_name, "r") as f_in: 49 | with self.assertRaises(ValueError): 50 | A2mParser().read(f_in) 51 | 52 | def test_write_1(self): 53 | msa = [ 54 | "GSMFTPKPPQDSAVI--GYCVKQGAVMKNWKRRY--LDENTIGYF", 55 | "EVHK--ECKQSDIMMRD--FEIVTTSRTFYVQADSPEEMHSWIKA", 56 | "EVHKVQECK--DIMMRDNLFEI--TSRTFWKRRY--LDENTIGYF", 57 | "EVHKVQECK--DIMMRDNLFEI--TSRTF--RRY--LDENTIGYF", 58 | ] 59 | f_name_in = self.tempfile(content='\n'.join(msa)) 60 | f_name_out = self.tempfile() 61 | with open(f_name_in, "r") as f_in, open(f_name_out, "w") as f_out: 62 | sequence_file = A2mParser().read(f_in) 63 | A2mParser().write(f_out, sequence_file) 64 | with open(f_name_out, "r") as f_in: 65 | output = f_in.read().splitlines() 66 | self.assertEqual(msa, output) 67 | 68 | 69 | if __name__ == "__main__": 70 | unittest.main(verbosity=2) 71 | -------------------------------------------------------------------------------- /conkit/io/tests/test_aleigen.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.aleigen""" 2 | 3 | import os 4 | import unittest 5 | 6 | from conkit.core.contact import Contact 7 | from conkit.core.contactfile import ContactFile 8 | from conkit.core.contactmap import ContactMap 9 | from conkit.core.sequence import Sequence 10 | from conkit.io.aleigen import AleigenParser 11 | from conkit.io.tests.helpers import ParserTestCase 12 | 13 | 14 | class TestAleigenParser(ParserTestCase): 15 | def test_read_1(self): 16 | content = """77 17 | 10 14 18 | 1 7 19 | 10 13 20 | 6 9 21 | 5 71 22 | 36 42 23 | 1 73 24 | 33 37 25 | 21 68 26 | 38 57 27 | """ 28 | f_name = self.tempfile(content=content) 29 | with open(f_name, "r") as f_in: 30 | contact_file = AleigenParser().read(f_in) 31 | contact_map1 = contact_file.top_map 32 | self.assertEqual(1, len(contact_file)) 33 | self.assertEqual(10, len(contact_map1)) 34 | self.assertEqual([10, 1, 10, 6, 5, 36, 1, 33, 21, 38], [c.res1_seq for c in contact_map1]) 35 | self.assertEqual([14, 7, 13, 9, 71, 42, 73, 37, 68, 57], [c.res2_seq for c in contact_map1]) 36 | self.assertEqual([0.5 for x in range(0, 10)], [c.raw_score for c in contact_map1]) 37 | 38 | def test_write_1(self): 39 | contact_file = ContactFile("RR") 40 | contact_file.target = "R9999" 41 | contact_file.author = "1234-5678-9000" 42 | contact_file.remark = ["Predictor remarks"] 43 | contact_file.method = ["Description of methods used", "Description of methods used"] 44 | contact_map = ContactMap("1") 45 | contact_file.add(contact_map) 46 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 47 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 48 | contact_map.add(contact) 49 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 50 | contact_map.set_sequence_register() 51 | f_name = self.tempfile() 52 | with open(f_name, "w") as f_out: 53 | AleigenParser().write(f_out, contact_file) 54 | content = ["12", "1 9", "1 10", "2 8", "3 12"] 55 | with open(f_name, "r") as f_in: 56 | output = f_in.read().splitlines() 57 | self.assertEqual(content, output) 58 | 59 | 60 | if __name__ == "__main__": 61 | unittest.main(verbosity=2) 62 | -------------------------------------------------------------------------------- /conkit/io/tests/test_alphafold.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.AlphaFold2Parser""" 2 | 3 | import numpy as np 4 | import pickle 5 | from conkit.core.distancefile import DistanceFile 6 | from conkit.core.distogram import Distogram 7 | from conkit.io.alphafold import AlphaFold2Parser 8 | from conkit.io.tests.helpers import ParserTestCase 9 | 10 | 11 | class TestAlphaFold2Parser(ParserTestCase): 12 | 13 | def test_read_1(self): 14 | np.random.seed(41) 15 | prediction = {'distogram': { 16 | 'bin_edges': np.array([2.3125, 2.625, 2.9375, 3.25, 3.5625, 3.875, 4.1875, 4.5, 4.8125, 5.125, 5.4375, 5.75, 17 | 6.0625, 6.375, 6.6875, 6.9999995, 7.3125, 7.625, 7.9375, 8.25, 8.5625, 8.875, 9.1875, 18 | 9.5, 9.812499, 10.124999, 10.4375, 10.75, 11.0625, 11.375, 11.687499, 12., 12.3125, 19 | 12.625, 12.9375, 13.25, 13.5625, 13.874999, 14.187501, 14.499999, 14.812499, 20 | 15.124999, 15.437499, 15.75, 16.0625, 16.375, 16.687502, 16.999998, 17.312498, 21 | 17.624998, 17.937498, 18.25, 18.5625, 18.875, 19.1875, 19.5, 19.8125, 20.125, 22 | 20.437498, 20.75, 21.062498, 21.374998, 21.6875]), 23 | 'logits': np.array([[np.random.dirichlet(np.ones(64)).tolist() for x in range(5)] for x in range(5)]) 24 | }} 25 | 26 | f_name = self.tempfile(content=None) 27 | with open(f_name, 'wb') as fhandle: 28 | pickle.dump(prediction, fhandle) 29 | with open(f_name, "rb") as fhandle: 30 | distancefile = AlphaFold2Parser().read(fhandle) 31 | 32 | self.assertIsInstance(distancefile, DistanceFile) 33 | self.assertEqual(1, len(distancefile)) 34 | distogram = distancefile.top 35 | self.assertEqual('alphafold2', distogram.original_file_format) 36 | self.assertIsInstance(distogram, Distogram) 37 | self.assertEqual(15, len(distogram)) 38 | 39 | expected_res1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5] 40 | expected_res2 = [1, 2, 3, 4, 5, 2, 3, 4, 5, 3, 4, 5, 4, 5, 5] 41 | expected_raw_score = [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3] 42 | expected_bin_distance = [(12.625, 12.9375), (19.5, 19.8125), (16.0625, 16.375), (21.062498, 21.374998), 43 | (6.9999995, 7.3125), (10.124999, 10.4375), (7.9375, 8.25), (14.499999, 14.812499), 44 | (16.687502, 16.999998), (8.25, 8.5625), (5.125, 5.4375), (20.75, 21.062498), 45 | (6.375, 6.6875), (18.5625, 18.875), (7.9375, 8.25)] 46 | expected_bin_score = [0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02] 47 | 48 | self.assertListEqual(expected_res1, [distance.res1_seq for distance in distogram]) 49 | self.assertListEqual(expected_res2, [distance.res2_seq for distance in distogram]) 50 | self.assertListEqual(expected_raw_score, [round(contact.raw_score, 2) for contact in distogram]) 51 | self.assertListEqual(expected_bin_score, [round(distance.max_score, 2) for distance in distogram]) 52 | self.assertListEqual(expected_bin_distance, [distance.predicted_distance_bin for distance in distogram]) 53 | -------------------------------------------------------------------------------- /conkit/io/tests/test_bbcontacts.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.Bbcontacts""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.io.bbcontacts import BbcontactsParser 10 | from conkit.io.tests.helpers import ParserTestCase 11 | 12 | 13 | class TestBbcontactsParser(ParserTestCase): 14 | def test_read_1(self): 15 | content = """#identifier diversity direction viterbiscore indexpred state res1 res2 16 | 1EAZ 0.65 Antiparallel 9.860725 1 first 29 24 17 | 1EAZ 0.65 Antiparallel 9.860725 1 internal 30 23 18 | 1EAZ 0.65 Antiparallel 9.860725 1 last 31 22 19 | 1EAZ 0.65 Parallel -6.855870 29 first 87 54 20 | 1EAZ 0.65 Parallel -6.855870 29 internal 88 55 21 | 1EAZ 0.65 Parallel -6.855870 29 last 89 56 22 | """ 23 | f_name = self.tempfile(content=content) 24 | with open(f_name, "r") as f_in: 25 | contact_file = BbcontactsParser().read(f_in) 26 | contact_map1 = contact_file.top_map 27 | self.assertEqual(1, len(contact_file)) 28 | self.assertEqual(6, len(contact_map1)) 29 | self.assertEqual([24, 23, 22, 54, 55, 56], [c.res1_seq for c in contact_map1]) 30 | self.assertEqual([29, 30, 31, 87, 88, 89], [c.res2_seq for c in contact_map1]) 31 | self.assertEqual( 32 | sorted([9.860725, 9.860725, 9.860725, -6.855870, -6.855870, -6.855870]), 33 | sorted([c.raw_score for c in contact_map1]), 34 | ) 35 | 36 | def test_read_2(self): 37 | content = """#identifier diversity direction viterbiscore indexpred state res1 res2 38 | 1EAZ 0.65 Antiparallel 9.860725 1 first 29 24 39 | 1EAZ 0.65 Antiparallel 9.860725 1 last 30 23 40 | 1EAZ 0.65 Parallel -6.855870 29 first 87 54 41 | """ 42 | f_name = self.tempfile(content=content) 43 | with open(f_name, "r") as f_in: 44 | contact_file = BbcontactsParser().read(f_in, del_one_two=True) 45 | contact_map1 = contact_file.top_map 46 | self.assertEqual(1, len(contact_file)) 47 | self.assertEqual(0, len(contact_map1)) 48 | 49 | def test_read_3(self): 50 | content = """#identifier diversity direction viterbiscore indexpred state res1 res2 51 | 1EAZ 0.65 Antiparallel 9.860725 1 first 29 24 52 | 1EAZ 0.65 Antiparallel 9.860725 1 internal 30 23 53 | 1EAZ 0.65 Antiparallel 9.860725 1 last 31 22 54 | 1EAZ 0.65 Parallel -6.855870 29 first 87 54 55 | 1EAZ 0.65 Parallel -6.855870 29 internal 88 55 56 | 1EAZ 0.65 Parallel -6.855870 29 last 89 56 57 | 1EAZ 0.65 Antiparallel 0.000000 1 first 100 24 58 | 1EAZ 0.65 Antiparallel 0.000000 1 last 101 23 59 | 1EAZ 0.65 Parallel 0.000000 29 first 100 15 60 | """ 61 | f_name = self.tempfile(content=content) 62 | with open(f_name, "r") as f_in: 63 | contact_file = BbcontactsParser().read(f_in, del_one_two=False) 64 | contact_map1 = contact_file.top_map 65 | self.assertEqual(1, len(contact_file)) 66 | self.assertEqual(9, len(contact_map1)) 67 | self.assertEqual([24, 23, 22, 54, 55, 56, 24, 23, 15], [c.res1_seq for c in contact_map1]) 68 | self.assertEqual([29, 30, 31, 87, 88, 89, 100, 101, 100], [c.res2_seq for c in contact_map1]) 69 | self.assertEqual( 70 | sorted([9.860725, 9.860725, 9.860725, -6.855870, -6.855870, -6.855870, 0.0, 0.0, 0.0]), 71 | sorted([c.raw_score for c in contact_map1]), 72 | ) 73 | 74 | 75 | if __name__ == "__main__": 76 | unittest.main(verbosity=2) 77 | -------------------------------------------------------------------------------- /conkit/io/tests/test_bclcontact.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.BCLContactIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "12 Dec 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.io.bclcontact import BCLContactParser 10 | from conkit.io.tests.helpers import ParserTestCase 11 | 12 | 13 | class TestBCLContactParser(ParserTestCase): 14 | def test_read_1(self): 15 | content = """5 I 9 Q 0.000 0.286 0.185 0.836 0.875 0.749 16 | 5 I 10 R 0.000 0.000 0.105 0.875 0.482 0.634 17 | 5 I 11 I 0.000 0.178 0.066 0.730 0.876 0.727 18 | 5 I 21 I 0.030 0.021 0.233 0.645 0.733 0.557 19 | 5 I 58 G 0.000 0.054 0.010 0.642 0.799 0.535 20 | 6 T 62 V 0.000 0.000 0.027 0.485 0.428 0.585 21 | 6 T 63 S 0.000 0.004 0.051 0.547 0.387 0.529 22 | 6 T 78 L 0.000 0.000 0.039 0.624 0.384 0.581 23 | 6 T 79 T 0.000 0.000 0.036 0.657 0.415 0.679 24 | 6 T 80 I 0.000 0.076 0.003 0.513 0.386 0.578 25 | 6 T 94 Q 0.000 0.068 0.041 0.534 0.489 0.679 26 | """ 27 | f_name = self.tempfile(content=content) 28 | with open(f_name, "r") as f_in: 29 | contact_file = BCLContactParser().read(f_in) 30 | contact_map1 = contact_file.top_map 31 | self.assertEqual(1, len(contact_file)) 32 | self.assertEqual(11, len(contact_map1)) 33 | self.assertEqual([5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6], [c.res1_seq for c in contact_map1]) 34 | self.assertEqual([9, 10, 11, 21, 58, 62, 63, 78, 79, 80, 94], [c.res2_seq for c in contact_map1]) 35 | self.assertEqual( 36 | [0.749, 0.634, 0.727, 0.557, 0.535, 0.585, 0.529, 0.581, 0.679, 0.578, 0.679], 37 | [c.raw_score for c in contact_map1], 38 | ) 39 | 40 | 41 | if __name__ == "__main__": 42 | unittest.main(verbosity=2) 43 | -------------------------------------------------------------------------------- /conkit/io/tests/test_comsat.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.ComsatIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "14 Sep 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.comsat import ComsatParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestComsatParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """19 A 41 A H1-H2 20 | 19 A 42 C H1-H2 21 | 11 L 47 L H1-H2 22 | 11 L 48 L H1-H2 23 | 12 L 47 L H1-H2 24 | 12 L 48 L H1-H2 25 | 40 I 66 I H2-H3 26 | 41 A 66 I H2-H3 27 | 33 Y 73 H H2-H3 28 | 33 Y 74 A H2-H3 29 | 46 L 62 L H2-H3 30 | 47 L 62 L H2-H3 31 | 69 M 88 V H3-H4 32 | 69 M 89 A H3-H4 33 | 96 A 117 V H4-H5 34 | 96 A 118 A H4-H5 35 | 82 A 129 A H4-H5 36 | 82 A 130 G H4-H5 37 | 82 A 133 F H4-H5 38 | 83 F 133 F H4-H5 39 | 128 I 154 I H5-H6 40 | 129 A 154 I H5-H6 41 | 118 A 163 A H5-H6 42 | 119 V 163 A H5-H6 43 | 20 A 160 A H1-H6 44 | 21 L 160 A H1-H6 45 | 8 N 171 V H1-H6 46 | 9 V 171 V H1-H6 47 | """ 48 | f_name = self.tempfile(content=content) 49 | with open(f_name, "r") as f_in: 50 | contact_file = ComsatParser().read(f_in, "r") 51 | contact_map1 = contact_file.top_map 52 | self.assertEqual(1, len(contact_file)) 53 | self.assertEqual(28, len(contact_map1)) 54 | self.assertEqual( 55 | [ 56 | 19, 57 | 19, 58 | 11, 59 | 11, 60 | 12, 61 | 12, 62 | 40, 63 | 41, 64 | 33, 65 | 33, 66 | 46, 67 | 47, 68 | 69, 69 | 69, 70 | 96, 71 | 96, 72 | 82, 73 | 82, 74 | 82, 75 | 83, 76 | 128, 77 | 129, 78 | 118, 79 | 119, 80 | 20, 81 | 21, 82 | 8, 83 | 9, 84 | ], 85 | [c.res1_seq for c in contact_map1], 86 | ) 87 | 88 | def test_write_1(self): 89 | contact_file = ContactFile("RR") 90 | contact_file.target = "R9999" 91 | contact_file.author = "1234-5678-9000" 92 | contact_file.remark = ["Predictor remarks"] 93 | contact_file.method = ["Description of methods used", "Description of methods used"] 94 | contact_map = ContactMap("1") 95 | contact_file.add(contact_map) 96 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 97 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 98 | contact_map.add(contact) 99 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 100 | contact_map.set_sequence_register() 101 | f_name = self.tempfile() 102 | with open(f_name, "w") as f_out: 103 | ComsatParser().write(f_out, contact_file) 104 | content = ["1 H 9 L Hx-Hx", "1 H 10 L Hx-Hx", "2 L 8 I Hx-Hx", "3 E 12 K Hx-Hx"] 105 | with open(f_name, "r") as f_in: 106 | output = f_in.read().splitlines() 107 | self.assertEqual(content, output) 108 | 109 | 110 | if __name__ == "__main__": 111 | unittest.main(verbosity=2) 112 | -------------------------------------------------------------------------------- /conkit/io/tests/test_epcmap.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.EPCMapIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "12 Dec 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.epcmap import EPCMapParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestEPCMapParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """46 78 0 8 9.301869 20 | 80 105 0 8 8.856009 21 | 111 129 0 8 7.252451 22 | 75 205 0 8 6.800462 23 | 19 44 0 8 6.588349 24 | 111 130 0 8 6.184269 25 | 23 41 0 8 6.163786 26 | 171 205 0 8 5.519271 27 | 53 126 0 8 5.440612 28 | 100 140 0 8 5.382865 29 | """ 30 | f_name = self.tempfile(content=content) 31 | with open(f_name, "r") as f_in: 32 | contact_file = EPCMapParser().read(f_in) 33 | contact_map1 = contact_file.top_map 34 | self.assertEqual(1, len(contact_file)) 35 | self.assertEqual(10, len(contact_map1)) 36 | self.assertEqual([46, 80, 111, 75, 19, 111, 23, 171, 53, 100], [c.res1_seq for c in contact_map1]) 37 | self.assertEqual([78, 105, 129, 205, 44, 130, 41, 205, 126, 140], [c.res2_seq for c in contact_map1]) 38 | self.assertEqual( 39 | [9.301869, 8.856009, 7.252451, 6.800462, 6.588349, 6.184269, 6.163786, 5.519271, 5.440612, 5.382865], 40 | [c.raw_score for c in contact_map1], 41 | ) 42 | 43 | def test_write_1(self): 44 | contact_file = ContactFile("RR") 45 | contact_file.target = "R9999" 46 | contact_file.author = "1234-5678-9000" 47 | contact_file.remark = ["Predictor remarks"] 48 | contact_file.method = ["Description of methods used", "Description of methods used"] 49 | contact_map = ContactMap("1") 50 | contact_file.add(contact_map) 51 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 52 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 53 | contact_map.add(contact) 54 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 55 | contact_map.set_sequence_register() 56 | f_name = self.tempfile() 57 | with open(f_name, "w") as f_out: 58 | EPCMapParser().write(f_out, contact_file) 59 | content = ["1 9 0 8 0.700000", "1 10 0 8 0.700000", "2 8 0 8 0.900000", "3 12 0 8 0.400000"] 60 | with open(f_name, "r") as f_in: 61 | output = f_in.read().splitlines() 62 | self.assertEqual(content, output) 63 | 64 | 65 | if __name__ == "__main__": 66 | unittest.main(verbosity=2) 67 | -------------------------------------------------------------------------------- /conkit/io/tests/test_evfold.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.EVfold""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.evfold import EVfoldParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestEVfoldParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """1 M 2 V 0 0.0338619 20 | 1 M 3 G 0 0.0307956 21 | 1 M 4 L 0 0.0268079 22 | 1 M 5 T 0 0.0219783 23 | 1 M 6 T 0 0.0222061 24 | 1 M 7 L 0 0.0213079 25 | 1 M 8 F 0 0.0119054 26 | 1 M 9 W 0 0.0275182 27 | 1 M 10 L 0 0.0134577 28 | 1 M 11 G 0 0.0234555 29 | """ 30 | f_name = self.tempfile(content=content) 31 | with open(f_name, "r") as f_in: 32 | contact_file = EVfoldParser().read(f_in) 33 | contact_map1 = contact_file.top_map 34 | self.assertEqual(1, len(contact_file)) 35 | self.assertEqual(10, len(contact_map1)) 36 | self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [c.res1_seq for c in contact_map1]) 37 | self.assertEqual([2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [c.res2_seq for c in contact_map1]) 38 | self.assertEqual( 39 | [ 40 | 0.0338619, 41 | 0.0307956, 42 | 0.0268079, 43 | 0.0219783, 44 | 0.0222061, 45 | 0.0213079, 46 | 0.0119054, 47 | 0.0275182, 48 | 0.0134577, 49 | 0.0234555, 50 | ], 51 | [c.raw_score for c in contact_map1], 52 | ) 53 | 54 | def test_write_1(self): 55 | contact_file = ContactFile("RR") 56 | contact_file.target = "R9999" 57 | contact_file.author = "1234-5678-9000" 58 | contact_file.remark = ["Predictor remarks"] 59 | contact_file.method = ["Description of methods used", "Description of methods used"] 60 | contact_map = ContactMap("1") 61 | contact_file.add(contact_map) 62 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 63 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 64 | contact_map.add(contact) 65 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 66 | contact_map.set_sequence_register() 67 | f_name = self.tempfile() 68 | with open(f_name, "w") as f_out: 69 | EVfoldParser().write(f_out, contact_file) 70 | content = ["1 H 9 L 0 0.7", "1 H 10 L 0 0.7", "2 L 8 I 0 0.9", "3 E 12 K 0 0.4"] 71 | with open(f_name, "r") as f_in: 72 | output = f_in.read().splitlines() 73 | self.assertEqual(content, output) 74 | 75 | 76 | if __name__ == "__main__": 77 | unittest.main(verbosity=2) 78 | -------------------------------------------------------------------------------- /conkit/io/tests/test_freecontact.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.FreeContactIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.freecontact import FreeContactParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestFreeContactParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """1 M 2 V 0.0338619 0 20 | 1 M 3 G 0.0307956 0 21 | 1 M 4 L 0.0268079 0 22 | 1 M 5 T 0.0219783 0 23 | 1 M 6 T 0.0222061 0 24 | 1 M 7 L 0.0213079 0 25 | 1 M 8 F 0.0119054 0 26 | 1 M 9 W 0.0275182 0 27 | 1 M 10 L 0.0134577 0 28 | 1 M 11 G 0.0234555 0 29 | """ 30 | f_name = self.tempfile(content=content) 31 | with open(f_name, "r") as f_in: 32 | contact_file = FreeContactParser().read(f_in) 33 | contact_map1 = contact_file.top_map 34 | self.assertEqual(1, len(contact_file)) 35 | self.assertEqual(10, len(contact_map1)) 36 | self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [c.res1_seq for c in contact_map1]) 37 | self.assertEqual([2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [c.res2_seq for c in contact_map1]) 38 | self.assertEqual( 39 | [ 40 | 0.0338619, 41 | 0.0307956, 42 | 0.0268079, 43 | 0.0219783, 44 | 0.0222061, 45 | 0.0213079, 46 | 0.0119054, 47 | 0.0275182, 48 | 0.0134577, 49 | 0.0234555, 50 | ], 51 | [c.raw_score for c in contact_map1], 52 | ) 53 | 54 | def test_write_1(self): 55 | contact_file = ContactFile("RR") 56 | contact_file.target = "R9999" 57 | contact_file.author = "1234-5678-9000" 58 | contact_file.remark = ["Predictor remarks"] 59 | contact_file.method = ["Description of methods used", "Description of methods used"] 60 | contact_map = ContactMap("1") 61 | contact_file.add(contact_map) 62 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 63 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 64 | contact_map.add(contact) 65 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 66 | contact_map.set_sequence_register() 67 | f_name = self.tempfile() 68 | with open(f_name, "w") as f_out: 69 | FreeContactParser().write(f_out, contact_file) 70 | content = ["1 H 9 L 0.7 0", "1 H 10 L 0.7 0", "2 L 8 I 0.9 0", "3 E 12 K 0.4 0"] 71 | with open(f_name, "r") as f_in: 72 | output = f_in.read().splitlines() 73 | self.assertEqual(content, output) 74 | 75 | 76 | if __name__ == "__main__": 77 | unittest.main(verbosity=2) 78 | -------------------------------------------------------------------------------- /conkit/io/tests/test_mapalign.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.map_align""" 2 | 3 | import os 4 | import unittest 5 | 6 | from conkit.core.contact import Contact 7 | from conkit.core.contactfile import ContactFile 8 | from conkit.core.contactmap import ContactMap 9 | from conkit.core.sequence import Sequence 10 | from conkit.io.mapalign import MapAlignParser 11 | from conkit.io.tests.helpers import ParserTestCase 12 | 13 | 14 | class TestMapAlignParser(ParserTestCase): 15 | def test_read_1(self): 16 | content = """LEN 77 17 | CON 10 14 1 18 | CON 1 7 0.883 19 | CON 10 13 0.871 20 | CON 6 9 0.847 21 | CON 5 71 0.816 22 | CON 36 42 0.807 23 | CON 1 73 0.806 24 | CON 33 37 0.8 25 | CON 21 68 0.563 26 | CON 38 57 0.561 27 | PRF 0 T X 0.0321 0.0078 0.0582 0.1021 0.0207 0.0384 0.038 0.0386 0.0697 0.0376 0.0586 28 | PRF 1 M X 0.0228 0.0052 0.0103 0.0112 0.1236 0.0083 0.0106 0.1182 0.0104 0.3046 0.1922 29 | PRF 2 K X 0.0322 0.0048 0.0563 0.128 0.0116 0.0481 0.0332 0.0319 0.1099 0.0366 0.0228 30 | PRF 3 I X 0.0147 0.0062 0.0025 0.0034 0.2786 0.0058 0.0057 0.1876 0.0053 0.2779 0.0302 31 | PRF 4 I X 0.0404 0.0057 0.1139 0.2398 0.0104 0.028 0.0275 0.0278 0.0491 0.0283 0.0051 32 | """ 33 | f_name = self.tempfile(content=content) 34 | with open(f_name, "r") as f_in: 35 | contact_file = MapAlignParser().read(f_in) 36 | contact_map1 = contact_file.top_map 37 | self.assertEqual(1, len(contact_file)) 38 | self.assertEqual(10, len(contact_map1)) 39 | self.assertEqual([10, 1, 10, 6, 5, 36, 1, 33, 21, 38], [c.res1_seq for c in contact_map1]) 40 | self.assertEqual([14, 7, 13, 9, 71, 42, 73, 37, 68, 57], [c.res2_seq for c in contact_map1]) 41 | self.assertEqual( 42 | [1.0, 0.883, 0.871, 0.847, 0.816, 0.807, 0.806, 0.8, 0.563, 0.561], [c.raw_score for c in contact_map1] 43 | ) 44 | 45 | def test_write_1(self): 46 | contact_file = ContactFile("RR") 47 | contact_file.target = "R9999" 48 | contact_file.author = "1234-5678-9000" 49 | contact_file.remark = ["Predictor remarks"] 50 | contact_file.method = ["Description of methods used", "Description of methods used"] 51 | contact_map = ContactMap("1") 52 | contact_file.add(contact_map) 53 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 54 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 55 | contact_map.add(contact) 56 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 57 | contact_map.set_sequence_register() 58 | f_name = self.tempfile() 59 | with open(f_name, "w") as f_out: 60 | MapAlignParser().write(f_out, contact_file) 61 | content = ["LEN 12", "CON 1 9 0.700000", "CON 1 10 0.700000", "CON 2 8 0.900000", "CON 3 12 0.400000"] 62 | with open(f_name, "r") as f_in: 63 | output = f_in.read().splitlines() 64 | self.assertEqual(content, output) 65 | 66 | 67 | if __name__ == "__main__": 68 | unittest.main(verbosity=2) 69 | -------------------------------------------------------------------------------- /conkit/io/tests/test_membrain.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.MemBrainIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.tests.helpers import ParserTestCase 14 | from conkit.io.membrain import MemBrainParser 15 | 16 | 17 | class TestMemBrainParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """Helix Position Residue Helix Position Residue Probability 20 | H1 30 F H2 55 F 1.000000 21 | H1 33 L H2 51 A 0.944091 22 | H1 18 G H2 65 C 0.942259 23 | H1 30 F H2 54 G 0.919241 24 | H1 26 I H2 57 L 0.817638 25 | H1 18 G H2 58 S 0.797449 26 | H1 33 L H2 63 L 0.795520 27 | H1 12 A H2 68 V 0.795462 28 | H1 29 V H2 55 F 0.791829 29 | H1 24 I H2 51 A 0.790044 30 | H1 19 L H2 62 G 0.784613 31 | H1 19 L H2 55 F 0.782741 32 | """ 33 | f_name = self.tempfile(content=content) 34 | with open(f_name, "r") as f_in: 35 | contact_file = MemBrainParser().read(f_in) 36 | contact_map1 = contact_file.top_map 37 | self.assertEqual(1, len(contact_file)) 38 | self.assertEqual(12, len(contact_map1)) 39 | self.assertEqual([30, 33, 18, 30, 26, 18, 33, 12, 29, 24, 19, 19], [c.res1_seq for c in contact_map1]) 40 | self.assertEqual([55, 51, 65, 54, 57, 58, 63, 68, 55, 51, 62, 55], [c.res2_seq for c in contact_map1]) 41 | self.assertEqual( 42 | [ 43 | 1.000000, 44 | 0.944091, 45 | 0.942259, 46 | 0.919241, 47 | 0.817638, 48 | 0.797449, 49 | 0.795520, 50 | 0.795462, 51 | 0.791829, 52 | 0.790044, 53 | 0.784613, 54 | 0.782741, 55 | ], 56 | [c.raw_score for c in contact_map1], 57 | ) 58 | 59 | def test_write_1(self): 60 | contact_file = ContactFile("RR") 61 | contact_file.target = "R9999" 62 | contact_file.author = "1234-5678-9000" 63 | contact_file.remark = ["Predictor remarks"] 64 | contact_file.method = ["Description of methods used", "Description of methods used"] 65 | contact_map = ContactMap("1") 66 | contact_file.add(contact_map) 67 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 68 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 69 | contact_map.add(contact) 70 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 71 | contact_map.set_sequence_register() 72 | f_name = self.tempfile() 73 | with open(f_name, "w") as f_out: 74 | MemBrainParser().write(f_out, contact_file) 75 | content = [ 76 | "Helix Position Residue Helix Position Residue Probability", 77 | "Hx 1 H Hx 9 L 0.700000", 78 | "Hx 1 H Hx 10 L 0.700000", 79 | "Hx 2 L Hx 8 I 0.900000", 80 | "Hx 3 E Hx 12 K 0.400000", 81 | ] 82 | with open(f_name, "r") as f_in: 83 | output = f_in.read().splitlines() 84 | self.assertEqual(content, output) 85 | 86 | 87 | if __name__ == "__main__": 88 | unittest.main(verbosity=2) 89 | -------------------------------------------------------------------------------- /conkit/io/tests/test_plmdca.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.PlmDCAIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.plmdca import PlmDCAParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestPlmDCAParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """1,2,0.12212 20 | 1,3,0.14004 21 | 1,4,0.12926 22 | 1,5,0.089211 23 | 1,6,0.079976 24 | 1,7,0.078954 25 | 1,8,0.052275 26 | 1,9,0.026012 27 | 1,10,0.049844 28 | 1,11,0.045109 29 | """ 30 | f_name = self.tempfile(content=content) 31 | with open(f_name, "r") as f_in: 32 | contact_file = PlmDCAParser().read(f_in) 33 | contact_map1 = contact_file.top_map 34 | self.assertEqual(1, len(contact_file)) 35 | self.assertEqual(10, len(contact_map1)) 36 | self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [c.res1_seq for c in contact_map1]) 37 | self.assertEqual([2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [c.res2_seq for c in contact_map1]) 38 | self.assertEqual( 39 | [0.12212, 0.14004, 0.12926, 0.089211, 0.079976, 0.078954, 0.052275, 0.026012, 0.049844, 0.045109], 40 | [c.raw_score for c in contact_map1], 41 | ) 42 | 43 | def test_write_1(self): 44 | contact_file = ContactFile("RR") 45 | contact_file.target = "R9999" 46 | contact_file.author = "1234-5678-9000" 47 | contact_file.remark = ["Predictor remarks"] 48 | contact_file.method = ["Description of methods used", "Description of methods used"] 49 | contact_map = ContactMap("1") 50 | contact_file.add(contact_map) 51 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 52 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 53 | contact_map.add(contact) 54 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 55 | contact_map.set_sequence_register() 56 | f_name = self.tempfile() 57 | with open(f_name, "w") as f_out: 58 | PlmDCAParser().write(f_out, contact_file) 59 | content = ["1,9,0.700000", "1,10,0.700000", "2,8,0.900000", "3,12,0.400000"] 60 | with open(f_name, "r") as f_in: 61 | output = f_in.read().splitlines() 62 | self.assertEqual(content, output) 63 | 64 | 65 | if __name__ == "__main__": 66 | unittest.main(verbosity=2) 67 | -------------------------------------------------------------------------------- /conkit/io/tests/test_psicov.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.PsicovIO""" 2 | 3 | __author__ = "Felix Simkovic" 4 | __date__ = "26 Oct 2016" 5 | 6 | import os 7 | import unittest 8 | 9 | from conkit.core.contact import Contact 10 | from conkit.core.contactfile import ContactFile 11 | from conkit.core.contactmap import ContactMap 12 | from conkit.core.sequence import Sequence 13 | from conkit.io.psicov import PsicovParser 14 | from conkit.io.tests.helpers import ParserTestCase 15 | 16 | 17 | class TestPsicovParser(ParserTestCase): 18 | def test_read_1(self): 19 | content = """46 78 0 8 9.301869 20 | 80 105 0 8 8.856009 21 | 111 129 0 8 7.252451 22 | 75 205 0 8 6.800462 23 | 19 44 0 8 6.588349 24 | 111 130 0 8 6.184269 25 | 23 41 0 8 6.163786 26 | 171 205 0 8 5.519271 27 | 53 126 0 8 5.440612 28 | 100 140 0 8 5.382865 29 | """ 30 | f_name = self.tempfile(content=content) 31 | with open(f_name, "r") as f_in: 32 | contact_file = PsicovParser().read(f_in) 33 | contact_map1 = contact_file.top_map 34 | self.assertEqual(1, len(contact_file)) 35 | self.assertEqual(10, len(contact_map1)) 36 | self.assertEqual([46, 80, 111, 75, 19, 111, 23, 171, 53, 100], [c.res1_seq for c in contact_map1]) 37 | self.assertEqual([78, 105, 129, 205, 44, 130, 41, 205, 126, 140], [c.res2_seq for c in contact_map1]) 38 | self.assertEqual( 39 | [9.301869, 8.856009, 7.252451, 6.800462, 6.588349, 6.184269, 6.163786, 5.519271, 5.440612, 5.382865], 40 | [c.raw_score for c in contact_map1], 41 | ) 42 | 43 | def test_write_1(self): 44 | contact_file = ContactFile("RR") 45 | contact_file.target = "R9999" 46 | contact_file.author = "1234-5678-9000" 47 | contact_file.remark = ["Predictor remarks"] 48 | contact_file.method = ["Description of methods used", "Description of methods used"] 49 | contact_map = ContactMap("1") 50 | contact_file.add(contact_map) 51 | for c in [(1, 9, 0, 8, 0.7), (1, 10, 0, 8, 0.7), (2, 8, 0, 8, 0.9), (3, 12, 0, 8, 0.4)]: 52 | contact = Contact(c[0], c[1], c[4], distance_bound=(c[2], c[3])) 53 | contact_map.add(contact) 54 | contact_map.sequence = Sequence("1", "HLEGSIGILLKKHEIVFDGCHDFGRTYIWQMSD") 55 | contact_map.set_sequence_register() 56 | f_name = self.tempfile() 57 | with open(f_name, "w") as f_out: 58 | PsicovParser().write(f_out, contact_file) 59 | content = ["1 9 0 8 0.700000", "1 10 0 8 0.700000", "2 8 0 8 0.900000", "3 12 0 8 0.400000"] 60 | with open(f_name, "r") as f_in: 61 | output = f_in.read().splitlines() 62 | self.assertEqual(content, output) 63 | 64 | 65 | if __name__ == "__main__": 66 | unittest.main(verbosity=2) 67 | -------------------------------------------------------------------------------- /conkit/io/tests/test_rosetta_npz.py: -------------------------------------------------------------------------------- 1 | """Testing facility for conkit.io.RosettaNpzParser""" 2 | 3 | import numpy as np 4 | import pickle 5 | from conkit.core.distancefile import DistanceFile 6 | from conkit.core.distogram import Distogram 7 | from conkit.io.rosetta_npz import RosettaNpzParser 8 | from conkit.io.tests.helpers import ParserTestCase 9 | 10 | 11 | class TestRosettaNpzParser(ParserTestCase): 12 | 13 | def test_read_1(self): 14 | np.random.seed(41) 15 | prediction = { 16 | 'dist': np.array([[np.random.dirichlet(np.ones(37)).tolist() for x in range(5)] for x in range(5)]) 17 | } 18 | 19 | f_name = self.tempfile(content=None) 20 | with open(f_name, 'wb') as fhandle: 21 | pickle.dump(prediction, fhandle) 22 | with open(f_name, "rb") as fhandle: 23 | distancefile = RosettaNpzParser().read(fhandle) 24 | 25 | self.assertIsInstance(distancefile, DistanceFile) 26 | self.assertEqual(1, len(distancefile)) 27 | distogram = distancefile.top 28 | self.assertEqual('rosettanpz', distogram.original_file_format) 29 | self.assertIsInstance(distogram, Distogram) 30 | self.assertEqual(15, len(distogram)) 31 | 32 | expected_res1 = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5] 33 | expected_res2 = [1, 2, 3, 4, 5, 2, 3, 4, 5, 3, 4, 5, 4, 5, 5] 34 | expected_raw_score = [0.2542024725712152, 0.2680150396842064, 0.31951115321526485, 0.2872068644639303, 35 | 0.3270142179786386, 0.4065752412086529, 0.19140953877084063, 0.325080041345469, 36 | 0.2342294456365818, 0.15548141805069934, 0.41178206457702593, 0.26026142628351123, 37 | 0.2798115875666083, 0.29054612017825876, 0.3008523890315092] 38 | 39 | expected_bin_distance = [(18.5, 19), (12, 12.5), (9, 9.5), (6, 6.5), (14, 14.5), (17, 17.5), (8, 8.5), 40 | (8.5, 9), (17.5, 18), (13, 13.5), (4.5, 5), (18.5, 19), (16, 16.5), (6, 6.5), (4, 4.5)] 41 | 42 | expected_bin_score = [0.25350480891411237, 0.08088144636134563, 0.08190930855105415, 0.1383295289038701, 43 | 0.09824995972452338, 0.1079242231548592, 0.12906386318101604, 0.11786428170511123, 44 | 0.12079995199505335, 0.15691065654436132, 0.13879490895313662, 0.10757779064007214, 45 | 0.10870485113910544, 0.0702085454511652, 0.0968560988412983] 46 | 47 | 48 | self.assertListEqual(expected_res1, [distance.res1_seq for distance in distogram]) 49 | self.assertListEqual(expected_res2, [distance.res2_seq for distance in distogram]) 50 | self.assertListEqual(expected_raw_score, [contact.raw_score for contact in distogram]) 51 | self.assertListEqual(expected_bin_score, [distance.max_score for distance in distogram]) 52 | self.assertListEqual(expected_bin_distance, [distance.predicted_distance_bin for distance in distogram]) 53 | -------------------------------------------------------------------------------- /conkit/misc/ext/__init__.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # 3 | # BSD 3-Clause License 4 | # 5 | # Copyright (c) 2016-21, University of Liverpool 6 | # All rights reserved. 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions are met: 10 | # 11 | # * Redistributions of source code must retain the above copyright notice, this 12 | # list of conditions and the following disclaimer. 13 | # 14 | # * Redistributions in binary form must reproduce the above copyright notice, 15 | # this list of conditions and the following disclaimer in the documentation 16 | # and/or other materials provided with the distribution. 17 | # 18 | # * Neither the name of the copyright holder nor the names of its 19 | # contributors may be used to endorse or promote products derived from 20 | # this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | """Extensions to conkit.core package""" 33 | 34 | __author__ = "Felix Simkovic" 35 | __date__ = "03 May 2018" 36 | __version__ = "0.13.3" 37 | -------------------------------------------------------------------------------- /conkit/misc/ext/c_bandwidth.pyx: -------------------------------------------------------------------------------- 1 | #cython: boundscheck=False, cdivision=True, wraparound=False 2 | 3 | cimport cython 4 | import numpy as np 5 | cimport numpy as np 6 | 7 | from libc.math cimport exp, fabs, sqrt, M_PI 8 | 9 | np.import_array() 10 | 11 | cdef double SQRT_PI = sqrt(M_PI) 12 | cdef double SQRT_2PI = sqrt(2.0 * M_PI) 13 | 14 | 15 | def c_optimize_bandwidth(np.ndarray[np.int64_t, ndim=2] A, double v): 16 | cdef double alpha, sigma, integral 17 | alpha = 1.0 / (2.0 * SQRT_PI) 18 | sigma = 1.0 19 | integral = c_get_stiffness_integral(A, v, 0.0001) 20 | return v - ((A.shape[0] * integral * sigma**4) / alpha)**(-1.0 / (A.shape[1] + 4)) 21 | 22 | 23 | def c_get_stiffness_integral(np.ndarray[np.int64_t, ndim=2] A, double v, double eps): 24 | cdef Py_ssize_t i, j, n 25 | cdef double min_, max_, dx, maxn, yy, y1, y2, y3, y 26 | min_ = A.min() - v * 3 27 | max_ = A.max() + v * 3 28 | dx = 1.0 * (max_ - min_) 29 | maxn = dx / sqrt(eps) 30 | if maxn > 2048: 31 | maxn = 2048 32 | y1 = c_get_gauss_curvature(A, min_, v) 33 | y2 = c_get_gauss_curvature(A, max_, v) 34 | yy = 0.5 * dx * (y1 * y1 + y2 * y2) 35 | n = 2 36 | 37 | while n <= maxn: 38 | dx /= 2.0 39 | y = 0.0 40 | for i in xrange(1, n, 2): 41 | y3 = c_get_gauss_curvature(A, min_ + i * dx, v) 42 | y += (y3 * y3) 43 | yy = 0.5 * yy + y * dx 44 | if n > 8 and fabs(y * dx - 0.5 * yy) < eps * yy: 45 | break 46 | n *= 2 47 | 48 | return yy 49 | 50 | 51 | def c_get_gauss_curvature(np.ndarray[np.int64_t, ndim=2] A, double x, double w): 52 | cdef Py_ssize_t i, j 53 | cdef double w_sq, w_sqrt_2pi, curvature, z 54 | w_sq = w*w 55 | w_sqrt_2pi = w * SQRT_2PI 56 | curvature = 0.0 57 | for i in xrange(A.shape[0]): 58 | for j in xrange(A.shape[1]): 59 | z = (x - A[i, j]) / w 60 | z *= z 61 | curvature += (A.shape[1] * (z - 1.0) * (exp(-0.5 * z) / w_sqrt_2pi) / w_sq) 62 | return curvature / A.shape[0] 63 | -------------------------------------------------------------------------------- /conkit/misc/standard_scaler.joblib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/conkit/misc/standard_scaler.joblib -------------------------------------------------------------------------------- /conkit/misc/tests/test_distances.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | __author__ = "Felix Simkovic" 32 | 33 | import itertools 34 | import unittest 35 | 36 | from conkit.misc.distances import DynamicDistances 37 | 38 | 39 | class TestDynamicDistances(unittest.TestCase): 40 | def test_1(self): 41 | amino_acids = [ 42 | "A", 43 | "C", 44 | "D", 45 | "E", 46 | "F", 47 | "G", 48 | "H", 49 | "I", 50 | "K", 51 | "L", 52 | "M", 53 | "N", 54 | "P", 55 | "Q", 56 | "R", 57 | "S", 58 | "T", 59 | "V", 60 | "W", 61 | "Y", 62 | ] 63 | for (a1, a2) in itertools.combinations(amino_acids, 2): 64 | self.assertEqual(DynamicDistances._CB_CB_CUTOFF[a1][a2], DynamicDistances.cutoff(a1, a2)) 65 | 66 | def test_2(self): 67 | amino_acids = [ 68 | "A", 69 | "C", 70 | "D", 71 | "E", 72 | "F", 73 | "G", 74 | "H", 75 | "I", 76 | "K", 77 | "L", 78 | "M", 79 | "N", 80 | "P", 81 | "Q", 82 | "R", 83 | "S", 84 | "T", 85 | "V", 86 | "W", 87 | "Y", 88 | ] 89 | for (a1, a2) in itertools.combinations(amino_acids, 2): 90 | self.assertEqual(DynamicDistances._CB_CB_PERCENT[a1][a2], DynamicDistances.percentile(a1, a2)) 91 | 92 | 93 | if __name__ == "__main__": 94 | unittest.main(verbosity=2) 95 | -------------------------------------------------------------------------------- /conkit/misc/tests/test_energyfunction.py: -------------------------------------------------------------------------------- 1 | __author__ = "Felix Simkovic" 2 | 3 | import unittest 4 | 5 | from conkit.misc.energyfunction import RosettaFunctionConstructs 6 | 7 | TEMPLATE = dict( 8 | atom1="CB", 9 | res1_seq=1, 10 | atom2="CB", 11 | res2_seq=2, 12 | lower_bound=0, 13 | upper_bound=2, 14 | scalar_score=0.1, 15 | sigmoid_cutoff=0.2, 16 | sigmoid_slope=0.3, 17 | energy_bonus=-15.0, 18 | raw_score=1.0, 19 | ) 20 | 21 | 22 | class TestRosettaFunctionConstructs(unittest.TestCase): 23 | def test_1(self): 24 | output = RosettaFunctionConstructs().BOUNDED_default.format(**TEMPLATE) 25 | self.assertEqual(output, "AtomPair CB 1 CB 2 BOUNDED 0.000 2.000 1 0.5 #") 26 | 27 | def test_2(self): 28 | output = RosettaFunctionConstructs().BOUNDED_gremlin.format(**TEMPLATE) 29 | self.assertEqual(output, "AtomPair CB 1 CB 2 SCALARWEIGHTEDFUNC 0.100 BOUNDED 0 0.000 1 0.5") 30 | 31 | def test_3(self): 32 | output = RosettaFunctionConstructs().FADE.format(**TEMPLATE) 33 | self.assertEqual(output, "AtomPair CB 1 CB 2 FADE -10 19 10 -15.00 0") 34 | 35 | def test_4(self): 36 | output = RosettaFunctionConstructs().FADE_default.format(**TEMPLATE) 37 | self.assertEqual(output, "AtomPair CB 1 CB 2 FADE -10 19 10 -15.00 0") 38 | 39 | def test_5(self): 40 | output = RosettaFunctionConstructs().SIGMOID_default.format(**TEMPLATE) 41 | self.assertEqual(output, "AtomPair CB 1 CB 2 SIGMOID 8.00 1.00 #ContactMap: 1.000") 42 | 43 | def test_6(self): 44 | output = RosettaFunctionConstructs().SIGMOID_gremlin.format(**TEMPLATE) 45 | self.assertEqual( 46 | output, 47 | "AtomPair CB 1 CB 2 SCALARWEIGHTEDFUNC 0.100 SUMFUNC 2 SIGMOID 0.200 0.300 CONSTANTFUNC -0.5", 48 | ) 49 | 50 | 51 | if __name__ == "__main__": 52 | unittest.main(verbosity=2) 53 | -------------------------------------------------------------------------------- /conkit/misc/tests/test_selectalg.py: -------------------------------------------------------------------------------- 1 | __author__ = "Felix Simkovic" 2 | 3 | import unittest 4 | 5 | from conkit.misc.selectalg import SubselectionAlgorithm 6 | 7 | 8 | class TestSubselectionAlgorithm(unittest.TestCase): 9 | def test_cutoff_1(self): 10 | data = [1.0, 0.6, 0.5, 0.4, 0.4, 0.3, 0.2, 0.1] 11 | keep, throw = SubselectionAlgorithm.cutoff(data) 12 | self.assertEqual([0, 1, 2, 3, 4, 5], keep) 13 | self.assertEqual([6, 7], throw) 14 | 15 | def test_cutoff_2(self): 16 | data = [1.0, 0.3, 0.2, 0.1, 0.6, 0.5, 0.4, 0.4] 17 | keep, throw = SubselectionAlgorithm.cutoff(data) 18 | self.assertEqual([0, 1, 4, 5, 6, 7], keep) 19 | self.assertEqual([2, 3], throw) 20 | 21 | def test_cutoff_3(self): 22 | data = [0.2, 0.1] 23 | keep, throw = SubselectionAlgorithm.cutoff(data) 24 | self.assertEqual([], keep) 25 | self.assertEqual([0, 1], throw) 26 | 27 | def test_cutoff_4(self): 28 | data = [0.286, 0.287, 0.288] 29 | keep, throw = SubselectionAlgorithm.cutoff(data) 30 | self.assertEqual([1, 2], keep) 31 | self.assertEqual([0], throw) 32 | 33 | def test_linear_1(self): 34 | data = [1.0, 0.6, 0.5, 0.45, 0.4, 0.3, 0.2, 0.1] 35 | keep, throw = SubselectionAlgorithm.linear(data) 36 | self.assertEqual([0, 1, 2, 3], keep) 37 | self.assertEqual([4, 5, 6, 7], throw) 38 | 39 | def test_linear_2(self): 40 | data = [0.1, 0.2, 0.3, 0.45, 0.4, 0.5, 0.6, 1.0] 41 | keep, throw = SubselectionAlgorithm.linear(data) 42 | self.assertEqual([7, 6, 5, 3], keep) 43 | self.assertEqual([4, 2, 1, 0], throw) 44 | 45 | def test_linear_3(self): 46 | data = [1.0, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1] 47 | keep, throw = SubselectionAlgorithm.linear(data) 48 | self.assertEqual([0, 1, 2, 3], keep) 49 | self.assertEqual([4, 5, 6], throw) 50 | 51 | def test_linear_4(self): 52 | data = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 1.0] 53 | keep, throw = SubselectionAlgorithm.linear(data) 54 | self.assertEqual([6, 5, 4, 3], keep) 55 | self.assertEqual([2, 1, 0], throw) 56 | 57 | def test_linear_5(self): 58 | data = [1.0, 0.21, 0.4, 0.6, 0.5, 0.3, 0.1, 0.2] 59 | keep, throw = SubselectionAlgorithm.linear(data) 60 | self.assertEqual([0, 3, 4, 2], keep) 61 | self.assertEqual([5, 1, 7, 6], throw) 62 | 63 | def test_scaled_1(self): 64 | data = [1.0, 0.6, 0.5, 0.45, 0.4, 0.3, 0.2, 0.1] 65 | keep, throw = SubselectionAlgorithm.scaled(data) 66 | self.assertEqual([0, 1, 2, 3, 4, 5], keep) 67 | self.assertEqual([6, 7], throw) 68 | 69 | def test_scaled_2(self): 70 | data = [1.0, 1.0, 1.0, 1.0] 71 | keep, throw = SubselectionAlgorithm.scaled(data) 72 | self.assertEqual([0, 1, 2, 3], keep) 73 | self.assertEqual([], throw) 74 | 75 | def test_scaled_3(self): 76 | data = [100.0, 1.0, 1.0, 1.0] 77 | keep, throw = SubselectionAlgorithm.scaled(data) 78 | self.assertEqual([0], keep) 79 | self.assertEqual([1, 2, 3], throw) 80 | 81 | def test_ignore_1(self): 82 | data = [1.0, 0.6, 0.5, 0.45, 0.4, 0.3, 0.2, 0.1] 83 | keep, throw = SubselectionAlgorithm.ignore(data) 84 | self.assertEqual([0, 1, 2, 3, 4, 5, 6, 7], keep) 85 | self.assertEqual([], throw) 86 | 87 | def test_ignore_2(self): 88 | data = [1.0, 1.0, 1.0, 1.0] 89 | keep, throw = SubselectionAlgorithm.ignore(data) 90 | self.assertEqual([0, 1, 2, 3], keep) 91 | self.assertEqual([], throw) 92 | 93 | def test_ignore_3(self): 94 | data = [100.0, 1.0, 1.0, 1.0] 95 | keep, throw = SubselectionAlgorithm.ignore(data) 96 | self.assertEqual([0, 1, 2, 3], keep) 97 | self.assertEqual([], throw) 98 | 99 | 100 | if __name__ == "__main__": 101 | unittest.main(verbosity=2) 102 | -------------------------------------------------------------------------------- /conkit/misc/trained_classifier.joblib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/conkit/misc/trained_classifier.joblib -------------------------------------------------------------------------------- /conkit/plot/__init__.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Plot interface for automated figure generation""" 31 | 32 | __author__ = "Felix Simkovic" 33 | __date__ = "07 Feb 2017" 34 | __version__ = "0.13.3" 35 | 36 | import matplotlib 37 | 38 | matplotlib.use("Agg") 39 | 40 | 41 | def ContactMapFigure(*args, **kwargs): 42 | """:obj:`~conkit.plot.contactmap.ContactMapFigure` instance""" 43 | from conkit.plot.contactmap import ContactMapFigure 44 | 45 | return ContactMapFigure(*args, **kwargs) 46 | 47 | 48 | def ContactMapChordFigure(*args, **kwargs): 49 | """:obj:`~conkit.plot.contactmapchord.ContactMapChordFigure` instance""" 50 | from conkit.plot.contactmapchord import ContactMapChordFigure 51 | 52 | return ContactMapChordFigure(*args, **kwargs) 53 | 54 | 55 | def ContactMapMatrixFigure(*args, **kwargs): 56 | """:obj:`~conkit.plot.contactmatrix.ContactMapMatrixFigure` instance""" 57 | from conkit.plot.contactmapmatrix import ContactMapMatrixFigure 58 | 59 | return ContactMapMatrixFigure(*args, **kwargs) 60 | 61 | 62 | def ContactDensityFigure(*args, **kwargs): 63 | """:obj:`~conkit.plot.contactdensity.ContactDensityFigure` instance""" 64 | from conkit.plot.contactdensity import ContactDensityFigure 65 | 66 | return ContactDensityFigure(*args, **kwargs) 67 | 68 | 69 | def PrecisionEvaluationFigure(*args, **kwargs): 70 | """:obj:`~conkit.plot.precisionevaluation.PrecisionEvaluationFigure` instance""" 71 | from conkit.plot.precisionevaluation import PrecisionEvaluationFigure 72 | 73 | return PrecisionEvaluationFigure(*args, **kwargs) 74 | 75 | 76 | def SequenceCoverageFigure(*args, **kwargs): 77 | """:obj:`~conkit.plot.sequencecoverage.SequenceCoverageFigure` instance""" 78 | from conkit.plot.sequencecoverage import SequenceCoverageFigure 79 | 80 | return SequenceCoverageFigure(*args, **kwargs) 81 | 82 | 83 | def DistogramHeatmapFigure(*args, **kwargs): 84 | """:obj:`~conkit.plot.distogramheatmap.DistogramHeatmapFigure` instance""" 85 | from conkit.plot.distogramheatmap import DistogramHeatmapFigure 86 | 87 | return DistogramHeatmapFigure(*args, **kwargs) 88 | 89 | 90 | def ModelValidationFigure(*args, **kwargs): 91 | """:obj:`~conkit.plot.modelvalidation.ModelValidationFigure` instance""" 92 | from conkit.plot.modelvalidation import ModelValidationFigure 93 | 94 | return ModelValidationFigure(*args, **kwargs) 95 | -------------------------------------------------------------------------------- /conkit/version.py: -------------------------------------------------------------------------------- 1 | # BSD 3-Clause License 2 | # 3 | # Copyright (c) 2016-21, University of Liverpool 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """The version number of ConKit is recorded here""" 31 | __version_info__ = (0, 13, 3) 32 | __version__ = ".".join(map(str, __version_info__)) 33 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS += 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | GH_PAGES_SOURCES = conkit docs 10 | 11 | # User-friendly check for sphinx-build 12 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 13 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 14 | endif 15 | 16 | # Internal variables. 17 | PAPEROPT_a4 = -D latex_paper_size=a4 18 | PAPEROPT_letter = -D latex_paper_size=letter 19 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 20 | # the i18n builder cannot share the environment and doctrees with the others 21 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 22 | 23 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext gh-pages 24 | 25 | help: 26 | @echo "Please use \`make ' where is one of" 27 | @echo " html to make standalone HTML files" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " epub to make an epub" 30 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 31 | @echo " figures to create all figures used in the documentation" 32 | @echo " apidoc to create the apidoc pages" 33 | 34 | clean: 35 | rm -rf $(BUILDDIR)/* api/generated/* examples/images/* _tmp 36 | 37 | 38 | html: 39 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 40 | @echo 41 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 42 | 43 | singlehtml: 44 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 45 | @echo 46 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 47 | 48 | epub: 49 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 50 | @echo 51 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 52 | 53 | doctest: 54 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 55 | @echo "Testing of doctests in the sources finished, look at the " \ 56 | "results in $(BUILDDIR)/doctest/output.txt." 57 | 58 | apidoc: 59 | sphinx-apidoc -e -f -l -M -o api/generated ../conkit 60 | 61 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/plot_cdens_4p9g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/plot_cdens_4p9g.png -------------------------------------------------------------------------------- /docs/_static/plot_distogram_simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/plot_distogram_simple.png -------------------------------------------------------------------------------- /docs/_static/plot_model_validation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/plot_model_validation.png -------------------------------------------------------------------------------- /docs/_static/plot_peval_toxd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/plot_peval_toxd.png -------------------------------------------------------------------------------- /docs/_static/plot_scov_toxd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/_static/plot_scov_toxd.png -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "!layout.html" %} 2 | 3 | {% block header %} 4 | 17 | {% endblock %} 18 | 19 | {%- block footer %} 20 |
21 |
22 |
23 |
24 | 32 |
33 |
34 | 39 |
40 |
41 |
42 |
43 | {%- if show_copyright %} 44 | 51 | {%- endif %} 52 |
53 |
54 | {%- if last_updated %} 55 | 58 | {%- endif %} 59 |
60 |
61 |
62 |
63 | {%- endblock %} 64 | -------------------------------------------------------------------------------- /docs/_templates/navbar.html: -------------------------------------------------------------------------------- 1 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/api/applications.rst: -------------------------------------------------------------------------------- 1 | Applications package 2 | ==================== 3 | 4 | .. automodule:: conkit.applications 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.applications.* 13 | 14 | -------------------------------------------------------------------------------- /docs/api/command_line.rst: -------------------------------------------------------------------------------- 1 | Command line package 2 | ==================== 3 | 4 | .. automodule:: conkit.command_line 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.command_line.* 13 | 14 | -------------------------------------------------------------------------------- /docs/api/core.rst: -------------------------------------------------------------------------------- 1 | Core package 2 | ============ 3 | 4 | .. automodule:: conkit.core 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.core.* 13 | 14 | -------------------------------------------------------------------------------- /docs/api/io.rst: -------------------------------------------------------------------------------- 1 | I/O package 2 | =========== 3 | 4 | .. automodule:: conkit.io 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.io.* 13 | 14 | -------------------------------------------------------------------------------- /docs/api/misc.rst: -------------------------------------------------------------------------------- 1 | Misc package 2 | ============ 3 | 4 | .. automodule:: conkit.misc 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.misc.* 13 | 14 | -------------------------------------------------------------------------------- /docs/api/plot.rst: -------------------------------------------------------------------------------- 1 | Plot package 2 | ============ 3 | 4 | .. automodule:: conkit.plot 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | 9 | .. toctree:: 10 | :glob: 11 | 12 | generated/conkit.plot.* 13 | 14 | -------------------------------------------------------------------------------- /docs/contents.rst: -------------------------------------------------------------------------------- 1 | .. _documentation: 2 | 3 | Documentation 4 | ============= 5 | 6 | .. only:: html 7 | 8 | :Release: |version| 9 | :Date: |today| 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | formats 15 | 16 | .. toctree:: 17 | :maxdepth: 2 18 | 19 | api/io 20 | 21 | .. toctree:: 22 | :maxdepth: 2 23 | 24 | api/core 25 | 26 | .. toctree:: 27 | :maxdepth: 2 28 | 29 | api/plot 30 | 31 | .. toctree:: 32 | :maxdepth: 2 33 | 34 | api/misc 35 | 36 | .. toctree:: 37 | :maxdepth: 2 38 | 39 | api/applications 40 | 41 | .. only:: html 42 | 43 | * :ref:`genindex` 44 | * :ref:`modindex` 45 | 46 | -------------------------------------------------------------------------------- /docs/contrib.rst: -------------------------------------------------------------------------------- 1 | .. 2 | 3 | .. include:: ../CONTRIB.rst 4 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | .. _examples_main: 2 | 3 | ConKit Usage Examples 4 | ===================== 5 | 6 | .. note:: 7 | 8 | Please download the example data `here `_. This data will be used throughout all examples. 9 | 10 | .. include:: examples/io.rst 11 | .. include:: examples/analysis.rst 12 | .. include:: examples/plot.rst 13 | .. include:: examples/validation.rst 14 | .. include:: examples/core.rst 15 | .. include:: examples/applications.rst 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/examples/analysis.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: Data Analysis 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - Multiple Sequence Alignment 7 | - .. cssclass:: btn btn-primary btn-sm btn-example 8 | 9 | :ref:`Script ` 10 | - .. cssclass:: btn btn-default btn-sm btn-example 11 | 12 | :ref:`Python ` 13 | * - - Contact prediction 14 | - 15 | - .. cssclass:: btn btn-default btn-sm btn-example 16 | 17 | :ref:`Python ` 18 | -------------------------------------------------------------------------------- /docs/examples/applications.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: Application Wrappers 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - Prediction Pipeline 7 | - .. cssclass:: btn btn-primary btn-sm btn-example 8 | 9 | :ref:`Script ` 10 | - .. cssclass:: btn btn-default btn-sm btn-example 11 | 12 | :ref:`Python ` 13 | -------------------------------------------------------------------------------- /docs/examples/code/plot_cdens.py: -------------------------------------------------------------------------------- 1 | """ 2 | Contact Density Plotting 3 | ======================== 4 | 5 | This script contains a simple example of how you can evaluate 6 | the contact density of your contact map using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "4p9g/4p9g.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "4p9g/4p9g.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # We need to tidy our contact prediction before plotting 30 | conpred.remove_neighbors(inplace=True) 31 | conpred.sort('raw_score', reverse=True, inplace=True) 32 | 33 | # Truncate your contact list to 10L contacts 34 | conpred = conpred[:int(seq.seq_len * 10.)] 35 | 36 | # Then we can plot the density plot 37 | fig = conkit.plot.ContactDensityFigure(conpred, legend=True) 38 | fig.savefig("4p9g/4p9g_cdens.png") 39 | -------------------------------------------------------------------------------- /docs/examples/code/plot_chord_simple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple contact cmap Chord plotting 3 | ================================= 4 | 5 | This script contains a simple example of how you can plot 6 | contact cmaps in Chord Diagram style using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "toxd/toxd.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "toxd/toxd.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # We need to tidy our contact prediction before plotting 30 | conpred.remove_neighbors(inplace=True) 31 | conpred.sort('raw_score', reverse=True, inplace=True) 32 | 33 | # Finally, we don't want to plot all contacts but only the top-L, 34 | # so we need to slice the contact cmap 35 | cmap = conpred[:conpred.sequence.seq_len] 36 | 37 | # Then we can plot the cmap 38 | fig = conkit.plot.ContactMapChordFigure(cmap, legend=True) 39 | fig.savefig("toxd/toxd.png") 40 | -------------------------------------------------------------------------------- /docs/examples/code/plot_distogram_simple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple distogram plotting 3 | ============================= 4 | 5 | This script contains a simple example of how you can plot 6 | distograms using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "7l6q/7l6q.fasta" 15 | sequence_format = "fasta" 16 | distance_file = "7l6q/7l6q.af2" 17 | distance_format = "alphafold2" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/Distogram 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | distpred = conkit.io.read(distance_file, distance_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | distpred.sequence = seq 27 | distpred.set_sequence_register() 28 | 29 | # Then we can plot the distogram predicted with AlphaFold 2 30 | fig = conkit.plot.DistogramHeatmapFigure(distpred) 31 | fig.savefig("7l6q/7l6q.png") 32 | -------------------------------------------------------------------------------- /docs/examples/code/plot_map_reference.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple contact map plotting 2 3 | ============================= 4 | 5 | This script contains a simple example of how you can plot 6 | contact maps with a reference structure using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "toxd/toxd.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "toxd/toxd.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # We need to tidy our contact prediction before plotting 30 | conpred.remove_neighbors(inplace=True) 31 | conpred.sort('raw_score', reverse=True, inplace=True) 32 | 33 | # Finally, we don't want to plot all contacts but only the top-L, 34 | # so we need to slice the contact map 35 | cmap = conpred[:conpred.sequence.seq_len] 36 | 37 | # ==================================================== 38 | # The code above is identical to the previous example 39 | # Now we need to compare it to our reference structure 40 | pdb_file = "toxd/toxd.pdb" 41 | pdb = conkit.io.read(pdb_file, "pdb").top 42 | pdb = pdb.as_contactmap() 43 | # The two keywords do the following: 44 | # - match_other : renumber the pdb to match gaps in target 45 | # - remove_unmatched : remove contacts absent from the pdb_file 46 | # - renumber : match the numbering to the pdb_file 47 | map_matched = cmap.match(pdb, match_other=True, remove_unmatched=True, renumber=True) 48 | 49 | # Then we can plot the map 50 | fig = conkit.plot.ContactMapFigure(map_matched, reference=pdb) 51 | fig.savefig("toxd/toxd.png") 52 | -------------------------------------------------------------------------------- /docs/examples/code/plot_map_simple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple contact cmap plotting 1 3 | ============================= 4 | 5 | This script contains a simple example of how you can plot 6 | contact cmaps using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "toxd/toxd.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "toxd/toxd.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # We need to tidy our contact prediction before plotting 30 | conpred.remove_neighbors(inplace=True) 31 | conpred.sort('raw_score', reverse=True, inplace=True) 32 | 33 | # Finally, we don't want to plot all contacts but only the top-L, 34 | # so we need to slice the contact cmap 35 | cmap = conpred[:conpred.sequence.seq_len] 36 | 37 | # Then we can plot the cmap 38 | fig = conkit.plot.ContactMapFigure(cmap, legend=True) 39 | fig.savefig("toxd/toxd.png") 40 | -------------------------------------------------------------------------------- /docs/examples/code/plot_mat_simple.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple contact cmap plotting 1 3 | ============================= 4 | 5 | This script contains a simple example of how you can plot 6 | contact cmaps using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "toxd/toxd.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "toxd/toxd.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # Then we can plot the cmap 30 | fig = conkit.plot.ContactMapMatrixFigure(cmap) 31 | fig.savefig("toxd/toxd.png") 32 | -------------------------------------------------------------------------------- /docs/examples/code/plot_peval.py: -------------------------------------------------------------------------------- 1 | """ 2 | Contact Map Precision Evaluation 3 | ================================ 4 | 5 | This script contains a simple example of how you can evaluate 6 | the precision scores of your contact map using ConKit 7 | 8 | """ 9 | 10 | import conkit.io 11 | import conkit.plot 12 | 13 | # Define the input variables 14 | sequence_file = "toxd/toxd.fasta" 15 | sequence_format = "fasta" 16 | contact_file = "toxd/toxd.mat" 17 | contact_format = "ccmpred" 18 | 19 | # Create ConKit hierarchies 20 | # Note, we only need the first Sequence/ContactMap 21 | # from each file 22 | seq = conkit.io.read(sequence_file, sequence_format).top 23 | conpred = conkit.io.read(contact_file, contact_format).top 24 | 25 | # Assign the sequence register to your contact prediction 26 | conpred.sequence = seq 27 | conpred.set_sequence_register() 28 | 29 | # We need to tidy our contact prediction before plotting 30 | conpred.remove_neighbors(inplace=True) 31 | conpred.sort('raw_score', reverse=True, inplace=True) 32 | 33 | # ==================================================== 34 | # The code above is identical to the previous example 35 | # Now we need to compare it to our reference structure 36 | pdb_file = "toxd/toxd.pdb" 37 | pdb = conkit.io.read(pdb_file, "pdb").top 38 | # The two keywords do the following: 39 | # - remove_unmatched : remove contacts absent from the pdb_file 40 | # - renumber : match the numbering to the pdb_file 41 | map_matched = map.match(pdb, remove_unmatched=True, renumber=True) 42 | 43 | # Then we can plot the evaluation plot 44 | fig = conkit.plot.PrecisionEvaluationFigure(map_matched, cutoff_step=0.1, min_cutoff=0.0, max_cutoff=2.0, legend=True) 45 | fig.savefig("toxd/cdens.png") 46 | -------------------------------------------------------------------------------- /docs/examples/code/predict_pipeline.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple contact prediction pipeline 3 | ================================== 4 | 5 | This script contains a simple example of how we can create pipelines 6 | using ConKit. 7 | 8 | .. warning:: 9 | You need to exchange the paths to the executables 10 | 11 | """ 12 | 13 | import conkit.applications 14 | import conkit.io 15 | import conkit.plot 16 | 17 | # Define the input variables 18 | sequence_file = "toxd/toxd.fasta" 19 | sequence_format = "fasta" 20 | 21 | # Define the paths to the software we use 22 | hhblits_exe = "path/to/hhblits" # <-- MODIFY THIS 23 | hhblits_database = "path/to/hhblits_database" # <-- MODIFY THIS 24 | ccmpred_exe = "path/to/ccmpred" # <-- MODIFY THIS 25 | 26 | # Generate a Multiple Sequence Alignment 27 | print("Generating the Multiple Sequence Alignment") 28 | a3m_file = "toxd/toxd.a3m" 29 | hhblits_cline = conkit.applications.HHblitsCommandLine( 30 | cmd=hhblits_exe, database=hhblits_database, input=sequence_file, oa3m=a3m_file) 31 | hhblits_cline() # Execute HHblits 32 | 33 | # Analyse the alignment 34 | msa = conkit.io.read(a3m_file, "a3m") 35 | print("Length of the Target Sequence: %d" % msa.top_sequence.seq_len) 36 | print("Total Number of Sequences: %d" % msa.nseq) 37 | print("Number of Effective Sequences: %d" % msa.neff) 38 | 39 | # Plot the amino acid coverage per position in the alignment 40 | fig1 = conkit.plot.SequenceCoverageFigure(msa) 41 | seq_cov_file = "toxd/toxd.freq.png" 42 | fig2.savefig(seq_cov_file) 43 | print("Sequence Coverage Plot: %s" % seq_cov_file) 44 | 45 | # Convert the alignment into a CCMpred-readable format 46 | jones_file = "toxd/toxd.jones" 47 | conkit.io.write(jones_file, "jones", msa) 48 | 49 | # Predict the contacts 50 | print("Predicting contacts") 51 | mat_file = "toxd/toxd.mat" 52 | ccmpred_cline = conkit.applications.CCMpredCommandLine(alnfile=jones_file, matfile=mat_file) 53 | ccmpred_cline() # Execute CCMpred 54 | 55 | # Plot the top-30 contacts 56 | conpred = conkit.io.read(mat_file, "ccmpred").top_map 57 | # Remove contacts of neigbouring residues 58 | conpred.remove_neighbors(inplace=True) 59 | # Sort the list of contacts by their score 60 | conpred.sort("raw_score", reverse=True, inplace=True) 61 | conpred = conpred[:30] # Slice the contact map 62 | fig2 = conkit.plot.ContactMapFigure(conpred, legend=True) 63 | contact_map_file = "toxd/toxd.map.png" 64 | fig2.savefig(contact_map_file) 65 | print("Contact Map Plot: %s" % contact_map_file) 66 | 67 | # Convert the contact prediction to a standardised format 68 | casp_file = "toxd/toxd.rr" 69 | conkit.io.convert(mat_file, "ccmpred", casp_file, "casprr") 70 | print("Final Contact Prediction File: %s" % casp_file) 71 | -------------------------------------------------------------------------------- /docs/examples/core.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: Data Model 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - (Multiple) Sequence File 7 | - 8 | - .. cssclass:: btn btn-default btn-sm btn-example 9 | 10 | :ref:`Python ` 11 | * - - Contact Prediction File 12 | - 13 | - .. cssclass:: btn btn-default btn-sm btn-example 14 | 15 | :ref:`Python ` 16 | -------------------------------------------------------------------------------- /docs/examples/io.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: File Conversions 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - (Multiple) Sequence File 7 | - .. cssclass:: btn btn-primary btn-sm btn-example 8 | 9 | :ref:`Script ` 10 | - .. cssclass:: btn btn-default btn-sm btn-example 11 | 12 | :ref:`Python ` 13 | * - - Contact prediction 14 | - .. cssclass:: btn btn-primary btn-sm btn-example 15 | 16 | :ref:`Script ` 17 | - .. cssclass:: btn btn-default btn-sm btn-example 18 | 19 | :ref:`Python ` 20 | * - - Residue distance predictions 21 | - .. cssclass:: btn btn-primary btn-sm btn-example 22 | 23 | :ref:`Script ` 24 | - .. cssclass:: btn btn-default btn-sm btn-example 25 | 26 | :ref:`Python ` 27 | -------------------------------------------------------------------------------- /docs/examples/plot.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: Data Visualisation 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - Contact Map 7 | - .. cssclass:: btn btn-primary btn-sm btn-example 8 | 9 | :ref:`Script ` 10 | - .. cssclass:: btn btn-default btn-sm btn-example 11 | 12 | :ref:`Python ` 13 | 14 | * - - Contact Map Matrix 15 | - .. cssclass:: btn btn-primary btn-sm btn-example 16 | 17 | :ref:`Script ` 18 | - .. cssclass:: btn btn-default btn-sm btn-example 19 | 20 | :ref:`Python ` 21 | 22 | * - - Contact Map Chord Diagram 23 | - .. cssclass:: btn btn-primary btn-sm btn-example 24 | 25 | :ref:`Script ` 26 | - .. cssclass:: btn btn-default btn-sm btn-example 27 | 28 | :ref:`Python ` 29 | 30 | * - - Contact Density Plot 31 | - .. cssclass:: btn btn-primary btn-sm btn-example 32 | 33 | :ref:`Script ` 34 | - .. cssclass:: btn btn-default btn-sm btn-example 35 | 36 | :ref:`Python ` 37 | 38 | * - - Distogram 39 | - .. cssclass:: btn btn-primary btn-sm btn-example 40 | 41 | :ref:`Script ` 42 | - .. cssclass:: btn btn-default btn-sm btn-example 43 | 44 | :ref:`Python ` 45 | 46 | * - - Precision Evaluation 47 | - .. cssclass:: btn btn-primary btn-sm btn-example 48 | 49 | :ref:`Script ` 50 | - .. cssclass:: btn btn-default btn-sm btn-example 51 | 52 | :ref:`Python ` 53 | 54 | * - - Sequence Coverage 55 | - .. cssclass:: btn btn-primary btn-sm btn-example 56 | 57 | :ref:`Script ` 58 | - .. cssclass:: btn btn-default btn-sm btn-example 59 | 60 | :ref:`Python ` 61 | 62 | -------------------------------------------------------------------------------- /docs/examples/rst/python_analyse_msa.rst: -------------------------------------------------------------------------------- 1 | .. _python_analyse_msa: 2 | 3 | Multiple Sequence Alignment Analysis 4 | ------------------------------------ 5 | 6 | .. warning:: 7 | You require the :mod:`scipy` package to use this script. If you are unsure if it is installed on your system, refer to the :ref:`Installation` documentation 8 | 9 | **1. The MSA ConKit hierarchy needs to be created first.** 10 | 11 | .. code-block:: python 12 | 13 | >>> import conkit.io 14 | >>> msa = conkit.io.read('toxd/toxd.a3m', 'a3m') 15 | 16 | **2. To obtain the length of the target sequence, you can simply ask the ``msa`` hierarchy for it.** 17 | 18 | .. code-block:: python 19 | 20 | >>> print('Length of the Target Sequence: %d' % msa.top_sequence.seq_len) 21 | 59 22 | 23 | This tells you the first sequence in the alignment has 59 residues, i.e. the chain length of your target. 24 | 25 | **3. We can again use the ``msa`` hierarchy to figure out the total number of sequences.** 26 | 27 | .. code-block:: python 28 | 29 | >>> print('Total number of sequences: %d' % msa.nseq) 30 | Total number of sequences: 13488 31 | 32 | **4. ... and the number of effective sequences in the alignment at 70% identity cutoff.** 33 | 34 | .. code-block:: python 35 | 36 | >>> n_eff = msa.meff 37 | >>> print('Number of Effective Sequences: %d' % n_eff) 38 | Number of Effective Sequences: 3318 39 | 40 | **5. We can also plot the amino acid frequency at each position in the alignment.** 41 | 42 | .. code-block:: python 43 | 44 | >>> file_name = 'toxd/toxd.png' 45 | >>> import conkit.plot 46 | >>> conkit.plot.SequenceCoverageFigure(msa, file_name=file_name) 47 | 48 | .. _Toxd Frequency Plot: 49 | 50 | .. figure:: ../../_static/plot_scov_toxd.png 51 | :alt: Toxd Sequence Coverage Plot 52 | :scale: 30 53 | 54 | -------------------------------------------------------------------------------- /docs/examples/rst/python_convert_conpred.rst: -------------------------------------------------------------------------------- 1 | .. _python_convert_conpred: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | In order to convert files in ConKit, we need to use the ConKit I/O framework. 7 | 8 | .. note:: 9 | ConKit I/O framework consists of three main functions that handle the relevant parsers: :func:`~conkit.io.read`, :func:`~conkit.io.write` and :func:`~conkit.io.convert`. The latter effectively uses the former two but handles everything in one step. 10 | 11 | **1. Files can be read in ConKit's internal hierarchies using simple Python code.** 12 | 13 | .. code-block:: python 14 | 15 | >>> import conkit.io 16 | >>> conpred = conkit.io.read('toxd/toxd.mat', 'ccmpred') 17 | 18 | **2. Contact prediction hierarchies can also be written in a similarly easy format. Using the ``conpred`` hierarchy we have created above:** 19 | 20 | .. code-block:: python 21 | 22 | >>> import conkit.io 23 | >>> conkit.io.write('toxd/toxd.rr', 'casprr', conpred) 24 | 25 | **3. To convert file formats in single call, you can use the :func:`~conkit.io.convert` function.** 26 | 27 | .. code-block:: python 28 | 29 | >>> import conkit.io 30 | >>> conkit.io.convert('toxd/toxd.mat', 'ccmpred', 'toxd/toxd.rr', 'casprr') 31 | 32 | You can convert these files to many different other formats, for a full list check out the :ref:`file_formats`. 33 | -------------------------------------------------------------------------------- /docs/examples/rst/python_convert_distpred.rst: -------------------------------------------------------------------------------- 1 | .. _python_convert_distpred: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | In order to convert files in ConKit, we need to use the ConKit I/O framework. 7 | 8 | .. note:: 9 | ConKit I/O framework consists of three main functions that handle the relevant parsers: :func:`~conkit.io.read`, :func:`~conkit.io.write` and :func:`~conkit.io.convert`. The latter effectively uses the former two but handles everything in one step. 10 | 11 | **1. Files can be read in ConKit's internal hierarchies using simple Python code.** 12 | 13 | .. code-block:: python 14 | 15 | >>> import conkit.io 16 | >>> distpred = conkit.io.read('7l6q/7l6q.af2', 'alphafold2') 17 | 18 | **2. Residue distance prediction hierarchies can also be written in a similarly easy format. Using the ``distpred`` hierarchy we have created above:** 19 | 20 | .. code-block:: python 21 | 22 | >>> import conkit.io 23 | >>> conkit.io.write('7l6q/7l6q.casprr2', 'caspmode2', distpred) 24 | 25 | **3. To convert file formats in single call, you can use the :func:`~conkit.io.convert` function.** 26 | 27 | .. code-block:: python 28 | 29 | >>> import conkit.io 30 | >>> conkit.io.convert('7l6q/7l6q.af2', 'alphafold2', '7l6q/7l6q.casprr2', 'caspmode2') 31 | 32 | You can convert these files to many different other formats, for a full list check out the :ref:`file_formats`. It is possible to convert distance prediction files into contact prediction files, but not the other way around. 33 | -------------------------------------------------------------------------------- /docs/examples/rst/python_convert_msa.rst: -------------------------------------------------------------------------------- 1 | .. _python_convert_msa: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | In order to convert files in ConKit, we need to use the ConKit I/O framework. 7 | 8 | .. note:: 9 | ConKit I/O framework consists of three main functions that handle the relevant parsers: :func:`~conkit.io.read`, :func:`~conkit.io.write` and :func:`~conkit.io.convert`. The latter effectively uses the former two but handles everything in one step. 10 | 11 | **1. Files can be read in ConKit's internal hierarchies using simple Python code.** 12 | 13 | .. code-block:: python 14 | 15 | >>> import conkit.io 16 | >>> msa = conkit.io.read('toxd/toxd.a3m', 'a3m') 17 | 18 | **2. Sequence hierarchies can also be written in a similarly easy format. Using the ``msa`` hierarchy we have created above:** 19 | 20 | .. code-block:: python 21 | 22 | >>> import conkit.io 23 | >>> conkit.io.write('toxd/toxd.mfa', 'fasta', msa) 24 | 25 | **3. To convert file formats in single call, you can use the :func:`~conkit.io.convert` function.** 26 | 27 | .. code-block:: python 28 | 29 | >>> import conkit.io 30 | >>> conkit.io.convert('toxd/toxd.a3m', 'a3m', 'toxd/toxd.mfa', 'fasta') 31 | 32 | You can convert these files to many different other formats, for a full list check out the :ref:`file_formats`. 33 | -------------------------------------------------------------------------------- /docs/examples/rst/python_create_contactfile.rst: -------------------------------------------------------------------------------- 1 | .. _python_create_contactfile: 2 | 3 | ConKit ContactFile Hierarchy Construction 4 | ----------------------------------------- 5 | 6 | If you wish to construct it as part of a new development to store your contact information, you might find the following helpful. 7 | 8 | Entities 9 | ++++++++ 10 | 11 | **1. How to create a :obj:`~conkit.core.contact.Contact`?** 12 | 13 | .. code-block:: python 14 | 15 | >>> from conkit.core import Contact 16 | >>> contact = Contact(1, 10, 1.0) 17 | 18 | The example above creates a contact between residues ``1`` and ``10`` and assigns a :attr:`~conkit.core.contact.Contact.raw_score` of ``1.0`` to it. By default, this contact has many more default attributes assigned, such as the distance value often seen in columns 3 and 4 in the Casp RR format. 19 | 20 | **2. How to create a :obj:`~conkit.core.contactmap.ContactMap`?** 21 | 22 | .. code-block:: python 23 | 24 | >>> from conkit.core import ContactMap 25 | >>> cmap = ContactMap('example') 26 | 27 | This example shows you how to create a :obj:`~conkit.core.contactmap.ContactMap` which can store a :obj:`~conkit.core.contact.Contact`. 28 | 29 | **3. How to create a :obj:`~conkit.core.contactfile.ContactFile`?** 30 | 31 | .. code-block:: python 32 | 33 | >>> from conkit.core import ContactFile 34 | >>> cmap = ContactFile('example') 35 | 36 | This example shows you how to create a :obj:`~conkit.core.contactfile.ContactFile` which can store a :obj:`~conkit.core.contactmap.ContactMap`. 37 | 38 | Hierarchy 39 | +++++++++ 40 | 41 | Above is an outline for the different contact-related :obj:`~conkit.core.entity.Entity` classes. Each higher entity allows you to store one or more lower-level ones, i.e. you can store one or more :obj:`~conkit.core.contactmap.ContactMap` entities in a single :obj:`~conkit.core.contactfile.ContactFile`. Similarly, you could many :obj:`~conkit.core.contact.Contact` entities in a :obj:`~conkit.core.contactmap.ContactMap`; however, be aware that all **must** have unique IDs. 42 | 43 | To illustrate how you can combine the :obj:`~conkit.core.entity.Entity` classes, look at the following: 44 | 45 | .. code-block:: python 46 | 47 | >>> from conkit.core import Contact, ContactMap, ContactFile 48 | >>> cfile = ContactFile('example_file') 49 | >>> cmap = ContactMap('example_map') 50 | >>> contact = Contact(1, 10, 1.0) 51 | >>> # Add the contact to the contact map 52 | >>> cmap.add(contact) 53 | >>> # Add the contact map to the contact file 54 | >>> cfile.add(cmap) 55 | 56 | Note, the order in which you add :obj:`~conkit.core.entity.Entity` instances does not matter. We could also add the ``cmap`` to the ``cfile`` before adding the ``contact`` to the ``cmap``. 57 | 58 | Once you have constructed your hierarchy, all related functions are available to you. 59 | -------------------------------------------------------------------------------- /docs/examples/rst/python_create_sequencefile.rst: -------------------------------------------------------------------------------- 1 | .. _python_create_sequencefile: 2 | 3 | ConKit SequenceFile Hierarchy Construction 4 | ------------------------------------------ 5 | 6 | If you wish to construct it as part of a new development to store your sequence information, you might find the following helpful. 7 | 8 | Entities 9 | ++++++++ 10 | 11 | 1. **How to create a :obj:`~conkit.core.sequence.Sequence`?** 12 | 13 | .. code-block:: python 14 | 15 | >>> import conkit.core 16 | >>> seq = conkit.core.Sequence("example", "ABCDEF") 17 | 18 | The example above creates a :obj:`~conkit.core.sequence.Sequence` object with id "example" and sequence "ABCDEF". This sequence contains numerous functions, such as :meth:`~conkit.core.sequence.Sequence.align_global` for a global pairwise alignment with a second sequence 19 | 20 | 2. **How to create a :obj:`~conkit.core.sequencefile.SequenceFile`?** 21 | 22 | .. code-block:: python 23 | 24 | >>> import conkit.core 25 | >>> sfile = conkit.core.SequenceFile("example") 26 | 27 | This example shows you how to create a :obj:`~conkit.core.sequencefile.SequenceFile` which can store one or more :obj:`~conkit.core.sequence.Sequence` objects. 28 | 29 | Hierarchy 30 | +++++++++ 31 | 32 | Above is an outline for the different sequence-related :obj:`~conkit.core.entity.Entity` classes. Each higher entity allows you to store one or more lower-level ones, i.e. you can store one or more :obj:`~conkit.core.sequence.Sequence` entities in a single :obj:`~conkit.core.sequencefile.SequenceFile`; however, be aware that all **must** have unique IDs. 33 | 34 | To illustrate how you can combine the entities, look at the following: 35 | 36 | .. code-block:: python 37 | 38 | >>> import conkit.core 39 | >>> sfile = conkit.core.SequenceFile("example") 40 | >>> seq1 = conkit.core.Sequence("example", "ABCDEF") 41 | >>> seq2 = conkit.core.Sequence("elpmaxe", "FEDCBA") 42 | >>> sfile.add(seq1) 43 | >>> sfile.add(seq2) 44 | 45 | Note, the order in which you add :obj:`~conkit.core.entity.Entity` instances does not matter. 46 | 47 | Once you have constructed your hierarchy, all related functions are available to you. 48 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_cdens.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_cdens: 2 | 3 | Contact Density Plotting 4 | ------------------------ 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_cdens.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_cdens.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../../_static/plot_cdens_4p9g.png 15 | :alt: 4p9g Contact Density Plot 16 | :scale: 30 17 | 18 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_chord.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_chord: 2 | 3 | Contact Map Chord Diagram Plotting 4 | ---------------------------------- 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_chord_simple.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_chord_simple.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../images/toxd_chord_simple.png 15 | :alt: Toxd Chord Simple 16 | :scale: 30 17 | 18 | Each residue in the Chord plot corresponds to an amino acid in your sequence. For a full list of the encoding used, check the :obj:`ContactMapChordFigure `. 19 | 20 | .. role:: ala 21 | .. role:: cys 22 | .. role:: asp 23 | .. role:: glu 24 | .. role:: phe 25 | .. role:: gly 26 | .. role:: his 27 | .. role:: ile 28 | .. role:: lys 29 | .. role:: leu 30 | .. role:: met 31 | .. role:: asn 32 | .. role:: pro 33 | .. role:: gln 34 | .. role:: arg 35 | .. role:: ser 36 | .. role:: thr 37 | .. role:: val 38 | .. role:: trp 39 | .. role:: tyr 40 | .. role:: unk 41 | 42 | The color coding of the full sequence used is the following: 43 | 44 | :gln:`Q` :pro:`P` :arg:`R` :arg:`R` :lys:`K` :leu:`L` :cys:`C` :ile:`I` :leu:`L` :his:`H` :arg:`R` :asn:`N` :pro:`P` :gly:`G` :arg:`R` :cys:`C` :thr:`T` :tyr:`Y` :asp:`D` :lys:`K` :ile:`I` :pro:`P` :ala:`A` :phe:`F` :tyr:`Y` :tyr:`Y` :asn:`N` :gln:`Q` :lys:`K` :lys:`K` :lys:`K` Q :cys:`C` :glu:`E` :arg:`R` :phe:`F` :asp:`D` :trp:`W` :ser:`S` :gly:`G` :cys:`C` :gly:`G` :gly:`G` :asn:`N` :ser:`S` :asn:`N` :arg:`R` :phe:`F` :lys:`K` :thr:`T` :ile:`I` :glu:`E` :glu:`E` :cys:`C` :arg:`R` :arg:`R` :thr:`T` :cys:`C` :ile:`I` :gly:`G` 45 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_distogram.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_distogram: 2 | 3 | Distogram Plotting 4 | ------------------- 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_distogram_simple.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_distogram_simple.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../../_static/plot_distogram_simple.png 15 | :alt: 7l6q Distogram Simple 16 | :scale: 30 17 | 18 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_map.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_map: 2 | 3 | Contact Map Plotting 4 | -------------------- 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_map_simple.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_map_simple.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../images/toxd_cmap_simple.png 15 | :alt: Toxd CMap Simple 16 | :scale: 30 17 | 18 | -------------------------------------------------------------- 19 | 20 | .. only:: html 21 | 22 | (:download:`Source Code <../code/plot_map_reference.py>`) 23 | 24 | .. literalinclude:: /../docs/examples/code/plot_map_reference.py 25 | :language: python 26 | :linenos: 27 | 28 | .. figure:: ../images/toxd_cmap_reference.png 29 | :alt: Toxd CMap Reference 30 | :scale: 30 31 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_mat.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_mat: 2 | 3 | Contact Map Matrix Plotting 4 | --------------------------- 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_mat_simple.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_mat_simple.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../images/toxd_cmat_simple.png 15 | :alt: Toxd CMat Simple 16 | :scale: 30 17 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_peval.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_peval: 2 | 3 | Sequence Coverage Plotting 4 | -------------------------- 5 | 6 | .. only:: html 7 | 8 | (:download:`Source Code <../code/plot_peval.py>`) 9 | 10 | .. literalinclude:: /../docs/examples/code/plot_peval.py 11 | :language: python 12 | :linenos: 13 | 14 | .. figure:: ../../_static/plot_peval_toxd.png 15 | :alt: Toxd Precision Evaluation Plot 16 | :scale: 30 17 | 18 | -------------------------------------------------------------------------------- /docs/examples/rst/python_plot_scov.rst: -------------------------------------------------------------------------------- 1 | .. _python_plot_scov: 2 | 3 | Sequence Coverage Plotting 4 | -------------------------- 5 | 6 | .. code-block:: python 7 | 8 | >>> import conkit.io 9 | >>> import conkit.plot 10 | >>> msa = conkit.io.read('toxd/toxd.a3m', 'a3m') 11 | >>> conkit.plot.SequenceCoverageFigure(msa) 12 | 13 | The following plot will be produced. Your alignment coverage is shown with the black line with each point corresponding to a residue in the alignment. The other two lines give you indicators of how good your alignment is. 14 | 15 | .. figure:: ../../_static/plot_scov_toxd.png 16 | :alt: Toxd Sequence Coverage Plot 17 | :scale: 30 18 | 19 | If parts or all of your coverage fall below the "5 x Nresidues" line, the suitability for covariance-based contact prediction is very low. If most residues in the alignment are well above the "5 x Nresidues" line, possibly even the "20 x Nresidues", and bigger chunks are below, then you might want to consider re-defining your sequence boundaries to predict contacts only for the well-covered area. 20 | 21 | If most residues in your alignment have a better coverage than the "20 x Nresidues" line, the alignment is well-suited for covariance-based predictions. 22 | 23 | -------------------------------------------------------------------------------- /docs/examples/rst/python_predict_pipeline.rst: -------------------------------------------------------------------------------- 1 | .. _python_predict_pipeline: 2 | 3 | Contact Prediction 4 | ------------------ 5 | 6 | .. warning:: 7 | 8 | External software is required to execute this script. For further information, refer to the :ref:`installation` page. 9 | 10 | .. only:: html 11 | 12 | (:download:`Source Code <../code/predict_pipeline.py>`) 13 | 14 | .. literalinclude:: /../docs/examples/code/predict_pipeline.py 15 | :language: python 16 | :linenos: 17 | -------------------------------------------------------------------------------- /docs/examples/rst/script_analyse_msa.rst: -------------------------------------------------------------------------------- 1 | .. _script_analyse_msa: 2 | 3 | Multiple Sequence Alignment Analysis 4 | ------------------------------------ 5 | 6 | .. warning:: 7 | You require the :mod:`scipy` package to use this script. If you are unsure if it is installed on your system, refer to the :ref:`Installation` documentation 8 | 9 | 10 | If you would like to analyse a Multiple Sequence Alignment (MSA) file, you can do so using ConKit's provided script, which is called ``conkit-msatool``. 11 | 12 | .. code-block:: bash 13 | 14 | $> conkit-msatool toxd/toxd.a3m a3m 15 | 16 | The call above analyses the ``toxd.a3m`` MSA file, which is in ``a3m`` format. This call with will procude the following output: 17 | 18 | 19 | .. code-block:: none 20 | 21 | Input MSA File: toxd/toxd.a3m 22 | Input MSA Format: a3m 23 | Sequence Identity Threshold: 0.7 24 | Length of the Target Sequence: 59 25 | Total Number of Sequences: 13448 26 | Number of Effective Sequences: 3318 27 | Sequence Coverage Plot: toxd/toxd.png 28 | 29 | The output tells you the file and format you have provided. It also prints which identity threshold was used to compare sequences during the analysis. Furthermore, it tells you the total number of sequences in your alignment and the number of effective sequences, or depth, of your alignment. Finally, this script will produce a plot that illustrates the coverage of your alignment in individual positions. The plot is shown below: 30 | 31 | .. _Toxd Frequency Plot: 32 | 33 | .. figure:: ../../_static/plot_scov_toxd.png 34 | :alt: Toxd Sequence Coverage Plot 35 | :align: center 36 | :scale: 30 37 | 38 | -------------------------------------------------------------------------------- /docs/examples/rst/script_convert_conpred.rst: -------------------------------------------------------------------------------- 1 | .. _script_convert_conpred: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | If you would like to convert a file from one format to another, you can do so using ConKit's provided script, which is called ``conkit-convert``. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-convert toxd/toxd.mat ccmpred toxd/toxd.rr casprr 11 | 12 | The call above converts the ``toxd.mat`` file, which is in ``ccmpred`` format, to the ``toxd.rr`` file in ``casprr`` format. 13 | 14 | You can convert these files to many different other formats, for a full list check out the :ref:`file_formats`. 15 | -------------------------------------------------------------------------------- /docs/examples/rst/script_convert_distpred.rst: -------------------------------------------------------------------------------- 1 | .. _script_convert_distpred: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | If you would like to convert a file from one format to another, you can do so using ConKit's provided script, which is called ``conkit-convert``. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-convert 7l6q/7l6q.af2 alphafold2 7l6q/7l6q.rr2 caspmode2 11 | 12 | The call above converts the ``7l6q.af2`` file, which is in ``alphafold2`` format, to the ``7l6q.rr2`` file in ``caspmode2`` format. These two file formats contain inter-residue distance predictions. You can also choose to convert residue distance predictions into a residue contact prediction file, for example: 13 | 14 | .. code-block:: bash 15 | 16 | $> conkit-convert 7l6q/7l6q.af2 alphafold2 7l6q/7l6q.psicov psicov 17 | 18 | The call above converts the ``7l6q.af2`` file, which is in ``alphafold2`` distance prediction format, to the ``7l6q.psicov`` file in ``psicov`` contact prediction format. It is not possible to perform the inverse conversion (residue contact predictions into inter-residue distance predictions). 19 | 20 | Conkit supports many different other formats, for a full list check out the :ref:`file_formats`. 21 | -------------------------------------------------------------------------------- /docs/examples/rst/script_convert_msa.rst: -------------------------------------------------------------------------------- 1 | .. _script_convert_msa: 2 | 3 | File Format Conversion 4 | ---------------------- 5 | 6 | If you would like to convert a file from one format to another, you can do so using ConKit's provided script, which is called ``conkit-convert``. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-convert toxd/toxd.a3m a3m toxd/toxd.mfa fasta 11 | 12 | The call above converts the ``toxd.a3m`` file, which is in ``a3m`` format, to the ``toxd.mfa`` file in ``fasta`` format. 13 | 14 | You can convert these files to many different other formats, for a full list check out the :ref:`file_formats`. 15 | -------------------------------------------------------------------------------- /docs/examples/rst/script_model_validation.rst: -------------------------------------------------------------------------------- 1 | .. _script_model_validation: 2 | 3 | Model validation 4 | -------------------- 5 | 6 | Conkit can be used to perform model validation using inter-residue distance predictions. This can be used to detect sequence register errors and other kinds of modelling errors in the protein model. To be able to use this functionality, you must ensure that you install first mkdssp and map_align 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-validate 7l6q/7l6q.fasta fasta 7l6q/7l6q.af2 alphafold2 7l6q/7l6q_B.pdb alphafold2 pdb -dssp_exe /usr/bin/mkdssp --map_align_exe /usr/bin/map_align -output 7l6q/7l6q.png 11 | 12 | The call above uses the AlphaFold 2 distance prediction file ``7l6q.af2`` file, which is in ``alphafold2`` format, and compares the predicted inter-residue distances with those observed in the protein model at ``7l6q_B.pdb``. Note that you need to provide a path to the executables of ``dssp` and ``map_align`` using the keywords ``-dssp_exe`` and ``--map_align_exe`` respectively. This command will create the file ``7l6q.png`` with the following figure: 13 | 14 | .. figure:: ../../_static/plot_model_validation.png 15 | :alt: 7l6q Model Validation 16 | :align: center 17 | :scale: 30 18 | 19 | In this representation, scores predicted by a trained SVM classifier are shown as a turquoise line, and they have been smoothed using a five residue rolling average. The higher this score, the more likely it is that a given residue is part of a modelling error. A red dotted line shows the 0.5 score threshold, and a top horizontal bar at the bottom of the figure shows for each residue position whether the predicted score was above 0.5 (red) or below (cyan). The lower horizontal bar at the bottom of the figure shows for each residue position whether the CMO was achieved using the sequence register observed in the model (dark blue) or an alternative register (yellow). The same information will also be printed into the terminal in the form of a table, which will contain the predicted SVM score and the CMO results at each residue position. 20 | If you want to know more about ``conkit-validate`` you may want to `watch our video at the CCP4 SW 2022 `_ 21 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_cdens.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_cdens: 2 | 3 | Contact Density Plotting 4 | ------------------------ 5 | 6 | The ``cdens`` subcommand of the ``conkit-plot`` script is used to plot the contact density plot of the contact prediction file. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot cdens 4p9g/4p9g.fasta fasta 4p9g/4p9g.mat ccmpred 11 | 12 | .. figure:: ../../_static/plot_cdens_4p9g.png 13 | :alt: 4p9g Precision Evaluation Plot 14 | :align: center 15 | :scale: 30 16 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_chord.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_chord: 2 | 3 | Contact Map Chord Diagram Plotting 4 | ---------------------------------- 5 | 6 | If you would like to plot a contact map in Chord diagram style using ConKit without the overhead of using Python, you can simply use the ``conkit-plot`` script. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot chord toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 11 | 12 | The call above uses the contact prediction file ``toxd.mat`` file, which is in ``ccmpred`` format, and plots the following contact map stored in the file ``toxd/toxd.png``. 13 | 14 | .. figure:: ../images/toxd_chord_simple.png 15 | :alt: Toxd Chord Simple 16 | :align: center 17 | :scale: 30 18 | 19 | Each residue in the Chord plot corresponds to an amino acid in your sequence. For a full list of the encoding used, check the :obj:`~conkit.plot.contactmapchord.ContactMapChordFigure`. 20 | 21 | .. role:: ala 22 | .. role:: cys 23 | .. role:: asp 24 | .. role:: glu 25 | .. role:: phe 26 | .. role:: gly 27 | .. role:: his 28 | .. role:: ile 29 | .. role:: lys 30 | .. role:: leu 31 | .. role:: met 32 | .. role:: asn 33 | .. role:: pro 34 | .. role:: gln 35 | .. role:: arg 36 | .. role:: ser 37 | .. role:: thr 38 | .. role:: val 39 | .. role:: trp 40 | .. role:: tyr 41 | .. role:: unk 42 | 43 | The color coding of the full sequence used is the following: 44 | 45 | :gln:`Q` :pro:`P` :arg:`R` :arg:`R` :lys:`K` :leu:`L` :cys:`C` :ile:`I` :leu:`L` :his:`H` :arg:`R` :asn:`N` :pro:`P` :gly:`G` :arg:`R` :cys:`C` :thr:`T` :tyr:`Y` :asp:`D` :lys:`K` :ile:`I` :pro:`P` :ala:`A` :phe:`F` :tyr:`Y` :tyr:`Y` :asn:`N` :gln:`Q` :lys:`K` :lys:`K` :lys:`K` Q :cys:`C` :glu:`E` :arg:`R` :phe:`F` :asp:`D` :trp:`W` :ser:`S` :gly:`G` :cys:`C` :gly:`G` :gly:`G` :asn:`N` :ser:`S` :asn:`N` :arg:`R` :phe:`F` :lys:`K` :thr:`T` :ile:`I` :glu:`E` :glu:`E` :cys:`C` :arg:`R` :arg:`R` :thr:`T` :cys:`C` :ile:`I` :gly:`G` 46 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_distogram.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_distogram: 2 | 3 | Distogram Plotting 4 | -------------------- 5 | 6 | If you would like to plot a distogram using ConKit without the overhead of using Python, you can simply use the ``conkit-plot`` script. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot distheat -o 7l6q/7l6q.png 7l6q/7l6q.fasta fasta 7l6q/7l6q.af2 alphafold2 11 | 12 | The call above uses the AlphaFold 2 distance prediction file ``7l6q.af2`` file, which is in ``alphafold2`` format, and plots the following distogram stored in the file ``7l6q/7l6q.png`` 13 | 14 | .. figure:: ../../_static/plot_distogram_simple.png 15 | :alt: 7l6q Distogram Simple 16 | :align: center 17 | :scale: 30 18 | 19 | -------------------------------------------------------------- 20 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_map.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_map: 2 | 3 | Contact Map Plotting 4 | -------------------- 5 | 6 | If you would like to plot a contact map using ConKit without the overhead of using Python, you can simply use the ``conkit-plot`` script. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot cmap toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 11 | 12 | The call above uses the contact prediction file ``toxd.mat`` file, which is in ``ccmpred`` format, and plots the following 2D contact map stored in the file ``toxd/toxd.png`` 13 | 14 | .. figure:: ../images/toxd_cmap_simple.png 15 | :alt: Toxd CMap Simple 16 | :align: center 17 | :scale: 30 18 | 19 | -------------------------------------------------------------- 20 | 21 | You can also add a reference structure to determine which contacts are true and false positive contacts. By default, all contacts are identified in the reference structure by measuring the distance between Cβ atoms, whereby all atoms closer than 8Å are considered to be in contact. 22 | 23 | .. code-block:: bash 24 | 25 | $> conkit-plot cmap -p toxd/toxd.pdb -pf pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 26 | 27 | 28 | The call above produces a contact map plot looking like this. The gray points are the reference contacts, and matched and mismatched contacts are shown in color. 29 | 30 | .. figure:: ../images/toxd_cmap_reference.png 31 | :alt: Toxd CMap Reference 32 | :align: center 33 | :scale: 30 34 | 35 | -------------------------------------------------------------- 36 | 37 | You could also add a second contact prediction file to the call to compare two maps against each other. 38 | 39 | .. code-block:: bash 40 | 41 | $> conkit-plot cmap -e toxd/toxd.psicov -ef psicov -p toxd/toxd.pdb -pf pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 42 | 43 | The call above produces a contact map plot looking like this. The gray points are the reference contacts, and matched and mismatched contacts are shown in color. The top triangle is the second contact map from file ``toxd/toxd.psicov`` whereas the bottom one is from ``toxd/toxd.mat``. 44 | 45 | .. figure:: ../images/toxd_cmap_advanced.png 46 | :alt: Toxd CMap Advanced 47 | :align: center 48 | :scale: 30 49 | 50 | -------------------------------------------------------------- 51 | 52 | Finally, you could also illustrate the confidence with which each contact was predicted. 53 | 54 | .. code-block:: bash 55 | 56 | $> conkit-plot cmap --confidence -e toxd/toxd.psicov -ef psicov -p toxd/toxd.pdb -pf pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 57 | 58 | The call above produces a contact map plot looking like this. All parameters and settings are identical to the previous map except the ``--confidence`` flag, which will show more confidently predicted contacts as larger markers. 59 | 60 | .. figure:: ../images/toxd_cmap_confidence.png 61 | :alt: Toxd CMap Confidence 62 | :align: center 63 | :scale: 30 64 | 65 | .. note:: 66 | 67 | You can use the last two examples also **without** a reference structure! 68 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_mat.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_mat: 2 | 3 | Contact Map Matrix Plotting 4 | --------------------------- 5 | 6 | If you would like to plot a contact map using ConKit without the overhead of using Python, you can simply use the ``conkit-plot`` script. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot cmat toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 11 | 12 | The call above uses the contact prediction file ``toxd.mat`` file, which is in ``ccmpred`` format, and plots the following 2D contact map matrix stored in the file ``toxd/toxd.png`` 13 | 14 | .. figure:: ../images/toxd_cmat_simple.png 15 | :alt: Toxd CMat Simple 16 | :align: center 17 | :scale: 30 18 | 19 | -------------------------------------------------------------- 20 | 21 | You could also add a second contact prediction file to the call to compare two maps against each other. 22 | 23 | .. code-block:: bash 24 | 25 | $> conkit-plot cmat -e toxd/toxd.psicov -ef psicov toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 26 | 27 | The call above produces a contact map plot looking like this. The gray points are the reference contacts, and matched and mismatched contacts are shown in color. The top triangle is the second contact map from file ``toxd/toxd.psicov`` whereas the bottom one is from ``toxd/toxd.mat``. 28 | 29 | .. figure:: ../images/toxd_cmat_advanced.png 30 | :alt: Toxd CMat Advanced 31 | :align: center 32 | :scale: 30 33 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_peval.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_peval: 2 | 3 | Precision Evaluation Plotting 4 | ----------------------------- 5 | 6 | The ``peval`` subcommand of the ``conkit-plot`` script is used to plot the precision evaluation plot of the contact prediction file **when compared against a second contact prediction or structure**. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot peval -j 0.1 -min 0 -max 2.0 toxd/toxd.pdb pdb toxd/toxd.fasta fasta toxd/toxd.mat ccmpred 11 | 12 | Three command line flags above are important to note. The ``-min`` flag is the minimum factor for contact selection, i.e. ``L * min`` number of contacts. The ``-max`` flag is the maximum factor for contact selection, i.e. ``L * max`` number of contacts. The ``-j`` flag defines the stepwise increase inbetween ``-min`` and ``-max``. 13 | 14 | .. figure:: ../../_static/plot_peval_toxd.png 15 | :alt: Toxd Precision Evaluation Plot 16 | :align: center 17 | :scale: 30 18 | -------------------------------------------------------------------------------- /docs/examples/rst/script_plot_scov.rst: -------------------------------------------------------------------------------- 1 | .. _script_plot_scov: 2 | 3 | Sequence Coverage Plotting 4 | -------------------------- 5 | 6 | The ``scov`` subcommand of the ``conkit-plot`` script is used to plot the coverage plot of the multiple sequence alignment. 7 | 8 | .. code-block:: bash 9 | 10 | $> conkit-plot scov toxd/toxd.a3m a3m 11 | 12 | The following plot will be produced. Your alignment coverage is shown with the black line with each point corresponding to a residue in the alignment. The other two lines give you indicators of how good your alignment is. 13 | 14 | .. figure:: ../../_static/plot_scov_toxd.png 15 | :alt: Toxd Sequence Coverage Plot 16 | :align: center 17 | :scale: 30 18 | 19 | If parts or all of your coverage fall below the "5 x Nresidues" line, the suitability for covariance-based contact prediction is very low. If most residues in the alignment are well above the "5 x Nresidues" line, possibly even the "20 x Nresidues", and bigger chunks are below, then you might want to consider re-defining your sequence boundaries to predict contacts only for the well-covered area. 20 | 21 | If most residues in your alignment have a better coverage than the "20 x Nresidues" line, the alignment is well-suited for covariance-based predictions. 22 | 23 | -------------------------------------------------------------------------------- /docs/examples/rst/script_predict_pipeline.rst: -------------------------------------------------------------------------------- 1 | .. _script_predict_pipeline: 2 | 3 | Contact Prediction 4 | ------------------ 5 | 6 | .. warning:: 7 | 8 | External software is required to execute this script. For further information, refer to the :ref:`installation` page. 9 | 10 | The script to run contact prediction using `HHblits `_ to generate your sequence alignment and `CCMpred `_ to predict the contacts is called ``conkit-predict``. You can run this script using two different modes. 11 | 12 | **1. Starting with a sequence** 13 | 14 | .. code-block:: bash 15 | 16 | $> conkit-predict seq toxd/toxd.fasta fasta 17 | 18 | The call above uses your sequence file ``toxd/toxd.fasta`` in ``fasta`` format to first generate a Multiple Sequence Alignment. It will then analyse your alignment identical to the ``conkit-msatool`` script. It will also sort out all the required conversions before executing CCMpred to run the contact prediction. Finally, it will analyse your contact prediciton and plot a contact map, just like the ``conkit-plot`` script does. 19 | 20 | **2. Starting with a Multiple Sequence Alignment** 21 | 22 | .. code-block:: bash 23 | 24 | $> conkit-predict aln toxd/toxd.a3m a3m 25 | 26 | This call performs identical operations to the full call under point 1, except that it skips the generation of the alignment. This might be particularly useful if you have limited disk space and cannot store the rather large sequence database that HHblits requires. You can generate your alignment using online servers, such as the `HHblits Server `_ or the `Jackhmmer Server `_. Both formats are accepted by ConKit, the keywords can be found in the :ref:`file_formats`. 27 | -------------------------------------------------------------------------------- /docs/examples/validation.rst: -------------------------------------------------------------------------------- 1 | 2 | .. list-table:: Model Validation 3 | :class: table-hover 4 | :widths: 1000, 10, 10 5 | 6 | * - - Model validation with AlphaFold 2 predictions 7 | - 8 | - .. cssclass:: btn btn-default btn-sm btn-example 9 | 10 | :ref:`Script ` 11 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. 2 | 3 | .. include:: ../README.rst 4 | :end-before: CHECKPOINT FOR READTHEDOCS 5 | 6 | Changelog 7 | +++++++++ 8 | 9 | .. include:: ../CHANGELOG.rst 10 | :number-lines: 10 11 | -------------------------------------------------------------------------------- /docs/install.rst: -------------------------------------------------------------------------------- 1 | .. _installation: 2 | 3 | Installation 4 | ============ 5 | 6 | This page contains information on how to install ConKit on your local machine or server. A number of different options exist; however, note that the installation via the :ref:`Python Package Index` remains to be the recommended and simplest. 7 | 8 | Python Package Index 9 | ~~~~~~~~~~~~~~~~~~~~ 10 | The easiest way to install ConKit is via `easy_install` or `pip`. To do so, simply run the following command on your command line and you are ready to go. 11 | 12 | To install using `easy_install`: 13 | 14 | .. code-block:: bash 15 | 16 | $> easy_install conkit 17 | 18 | To install using `pip`: 19 | 20 | .. code-block:: bash 21 | 22 | $> pip install conkit 23 | 24 | .. note:: 25 | 26 | The executable scripts are automatically installed in your default ``bin`` directory. There is nothing more that you need to do. 27 | 28 | Source Code 29 | ~~~~~~~~~~~ 30 | 31 | If you would like to install ConKit from source, download the `latest version `_ from the GitHub repository. Then, use the following commands to install ConKit. 32 | 33 | .. code-block:: bash 34 | 35 | $> git clone https://github.com/rigdenlab/conkit 36 | $> cd conkit 37 | 38 | Once downloaded, you might want to check that all functions are available on your system. Run the following command: 39 | 40 | .. code-block:: bash 41 | 42 | $> python setup.py test 43 | 44 | If this has completed successfully, you are good to go and you can now install ConKit. 45 | 46 | .. code-block:: bash 47 | 48 | $> python setup.py build install 49 | 50 | ConKit is now successfully installed in your system's default Python. 51 | 52 | .. note:: 53 | 54 | Similarly to the :ref:`Python Package Index` install, the executable scripts are automatically installed. 55 | 56 | External software 57 | ~~~~~~~~~~~~~~~~~ 58 | 59 | .. note:: 60 | 61 | If you install ConKit via the :ref:`Python Package Index`, the dependencies are automatically installed for you! 62 | 63 | Required dependencies 64 | +++++++++++++++++++++ 65 | Python 3.7, 3.8 or 3.9 66 | `Download Python `_ 67 | NumPy 1.8.2 (or later) 68 | `Download NumPy `_ 69 | Pandas 70 | `Documentation NumPy `_ 71 | BioPython 1.74 (or later) 72 | `Download BioPython `_ 73 | Matplotlib 1.3.1 (or later) 74 | `Download matplotlib `_ 75 | setuptools 76 | `Documentation `_ 77 | 78 | Optional dependencies 79 | +++++++++++++++++++++ 80 | SciPy 0.16 (or later) 81 | `Download SciPy `_ 82 | Cython 83 | `Documentation Cython `_ 84 | scikit-learn 0.24.1 85 | `Download scikit-learn `_ 86 | HHblits 87 | `Download HHblits `_ 88 | HHblits Database 89 | `Download HHblits Database `_ 90 | CCMpred 91 | `Download CCMpred `_ 92 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx_bootstrap_theme 3 | cython 4 | matplotlib 5 | numpy 6 | biopython 7 | scikit-learn 8 | scipy 9 | docutils<0.18 -------------------------------------------------------------------------------- /docs/sphinxext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rigdenlab/conkit/926f194a660d95350e9172d236c9c002e8a921a3/docs/sphinxext/__init__.py -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["cython", "pytest-runner", "scipy", "setuptools", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [tool.black] 6 | line-length = 120 7 | target-version = ['py37'] 8 | 9 | [tool.pytest.ini_options] 10 | minversion = "2.0" 11 | addopts = "-vv --pep8 --cov=conkit --cov-report=xml --pyargs conkit" 12 | pep8maxlinelength = "120" 13 | pep8ignore = "E203 E402 E501 W503 .eggs ALL *.egg ALL" 14 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | scipy 2 | cython 3 | numpy 4 | pandas 5 | matplotlib 6 | biopython>=1.74 7 | scikit-learn>=0.24.1, <=0.24.2 8 | prettytable 9 | joblib 10 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [aliases] 2 | test = pytest 3 | --------------------------------------------------------------------------------