Example #1
0
def test_protein_init_raises_when_protein_file_ambiguous(tmp_path):
    dummy_protein_files = (tmp_path / 'first_protein_file.pdb',
                           tmp_path / 'second_protein_file.pdb')
    for file in dummy_protein_files:
        file.write_text('dummy')

    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)
Example #2
0
def test_protein_init_raises_when_pocket_center_is_not_coordinates(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')
    metadata_file = tmp_path / 'metadata.json'
    metadata_file.write_text('{"pocket_center": ["f"]}')

    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)
Example #3
0
def test_protein_init_raises_when_pocket_center_has_invalid_length(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')
    metadata_file = tmp_path / 'metadata.json'
    metadata_file.write_text('{"pocket_center": [0.0, 0.0]}')

    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)
Example #4
0
def test_protein_init_raises_when_metadata_has_no_pocket_center(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')
    metadata_file = tmp_path / 'metadata.json'
    metadata_file.write_text('{}')

    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)
Example #5
0
def test_protein_init_happy_path(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')
    metadata_file = tmp_path / 'metadata.json'
    metadata_file.write_text('{"pocket_center": [0.0, 0.0, 0.0]}')

    uut = proteins.Protein('test_name', tmp_path)

    assert uut.name == 'test_name'
    assert uut.directory == tmp_path
    assert uut.pocket_center == [0.0, 0.0, 0.0]
Example #6
0
def mock_valid_protein(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')
    metadata_file = tmp_path / 'metadata.json'
    datasets_dir = tmp_path / 'datasets'
    datasets_dir.mkdir()
    dummy_dataset = datasets_dir / 'dummy.csv'
    dummy_dataset.write_text(
        textwrap.dedent('''\
    SMILES,DOCKING_SCORE,A,B,()
    C,-2.3,1.0,1.0,1.0
    '''))
    metadata_file.write_text('''
    {
        "pocket_center": [0.0, 0.0, 0.0],
        "datasets": {
            "dummy": {
                "path": "datasets/dummy.csv"
            }
        }
    }
    ''')

    return proteins.Protein('mocked_protein', tmp_path)
Example #7
0
def test_protein_init_raises_if_metadata_file_does_not_exist(tmp_path):
    dummy_protein_file = tmp_path / 'protein_file.pdb'
    dummy_protein_file.write_text('dummy')

    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)
Example #8
0
def test_protein_init_raises_if_directory_does_not_exist():
    with pytest.raises(ValueError):
        proteins.Protein('test_name', '/no/such/directory')
Example #9
0
def test_protein_init_raises_when_no_protein_files(tmp_path):
    with pytest.raises(ValueError):
        proteins.Protein('test_name', tmp_path)