How to use the stk.cage.FourPlusSix function in stk

To help you get started, we’ve selected a few stk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lukasturcani / stk / tests / molecular / molecules / test_constructed_molecule.py View on Github external
def test_get_identity_key(
    polymer,
    tmp_polymer,
    amine2,
    aldehyde3,
    amine2_alt1
):
    assert polymer is not tmp_polymer
    assert polymer.get_identity_key() == tmp_polymer.get_identity_key()

    four_plus_six = stk.cage.FourPlusSix()
    cage1 = stk.ConstructedMolecule(
        building_blocks=[amine2, aldehyde3, amine2_alt1],
        topology_graph=four_plus_six,
        building_block_vertices={
            aldehyde3: four_plus_six.vertices[:4],
            amine2: four_plus_six.vertices[4:6],
            amine2_alt1: four_plus_six.vertices[6:]
        }
    )
    cage2 = stk.ConstructedMolecule(
        building_blocks=[amine2, aldehyde3, amine2_alt1],
        topology_graph=four_plus_six,
        building_block_vertices={
            aldehyde3: four_plus_six.vertices[:4],
            amine2: four_plus_six.vertices[4:5],
            amine2_alt1: four_plus_six.vertices[5:]
github lukasturcani / stk / tests / populations / test_populations.py View on Github external
def test_init_random():
    amines = [
        stk.BuildingBlock('NCCCN', ['amine']),
        stk.BuildingBlock('NCCCCCN', ['amine']),
        stk.BuildingBlock('NCCOCCN', ['amine']),
    ]
    aldehydes = [
        stk.BuildingBlock('O=CCC(C=O)CC=O', ['aldehyde']),
        stk.BuildingBlock('O=CCC(C=O)CC=O', ['aldehyde']),
        stk.BuildingBlock('O=CC(C=O)COCC=O', ['aldehyde']),
    ]

    cages = stk.Population.init_random(
        building_blocks=[amines, aldehydes],
        topology_graphs=[stk.cage.FourPlusSix()],
        size=5
    )

    assert len(cages) == 5
    assert len(cages.direct_members) == 5
    assert len(cages.subpopulations) == 0

    for cage in cages:
        bbs = tuple(cage.building_block_vertices.keys())
        assert len(bbs) == 2
        assert (
            repr(cage.topology_graph) == repr(stk.cage.FourPlusSix())
        )
        amines = tuple(
            bb for bb in bbs
            if bb.func_groups[0].fg_type.name == 'amine'
github lukasturcani / stk / tests / populations / test_populations.py View on Github external
def test_init_all():

    amines = [
        stk.BuildingBlock('NCCCN', ['amine']),
        stk.BuildingBlock('NCCCCCN', ['amine']),
        stk.BuildingBlock('NCCOCCN', ['amine']),
    ]
    aldehydes = [
        stk.BuildingBlock('O=CCC(C=O)CC=O', ['aldehyde']),
        stk.BuildingBlock('O=CCC(C=O)CC=O', ['aldehyde']),
        stk.BuildingBlock('O=CC(C=O)COCC=O', ['aldehyde']),
    ]
    # A total of 9 cages will be created.
    cages = stk.Population.init_all(
        building_blocks=[amines, aldehydes],
        topology_graphs=[stk.cage.FourPlusSix()]
    )

    assert len(cages) == 9
    cages.remove_duplicates(key=lambda mol: mol.get_identity_key())
    assert len(cages) == 6

    for cage in cages:
        bbs = tuple(cage.building_block_vertices.keys())
        assert len(bbs) == 2
        assert (
            repr(cage.topology_graph) == repr(stk.cage.FourPlusSix())
        )
        amines = tuple(
            bb for bb in bbs
            if bb.func_groups[0].fg_type.name == 'amine'
        )
github lukasturcani / stk / tests / populations / test_populations.py View on Github external
]
    # A total of 9 cages will be created.
    cages = stk.Population.init_all(
        building_blocks=[amines, aldehydes],
        topology_graphs=[stk.cage.FourPlusSix()]
    )

    assert len(cages) == 9
    cages.remove_duplicates(key=lambda mol: mol.get_identity_key())
    assert len(cages) == 6

    for cage in cages:
        bbs = tuple(cage.building_block_vertices.keys())
        assert len(bbs) == 2
        assert (
            repr(cage.topology_graph) == repr(stk.cage.FourPlusSix())
        )
        amines = tuple(
            bb for bb in bbs
            if bb.func_groups[0].fg_type.name == 'amine'
        )
        assert len(amines) == 1
        aldehydes = tuple(
            bb for bb in bbs
            if bb.func_groups[0].fg_type.name == 'aldehyde'
        )
        assert len(aldehydes) == 1
github lukasturcani / stk / tests / molecular / topology_graphs / test_cage_topologies.py View on Github external
},
        )
        c = stk.ConstructedMolecule(
            building_blocks=building_blocks,
            topology_graph=four_plus_six,
            building_block_vertices={
                amine2: four_plus_six.vertices[4:9],
                amine2_alt3: four_plus_six.vertices[9:],
                aldehyde3: four_plus_six.vertices[:3],
                aldehyde3_alt3: four_plus_six.vertices[3:4]
            }
        )
        c.write(join(test_dir, f'4p6_valignment_{fg}.mol'))

    v10 = stk.cage.FourPlusSix.vertices[9]
    four_plus_six = stk.cage.FourPlusSix(
        vertex_alignments={
            v10: v10.edges[1]
        }
    )
    c = stk.ConstructedMolecule(
        building_blocks=building_blocks,
        topology_graph=four_plus_six,
        building_block_vertices={
            amine2: four_plus_six.vertices[4:9],
            amine2_alt3: four_plus_six.vertices[9:],
            aldehyde3: four_plus_six.vertices[:3],
            aldehyde3_alt3: four_plus_six.vertices[3:4]
        }
    )
    c.write(join(test_dir, f'4p6_edge_alignment.mol'))
github lukasturcani / stk / tests / fixtures / constructed_molecules / cages.py View on Github external
def tmp_four_plus_six(tmp_amine2, tmp_aldehyde3):
    return stk.ConstructedMolecule(
        building_blocks=[tmp_amine2, tmp_aldehyde3],
        topology_graph=stk.cage.FourPlusSix()
    )
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
def _population_members():
    bb1 = stk.BuildingBlock('NC(CCO)CN', ['amine'])
    bb2 = stk.BuildingBlock('[Br]CCCC[Br]', ['bromine'])
    bb3 = stk.BuildingBlock('[I]COCC[I]', ['iodine'])
    bb4 = stk.BuildingBlock('O=CC(C=O)CC=O', ['aldehyde'])

    c1 = stk.ConstructedMolecule(
        building_blocks=[bb2],
        topology_graph=stk.polymer.Linear('A', 3)
    )
    c2 = stk.ConstructedMolecule(
        building_blocks=[bb1, bb4],
        topology_graph=stk.cage.FourPlusSix()
    )
    c3 = stk.ConstructedMolecule(
        building_blocks=[bb1, bb4],
        topology_graph=stk.cage.EightPlusTwelve()
    )
    c4 = stk.ConstructedMolecule(
        building_blocks=[bb2, bb3],
        topology_graph=stk.polymer.Linear('AB', 3)
    )

    return bb1, bb2, bb3, bb4, c1, c2, c3, c4
github lukasturcani / stk / tests / molecular / topology_graphs / test_host_guest_topologies.py View on Github external
def _create_host(amine2, amine2_alt3, aldehyde3):
    four_plus_six = stk.cage.FourPlusSix()
    return stk.ConstructedMolecule(
        building_blocks=[amine2, amine2_alt3, aldehyde3],
        topology_graph=four_plus_six,
        building_block_vertices={
            amine2: four_plus_six.vertices[5:],
            amine2_alt3: four_plus_six.vertices[4:5],
            aldehyde3: four_plus_six.vertices[:4]
        }