Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve structure and add modules #625

Merged
merged 37 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6d260fc
remove unnecessary sections
gcroci2 Jul 9, 2024
2842e2f
improve contributing section
gcroci2 Jul 9, 2024
338ca2b
use md files instead of rst for contributing and code of conduct
gcroci2 Jul 9, 2024
f71c529
include contributing doc from outside docs/
gcroci2 Jul 9, 2024
9d2f739
fix the contributing section
gcroci2 Jul 9, 2024
cc32a4e
add literalinclude ref
gcroci2 Jul 9, 2024
0938685
insert contributing doc copy into docs/
gcroci2 Jul 9, 2024
712f9a7
remove duplication
gcroci2 Jul 9, 2024
a6c879f
add include directive and change to md
gcroci2 Jul 9, 2024
f4abade
use m2r
gcroci2 Jul 9, 2024
2181c1b
switch back to md
gcroci2 Jul 9, 2024
87e032d
update filename
gcroci2 Jul 9, 2024
a8b6628
add features module
gcroci2 Jul 10, 2024
13d5c5d
fix path
gcroci2 Jul 10, 2024
5ce62db
change sys path
gcroci2 Jul 10, 2024
4c19c50
change reference file
gcroci2 Jul 10, 2024
130920a
change ref file with deeprank2.rst
gcroci2 Jul 10, 2024
9e74e0f
remove submodules
gcroci2 Jul 10, 2024
029645f
try to fix the modules
gcroci2 Jul 10, 2024
fcad2c4
render more modules and fix doc strings
gcroci2 Jul 10, 2024
806fa2e
fix conf path
gcroci2 Jul 10, 2024
785fcc2
fix links in the installation
gcroci2 Jul 10, 2024
855ab87
fix link to contributing
gcroci2 Jul 10, 2024
fd1a0bc
fix links to sections
gcroci2 Jul 10, 2024
50611af
fix manual installation link
gcroci2 Jul 10, 2024
62abbe0
fix manual installation ref
gcroci2 Jul 10, 2024
53cd887
remove sentence
gcroci2 Jul 10, 2024
f9b41f5
fix cross refs
gcroci2 Jul 10, 2024
61fe684
fix installation path
gcroci2 Jul 10, 2024
e21fbc7
add module path
gcroci2 Jul 10, 2024
15cdd6c
add required deps
gcroci2 Jul 10, 2024
b60ebdf
fix trainer rendering
gcroci2 Jul 10, 2024
01d6eb7
remove useless class ref
gcroci2 Jul 10, 2024
9eecf5e
remove useless class ref
gcroci2 Jul 10, 2024
bb84d62
style: add empty lines at end of file
DaniBodor Jul 11, 2024
486ab48
merge with dev
gcroci2 Jul 11, 2024
72c71c8
fix ruff error
gcroci2 Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ build:
tools:
python: "3.11"

# Build from the docs/ directory with Sphinx
# Build from the docs/source directory with Sphinx
sphinx:
configuration: docs/conf.py
configuration: docs/source/conf.py

# Explicitly set the version of Python and its requirements
python:
Expand Down
43 changes: 43 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 1.4, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html)
79 changes: 0 additions & 79 deletions CODE_OF_CONDUCT.rst

This file was deleted.

40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing guidelines

We welcome any kind of contribution to our software, from simple comment or question to a full fledged [pull request](https://help.github.com/articles/about-pull-requests/). Please read and follow our [Code of Conduct](https://github.com/DeepRank/deeprank2/blob/main/CODE_OF_CONDUCT.rst).

A contribution can be one of the following cases:

1. you have a question;
2. you think you may have found a bug (including unexpected behavior);
3. you want to make some kind of change to the code base (e.g. to fix a bug, to add a new feature, to update documentation).

The sections below outline the steps in each case.

## You have a question

1. use the search functionality [here](https://github.com/DeepRank/deeprank2/issues) to see if someone already filed the same issue;
2. if your issue search did not yield any relevant results, make a new issue;
3. apply the "Question" label; apply other labels when relevant.

## You think you may have found a bug

1. use the search functionality [here](https://github.com/DeepRank/deeprank2/issues) to see if someone already filed the same issue;
2. if your issue search did not yield any relevant results, make a new issue, making sure to provide enough information to the rest of the community to understand the cause and context of the problem. Depending on the issue, you may want to include:
- the [SHA hashcode](https://help.github.com/articles/autolinked-references-and-urls/#commit-shas) of the commit that is causing your problem;
- some identifying information (name and version number) for dependencies you're using;
- information about the operating system;
3. apply relevant labels to the newly created issue.

## You want to make some kind of change to the code base

1. (**important**) announce your plan to the rest of the community _before you start working_. This announcement should be in the form of a (new) issue;
2. (**important**) wait until some kind of consensus is reached about your idea being a good idea;
3. if needed, fork the repository to your own Github profile and create your own feature branch off of the latest main commit. While working on your feature branch, make sure to stay up to date with the main branch by pulling in changes, possibly from the 'upstream' repository (follow the instructions [here](https://help.github.com/articles/configuring-a-remote-for-a-fork/) and [here](https://help.github.com/articles/syncing-a-fork/));
4. make sure the existing tests still work;
5. add your own tests (if necessary);
6. see our [developer's readme](README.dev.md) for detailed information on our style conventions, etc.;
7. update or expand the documentation;
8. [push](http://rogerdudler.github.io/git-guide/) your feature branch to (your fork of) the DeepRank2 repository on GitHub;
9. create the pull request, e.g. following the instructions [here](https://help.github.com/articles/creating-a-pull-request/).

In case you feel like you've made a valuable contribution, but you don't know how to write or run tests for it, or how to generate the documentation: don't let this discourage you from making the pull request; we can help you! Just go ahead and submit the pull request, but keep in mind that you might be asked to append additional commits to your pull request.
46 changes: 0 additions & 46 deletions CONTRIBUTING.rst

This file was deleted.

39 changes: 14 additions & 25 deletions deeprank2/query.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from __future__ import annotations

import importlib
import logging
import os
import pickle
import pkgutil
import re
import warnings
from collections.abc import Iterator
from dataclasses import MISSING, dataclass, field, fields
from functools import partial
from glob import glob
from multiprocessing import Pool
from random import randrange
from types import ModuleType
from typing import Literal
from typing import TYPE_CHECKING, Literal

import h5py
import numpy as np
Expand All @@ -21,38 +22,28 @@
import deeprank2.features
from deeprank2.domain.aminoacidlist import convert_aa_nomenclature
from deeprank2.features import components, conservation, contact
from deeprank2.molstruct.aminoacid import AminoAcid
from deeprank2.molstruct.residue import Residue, SingleResidueVariant
from deeprank2.molstruct.structure import PDBStructure
from deeprank2.utils.buildgraph import get_contact_atoms, get_structure, get_surrounding_residues
from deeprank2.utils.graph import Graph
from deeprank2.utils.grid import Augmentation, GridSettings, MapMethod
from deeprank2.utils.parsing.pssm import parse_pssm

if TYPE_CHECKING:
from collections.abc import Iterator

from deeprank2.molstruct.aminoacid import AminoAcid
from deeprank2.molstruct.structure import PDBStructure

_log = logging.getLogger(__name__)

VALID_RESOLUTIONS = ["atom", "residue"]


@dataclass(repr=False, kw_only=True)
class Query:
"""Represents one entity of interest: a single residue variant (SRV) or a protein-protein interface (PPI).

:class:`Query` objects are used to generate graphs from structures, and they should be created before any model is loaded.
They can have target values associated with them, which will be stored with the resulting graph.
"""Parent class of :class:`SingleResidueVariantQuery` and :class:`ProteinProteinInterfaceQuery`.

Args:
pdb_path (str): the path to the PDB file to query.
resolution (Literal['residue', 'atom']): sets whether each node is a residue or atom.
chain_ids (list[str] | str): the chain identifier(s) of the variant residue or interacting interfaces.
Note that this does not limit the structure to residues from this/these chain(s).
pssm_paths (dict[str, str]): the name of the chain(s) (key) and path to the pssm file(s) (value).
targets (dict[str, float]) = Name(s) (key) and target value(s) (value) associated with this query.
influence_radius (float | None): all residues within this radius from the variant residue or interacting interfaces
will be included in the graph, irrespective of the chain they are on.
max_edge_length (float | None): the maximum distance between two nodes to generate an edge connecting them.
suppress_pssm_errors (bool): Whether or not to suppress the error raised if the .pssm files do not
match the .pdb files. If True, a warning is returned instead.
More detailed information about the parameters can be found in :class:`SingleResidueVariantQuery` and :class:`ProteinProteinInterfaceQuery`.
"""

pdb_path: str
Expand Down Expand Up @@ -126,7 +117,7 @@ def _check_pssm(self, verbosity: Literal[0, 1, 2] = 0) -> None: # noqa: C901
2 (high): Also list the incorrect residues

Raises:
ValueError: Raised if info between pdb file and pssm file doesn't match or if no pssms were provided
ValueError: Raised if info between pdb file and pssm file doesn't match or if no pssms were provided.
"""
if not self.pssm_paths:
msg = "No pssm paths provided for conservation feature module."
Expand Down Expand Up @@ -221,7 +212,7 @@ def get_query_id(self) -> str:
class SingleResidueVariantQuery(Query):
"""A query that builds a single residue variant graph.

Args (common for `Query`):
Args:
pdb_path (str): the path to the PDB file to query.
resolution (Literal['residue', 'atom']): sets whether each node is a residue or atom.
chain_ids (list[str] | str): the chain identifier of the variant residue (generally a single capital letter).
Expand All @@ -231,16 +222,14 @@ class SingleResidueVariantQuery(Query):
influence_radius (float | None): all residues within this radius from the variant residue
will be included in the graph, irrespective of the chain they are on.
max_edge_length (float | None): the maximum distance between two nodes to generate an edge connecting them.

suppress_pssm_errors (bool): Whether or not to suppress the error raised if the .pssm files do not
match the .pdb files. If True, a warning is returned instead.
SRV specific Args:
variant_residue_number (int): the residue number of the variant residue.
insertion_code (str | None): the insertion code of the variant residue.
wildtype_amino_acid (AminoAcid): the amino acid at above position in the wildtype protein.
variant_amino_acid (AminoAcid): the amino acid at above position in the variant protein.
radius (float): all Residues within this radius (in Å) from the variant residue will
be included in the graph
be included in the graph.
"""

variant_residue_number: int
Expand Down
2 changes: 2 additions & 0 deletions deeprank2/trainer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import copy
import inspect
import logging
Expand Down
7 changes: 6 additions & 1 deletion deeprank2/utils/grid.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""This module holds the classes that are used when working with a 3D grid."""

from __future__ import annotations

import itertools
import logging
from enum import Enum
from typing import TYPE_CHECKING

import h5py
import numpy as np
from numpy.typing import NDArray
from scipy.interpolate import BSpline

from deeprank2.domain import gridstorage

if TYPE_CHECKING:
from numpy.typing import NDArray

_log = logging.getLogger(__name__)


Expand Down
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
7 changes: 0 additions & 7 deletions docs/reference/modules.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ sphinx_rtd_theme==1.1.1
readthedocs-sphinx-search==0.3.2
myst-parser
toml
typing-extensions
dill
Loading
Loading