diff --git a/exon/exon-sdf/src/io.rs b/exon/exon-sdf/src/io.rs index ac877167..275ae452 100644 --- a/exon/exon-sdf/src/io.rs +++ b/exon/exon-sdf/src/io.rs @@ -71,8 +71,8 @@ mod tests { #[tokio::test] async fn test_read_record() -> crate::Result<()> { let molfile_content = r#" -Methane -Example + Methane + Example 2 1 0 0 0 0 999 V2000 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 @@ -97,7 +97,7 @@ $$$$ let record = reader.read_record().await?.unwrap(); - assert_eq!(record.header(), "Methane\nExample\n"); + assert_eq!(record.header(), "Methane\nExample"); assert_eq!(record.data().len(), 3); assert_eq!(record.atom_count(), 2); assert_eq!(record.bond_count(), 1); diff --git a/exon/exon-sdf/src/record.rs b/exon/exon-sdf/src/record.rs index 7730cd10..23c68724 100644 --- a/exon/exon-sdf/src/record.rs +++ b/exon/exon-sdf/src/record.rs @@ -100,7 +100,19 @@ pub(crate) fn parse_to_record(content: &str) -> crate::Result { let mut lines = content.lines(); // Parse header (first 3 lines) - let header = lines.by_ref().take(3).collect::>().join("\n"); + let header = lines + .by_ref() + .take(3) + .filter_map(|l| { + let line = l.trim(); + if line.is_empty() { + None + } else { + Some(line) + } + }) + .collect::>() + .join("\n"); // Parse counts line let counts_line = lines.next().expect("Missing counts line");