Skip to content

Commit

Permalink
Pymol Refactor (#75)
Browse files Browse the repository at this point in the history
* refactoring pymol conversion to its own crate

* optimize imports
  • Loading branch information
zachcp authored Dec 9, 2024
1 parent 0b7dda9 commit 23a98f1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ferritin-amplify/src/amplify/amplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//!
use super::config::AMPLIFYConfig;
use super::encoder::EncoderBlock;
use super::rotary::precompute_freqs_cis;
use super::outputs::ModelOutput;
use super::rotary::precompute_freqs_cis;
use candle_core::{Device, Module, Result, Tensor, D};
use candle_nn::{embedding, linear, rms_norm, Embedding, Linear, RmsNorm, VarBuilder};
use tokenizers::Tokenizer;
Expand Down
2 changes: 1 addition & 1 deletion ferritin-amplify/src/amplify/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::config::AMPLIFYConfig;
use super::rotary::apply_rotary_emb;
use candle_core::{Module, Result, Tensor, D};
use candle_nn::{
linear, linear_no_bias, ops::softmax_last_dim, rms_norm, Dropout, Linear, RmsNorm, VarBuilder,
linear_no_bias, ops::softmax_last_dim, rms_norm, Dropout, Linear, RmsNorm, VarBuilder,
};

/// An encoder block in the AMPLIFY transformer architecture.
Expand Down
1 change: 0 additions & 1 deletion ferritin-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license.workspace = true
description.workspace = true

[dependencies]
ferritin-pymol = { path = "../ferritin-pymol", optional = true }
pdbtbx.workspace = true
itertools.workspace = true
lazy_static = "1.5.0"
Expand Down
1 change: 0 additions & 1 deletion ferritin-core/src/conversions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
mod pdb;
mod pse;
1 change: 1 addition & 0 deletions ferritin-pymol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license.workspace = true
description.workspace = true

[dependencies]
ferritin-core = { path = "../ferritin-core" }
ferritin-molviewspec = { path = "../ferritin-molviewspec" }
clap = { version = "4.5.23", features = ["derive"] }
serde-pickle = "1.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{AtomCollection, Bond, BondOrder};
use ferritin_pymol::PSEData;
use ferritin_core::{AtomCollection, Bond, BondOrder};
use crate::{PSEData,pymolparsing};
use itertools::Itertools;
use pdbtbx::Element;

Expand All @@ -8,11 +8,11 @@ impl From<&PSEData> for AtomCollection {
let mols = pse_data.get_molecule_data();

// Pymol: most of the descriptive data is there
let atoms: Vec<&ferritin_pymol::pymolparsing::parsing::AtomInfo> =
let atoms: Vec<&pymolparsing::parsing::AtomInfo> =
mols.iter().flat_map(|mol| mol.atom.iter()).collect();

// Pymol: coord sets are maintained seperately.
let coord_sets: Vec<&ferritin_pymol::pymolparsing::parsing::CoordSet> =
let coord_sets: Vec<&pymolparsing::parsing::CoordSet> =
mols.iter().flat_map(|mol| mol.coord_set.iter()).collect();

let coords: Vec<[f32; 3]> = coord_sets
Expand All @@ -21,7 +21,7 @@ impl From<&PSEData> for AtomCollection {
.collect();

// Pymol: most of the descriptive data is there
let pymol_bonds: Vec<&ferritin_pymol::pymolparsing::parsing::Bond> =
let pymol_bonds: Vec<&pymolparsing::parsing::Bond> =
mols.iter().flat_map(|mol| mol.bond.iter()).collect();

let bonds = pymol_bonds
Expand Down Expand Up @@ -67,8 +67,8 @@ impl From<&PSEData> for AtomCollection {

#[cfg(test)]
mod tests {
use crate::AtomCollection;
use ferritin_pymol::PSEData;
use ferritin_core::AtomCollection;
use crate::PSEData;
use ferritin_test_data::TestFile;

#[test]
Expand Down
1 change: 1 addition & 0 deletions ferritin-pymol/src/conversions/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod atomcollection;
1 change: 1 addition & 0 deletions ferritin-pymol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
//! ```
//!
pub mod pymolparsing;
pub mod conversions;
pub use self::pymolparsing::parsing::PyObjectMolecule;
pub use self::pymolparsing::psedata::PSEData;

0 comments on commit 23a98f1

Please sign in to comment.