diff --git a/src/lib.rs b/src/lib.rs index 01cac9fa..c5e27856 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -381,6 +381,16 @@ fn load_sketchlist_filenames>(sketchlist_filename: &P) -> fn load_sketch_fromfile>(sketchlist_filename: &P) -> Result> { let mut rdr = csv::Reader::from_path(sketchlist_filename)?; + + // Check for right header + let headers = rdr.headers()?; + if headers.len() != 3 || + headers.get(0).unwrap() != "name" || + headers.get(1).unwrap() != "genome_filename" || + headers.get(2).unwrap() != "protein_filename" { + return Err(anyhow!("Invalid header. Expected 'name,genome_filename,protein_filename', but got {:?}", headers)); + } + let mut results = Vec::new(); let mut row_count = 0; diff --git a/src/python/tests/test_sketch.py b/src/python/tests/test_sketch.py index d28caf83..a95ad54f 100644 --- a/src/python/tests/test_sketch.py +++ b/src/python/tests/test_sketch.py @@ -194,6 +194,7 @@ def test_manysketch_bad_fa_csv_2(runtmp, capfd): captured = capfd.readouterr() print(captured.err) + assert "Invalid header" in captured.err assert "Could not load fromfile csv" in captured.err