pdbrust

A Rust library for parsing PDB (Protein Data Bank) files

https://github.com/hfooladi/pdbrust

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary

Keywords

cheminformatics mmcif parser pdb rust
Last synced: 4 months ago · JSON representation ·

Repository

A Rust library for parsing PDB (Protein Data Bank) files

Basic Info
  • Host: GitHub
  • Owner: HFooladi
  • License: mit
  • Language: Rust
  • Default Branch: main
  • Homepage:
  • Size: 1.81 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
cheminformatics mmcif parser pdb rust
Created 9 months ago · Last pushed 5 months ago
Metadata Files
Readme Changelog License Citation Security

README.md

Rust CI/CD codecov License: MIT Crates.io Documentation

PDBRust Banner

PDBRust

A comprehensive Rust library for parsing and analyzing PDB (Protein Data Bank) files. This library provides a robust and efficient way to work with protein structure data in PDB format.

Features

  • Complete Record Support

    • ATOM/HETATM records with full coordinate and metadata support
    • MODEL/ENDMDL for multi-model structures
    • SEQRES records for sequence information
    • CONECT records for connectivity data
    • SSBOND records for disulfide bonds
    • REMARK records with categorization
    • HEADER and TITLE metadata
  • Robust Error Handling

    • Custom error types for different parsing scenarios
    • Detailed error messages for debugging
    • Safe handling of malformed PDB files
  • Utility Functions

    • Chain identification and analysis
    • Residue sequence extraction
    • Connectivity analysis
    • Model-based structure organization
    • Disulfide bond analysis

Installation

Add this to your Cargo.toml:

toml [dependencies] pdbrust = "0.1.0"

Usage

Basic Structure Loading

```rust use pdbrust::PdbStructure;

fn main() -> Result<(), Box> { // Load a PDB file let structure = PdbStructure::from_file("protein.pdb")?;

// Access basic information
if let Some(header) = &structure.header {
    println!("Structure header: {}", header);
}

println!("Number of atoms: {}", structure.atoms.len());
println!("Number of models: {}", structure.models.len());

Ok(())

} ```

Chain and Residue Analysis

```rust use pdbrust::PdbStructure;

fn analyzechains(structure: &PdbStructure) { // Get all chain IDs let chainids = structure.getchainids();

for chain_id in chain_ids {
    // Get residues in this chain
    let residues = structure.get_residues_for_chain(&chain_id);
    println!("Chain {} has {} residues", chain_id, residues.len());

    // Get sequence if available
    let sequence = structure.get_sequence(&chain_id);
    if !sequence.is_empty() {
        println!("Sequence: {}", sequence.join("-"));
    }
}

} ```

Connectivity Analysis

```rust use pdbrust::PdbStructure;

fn analyzeconnectivity(structure: &PdbStructure) { // Analyze disulfide bonds for bond in &structure.ssbonds { println!("Disulfide bond between:"); println!(" Residue 1: {} {} {}", bond.residue1name, bond.chain1id, bond.residue1seq); println!(" Residue 2: {} {} {}", bond.residue2name, bond.chain2id, bond.residue2_seq); println!(" Distance: {:.2} Å", bond.length); } } ```

Parallel Processing

```rust use pdbrust::PdbStructure; use pdbrust::features::parallel;

[cfg(feature = "parallel")]

fn processstructuresparallel(structures: Vec) { use rayon::prelude::*;

let results: Vec<_> = structures.par_iter()
    .map(|structure| {
        // Process each structure in parallel
        structure.atoms.len()
    })
    .collect();

println!("Total atoms across all structures: {}", results.iter().sum::<usize>());

} ```

Geometric Analysis

```rust use pdbrust::PdbStructure; use pdbrust::features::geometry;

[cfg(feature = "geometry")]

fn analyzestructuregeometry(structure: &PdbStructure) { use nalgebra::Vector3;

// Calculate center of mass
let com = structure.calculate_center_of_mass();
println!("Center of mass: {:?}", com);

// Calculate radius of gyration
let rg = structure.calculate_radius_of_gyration();
println!("Radius of gyration: {:.2} Å", rg);

} ```

Features

PDBRust supports several optional features that can be enabled in your Cargo.toml:

toml [dependencies] pdbrust = { version = "0.1.0", features = ["parallel", "geometry"] }

  • parallel: Enables parallel processing capabilities using Rayon
  • geometry: Adds geometric analysis functions using nalgebra

Contributing

We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

  1. Clone the repository: bash git clone https://github.com/hfooladi/pdbrust.git cd pdbrust

  2. Install dependencies: bash cargo build

  3. Run tests: bash cargo test

  4. Run benchmarks: bash cargo bench

Code Style

  • Follow the Rust standard style guide
  • Run cargo fmt before committing
  • Run cargo clippy to check for linting issues
  • Ensure all tests pass with cargo test
  • Add tests for new functionality
  • Update documentation as needed

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • The Protein Data Bank (PDB) for providing the standard format
  • The Rust community for excellent tools and libraries
  • All contributors to this project

Owner

  • Name: Hosein Fooladi
  • Login: HFooladi
  • Kind: user

Machine Learning researcher. Deep learning for drug discovery. Finding bugs in intelligence. Interested in Artificial Life. @ShenakhtPajouh

Citation (citation.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it using these metadata."
type: software
abstract: "PDBRust is a high-performance Rust library designed for parsing and analyzing Protein Data Bank (PDB) files. It provides efficient data structures and methods for working with molecular structures, making it suitable for structural biology and bioinformatics applications."
authors:
  - given-names: "Hossein"
    family-names: "Fooladi"
    orcid: "https://orcid.org/0000-0002-3124-2761"
title: "PDBRust: A Rust library for parsing and analyzing PDB files"
version: 0.1.0
date-released: "2025-03-25"
repository-code: "https://github.com/hfooladi/pdbrust"
repository-artifact: "https://github.com/hfooladi/pdbrust/releases"
url: "https://github.com/hfooladi/pdbrust"
keywords:
  - bioinformatics
  - structural biology
  - PDB
  - protein structure
  - crystallography
  - Rust
license: MIT
programming-languages:
  - Rust
operating-systems:
  - cross-platform
dependencies:
  - type: "software"
    name: "Rust"
    version: ">=1.70.0"
    url: "https://www.rust-lang.org/"

GitHub Events

Total
  • Delete event: 2
  • Issue comment event: 4
  • Push event: 25
  • Pull request event: 5
  • Create event: 4
Last Year
  • Delete event: 2
  • Issue comment event: 4
  • Push event: 25
  • Pull request event: 5
  • Create event: 4

Issues and Pull Requests

Last synced: 9 months ago


Dependencies

Cargo.toml cargo
.github/workflows/rust.yml actions
  • actions/cache v3 composite
  • actions/checkout v4 composite
  • codecov/codecov-action v4 composite
  • dtolnay/rust-toolchain stable composite
  • dtolnay/rust-toolchain master composite
  • taiki-e/install-action cargo-llvm-cov composite