Skip to content

Commit

Permalink
reorganize
Browse files Browse the repository at this point in the history
  • Loading branch information
rvhonorato committed Aug 2, 2024
1 parent 0a07def commit 15db81b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ fn restraint_bodies(input_file: &str) -> Result<(), Box<dyn Error>> {
};

// Find in-contiguous chains
let gaps = structure::find_structural_gaps(&pdb);
let bodies = structure::find_bodies(&pdb);
let gaps = structure::create_iter_body_gaps(&bodies);

// Create the interactors
let mut interactors: Vec<Interactor> = Vec::new();
Expand Down
17 changes: 8 additions & 9 deletions src/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ pub struct Gap {
pub distance: f64,
}

pub fn find_structural_gaps(pdb: &pdbtbx::PDB) -> Vec<Gap> {
pub fn find_bodies(pdb: &pdbtbx::PDB) -> HashMap<isize, Vec<(isize, &str, &pdbtbx::Atom)>> {
// Check if the distance of a given atom to its next one is higher than 4A
let mut gaps: Vec<Gap> = Vec::new();

// Get only the `CA` atoms
let mut ca_atoms: Vec<(&str, isize, &pdbtbx::Atom)> = Vec::new();
Expand All @@ -177,16 +176,16 @@ pub fn find_structural_gaps(pdb: &pdbtbx::PDB) -> Vec<Gap> {
}
bodies
.entry(body_id)
.or_insert_with(Vec::new)
.or_default()
.push((*res_i, chain_i, atom_i));
}

let pairs = create_iter_body_gaps(&bodies);

pairs
bodies
}

fn create_iter_body_gaps(bodies: &HashMap<isize, Vec<(isize, &str, &pdbtbx::Atom)>>) -> Vec<Gap> {
pub fn create_iter_body_gaps(
bodies: &HashMap<isize, Vec<(isize, &str, &pdbtbx::Atom)>>,
) -> Vec<Gap> {
let mut rng = StdRng::seed_from_u64(42);
let mut pairs: Vec<Gap> = Vec::new();
let body_ids: Vec<isize> = bodies.keys().cloned().collect();
Expand All @@ -199,12 +198,12 @@ fn create_iter_body_gaps(bodies: &HashMap<isize, Vec<(isize, &str, &pdbtbx::Atom

for i in 0..2 {
pairs.push(Gap {
chain: selected1[i].1.clone().to_string(),
chain: selected1[i].1.to_string(),
atom_i: selected1[i].2.name().to_string(),
atom_j: selected2[i].2.name().to_string(),
res_i: selected1[i].0,
res_j: selected2[i].0,
distance: selected1[i].2.distance(&selected2[i].2),
distance: selected1[i].2.distance(selected2[i].2),
});
}
}
Expand Down

0 comments on commit 15db81b

Please sign in to comment.