use pdbrust::core::PdbStructure;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut structure = PdbStructure::new();
structure.header = Some("Example PDB Structure".to_string());
structure.title = Some("Basic Usage Example".to_string());
structure.atoms.push(pdbrust::records::Atom {
serial: 1,
name: "CA".to_string(),
alt_loc: None,
residue_name: "ALA".to_string(),
chain_id: "A".to_string(),
residue_seq: 1,
ins_code: None,
is_hetatm: false,
x: 0.0,
y: 0.0,
z: 0.0,
occupancy: 1.0,
temp_factor: 20.0,
element: "C".to_string(),
});
structure.seqres.push(pdbrust::records::SeqRes {
serial: 1,
chain_id: "A".to_string(),
num_residues: 1,
residues: vec!["ALA".to_string()],
});
structure.remarks.push(pdbrust::records::Remark {
number: 2,
content: "RESOLUTION. 2.0 ANGSTROMS.".to_string(),
});
let chain_ids = structure.get_chain_ids();
println!("Found chains: {:?}", chain_ids);
let residues = structure.get_residues_for_chain("A");
println!("Residues in chain A: {:?}", residues);
let sequence = structure.get_sequence("A");
println!("Sequence of chain A: {:?}", sequence);
let resolution_remarks = structure.get_remarks_by_number(2);
for remark in resolution_remarks {
println!("Resolution remark: {}", remark.content);
}
structure.translate(1.0, 2.0, 3.0);
println!(
"Translated first atom coordinates: ({}, {}, {})",
structure.atoms[0].x, structure.atoms[0].y, structure.atoms[0].z
);
structure.to_file("example_output.pdb")?;
println!("Structure saved to example_output.pdb");
Ok(())
}