def test_fingerprint_products(): '''Tests fingerprint_products function in metamoles.py''' input_df = pd.read_csv('playground_df_cleaned_kegg_with_smiles.csv') test_df = metamoles.input_data(input_df) assert isinstance(metamoles.fingerprint_products(test_df), pd.DataFrame) == True, """TypeError, function should return a pandas dataframe""" #assert return '1/1 tests successful'
def test_sim_i_j(): '''Tests sim_i_j function in metamoles.py''' input_df = pd.read_csv('playground_df_cleaned_kegg_with_smiles.csv') test_df = metamoles.fingerprint_products(metamoles.input_data(input_df)) A = test_df.iloc[0] #B = test_df.iloc[1] #C = test_df.iloc[2] assert metamoles.sim_i_j(A, A) == 1, "Self correlation is broken" #assert metamoles.sim_i_j(A, B) == -1, "Standard correlation is broken" #assert metamoles.sim_i_j(A, C) == 0, "Standard correlation is broken" return '1/1 tests successful'
def test_sim_metric(): '''Test sim_i_all function in metamoles.py''' input_df = pd.read_csv('playground_df_cleaned_kegg_with_smiles.csv') test_df = metamoles.fingerprint_products(metamoles.input_data(input_df)) assert isinstance(metamoles.sim_metric(test_df), pd.DataFrame) == True, """TypeError, function should return a dataframe""" assert metamoles.sim_metric( test_df).isnull().values.any() == False, """ValueError, function-generated dataframe should not contain null values""" #assert test_df.size == metamoles.sim_metric(test_df).size, """ShapeError, #function-generated dataframe should be the same size as input dataframe""" return "2/2 Tests successful"
def test_sim_i_all(): '''Test sim_i_all function in metamoles.py''' input_df = pd.read_csv('playground_df_cleaned_kegg_with_smiles.csv') test_df = metamoles.fingerprint_products(metamoles.input_data(input_df)) metric = pd.DataFrame() assert metric.empty == True, """ShapeError, input metric dataframe should be initialized as empty""" for index, row in test_df.iterrows(): assert metamoles.sim_i_all(test_df, index, row, metric) == None, """OutputError, function shouldn't return anything""" assert metric[index].all() >= 0 and metric[index].all( ) <= 1.0, """ValueError, metric should be between 0 and 1""" return "3/3 Tests successful"