def get_case_data_1() -> CaseData: return CaseData( molecule=stk.BuildingBlock( smiles='Br[C+2][N+]Cl', functional_groups=[stk.BromoFactory()], placer_ids=(0, ), ), result=stk.BuildingBlock.init( atoms=( stk.Cl(0), stk.Br(1), stk.C(2, 2), stk.N(3, 1), ), bonds=( stk.Bond(stk.Cl(0), stk.N(3, 1), 1), stk.Bond(stk.Br(1), stk.C(2, 2), 1), stk.Bond(stk.C(2, 2), stk.N(3, 1), 1), ), position_matrix=np.array([ ]), functional_groups=( stk.Bromo( bromine=stk.Br(1), atom=stk.C(2, 2), bonders=(stk.C(2, 2), ), deleters=(stk.Br(1), ), ), ), placer_ids=(1, ), ) )
def carboxylic_acid(get_atom_ids): a, b, c, d, e = get_atom_ids(5) return _carboxylic_acid( carbon=stk.C(a), oxygen1=stk.O(b), oxygen2=stk.O(c), hydrogen=stk.H(d), atom=stk.C(e), )
def diol(get_atom_ids): a, b, c, d, e, f = get_atom_ids(6) return _diol( atom1=stk.C(a), oxygen1=stk.O(b), hydrogen1=stk.H(c), atom2=stk.C(d), oxygen2=stk.O(e), hydrogen2=stk.H(f), )
def amide(get_atom_ids): a, b, c, d, e, f = get_atom_ids(6) return _amide( carbon=stk.C(a), oxygen=stk.O(b), nitrogen=stk.N(c), hydrogen1=stk.H(d), hydrogen2=stk.H(e), atom=stk.C(f), )
def ring_amine(get_atom_ids): a, b, c, d, e, f, g = get_atom_ids(7) return _ring_amine( nitrogen=stk.N(a), hydrogen1=stk.H(b), hydrogen2=stk.H(c), carbon1=stk.C(d), carbon2=stk.C(e), hydrogen3=stk.H(f), carbon3=stk.C(g), )
def make_xor_monomer(self, position=0): # initialize building blocks benzene = self.init_building_block(smiles='C1=CC=CC=C1') acetaldehyde = self.init_building_block(smiles='CC=O') benzene = benzene.with_functional_groups([stk.SingleAtom(stk.C(position))]) acetaldehyde = acetaldehyde.with_functional_groups( [stk.SingleAtom(stk.C(1))]) # construct xor gate monomer xor_gate = stk.ConstructedMolecule( topology_graph=stk.polymer.Linear( building_blocks=(benzene, acetaldehyde), repeating_unit='AB', num_repeating_units=1 ) ) # construct functional groups for xor gate monomer # numbering starts at top and proceeds clockwise c_0, c_1, c_2, c_3, c_4, c_5 = stk.C(0), stk.C( 1), stk.C(2), stk.C(3), stk.C(4), stk.C(5) functional_groups = [stk.GenericFunctionalGroup(atoms=(c_0, c_1, c_2, c_3, c_4, c_5), bonders=(c_0, c_3), deleters=(c_4, c_5)), stk.GenericFunctionalGroup(atoms=(c_0, c_1, c_2, c_3, c_4, c_5), bonders=(c_1, c_2), deleters=())] return stk.BuildingBlock.init_from_molecule(xor_gate, functional_groups=functional_groups)
def boronic_acid(get_atom_ids): a, b, c, d, e, f = get_atom_ids(6) return _boronic_acid( boron=stk.B(a), oxygen1=stk.O(b), hydrogen1=stk.H(c), oxygen2=stk.O(d), hydrogen2=stk.H(e), atom=stk.C(f), )
def test_torsion_matching(): """ Confirm torsions are appropriately mapped. Check corresponding torsion angles between building blocks and constructed molecules to confirm that the angle is the same in both. """ bb1 = stk.BuildingBlock('NCCNCCN', [stk.PrimaryAminoFactory()]) bb2 = stk.BuildingBlock('O=CCCC=O', [stk.AldehydeFactory()]) assert _polymer_angles_match(bb1, bb2) # Test case designed such that default rdkit torsion for # constructed molecule spans over both building blocks, requiring # stko to correctly clean this up. bonders3 = (stk.C(1), ) deleters3 = (stk.H(7), ) functional_group3 = stk.GenericFunctionalGroup(atoms=bonders3 + deleters3, bonders=bonders3, deleters=deleters3) bb3 = stk.BuildingBlock('CCCC', [functional_group3]) bonders4 = (stk.C(0), ) deleters4 = (stk.H(1), ) functional_group4 = stk.GenericFunctionalGroup(atoms=bonders4 + deleters4, bonders=bonders4, deleters=deleters4) bb4 = stk.BuildingBlock('C', [functional_group4]) assert _polymer_angles_match(bb3, bb4) # Test case for an exterior atom of a building block torsion being # deleted in construction. bonders5 = (stk.C(1), ) deleters5 = (stk.C(0), stk.H(4), stk.H(5), stk.H(6)) functional_group5 = stk.GenericFunctionalGroup(atoms=bonders5 + deleters5, bonders=bonders5, deleters=deleters5) bb5 = stk.BuildingBlock('CCCC', [functional_group5]) bb6 = bb4 assert not _polymer_angles_match(bb5, bb6)
def alkene(get_atom_ids): a, b, c, d, e, f = get_atom_ids(6) return _alkene( carbon1=stk.C(a), atom1=stk.C(b), atom2=stk.C(c), carbon2=stk.C(d), atom3=stk.C(e), atom4=stk.C(f), )
def thiol(get_atom_ids): a, b, c = get_atom_ids(3) return _thiol(stk.S(a), stk.H(b), stk.C(c))
import pytest import stk from .case_data import CaseData @pytest.fixture( params=(CaseData( molecule=stk.BuildingBlock('NCCN'), bonds=( stk.Bond(stk.N(0), stk.C(1), 1), stk.Bond(stk.C(1), stk.C(2), 1), stk.Bond(stk.C(2), stk.N(3), 1), stk.Bond(stk.N(0), stk.H(4), 1), stk.Bond(stk.N(0), stk.H(5), 1), stk.Bond(stk.C(1), stk.H(6), 1), stk.Bond(stk.C(1), stk.H(7), 1), stk.Bond(stk.C(2), stk.H(8), 1), stk.Bond(stk.C(2), stk.H(9), 1), stk.Bond(stk.N(3), stk.H(10), 1), stk.Bond(stk.N(3), stk.H(11), 1), ), ), ), ) def case_data(request): return request.param
canonical_bb2 = bb2.with_canonical_atom_ordering() @pytest.fixture( params=( lambda: CaseData( molecule=stk.BuildingBlock( smiles='Br[C+2][N+]Cl', functional_groups=[stk.BromoFactory()], placer_ids=(0, ), ), result=stk.BuildingBlock.init( atoms=( stk.Cl(0), stk.Br(1), stk.C(2, 2), stk.N(3, 1), ), bonds=( stk.Bond(stk.Cl(0), stk.N(3, 1), 1), stk.Bond(stk.Br(1), stk.C(2, 2), 1), stk.Bond(stk.C(2, 2), stk.N(3, 1), 1), ), position_matrix=np.array([ ]), functional_groups=( stk.Bromo( bromine=stk.Br(1), atom=stk.C(2, 2), bonders=(stk.C(2, 2), ), deleters=(stk.Br(1), ),
import pytest import stk from ..case_data import CaseData @pytest.fixture( scope='session', params=(lambda: CaseData( factory=stk.RingAmineFactory(), molecule=stk.BuildingBlock('NCC(Br)c1c(Br)cccc1'), functional_groups=(stk.RingAmine( nitrogen=stk.N(0), carbon1=stk.C(1), carbon2=stk.C(2), carbon3=stk.C(4), hydrogen1=stk.H(11), hydrogen2=stk.H(12), hydrogen3=stk.H(15), ), ), ), ), ) def case_data(request) -> CaseData: """ A :class:`.CaseData` instance. """ return request.param()
import pytest import stk from .case_data import CaseData @pytest.fixture(params=[stk.C(0), stk.H(1), stk.K(12)]) def atom(request): """ An :class:`.Atom` instance. """ return request.param.clone() @pytest.fixture def atom1(atom): """ An :class:`.Atom` instance. """ return atom.clone() @pytest.fixture def atom2(atom): """ An :class:`.Atom` instance.
import re import os from pytest_lazyfixture import lazy_fixture import stk import numpy as np from rdkit.Chem import AllChem as rdkit from .case_data import CaseData # Fixtures need to be visible for lazy_fixture() calls. from .fixtures import * # noqa @pytest.fixture( params=[ stk.BuildingBlock.init( atoms=(stk.C(0, 4), ), bonds=(), position_matrix=np.array([[0.0, 0.0, 0.0]]), functional_groups=(), ), stk.BuildingBlock.init( atoms=(stk.C(0, 3), stk.H(1)), bonds=(stk.Bond(stk.C(0, 3), stk.H(1), 1), ), position_matrix=np.array([ [0.39382080513175644, 0.0, 0.0], [-0.39382080513175644, 0.0, 0.0], ]), functional_groups=(), ), stk.BuildingBlock.init( atoms=(stk.C(0, 2), stk.H(1), stk.H(2)),
import pytest import stk from .case_data import CaseData @pytest.fixture( params=( stk.Bond(stk.C(0), stk.N(1), 1), ), ) def bond(request): """ A :class:`.Bond` instance. """ return request.param @pytest.fixture( params=( stk.BuildingBlock('NCCN'), None, ), ) def building_block(request): """ A valid building block for a :class:`.BondInfo`. """
def alcohol(get_atom_ids): a, b, c = get_atom_ids(3) return _alcohol(stk.O(a), stk.H(b), stk.C(c))
import pytest from pytest_lazyfixture import lazy_fixture import stk # Fixtures need to visible for lazy_fixture() calls. from .fixtures import * # noqa @pytest.fixture( params=( stk.Alcohol( oxygen=stk.O(1), hydrogen=stk.H(2), atom=stk.C(2), bonders=(stk.C(2), ), deleters=(stk.O(1), stk.H(2)), ), stk.Aldehyde( carbon=stk.C(0), oxygen=stk.O(1), hydrogen=stk.H(2), atom=stk.C(3), bonders=(stk.C(0), ), deleters=(stk.O(1), ), ), stk.Alkene( carbon1=stk.C(1), atom1=stk.C(2), atom2=stk.C(3), carbon2=stk.C(4), atom3=stk.C(5),
import pytest import stk from .case_data import CaseData @pytest.fixture( params=(stk.Bond(stk.C(0), stk.N(1), 1), ), ) def bond(request): """ A :class:`.Bond` instance. """ return request.param @pytest.fixture( params=( stk.BuildingBlock('NCCN'), None, ), ) def building_block(request): """ A valid building block for a :class:`.BondInfo`. """ return request.param
from ..case_data import CaseData @pytest.fixture( scope='session', params=( lambda: CaseData( factory=stk.PrimaryAminoFactory(), molecule=stk.BuildingBlock('NCCN'), functional_groups=( stk.PrimaryAmino( nitrogen=stk.N(0), hydrogen1=stk.H(4), hydrogen2=stk.H(5), atom=stk.C(1), bonders=(stk.N(0), ), deleters=(stk.H(4), stk.H(5)), ), stk.PrimaryAmino( nitrogen=stk.N(3), hydrogen1=stk.H(10), hydrogen2=stk.H(11), atom=stk.C(2), bonders=(stk.N(3), ), deleters=(stk.H(10), stk.H(11)), ), ), ), lambda: CaseData( factory=stk.PrimaryAminoFactory(),
def bromo(get_atom_ids): a, b = get_atom_ids(2) return _bromo(stk.Br(a), stk.C(b))
def fluoro(get_atom_ids): a, b = get_atom_ids(2) return _fluoro(stk.F(a), stk.C(b))
import pytest import stk from .case_data import CaseData @pytest.fixture( params=(CaseData( molecule=stk.BuildingBlock('NCCN'), atoms=( stk.N(0), stk.C(1), stk.C(2), stk.N(3), stk.H(4), stk.H(5), stk.H(6), stk.H(7), stk.H(8), stk.H(9), stk.H(10), stk.H(11), ), ), ), ) def case_data(request): """ A :class:`.CaseData` instance. """ return request.param
def alkyne(get_atom_ids): a, b, c, d = get_atom_ids(4) return _alkyne(stk.C(a), stk.C(b), stk.C(c), stk.C(d))
def difluoro(get_atom_ids): a, b, c, d = get_atom_ids(4) return _difluoro(stk.F(a), stk.C(b), stk.F(c), stk.C(d))
def aldehyde(get_atom_ids): a, b, c, d = get_atom_ids(4) return _aldehyde(stk.C(a), stk.O(b), stk.H(c), stk.C(d))
def dibromo(get_atom_ids): a, b, c, d = get_atom_ids(4) return _dibromo(stk.Br(a), stk.C(b), stk.Br(c), stk.C(d))
lambda: CaseData( building_block=stk.BuildingBlock.init_from_molecule( molecule=stk.BuildingBlock('Br[C+2][C+2]Br'), ), functional_groups=(), core_atom_ids=(0, 1, 2, 3), placer_ids=(0, 1, 2, 3), ), lambda: CaseData( building_block=stk.BuildingBlock.init_from_molecule( molecule=stk.BuildingBlock('Br[C+2][C+2]Br'), functional_groups=[stk.BromoFactory()], ), functional_groups=( stk.Bromo( bromine=stk.Br(0), atom=stk.C(1, 2), bonders=(stk.C(1, 2), ), deleters=(stk.Br(0), ), ), stk.Bromo( bromine=stk.Br(3), atom=stk.C(2, 2), bonders=(stk.C(2, 2), ), deleters=(stk.Br(3), ), ), ), core_atom_ids=(1, 2), placer_ids=(1, 2), ), lambda: CaseData( building_block=stk.BuildingBlock.init_from_molecule(
def secondary_amino(get_atom_ids): a, b, c, d = get_atom_ids(4) return _secondary_amino(stk.N(a), stk.H(b), stk.C(c), stk.C(d))
def carbon(): return stk.C(333, attr2=None, attr12='abc', _pattr=22.22)