@@ -179,6 +179,8 @@ use crate::sketch::sketch_datafile::SketchArrayReader;
179179use crate :: sketch:: { num_bins, sketch_files} ;
180180
181181pub mod inverted;
182+ #[ cfg( target_family = "wasm" ) ]
183+ use crate :: distances:: ani_pois;
182184use crate :: inverted:: Inverted ;
183185
184186pub mod distances;
@@ -1054,7 +1056,7 @@ impl SketchlibData {
10541056 }
10551057
10561058 /// Mapping function.
1057- pub fn get_probs ( & self , nouts : usize ) -> String {
1059+ pub fn get_ani ( & self , nouts : usize ) -> String {
10581060 if self . out_probs . is_empty ( ) {
10591061 panic ! ( "No probabilities calculated!" ) ;
10601062 }
@@ -1068,13 +1070,13 @@ impl SketchlibData {
10681070
10691071 let selected = select_ranked_matches ( & self . out_probs , nouts) ;
10701072
1071- results[ "probs " ] = json:: JsonValue :: Array (
1073+ results[ "ani " ] = json:: JsonValue :: Array (
10721074 selected
10731075 . iter ( )
10741076 . map ( |x| {
10751077 let matches = x. 0 as f64 ;
1076- let similarity = matches / ( ( 2 * self . index . sketch_size ( ) ) as f64 - matches) ;
1077- json:: JsonValue :: Number ( similarity . into ( ) )
1078+ let jaccard = matches / ( ( 2 * self . index . sketch_size ( ) ) as f64 - matches) ;
1079+ json:: JsonValue :: Number ( ani_pois ( jaccard , self . index . kmer ( ) as f64 ) . into ( ) )
10781080 } )
10791081 . collect ( ) ,
10801082 ) ;
@@ -1147,7 +1149,7 @@ mod wasm_result_ranking_tests {
11471149 }
11481150
11491151 #[ test]
1150- fn get_probs_three_excludes_internal_rank_three ( ) {
1152+ fn get_ani_three_excludes_internal_rank_three ( ) {
11511153 let matches = vec ! [ ( 10 , 0 ) , ( 9 , 1 ) , ( 8 , 2 ) , ( 7 , 3 ) ] ;
11521154 assert ! ( !select_ranked_matches( & matches, 3 ) . contains( & ( 7 , 3 , 3 ) ) ) ;
11531155 }
0 commit comments