From 2208d58c5804be58194415a8c11a5b1bd66f01f2 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 29 May 2020 00:11:10 +0200 Subject: [PATCH] Read only the n first atoms in xyz --- GITHUB.md | 7 ++----- ocaml/Molecule.ml | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/GITHUB.md b/GITHUB.md index cee4cc8c..3240d198 100644 --- a/GITHUB.md +++ b/GITHUB.md @@ -13,11 +13,8 @@ dev: bugfix: A fork of the *master* on which the bug fixes are made. -dev-lcpq: - Toulouse development branch - -dev-lct: - Paris development branch +dev: + Development branch gh-pages: This is an independent branch, containing only the web site of QP2. diff --git a/ocaml/Molecule.ml b/ocaml/Molecule.ml index 78ceff0c..f3633155 100644 --- a/ocaml/Molecule.ml +++ b/ocaml/Molecule.ml @@ -149,14 +149,18 @@ let of_xyz_file let lines = match Io_ext.input_lines filename with | natoms :: title :: rest -> - begin - try - if (int_of_string @@ String_ext.strip natoms) <= 0 then - raise XYZError - with - | _ -> raise XYZError - end; - String.concat "\n" rest + let natoms = + try + int_of_string @@ String_ext.strip natoms + with + | _ -> raise XYZError + in + if natoms <= 0 then + raise XYZError; + let a = Array.of_list rest in + Array.sub a 0 natoms + |> Array.to_list + |> String.concat "\n" | _ -> raise XYZError in of_xyz_string ~charge:charge ~multiplicity:multiplicity