Skip to content

Commit 3e49a66

Browse files
committed
First commit!
0 parents  commit 3e49a66

File tree

8 files changed

+2354
-0
lines changed

8 files changed

+2354
-0
lines changed

.github/workflows/build.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
jobs:
9+
build_wheels:
10+
name: Build wheels for ${{ matrix.platform_id }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ ubuntu-latest, macos-latest, windows-latest ]
16+
include:
17+
- os: ubuntu-latest
18+
platform_id: manylinux_x86_64
19+
- os: macos-latest
20+
platform_id: macosx
21+
- os: windows-latest
22+
platform_id: win_amd64
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up MSVC environment (Windows)
27+
if: runner.os == 'Windows'
28+
uses: ilammy/msvc-dev-cmd@v1
29+
with:
30+
arch: x64
31+
32+
- name: Setup Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.9"
36+
37+
- name: Build wheels
38+
uses: pypa/cibuildwheel@v2.23.3
39+
env:
40+
CIBW_BUILD_VERBOSITY: 1
41+
CIBW_ARCHS: ${{ runner.os == 'macOS' && 'universal2' || 'auto64' }}
42+
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: cibw-wheels-${{ matrix.platform_id }}-${{ strategy.job-index }}
46+
path: ./wheelhouse/*.whl
47+
48+
build_sdist:
49+
name: Build source distribution
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
submodules: true
55+
- uses: actions/setup-python@v5
56+
name: Install Python
57+
with:
58+
python-version: '3.13'
59+
- run: python -m pip install build
60+
- name: Build sdist
61+
run: python -m build --sdist
62+
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: cibw-sdist
66+
path: dist/*.tar.gz
67+
68+
upload_pypi:
69+
needs: [ build_sdist, build_wheels ]
70+
runs-on: ubuntu-latest
71+
if: startsWith(github.ref, 'refs/tags/')
72+
permissions:
73+
id-token: write
74+
steps:
75+
- name: Download all distribution files
76+
uses: actions/download-artifact@v4
77+
with:
78+
pattern: cibw-*
79+
path: dist/
80+
merge-multiple: true
81+
82+
- name: List files in dist
83+
run: ls -lR dist/
84+
85+
- name: Publish package to PyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1

CMakeLists.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CMakeLists.txt
2+
3+
cmake_minimum_required(VERSION 3.15)
4+
project(vcon_py C)
5+
6+
# Ensure we compile as C99 (code uses classic C interfaces)
7+
set(CMAKE_C_STANDARD 99)
8+
set(CMAKE_C_STANDARD_REQUIRED ON)
9+
10+
11+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/vconpy/vcon)
12+
13+
add_executable(vcon
14+
${CMAKE_CURRENT_SOURCE_DIR}/src/vconpy/vcon/Vcontacts-v1-2.c
15+
)
16+
17+
if(MSVC)
18+
target_compile_options(vcon PRIVATE /O2)
19+
else()
20+
target_compile_options(vcon PRIVATE -O3)
21+
target_link_libraries(vcon PRIVATE m)
22+
endif()
23+
24+
# Install
25+
include(GNUInstallDirs)
26+
27+
install(TARGETS vcon
28+
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
29+
)
30+
31+
# Install Python module files
32+
install(FILES
33+
${CMAKE_CURRENT_SOURCE_DIR}/src/vconpy/__init__.py
34+
${CMAKE_CURRENT_SOURCE_DIR}/src/vconpy/vcontacts_wrapper.py
35+
DESTINATION ${CMAKE_INSTALL_PREFIX}
36+
)

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# vcontacts-wrapper (vconpy)
2+
3+
A lightweight Python package to prepare arguments and run **Vcontacts**,
4+
a tool to compute surface areas in contact using the constrained Voronoi procedure from the paper:
5+
6+
> **Quantification of protein surfaces, volumes and atom-atom contacts using a constrained Voronoi procedure**
7+
> (doi: [10.1093/bioinformatics/18.10.1365](https://doi.org/10.1093/bioinformatics/18.10.1365))
8+
9+
This wrapper makes it easy to call the `Vcontacts` executables (`vcon_surfaces` or `vcon_nrgten`) directly from Python, capture their output, and optionally parse `.vcon` files into Python dictionaries.
10+
11+
---
12+
13+
## Installation
14+
15+
```bash
16+
pip install vcon-py
17+
```
18+
19+
---
20+
21+
## Example Usage
22+
23+
```python
24+
from vconpy import run_vcon
25+
26+
# Run Vcontacts
27+
result_surfaces = run_vcon(
28+
"/path/to/receptor.pdb",
29+
vcon_type="surfaces"
30+
)
31+
32+
# Run Vcontacts and return a dictionary instead of outputting a file
33+
result_nrgten = run_vcon(
34+
"/path/to/receptor.pdb",
35+
as_dictionary=True
36+
)
37+
38+
# NRGTEN requires setting showbonded as True
39+
result_nrgten = run_vcon(
40+
"/path/to/receptor.pdb",
41+
as_dictionary=True,
42+
showbonded=True
43+
)
44+
45+
print(result_nrgten.surface_dictionary) # dict of atom-atom contact areas
46+
```
47+
48+
---
49+
50+
## Arguments
51+
52+
| Argument | Type | Description | Default |
53+
|------------------|--------|----------------------------------------------------------------------------------------------------------------------------------|--------------|
54+
| `pdb_filename` | `str` | Path to the input PDB file. | **Required** |
55+
| `showbonded` | `bool` | If `True`, include covalently bonded atoms in the contacts (`-all` flag). | `False` |
56+
| `normalize` | `bool` | If `True`, normalize contacts to percent of total contact area. Otherwise, contacts are given in SAS units (Ų). (`-norm` flag). | `False` |
57+
| `planedef` | `str` | Plane definition for analysis. Options: `X` (extended radical plane), `R` (radical plane), `B` (bisecting plane). | `None` |
58+
| `as_dictionary` | `bool` | If `True`, returns a Python dictionary. The `.vcon` file is deleted after parsing. | `False` |
59+
60+
---
61+
62+
## Returns
63+
64+
The function returns a `VconResult` namedtuple with the following fields:
65+
66+
| Field | Type | Description |
67+
|----------------------|--------|------------------------------------------------------------------------|
68+
| `vcon_filename` | `str` | Path to the generated `.vcon` file. |
69+
| `surface_dictionary` | `dict` | Dictionary of atom-atom contact areas (only if `as_dictionary=True`). |
70+
| `stdout` | `str` | Standard output from the Vcontacts process. |
71+
| `stderr` | `str` | Standard error from the Vcontacts process. |
72+
| `returncode` | `int` | Exit code from the Vcontacts process. |
73+
74+
---
75+
76+
## Raises
77+
78+
| Error | Condition |
79+
|-------------|---------------------------------------------------------------------------|
80+
| `ValueError` | Raised if the input file does not exist, or if `vcon_type` is invalid. |
81+
| `VconError` | Raised if the Vcontacts executable is missing, not executable, or fails. |
82+
83+
---

pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[build-system]
2+
requires = [
3+
"scikit-build-core",
4+
"setuptools_scm[toml]>=6.2"
5+
]
6+
build-backend = "scikit_build_core.build"
7+
8+
[project]
9+
name = "vcon-py"
10+
dynamic = ["version"]
11+
description = "Python wheels and a wrapper for Vcontacts, a tool to compute surface areas in contact using the constrained Voronoi procedure."
12+
authors = [
13+
{name = "Thomas DesCôteaux"},
14+
{name = "Rafael Najmanovich", email = "rafael.najmanovich@umontreal.ca"},
15+
]
16+
classifiers = [
17+
'Intended Audience :: Science/Research',
18+
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
19+
'Natural Language :: English',
20+
]
21+
22+
readme = "README.md"
23+
requires-python = ">=3.9"
24+
25+
[project.urls]
26+
Homepage = "https://github.com/NRGlab"
27+
Documentation = "https://github.com/NRGlab/vcon-py/blob/main/README.md"
28+
Repository = "https://github.com/NRGlab/vcon-py"
29+
Issues = "https://github.com/NRGlab/vcon-py/issues"
30+
31+
[tool.scikit-build]
32+
wheel.install-dir = "vconpy"
33+
wheel.py-api = "py3"
34+
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
35+
cmake.build-type = "Release"
36+
37+
[tool.setuptools.packages.find]
38+
include = ["vconpy","vconpy.*"]
39+
40+
[tool.setuptools_scm]
41+
42+
[tool.cibuildwheel]
43+
build = "cp39-*"
44+
skip = [
45+
"*-win32",
46+
"*-manylinux_i686",
47+
"*-musllinux*",
48+
]
49+
50+
environment-pass = ["CIBW_BUILD"]

src/vconpy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .vcontacts_wrapper import run_vcon

0 commit comments

Comments
 (0)