-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added first pytests
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
openmmdl/tests/openmmdl_analysis/test_barcode_generation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import re | ||
import os | ||
import matplotlib.pyplot as plt | ||
import pytest | ||
from openmmdl.openmmdl_analysis.barcode_generation import BarcodeGenerator, BarcodePlotter | ||
|
||
# Barcode generation tests | ||
@pytest.fixture | ||
def sample_dataframe_barcode_generation(): | ||
data = { | ||
'FRAME': [1, 1, 2, 2, 3], | ||
'Interaction1': [1, 0, 1, 0, 0], | ||
'Interaction2': [0, 0, 0, 1, 1], | ||
'WATER_IDX': [101, 102, 103, 104, 105], | ||
} | ||
return pd.DataFrame(data) | ||
|
||
def test_barcodegeneration(sample_dataframe_barcode_generation): | ||
interaction = 'Interaction1' | ||
barcode_generator = BarcodeGenerator(sample_dataframe_barcode_generation) | ||
|
||
barcode = barcode_generator.generate_barcode(interaction) | ||
|
||
assert isinstance(barcode, np.ndarray) | ||
|
||
expected_barcode = np.array([1, 1, 0]) | ||
assert np.array_equal(barcode, expected_barcode) | ||
|
||
def test_waterids_barcode_generator(sample_dataframe_barcode_generation): | ||
interaction = 'Interaction2' | ||
barcode_generator = BarcodeGenerator(sample_dataframe_barcode_generation) | ||
waterid_barcode = barcode_generator.generate_waterids_barcode(interaction) | ||
|
||
# Test if the output is a list | ||
assert isinstance(waterid_barcode, list) | ||
|
||
# Test the expected waterid barcode for the sample dataframe and interaction | ||
expected_waterid_barcode = [0, 104, 105] | ||
assert waterid_barcode == expected_waterid_barcode |