Skip to content

Commit

Permalink
Create test_barcode_generation.py
Browse files Browse the repository at this point in the history
added first pytests
  • Loading branch information
talagayev authored Dec 16, 2024
1 parent e9ed151 commit eab3517
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions openmmdl/tests/openmmdl_analysis/test_barcode_generation.py
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

0 comments on commit eab3517

Please sign in to comment.