diff --git a/srcs/utils.py b/srcs/utils.py index 376b949..33d07bf 100644 --- a/srcs/utils.py +++ b/srcs/utils.py @@ -155,32 +155,6 @@ def remove_corr_organisms_from_ref(sig_info_dict: Dict[str, Tuple[str, float, in manifest_df = pd.DataFrame(manifest_df, columns=['organism_name', 'md5sum', 'num_unique_kmers_in_genome_sketch', 'num_total_kmers_in_genome_sketch', 'genome_scale_factor']) return rep_remove_dict, manifest_df - -# def compute_sample_vector(sample_hashes, hash_to_idx): -# """ -# Helper function that computes the sample vector for a given sample signature. -# :param sample_hashes: hashes in the sample signature -# :param hash_to_idx: dictionary mapping hashes to indices in the training dictionary -# :return: numpy array (sample vector) -# """ -# # total number of hashes in the training dictionary -# hash_to_idx_keys = set(hash_to_idx.keys()) - -# # total number of hashes in the sample -# sample_hashes_keys = set(sample_hashes.keys()) - -# # initialize the sample vector -# sample_vector = np.zeros(len(hash_to_idx_keys)) - -# # get the hashes that are in both the sample and the training dictionary -# sample_intersect_training_hashes = hash_to_idx_keys.intersection(sample_hashes_keys) - -# # fill in the sample vector -# for sh in tqdm(sample_intersect_training_hashes): -# sample_vector[hash_to_idx[sh]] = sample_hashes[sh] - -# return sample_vector - class Prediction: """ diff --git a/tests/unittests.py b/tests/unittests.py index 38e1809..10ffc96 100644 --- a/tests/unittests.py +++ b/tests/unittests.py @@ -1,4 +1,5 @@ import json +import math import pytest import pandas as pd import os @@ -69,14 +70,14 @@ def test_get_cami_profile(): prediction1 = profile[0] assert prediction1.rank == 'superkingdom' assert prediction1.taxid == '2157' - assert prediction1.percentage == 0.029528 + assert math.isclose(prediction1.percentage, 0.029528, abs_tol=1e-6) assert prediction1.taxpath == '2157' assert prediction1.taxpathsn == 'Archaea' prediction2 = profile[1] assert prediction2.rank == 'superkingdom' assert prediction2.taxid == '2' - assert prediction2.percentage == 29.183763 + assert math.isclose(prediction2.percentage, 29.183763, rel_tol=1e-6) assert prediction2.taxpath == '2' assert prediction2.taxpathsn == 'Bacteria' @@ -87,7 +88,7 @@ def test_get_alt_mut_rate(): significance = 0.99 result = get_alt_mut_rate(nu, thresh, ksize, significance) expected_result = 0.047902071844405425 - assert result == expected_result + assert math.isclose(result, expected_result, rel_tol=1e-6, abs_tol=1e-6) def test_get_alt_mut_rate_zero_nu(): nu = 0