///|
/// Bio.PDB.PDBMLParser demo.
///
/// Parses a small PDBML (PDB XML) document and prints the header metadata plus
/// the Model -> Chain -> Residue -> Atom hierarchy.

///|
fn main raise {
  let xml = "" +
    "" +
    "TEST STRUCTURE" +
    "demo keyword" +
    "2020-01-02" +
    "" +
    "1.50" +
    "" +
    "ATOMALA1?A1CAC.1.12.23.31.0020.5" +
    "HETATMHOH2?B1OO.4.05.06.00.5030.0" +
    ""

  let s = @src.pdbml_get_structure(xml)
  println("idcode       : \{s.header.idcode}")
  println("name         : \{s.header.name}")
  println("head         : \{s.header.head}")
  println("deposition   : \{s.header.deposition_date}")
  println("method       : \{s.header.structure_method}")
  println("resolution   : \{Repr(s.header.resolution)}")

  for m in s.models {
    println("model serial : \{m.serial_number}")
    for c in m.chains {
      println("  chain      : \{c.chain_id}")
      for r in c.residues {
        println(
          "    residue  : \{r.component_id} hetero='\{r.hetero_field}' seq=\{r.sequence_id} ins='\{r.insertion_code}'",
        )
        for a in r.atoms {
          println(
            "      atom   : \{a.name} serial=\{a.serial_number} element=\{a.element} coord=(\{a.coord[0]},\{a.coord[1]},\{a.coord[2]})",
          )
        }
      }
    }
  }
}