Skip to content

Commit

Permalink
also check csv header
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegenes committed Sep 6, 2023
1 parent 82593c5 commit 3c819ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ fn load_sketchlist_filenames<P: AsRef<Path>>(sketchlist_filename: &P) ->

fn load_sketch_fromfile<P: AsRef<Path>>(sketchlist_filename: &P) -> Result<Vec<(String, PathBuf, String)>> {
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;
Expand Down
1 change: 1 addition & 0 deletions src/python/tests/test_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 3c819ff

Please sign in to comment.