Skip to content

Commit

Permalink
Repo-wide cleaning and linting (#25)
Browse files Browse the repository at this point in the history
* add trunk linter

* lint clis

* update pyproject.toml

* linting
  • Loading branch information
rvhonorato committed Apr 22, 2024
1 parent 19b53f0 commit 2003a9a
Show file tree
Hide file tree
Showing 32 changed files with 1,343 additions and 457 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
]
}
}
}
}
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: ci
on:
push:


jobs:
test:
runs-on: ubuntu-latest
Expand Down
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
4 changes: 4 additions & 0 deletions .trunk/configs/.hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Following source doesn't work in most setups
ignored:
- SC1090
- SC1091
2 changes: 2 additions & 0 deletions .trunk/configs/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
2 changes: 2 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
7 changes: 7 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
14 changes: 14 additions & 0 deletions .trunk/configs/svgo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
sortAttrs: true,
removeOffCanvasPaths: true,
},
},
},
],
};
45 changes: 45 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.21.0
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.5
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.21.0
- node@18.12.1
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- actionlint@1.6.27
- bandit@1.7.8
- black@24.4.0
- checkov@3.2.73
- git-diff-check
- hadolint@2.12.0
- isort@5.13.2
- markdownlint@0.39.0
- oxipng@9.1.0
- prettier@3.2.5
- ruff@0.4.1
- shellcheck@0.10.0
- shfmt@3.6.0
- svgo@3.2.0
- taplo@0.8.1
- terrascan@1.19.1
- trivy@0.50.1
- trufflehog@3.71.0
- yamllint@1.35.1
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
40 changes: 20 additions & 20 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ To install Whiscy, follow these steps:

- Clone the repository:

```bash
git clone https://github.com/haddocking/whiscy && cd whiscy
```
```bash
git clone https://github.com/haddocking/whiscy && cd whiscy
```

- Install the scripts

Expand All @@ -33,23 +33,23 @@ To install Whiscy, follow these steps:

- Check the installation

```text
$ whiscy -h
usage: whiscy [-h] [-o output_file] [--version]
surface_list conversion_table alignment_file distance_file
positional arguments:
surface_list Surface list
conversion_table Conversion table
alignment_file Alignment file
distance_file Distance file
options:
-h, --help show this help message and exit
-o output_file, --output output_file
If set, output prediction to this file
--version show program's version number and exit
```
```text
$ whiscy -h
usage: whiscy [-h] [-o output_file] [--version]
surface_list conversion_table alignment_file distance_file
positional arguments:
surface_list Surface list
conversion_table Conversion table
alignment_file Alignment file
distance_file Distance file
options:
-h, --help show this help message and exit
-o output_file, --output output_file
If set, output prediction to this file
--version show program's version number and exit
```

### Troubleshooting

Expand Down
36 changes: 18 additions & 18 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Below we will give an example of how to use WHISCY to predict the binding site o

Download the PDB file of the protein 1PPE from the [RCSB PDB](https://www.rcsb.org/structure/1PPE) website.

```bash
wget https://files.rcsb.org/download/1PPE.pdb
```
```bash
wget https://files.rcsb.org/download/1PPE.pdb
```

### Setup the prediction

Expand All @@ -32,26 +32,26 @@ $ whiscy_setup 1PPE.pdb E
2024-04-22 11:44:44,046 cli_setup:319 INFO - Protdist calculated
2024-04-22 11:44:44,054 cli_setup:326 INFO - Conversion table file generated
2024-04-22 11:44:44,054 cli_setup:328 INFO - Whiscy setup finished
```
```

This script will generate a set of files needed for the prediction step with `whiscy`. Here it is a list of the generated files in our 1PPE complex.

> Follow the links to see a set of pre-generated files for the 1PPE protein.
| File name | Explanation |
| ----------------------------------------- |----------------------------------------------------------------|
| [1ppe.hssp](example/1ppe.hssp) | Multiple sequence alignment download from the HSSP database |
| [1ppe.hssp.bz2](example/1ppe.hssp.bz2) | HSSP MSA file compressed |
| [1ppe.pdb](example/1ppe.pdb) | PDB file download from the Protein Data Bank |
| [1ppe_E.pdb](example/1ppe_E.pdb) | 1ppe.pdb parsed to select only the given `chain_id` |
| [1ppe_E.rsa](example/1ppe_E.rsa) | SASA output of `freesasa` in `NACCESS` format of `1ppe_E.pdb` file|
| [1ppe_E.fasta](example/1ppe_E.fasta) | Sequence of 1ppe_E.pdb. Alternative residues have been removed |
| [1ppe_E.phylseq](example/1ppe_E.phylseq) | MSA file translated from HSSP to PHYLIP format |
| [1ppe_E.conv](example/1ppe_E.conv) | PDB residue numeration to FASTA sequence numeration |
| [1ppe_E.out](example/1ppe_E.out) | Output of the `protdist` software on 1ppe_E.pdb |
| [1ppe_E.sur](example/1ppe_E.sur) | >15 % surface residue list according to `sa_pred_cutoff` cutoff |
| [1ppe_E.suract](example/1ppe_E.suract) | >40 % surface residue list according to `sa_act_cutoff` cutoff |
| [1ppe_E.lac](example/1ppe_E.lac) | 0-15 % accessible residue list |
| File name | Explanation |
| ---------------------------------------- | ------------------------------------------------------------------ |
| [1ppe.hssp](example/1ppe.hssp) | Multiple sequence alignment download from the HSSP database |
| [1ppe.hssp.bz2](example/1ppe.hssp.bz2) | HSSP MSA file compressed |
| [1ppe.pdb](example/1ppe.pdb) | PDB file download from the Protein Data Bank |
| [1ppe_E.pdb](example/1ppe_E.pdb) | 1ppe.pdb parsed to select only the given `chain_id` |
| [1ppe_E.rsa](example/1ppe_E.rsa) | SASA output of `freesasa` in `NACCESS` format of `1ppe_E.pdb` file |
| [1ppe_E.fasta](example/1ppe_E.fasta) | Sequence of 1ppe_E.pdb. Alternative residues have been removed |
| [1ppe_E.phylseq](example/1ppe_E.phylseq) | MSA file translated from HSSP to PHYLIP format |
| [1ppe_E.conv](example/1ppe_E.conv) | PDB residue numeration to FASTA sequence numeration |
| [1ppe_E.out](example/1ppe_E.out) | Output of the `protdist` software on 1ppe_E.pdb |
| [1ppe_E.sur](example/1ppe_E.sur) | >15 % surface residue list according to `sa_pred_cutoff` cutoff |
| [1ppe_E.suract](example/1ppe_E.suract) | >40 % surface residue list according to `sa_act_cutoff` cutoff |
| [1ppe_E.lac](example/1ppe_E.lac) | 0-15 % accessible residue list |

### Make the interface prediction

Expand Down
Binary file modified media/1ppe_whiscy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/loch_haddock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/whiscy_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 1 addition & 125 deletions media/whiscy_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[tool.poetry]
name = "whiscy"
version = "1.1.3"
description = "WHISCY is a software program that predicts protein-protein interfaces using conservation and structural information by calculating prediction scores for each surface residue based on sequence alignment."
version = "1.2.0"
description = "WHISCY is a software that predicts protein-protein interfaces using conservation and structural information by calculating prediction scores for each surface residue based on sequence alignment."
authors = ["Bonvin Lab <bonvinlab.support@uu.nl>"]
readme = "README.md"
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Operating System :: Unix",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Intended Audience :: Science/Research",
]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down
10 changes: 0 additions & 10 deletions src/whiscy/cli_bfactor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env python3

"""Adds the WHISCY scoring prediction to the B-factor column of a given PDB"""

__version__ = 1.0

import argparse
import os
import sys

STANDARD_TYPES = {
"ALA": "A",
Expand Down Expand Up @@ -65,9 +58,6 @@ def main():
action="store_true",
default=False,
)
parser.add_argument(
"--version", action="version", version="%(prog)s {}".format(__version__)
)
args = parser.parse_args()

input_pdb_file_name = args.input_pdb_file
Expand Down
13 changes: 2 additions & 11 deletions src/whiscy/cli_consadjust.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/usr/bin/env python3

__version__ = 1.0

import argparse

# Logging
import logging
import math
import os
Expand All @@ -13,12 +7,12 @@

import numpy as np

from whiscy.modules import PARAM_PATH
from whiscy.modules.whiscy_data import (
load_cons_file,
load_residue_weights,
load_z_table,
)
from whiscy.modules import PARAM_PATH

logger = logging.getLogger("consadjust")
logger.setLevel(logging.INFO)
Expand All @@ -45,9 +39,6 @@ def main():
dest="output_file",
metavar="output_file",
)
parser.add_argument(
"--version", action="version", version="%(prog)s {}".format(__version__)
)
args = parser.parse_args()

if not os.path.exists(args.cons_file):
Expand Down Expand Up @@ -93,7 +84,7 @@ def main():
neg = True

index = np.argmax(z_values < currz)
upperz = z_values[index]
z_values[index]

if index >= 24999:
pscore = 0.5
Expand Down
13 changes: 3 additions & 10 deletions src/whiscy/cli_haddock.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/usr/bin/env python3

"""Calculates the active/passive residues for HADDOCK
"""
Calculates the active/passive residues for HADDOCK
- Active residues: >=0.18 (WHISCY score)
- Passive residues: radius of 6.5A of active residues
"""

__version__ = 1.0

import argparse
import os
import sys

import Bio.PDB

Expand Down Expand Up @@ -64,9 +60,6 @@ def main():
parser.add_argument(
"whiscy_scores_file", help="WHISCY scores file", metavar="whiscy_scores_file"
)
parser.add_argument(
"--version", action="version", version="%(prog)s {}".format(__version__)
)
args = parser.parse_args()

input_pdb_file_name = args.input_pdb_file
Expand Down Expand Up @@ -104,7 +97,7 @@ def main():
neighbors.remove(active)
for passive in neighbors:
res_id = "{}{}".format(
STANDARD_TYPES[passive.get_resname()], passive.get_id()[1]
STANDARD_TYPES[passive.get_resname()], passive.get_id()[1] # type: ignore
)
passive_residue_ids.append(res_id)

Expand Down
9 changes: 0 additions & 9 deletions src/whiscy/cli_parasmooth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/usr/bin/env python3

__version__ = 1.0

import argparse

# Logging
import logging
import math
import os
Expand Down Expand Up @@ -134,9 +128,6 @@ def main():
dest="output_file",
metavar="output_file",
)
parser.add_argument(
"--version", action="version", version="%(prog)s {}".format(__version__)
)
args = parser.parse_args()

logger.info("Reading input files")
Expand Down
Loading

0 comments on commit 2003a9a

Please sign in to comment.