Add torsion edges to aspirin reference data and update ToyReferenceData structure to include them in the toy pipeline

This commit is contained in:
demian3b
2026-04-15 23:24:00 +09:00
parent 9e45a090af
commit 9827bd2491
2 changed files with 51 additions and 3 deletions

View File

@@ -339,5 +339,34 @@
"length_angstrom": 1.417065754107979 "length_angstrom": 1.417065754107979
} }
], ],
"torsion_edges": [] "torsion_edges": [
{
"bond_index": 2,
"atom_left": 1,
"atom_right": 3,
"rotating_side": [
0,
2
]
},
{
"bond_index": 3,
"atom_left": 3,
"atom_right": 4,
"rotating_side": [
0,
1,
2
]
},
{
"bond_index": 9,
"atom_left": 10,
"atom_right": 9,
"rotating_side": [
11,
12
]
}
]
} }

View File

@@ -8,7 +8,7 @@ use riemann_flow_gnn::{
api::{OneSampleToyBatch, OneSampleToyPipeline}, api::{OneSampleToyBatch, OneSampleToyPipeline},
conformer::LigandConformer, conformer::LigandConformer,
geometry::PoseState, geometry::PoseState,
graph::{Atom, Bond, LigandGraph}, graph::{Atom, Bond, LigandGraph, TorsionEdge},
viz::{export_simulation_video, plot_static_png}, viz::{export_simulation_video, plot_static_png},
}; };
use serde::Deserialize; use serde::Deserialize;
@@ -48,6 +48,15 @@ struct ToyReferenceData {
atoms: Vec<ToyAtom>, atoms: Vec<ToyAtom>,
bonds: Vec<ToyBond>, bonds: Vec<ToyBond>,
coords_angstrom: Vec<[f32; 3]>, coords_angstrom: Vec<[f32; 3]>,
torsion_edges: Vec<TorsionEdgeJson>,
}
#[derive(Debug, Deserialize)]
struct TorsionEdgeJson {
bond_index: usize,
atom_left: usize,
atom_right: usize,
rotating_side: Vec<usize>,
} }
fn load_toy_reference(path: &str) -> Result<(LigandGraph, LigandConformer), Box<dyn std::error::Error>> { fn load_toy_reference(path: &str) -> Result<(LigandGraph, LigandConformer), Box<dyn std::error::Error>> {
@@ -76,7 +85,17 @@ fn load_toy_reference(path: &str) -> Result<(LigandGraph, LigandConformer), Box<
is_rotatable: b.is_rotatable, is_rotatable: b.is_rotatable,
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let graph = LigandGraph::new(atoms, bonds, vec![]); let torsion_edges = parsed
.torsion_edges
.into_iter()
.map(|t| TorsionEdge {
bond_index: t.bond_index,
atom_left: t.atom_left,
atom_right: t.atom_right,
rotating_side: t.rotating_side,
})
.collect::<Vec<_>>();
let graph = LigandGraph::new(atoms, bonds, torsion_edges);
let reference = LigandConformer::new(graph.clone(), parsed.coords_angstrom)?; let reference = LigandConformer::new(graph.clone(), parsed.coords_angstrom)?;
Ok((graph, reference)) Ok((graph, reference))
} }