Skip to content

Commit

Permalink
Add tensor parsing util (#244)
Browse files Browse the repository at this point in the history
* Add tensor parsing util

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add missing arg comma

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add backbone check util

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add chain tensor

* add test for io utils

* fix loguru import

* add torchtyping dependency

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix import message import

* add tests for angle utils

* add tests for angle utils

* add tests for tensor parsing

* add tests for tensor parsing

* add sidechain atom groups

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add io tests

* add geometry tests

* add geom ad sequence mnodules

* add test for inferring sequence from coordinates

* add einops as an optional dependecy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add sequence inference utils

* add data testing utils

* add nan util

* add angle computation utils

* add test for distmat reconstruction

* wrap torch imports

* wrap imports

* wrap imports

* add representation utils

* wrap torch-dependent tests

* add edge tensor type

* update changelog

* add build params

* add updated angles script

* add graphein package test

* wrap imports

* add plotting utils

* push tensor utils

* update centering default args

* add reconstruction utils

* add data objects

* add PyG dep

* add PyG dep

* add PyG dep

* add PyG dep

* add PyG dep

* add PyG dep

* add PyG dep

* add PyG dep

* add pnerf

* update nx to numpy array to support 3.0

* fix kabsch test

* fix centering masking

* remove nx.info - deprecated in nx 3.0

* rm gpickle reference - deprecated in nx 3.0

* rm gpickle reference - deprecated in nx 3.0

* fix nx 3.0 adjacency issues

* fix for nx 3.0

* ignore tensor tests for minimal build

* ignore tensor tests for minimal build

* add additional docs

* add additional testin utils

* add docstrings to plot

* finish sequence docstrings

* add notimplemented errors and todos

* finalise io

* add tensor submodule to docs

* add edges

* update license year

* add documented code

* add documented code and edge funcs

* add updated tests

* update doc config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add additional constants

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix test

* update changelog

* update readme

* update docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update docstrings

* update docstrings

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* bump license year

* fix angle dims

* add noising and plotting

* add node id to plots

* add esmfold util

* add noise util

* Add structural metrics (#245)

* Add gdt metric

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add TMScore

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add init

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update readme

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* add dataloader

* add folding utils

* update readme

* add docs

* add tutorial notebooks

* add fasta parsing util

* add data updates

* fix df output

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove DL-dependent notebooks from minimal install test

* add watermark

* rm dataloaders from test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix typo in inc_dict attr

* add doc dep install to build

* fix typo

* remove wildcard pyyaml version

* add try/except for atomic peptide bonds

* update tensor tutorial

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
a-r-j and pre-commit-ci[bot] authored Jan 30, 2023
1 parent 4634887 commit 4f9563b
Show file tree
Hide file tree
Showing 57 changed files with 433,304 additions and 1,758 deletions.
51 changes: 28 additions & 23 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7, 3.8]
torch: [1.6.0, 1.7.0, 1.8.0, 1.9.0]
include:
- torch: 1.6.0
torchvision: 0.7.0
- torch: 1.7.0
torchvision: 0.8.1
- torch: 1.8.0
torchvision: 0.9.0
- torch: 1.9.0
torchvision: 0.10.0
- torch: 1.8.0
torchvision: 0.9.0
python-version: 3.9
- torch: 1.9.0
torchvision: 0.10.0
python-version: 3.8
- torch: 1.9.0
torchvision: 0.10.0
python-version: 3.9
python-version: [3.8, 3.9]
torch: [1.12.0, 1.13.0]
#include:
# - torch: 1.6.0
# torchvision: 0.7.0
# - torch: 1.7.0
# torchvision: 0.8.1
# - torch: 1.8.0
# torchvision: 0.9.0
# - torch: 1.9.0
# torchvision: 0.10.0
# - torch: 1.8.0
# torchvision: 0.9.0
# python-version: 3.9
# - torch: 1.9.0
# torchvision: 0.10.0
# python-version: 3.8
# - torch: 1.9.0
# torchvision: 0.10.0
# python-version: 3.9
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -44,7 +44,7 @@ jobs:
uses: s-weigand/setup-conda@v1
with:
python-version: ${{ matrix.python-version }}
conda-channels: "conda-forge, salilab"
conda-channels: "conda-forge, salilab, pytorch, pyg"

#- name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
Expand All @@ -57,7 +57,10 @@ jobs:
- name: Install DSSP
run: conda install -c salilab dssp
- name: Install PyTorch
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
run: conda install -c pytorch pytorch==${{matrix.torch}} cpuonly
#run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install PyG
run: conda install -c pyg pyg
- name: Install BLAST
run: sudo apt install ncbi-blast+
- name: Install Graphein
Expand All @@ -66,7 +69,9 @@ jobs:
run: pip install -r .requirements/extras.in
- name: Install Dev Dependencies
run: pip install -r .requirements/dev.in
- name: Install doc dependencies
run: pip install -r .requirements/docs.in
- name: Run unit tests and generate coverage report
run: pytest .
- name: Test notebook execution
run: pytest --nbval-lax notebooks/ --current-env --ignore-glob="notebooks/dataloader_tutorial.ipynb"
run: pytest --nbval-lax notebooks/ --current-env --ignore-glob="notebooks/dataloader_tutorial.ipynb" --ignore-glob="notebooks/datasets_and_dataloaders.ipynb"
4 changes: 2 additions & 2 deletions .github/workflows/minimal__install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
- name: Install Dev Dependencies
run: pip install -r .requirements/dev.in
- name: Run unit tests and generate coverage report
run: pytest .
run: pytest . --ignore-glob="tests/protein/tensor"
- name: Test notebook execution
run: pytest --nbval-lax notebooks/ --current-env --ignore-glob="notebooks/dataloader_tutorial.ipynb" --ignore-glob="notebooks/higher_order_graphs.ipynb" --ignore-glob="notebooks/protein_graph_analytics.ipynb" --ignore-glob="notebooks/subgraphing_tutorial.ipynb" --ignore-glob="notebooks/splitting_a_dataset.ipynb"
run: pytest --nbval-lax notebooks/ --current-env --ignore-glob="notebooks/dataloader_tutorial.ipynb" --ignore-glob="notebooks/higher_order_graphs.ipynb" --ignore-glob="notebooks/protein_graph_analytics.ipynb" --ignore-glob="notebooks/subgraphing_tutorial.ipynb" --ignore-glob="notebooks/splitting_a_dataset.ipynb" --ignore-glob="notebooks/protein_tensors.ipynb" --ignore-glob="notebooks/datasets_and_dataloaders.ipynb"
3 changes: 2 additions & 1 deletion .requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ pydantic
rich
rich-click
seaborn
pyyaml>=5.1,<6.*
pyyaml>=5.1,<6.0
scikit-learn
scipy
tqdm
typing_extensions
wget
xarray
torchtyping
1 change: 1 addition & 0 deletions .requirements/docs.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ sphinx-inline-tabs
sphinxext-opengraph
sphinxcontrib-gtagjs
ipython
watermark
1 change: 1 addition & 0 deletions .requirements/extras.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ mpl_chord_diagram==0.3.2
rdkit
selfies
smilite
einops
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
### 1.5.3 - UNRELEASED
### 1.6.0dev - UNRELEASED

#### New Features
* [Metrics] - [#245](https://github.com/a-r-j/graphein/pull/221) Adds a selection of structural metrics relevant to protein structures.
* [Tensor Operations] - [#244](https://github.com/a-r-j/graphein/pull/244) Adds suite of utilities for working directly with tensor-based representations of proteins (graphein.protein.tensor).
* [Tensor Operations] - [#244](https://github.com/a-r-j/graphein/pull/244) Adds suite of utilities for working with ESMfold (graphein.protein.folding_utils).



#### Improvements

* [Logging] - [#221](https://github.com/a-r-j/graphein/pull/221) Adds global control of logging with `graphein.verbose(enabled=False)`.
* [Logging] - [#242](https://github.com/a-r-j/graphein/pull/242) Adds control of protein graph construction logging. Resolves [#238](https://github.com/a-r-j/graphein/issues/238)

Expand All @@ -14,6 +21,18 @@
* [Bugfix] - [#220](https://github.com/a-r-j/graphein/pull/220) Fixes edge metadata conversion to PyG. Contribution by @manonreau.
* [Bugfix] - [#220](https://github.com/a-r-j/graphein/pull/220) Fixes centroid atom grouping & avoids unnecessary edge computation where none are found. Contribution by @manonreau.


#### Documentation
* [Tensor Module] - [#244](https://github.com/a-r-j/graphein/pull/244) Documents new graphein.protein.tensor module.
* [CI] - [#244](https://github.com/a-r-j/graphein/pull/244) Updates to intersphinx maps


#### Package
* [CI] - [#244](https://github.com/a-r-j/graphein/pull/244) CI now runs for python 3.8, 3.9 and torch 1.12.0 and 1.13.0
* [CI] - [#244](https://github.com/a-r-j/graphein/pull/244) Separate builds for core library and library with DL dependencies.
* [Licence] - [#244](https://github.com/a-r-j/graphein/pull/244) Bump to 2023


### 1.5.2 - 19/9/2022

#### Protein
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2022 Arian Jamasb
Copyright (c) 2019-2023 Arian Jamasb

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This package provides functionality for producing geometric representations of p

| | |
|---|---|
| [Protein Tensor Module](http://graphein.ai/notebooks/protein_tensors.html) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/a-r-j/graphein/blob/master/notebooks/protein_tensors.ipynb) |
| [Constructing molecular graphs](http://graphein.ai/notebooks/molecule_tutorial.html) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/a-r-j/graphein/blob/master/notebooks/molecule_tutorial.ipynb) |
| [Ready-to-go Dataloaders for PyTorch Geometric](http://graphein.ai/notebooks/dataloader_tutorial.html) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/a-r-j/graphein/blob/master/notebooks/dataloader_tutorial.ipynb) |
| [Extracting subgraphs from protein graphs](http://graphein.ai/notebooks/subgraphing_tutorial.html) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/a-r-j/graphein/blob/master/notebooks/subgraphing_tutorial.ipynb) |
Expand Down
31 changes: 24 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# -- Path setup --------------------------------------------------------------

import datetime

# 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.
Expand All @@ -14,6 +16,9 @@
import sys

import plotly.io as pio
import sphinx.ext.autodoc

sphinx.ext.autodoc.NewTypeDataDocumenter.directivetype = "class"

os.environ["PLOTLY_RENDERER"] = "sphinx_gallery"

Expand All @@ -25,11 +30,11 @@
# -- Project information -----------------------------------------------------

project = "Graphein"
copyright = "2022, Arian Jamasb"
author = "Arian Jamasb"
copyright = f"{datetime.datetime.now().year}, {author}"

# The full version, including alpha/beta/rc tags
release = "1.5.2"
release = "1.6.0dev"


# -- General configuration ---------------------------------------------------
Expand All @@ -39,6 +44,7 @@
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_copybutton",
Expand All @@ -48,7 +54,11 @@
"m2r2",
"nbsphinx",
"nbsphinx_link",
"sphinx.ext.napoleon",
# "sphinx_autorun",
]

autosummary_generate = True # Turn on sphinx.ext.autosummary
nbsphinx_allow_errors = True
nbsphinx_require_js_path = (
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"
Expand All @@ -67,16 +77,23 @@
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"networkx": ("https://networkx.github.io/documentation/stable/", None),
"nx": ("https://networkx.github.io/documentation/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"xarray": ("https://xarray.pydata.org/en/stable/", None),
"np": ("https://numpy.org/doc/stable/", None),
"pandas": ("https://pandas.pydata.org/docs/", None),
"pd": ("https://pandas.pydata.org/docs/", None),
"plotly": ("https://plotly.com/python-api-reference/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
"scikit-learn": ("https://scikit-learn.org/stable/", None),
"sklearn": ("https://scikit-learn.org/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
"Sphinx": ("https://www.sphinx-doc.org/en/stable/", None),
"networkx": ("https://networkx.github.io/documentation/stable/", None),
"nx": ("https://networkx.github.io/documentation/stable/", None),
"torch": ("https://pytorch.org/docs/master/", None),
"xarray": ("https://xarray.pydata.org/en/stable/", None),
"torch_geometric": (
"https://pytorch-geometric.readthedocs.io/en/latest/",
None,
),
}

mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
Expand All @@ -98,7 +115,7 @@
# 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 = []
exclude_patterns = ["_build"]
source_suffix = [".rst", ".md"]


Expand Down
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The repository can be found at `a-r-j/graphein <https://www.github.com/a-r-j/gra
:hidden:
:caption: Machine Learning

ml_protein_tensors
datasets
ml_examples

Expand All @@ -55,6 +56,7 @@ The repository can be found at `a-r-j/graphein <https://www.github.com/a-r-j/gra
:caption: API Reference

modules/graphein.protein
modules/graphein.protein.tensor
modules/graphein.molecule
modules/graphein.rna
modules/graphein.ppi
Expand Down
2 changes: 1 addition & 1 deletion docs/source/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ License

MIT License

Copyright (c) 2019-2022 Arian Jamasb
Copyright (c) 2019-2023 Arian Jamasb

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 13 additions & 0 deletions docs/source/ml_protein_tensors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
===============
Protein Tensors
===============


Introduction
---------
.. toctree::
:maxdepth: 2
:glob:

notebooks/protein_tensors.nblink
notebooks/datasets_and_dataloaders.nblink
11 changes: 10 additions & 1 deletion docs/source/modules/graphein.protein.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
graphein.protein
================

.. currentmodule:: graphein.protein

Config
------
---------

.. currentmodule:: graphein.protein.config


.. autosummary::
:nosignatures:

.. automodule:: graphein.protein.config
:members:

Expand Down
77 changes: 77 additions & 0 deletions docs/source/modules/graphein.protein.tensor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
graphein.protein.tensor
=======================

.. currentmodule:: graphein.protein.tensor

Data and Batch Objects
------------------------
.. automodule:: graphein.protein.tensor.data
:members:

I/O
------
.. automodule:: graphein.protein.tensor.io
:members:

Representation
---------------
.. automodule:: graphein.protein.tensor.representation
:members:


Geometry
------
Geometry Utils
^^^^^^^^^
.. automodule:: graphein.protein.tensor.geometry
:members:

Angles
^^^^^^^^^^^^^^^
.. automodule:: graphein.protein.tensor.angles
:members:


Reconstruction
---------

.. automodule:: graphein.protein.tensor.reconstruction
:members:

pNERF
^^^^^^^
.. automodule:: graphein.protein.tensor.pnerf
:members:

Sequence
---------
.. automodule:: graphein.protein.tensor.sequence
:members:

Plotting
---------
.. currentmodule:: graphein.protein.tensor.plot

.. autosummary::
:nosignatures:

graphein.protein.tensor.plot

.. automodule:: graphein.protein.tensor.plot
:members:

Types
---------
.. automodule:: graphein.protein.tensor.types
:members:


Testing
---------
.. automodule:: graphein.protein.tensor.testing
:members:

Constants
----------
.. automodule:: graphein.protein.resi_atoms
:members:
3 changes: 3 additions & 0 deletions docs/source/notebooks/datasets_and_dataloaders.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../notebooks/datasets_and_dataloaders.ipynb"
}
3 changes: 3 additions & 0 deletions docs/source/notebooks/protein_tensors.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../notebooks/protein_tensors.ipynb"
}
Loading

0 comments on commit 4f9563b

Please sign in to comment.