Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Cargo.lock
target/
**/*.rs.bk

# python generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Rust
target/

# venv
.venv
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ authors = ["Alex Carlin <alxcarln@gmail.com>"]
description = "PDB reader and other protein modeling tools"
license = "MIT"

# [lib]
# name = "heme"
# crate-type = ["cdylib"]
[lib]
name = "heme"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.18.0", features = ["extension-module"] }
Expand Down
5 changes: 5 additions & 0 deletions example_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import heme


#print(heme.hello())
print(heme.parse_my_pdb("demo/1ee9.pdb"))
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[project]
name = "heme"
version = "0.1.0"
description = "Add your description here"
authors = [
{ name = "Alex Carlin", email = "alxcarln@gmail.com" }
]
dependencies = [
"maturin>=1.7.0",
]
readme = "README.md"
requires-python = ">= 3.8"

[build-system]
requires = ["maturin>=1.2,<2.0"]
build-backend = "maturin"

[tool.rye]
managed = true
dev-dependencies = []

[tool.maturin]
python-source = "python"
module-name = "heme._lowlevel"
features = ["pyo3/extension-module"]
3 changes: 3 additions & 0 deletions python/heme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from heme._lowlevel import hello, parse_my_pdb

__all__ = ["hello", "parse_my_pdb"]
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ modeling, see the OpenMM or Lumol projects.)
- `Atom` and `Record` objects


## Development

Heme is a hybrid Python-Rust library with bindings provided by PyO3


14 changes: 14 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
maturin==1.7.0
# via heme
14 changes: 14 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
# universal: false

-e file:.
maturin==1.7.0
# via heme
44 changes: 43 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
pub mod conformation;
pub mod sampling;
pub mod transforms;
pub mod io;
pub mod io;

// Python bindings
use std::fs;
use std::fs::File;
use std::io::Read;
use pyo3::prelude::*;

/// Prints a message.
#[pyfunction]
fn hello() -> PyResult<String> {
Ok("Hello from Hemes!".into())
}

/// Reads a file and returns its contents with a greeting.
#[pyfunction]
fn parse_my_pdb(file_name: &str) -> PyResult<String> {

// read input files from Config object
let mut f = File::open(file_name)?;
let mut contents = String::new();
f.read_to_string(&mut contents)?;

// create pose object by parsing the PDB
let atoms = io::parse_pdb(&contents);
let mut pose = conformation::Pose::from_atoms(atoms);

println!("read pose");
// Apply a protocol to the Pose
//let protocol = sampling::get_protocol(&io::config.protocol);
//protocol.run(&mut pose);

Ok("read rule".into())
}


/// A Python module implemented in Rust.
#[pymodule]
fn _lowlevel(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(parse_my_pdb, m)?)?;
m.add_function(wrap_pyfunction!(hello, m)?)?;
Ok(())
}
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::env;
use std::process;

use heme::io::Config;

fn main() {
Expand Down