コード例 #1
0
def test_get_symmetry_hash():
    """Test the symmetry hashes"""
    zif3 = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "ZIF-3.cif"))
    print(type(zif3.structure))
    hash_a = get_symmetry_hash(zif3.structure, tight=True)
    assert len(hash_a) == 275
    hash_b = get_symmetry_hash(zif3.structure)
    assert len(hash_b) == 47
    assert hash_a[-3:] == hash_b[-3:]

    zif4 = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "ZIF-4.cif"))
    hash_zif4_a = get_symmetry_hash(zif4.structure, tight=True)
    hash_zif4_b = get_symmetry_hash(zif4.structure)

    assert hash_zif4_a != hash_a
    assert hash_zif4_b != hash_b

    assert zif4.symmetry_hash == hash_zif4_b

    structure = Structure.from_file(
        os.path.join(THIS_DIR, "test_files", "ABAXUZ.cif"))
    original_hash = get_symmetry_hash(MOFChecker(structure).structure)

    # rotate structure
    rotation_transformer = RotationTransformation([1, 0, 0], 10)
    rotated_structure = rotation_transformer.apply_transformation(structure)
    assert get_symmetry_hash(
        MOFChecker(rotated_structure).structure) == original_hash

    # create supercell
    structure.make_supercell([1, 2, 1])
    print(type(structure))
    assert get_symmetry_hash(MOFChecker(structure).structure) == original_hash
コード例 #2
0
def test_overvalent_h():
    mofchecker = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "overvalent_h.cif"))
    assert mofchecker.has_overvalent_h
    assert len(mofchecker.overvalent_h_indices) == 3

    mofchecker = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "XIGFOJ_manual.cif"))
    assert not mofchecker.has_overvalent_h
コード例 #3
0
def get_feat_one_structure(cif):
    """Run the MOFCheck on one structure"""
    try:
        mofchecker = MOFChecker.from_cif(cif)
        descriptors = mofchecker.get_mof_descriptors()
        return descriptors
    except NoMetal:
        print("{} has no metal".format(cif))
        return None
コード例 #4
0
def test_unknown_elements():
    """Parsing structure with unknown element raises warning for covalent radius."""
    # with pytest.warns(UserWarning) as record:
    #     mofchecker = MOFCheƒ√cker.from_cif(
    #         os.path.join(THIS_DIR, "test_files", "GUPQOA.cif")
    #     )
    #     mofchecker.get_mof_descriptors()
    # assert len(record) >= 1

    with pytest.raises(NotImplementedError):
        mofchecker = MOFChecker.from_cif(
            os.path.join(THIS_DIR, "test_files", "GUPQOA.cif"))
        mofchecker.get_mof_descriptors()
コード例 #5
0
def test_graph_hash_false_positives():
    """Test the hash on past issues of false positives.

    Cases where different structures gave the same hash.
    """
    # issue 130
    cof_18141N2 = MOFChecker.from_cif(  # pylint: disable=invalid-name
        os.path.join(THIS_DIR, "test_files", "18141N2.cif"))
    cof_20211N2 = MOFChecker.from_cif(  # pylint: disable=invalid-name
        os.path.join(THIS_DIR, "test_files", "20211N2.cif"))
    assert cof_18141N2.graph_hash != cof_20211N2.graph_hash

    # # Daniele's report
    mmpf7 = MOFChecker(
        Structure.from_file(os.path.join(THIS_DIR, "test_files",
                                         "943643.cif")))
    mmpf8 = MOFChecker(
        Structure.from_file(os.path.join(THIS_DIR, "test_files",
                                         "943644.cif")))

    assert mmpf7.graph_hash != mmpf8.graph_hash
    assert mmpf7.scaffold_hash != mmpf8.scaffold_hash
コード例 #6
0
def test_overvalent_c(get_overvalent_c_structures):
    for structure in get_overvalent_c_structures:
        mofchecker = MOFChecker(structure)
        assert mofchecker.has_overvalent_c == True

    mofchecker = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "XIGFOJ_manual.cif"))
    assert mofchecker.has_overvalent_c == False

    # alkine ligand
    mofchecker = MOFChecker(
        Structure.from_file(
            os.path.join(THIS_DIR, "test_files", "RUDQUD_clean.cif")))
    assert mofchecker.has_overvalent_c == False
コード例 #7
0
def run(primitive, descriptors, cif_files):
    """
    Check provided structures and print list of JSON objects with descriptors.
    """
    # Note: we want to see output as things progress,
    # thus this clumsy way of creating a JSON list
    print("[")
    for index, structure_file in enumerate(cif_files):
        mofchecker = MOFChecker.from_cif(structure_file, primitive=primitive)
        descriptors = mofchecker.get_mof_descriptors(descriptors=descriptors)

        string = json.dumps(descriptors, indent=2)
        if index != len(cif_files) - 1:
            string += ","
        print(string)
    print("]")
コード例 #8
0
def test_overlaps():
    mofchecker = MOFChecker.from_cif(
        os.path.join(THIS_DIR, "test_files", "overvalent_h.cif"))
    assert not mofchecker.has_atomic_overlaps
コード例 #9
0
def test_name():
    s = os.path.join(THIS_DIR, "test_files", "ABAVIJ_clean.cif")
    mofchecker = MOFChecker.from_cif(s)
    assert mofchecker.name == "ABAVIJ_clean"
コード例 #10
0
def test_partial_occupancy():
    with pytest.raises(NotImplementedError):
        MOFChecker.from_cif(os.path.join(THIS_DIR, "test_files", "ABUBIK.cif"))
コード例 #11
0
def test_has_oms_multiple(get_testdict):
    """Test on a bunch of different structures"""
    for key, value in get_testdict.items():
        omsdetector = MOFChecker.from_cif(key)
        assert omsdetector.has_oms == value
コード例 #12
0
def test_has_oms_multiple(get_testdict):
    for k, v in get_testdict.items():
        print(k)
        omsdetector = MOFChecker.from_cif(k)
        assert omsdetector.has_oms == v