Skip to content

Commit

Permalink
remove panic
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Aug 19, 2023
1 parent 7f0b517 commit cabf179
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
27 changes: 16 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,27 @@ fn load_sketches_above_threshold(
let matchlist: BinaryHeap<PrefetchResult> = sketchlist_paths
.par_iter()
.filter_map(|m| {
let sigs = Signature::from_path(m).unwrap();
let sigs = Signature::from_path(m);

let mut mm = None;
for sig in &sigs {
if let Some(mh) = prepare_query(sig, template) {
if let Ok(overlap) = mh.count_common(query, false) {
if overlap >= threshold_hashes {
let result = PrefetchResult {
name: sig.name(),
minhash: mh,
overlap,
};
mm = Some(result);
if let Ok(sigs) = sigs {
for sig in &sigs {
if let Some(mh) = prepare_query(sig, template) {
if let Ok(overlap) = mh.count_common(query, false) {
if overlap >= threshold_hashes {
let result = PrefetchResult {
name: sig.name(),
minhash: mh,
overlap,
};
mm = Some(result);
break;
}
}
}
}
} else {
// print out error here...
}
mm
})
Expand Down
25 changes: 24 additions & 1 deletion src/python/tests/test_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def test_missing_against(runtmp, capfd):
def test_bad_against(runtmp, capfd):
# test bad 'against' file - in this case, use a .sig.gz file.
query = get_test_data('SRR606249.sig.gz')
against_list = runtmp.output('against.txt')

sig2 = get_test_data('2.fa.sig.gz')

Expand All @@ -175,3 +174,27 @@ def test_bad_against(runtmp, capfd):
print(captured.err)

assert 'Error: invalid line in fromfile ' in captured.err




def test_bad_against_2(runtmp, capfd):
# test bad 'against' file - in this case, one containing a bad filename.
query = get_test_data('SRR606249.sig.gz')
against_list = runtmp.output('against.txt')

sig2 = get_test_data('2.fa.sig.gz')
make_file_list(against_list, [sig2, 'file-does-not-exist'])


g_output = runtmp.output('gather.csv')
p_output = runtmp.output('prefetch.csv')

runtmp.sourmash('scripts', 'fastgather', query, against_list,
'-o', g_output, '--output-prefetch', p_output,
'-s', '100000')

captured = capfd.readouterr()
print(captured.err)

# @CTB: should be some kind of error message here.

0 comments on commit cabf179

Please sign in to comment.