Commit f720d063 authored by Martin Larralde's avatar Martin Larralde
Browse files

Add Sphinx configuration files to build the project documentation

parent c6340958
......@@ -12,6 +12,7 @@
[![GitHub issues](](
......@@ -102,7 +103,7 @@ This library is provided under the [GNU General Public License v3.0](https://cho
The original R `Peptides` package was written by [Daniel Osorio](,
[Paola Rondón-Villarreal]( and
[Rodrigo Torres](, and is licensed under
the terms of the GPLv2.
the terms of the [GNU General Public License v2.0](
*This project is in no way not affiliated, sponsored, or otherwise endorsed
by the [original `Peptides` authors]( It was developed
# Minimal makefile for Sphinx documentation
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXBUILD ?= sphinx-build
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
p {
text-align: justify;
/* a.reference strong {
font-weight: bold;
font-size: 90%;
color: #c7254e;
box-sizing: border-box;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
} */
.field-list a.reference {
font-weight: bold;
font-size: 90%;
color: #c7254e;
box-sizing: border-box;
font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
.class dd {
margin-left: 2%
.exception dd {
margin-left: 2%
API Reference
.. autoclass:: peptides.Peptide
:special-members: __init__
\ No newline at end of file
# Configuration file for the Sphinx documentation builder.
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# -- Imports -----------------------------------------------------------------
import configparser
import datetime
import os
import sys
import re
import shutil
import semantic_version
import sphinx_bootstrap_theme
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
docssrc_dir = os.path.dirname(os.path.abspath(__file__))
project_dir = os.path.dirname(docssrc_dir)
sys.path.insert(0, project_dir)
# -- Sphinx Setup ------------------------------------------------------------
def setup(app):
# Add custom stylesheet
# app.add_js_file("js/apitoc.js")
# app.add_js_file("js/example-admonition.js")
# -- Project information -----------------------------------------------------
import peptides
# extract the project metadata from the module itself
project = peptides.__name__
author = re.match('(.*) <.*>', peptides.__author__).group(1)
year =
copyright = '{}, {}'.format("2021" if year==2021 else "2021-{}".format(year), author)
# extract the semantic version
semver = semantic_version.Version.coerce(peptides.__version__)
version = str(semver.truncate(level="patch"))
release = str(semver)
# extract the project URLs from ``setup.cfg``
cfgparser = configparser.ConfigParser(), "setup.cfg"))
project_urls = dict(
map(str.strip, line.split(" = ", 1))
for line in cfgparser.get("metadata", "project_urls").splitlines()
if line.strip()
# patch the docstring of the main module so that we don't show the link to
# redirect to the docs (we don't want to see it when reading the docs
# already, duh!)
doc_lines = peptides.__doc__.splitlines()
if "See Also:" in doc_lines:
see_also = peptides.index("See Also:")
peptides.__doc__ = "\n".join(doc_lines[:see_also])
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# "sphinx.ext.imgconverter",
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'requirements.txt']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "monokailight"
# The name of the default role for inline references
default_role = "py:obj"
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'bootstrap'
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
# Bootswatch ( theme.
"bootswatch_theme": "flatly",
# Choose Bootstrap version.
"bootstrap_version": "3",
# Tab name for entire site. (Default: "Site")
"navbar_site_name": "Documentation",
# HTML navbar class (Default: "navbar") to attach to <div> element.
# For black navbar, do "navbar navbar-inverse"
"navbar_class": "navbar",
# Render the next and previous page links in navbar. (Default: true)
"navbar_sidebarrel": True,
# Render the current pages TOC in the navbar. (Default: true)
"navbar_pagenav": False,
# A list of tuples containing pages or urls to link to.
"navbar_links": [
("GitHub", cfgparser.get("metadata", "url").strip(), True)
] + [
(k, v, True)
for k, v in project_urls.items()
if k in {"Zenodo", "PyPI"}
"admonition_use_panel": True,
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
html_sidebars = {
"*": ["localtoc.html"],
"api/*": ["localtoc.html"],
"examples/*": ["localtoc.html"],
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = peptides.__name__
# -- Extension configuration -------------------------------------------------
# -- Options for imgmath extension -------------------------------------------
imgmath_image_format = "svg"
# -- Options for napoleon extension ------------------------------------------
napoleon_include_init_with_doc = True
napoleon_include_special_with_doc = True
napoleon_include_private_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_rtype = False
# -- Options for autodoc extension -------------------------------------------
autoclass_content = "class"
autodoc_member_order = 'groupwise'
autosummary_generate = []
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("", None),
"biopython": ("", None),
# -- Options for recommonmark extension --------------------------------------
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
\ No newline at end of file
.. peptides documentation master file, created by
sphinx-quickstart on Sat Oct 23 18:17:35 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
`` |stars|
.. |Stars| image::
*Physicochemical properties and indices for amino-acid sequences.*
|Actions| |Coverage| |PyPI| |Wheel| |Versions| |Implementations| |License| |Source| |Mirror| |Issues| |Docs| |Changelog| |Downloads|
.. |Actions| image::
.. |Coverage| image::
.. |PyPI| image::
.. |Wheel| image::
.. |Versions| image::
.. |Implementations| image::
.. |License| image::
.. |Source| image::
.. |Mirror| image::
.. |Issues| image::
.. |Docs| image::
.. |Changelog| image::
.. |Downloads| image::
```` is a pure-Python package to compute common descriptors for
protein sequences. It is a port of `Peptides <>`_,
the R package written by `Daniel Osorio <>`_
for the same purpose. This library has no external dependency and is
available for all modern Python versions (3.6+).
A non-exhaustive list of available features:
- Amino-acid Statistics:
- Number of occurrences in the peptide sequence
- Frequency in the peptide sequence
- `QSAR <>`_ descriptors:
- `BLOSUM indices <>`_
- `Cruciani properties <>`_
- `FASGAI vectors <>`_
- `Kidera factors <>`_
- `MS-WHIM scores <>`_
- `ProtFP descriptors <>`_
- `ST-scales <>`_
- `T-scales <>`_
- `VHSE-scales <>`_
- `Z-scales <>`_
- Sequence profiles:
- Hydrophobicity profile using one of 38 proposed scales.
- Hydrophobic moment profile based on `Eisenberg, Weiss and Terwilliger (1984) <>`_.
- Membrane position based on `Eisenberg (1984) <>`_.
- Physico-chemical properties:
- Aliphatic index proposed in `Ikai (1980) <>`_.
- Instability index proposed in `Boman (2003) <>`_.
- Theoretical net charge based on the `Henderson-Hasselbach equation <>`_.
- Isoelectric point using one of 8 pKa scales.
- Molecular weight, taking into account isotope labelling, using one of 3 average weight tables.
Run ``pip install peptides`` in a shell to download the latest release, or have
a look at the :doc:`Installation page <install>` to find other ways to install
.. toctree::
:maxdepth: 2
Installation <install>
Contributing <contributing>
API Reference <api>
Changelog <changes>
This library is provided under the `GNU General Public License v3.0 <>`_.
The original R `Peptides` package was written by `Daniel Osorio <>`_,
`Paola Rondón-Villarreal <>`_ and
`Rodrigo Torres <>`_, and is licensed under
the terms of the `GPLv2 <>`_.
*This project is in no way not affiliated, sponsored, or otherwise endorsed
by the original* `Peptides`_ *authors. It was developed by*
`Martin Larralde <>`_ *during his
PhD project at the* `European Molecular Biology Laboratory <>`_
*in the* `Zeller team <>`_.
```` is hosted on GitHub, but the easiest way to install it is to
download the latest release from its `PyPi repository <>`_.
.. code:: console
$ pip install --user pyrodigal
.. Conda
.. ^^^^^
.. Pronto is also available as a `recipe <>`_
.. in the `bioconda <>`_ channel. To install, simply
.. use the ``conda`` installer:
.. .. code:: console
.. $ conda install -c bioconda pyrodigal
GitHub + ``pip``
If, for any reason, you prefer to download the library from GitHub, you can clone
the repository and install the repository by running (with the admin rights):
.. code:: console
$ git clone --recursive
$ pip install --user ./
.. caution::
Keep in mind this will install always try to install the latest commit,
which may not even build, so consider using a versioned release instead.
GitHub + ``setuptools``
If you do not want to use ``pip``, you can still clone the repository and
run the ```` file manually, although you will need to install the
build dependencies (mainly `astor <>`_):
.. code:: console
$ git clone --recursive
$ cd
# python build_py install
.. Danger::
Installing packages without ``pip`` is strongly discouraged, as they can
only be uninstalled manually, and may damage your system.
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
set BUILDDIR=_build
if "%1" == "" goto help
if errorlevel 9009 (
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.If you don't have Sphinx installed, grab it from
exit /b 1
goto end
# build dependencies
setuptools >=46.4
cython ~=0.29.16
# sphinx documentation dependencies
semantic_version ~=2.8
sphinx ~=4.0
recommonmark ~=0.7
# sphinx-bootstrap-theme ~=0.7 with patched admonition
"""Physicochemical properties and indices for amino-acid sequences.
import array
import collections
import math
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment