Пример #1
0
def test_ring_count():
    # Two rings
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    rule = SMARTSGraph(name='test', parser=PARSER,
                       smarts_string='[#6;R2]')

    match_indices = list(rule.find_matches(top))
    for atom_idx in (3, 4):
        assert atom_idx in match_indices
    assert len(match_indices) == 2

    rule = SMARTSGraph(name='test', parser=PARSER,
                       smarts_string='[#6;R1]')
    match_indices = list(rule.find_matches(top))
    for atom_idx in (0, 1, 2, 5, 6, 7, 8, 9):
        assert atom_idx in match_indices
    assert len(match_indices) == 8

    # One ring
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)

    rule = SMARTSGraph(name='test', parser=PARSER,
                       smarts_string='[#6;R1]')
    match_indices = list(rule.find_matches(top))
    for atom_idx in range(6):
        assert atom_idx in match_indices
    assert len(match_indices) == 6
Пример #2
0
def test_ringness():
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    _rule_match(top, typemap, '[#6]1[#6][#6][#6][#6][#6]1', True)

    not_ring = pmd.load_file(get_fn('not_ring.mol2'), structure=True)
    top, _ = generate_topology(not_ring)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    _rule_match(top, typemap, '[#6]1[#6][#6][#6][#6][#6]1', False)
Пример #3
0
def test_ring_count():
    # Two rings
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    rule = SMARTSGraph(name='test', parser=PARSER, smarts_string='[#6;R2]')

    match_indices = list(rule.find_matches(top))
    for atom_idx in (3, 4):
        assert atom_idx in match_indices
    assert len(match_indices) == 2

    rule = SMARTSGraph(name='test', parser=PARSER, smarts_string='[#6;R1]')
    match_indices = list(rule.find_matches(top))
    for atom_idx in (0, 1, 2, 5, 6, 7, 8, 9):
        assert atom_idx in match_indices
    assert len(match_indices) == 8

    # One ring
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)

    rule = SMARTSGraph(name='test', parser=PARSER, smarts_string='[#6;R1]')
    match_indices = list(rule.find_matches(top))
    for atom_idx in range(6):
        assert atom_idx in match_indices
    assert len(match_indices) == 6
Пример #4
0
def test_ringness():
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)
    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', True)

    not_ring = pmd.load_file(get_fn('not_ring.mol2'), structure=True)
    top, _ = generate_topology(not_ring)
    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', False)
Пример #5
0
def test_ringness():
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)
    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', True)

    not_ring = pmd.load_file(get_fn('not_ring.mol2'), structure=True)
    top, _ = generate_topology(not_ring)
    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', False)
Пример #6
0
def test_independent_residues_molecules():
    """Test to see that _check_independent_residues works for molecules."""
    butane = Alkane(4)
    structure = butane.to_parmed()
    topo, NULL = generate_topology(structure)
    assert _check_independent_residues(topo)
    structure = butane.to_parmed(residues=['RES', 'CH3'])
    topo, NULL = generate_topology(structure)
    assert not _check_independent_residues(topo)
Пример #7
0
def test_independent_residues_molecules():
    """Test to see that _check_independent_residues works for molecules."""
    butane = Alkane(4)
    structure = butane.to_parmed()
    topo, NULL = generate_topology(structure)
    assert _check_independent_residues(topo)
    structure = butane.to_parmed(residues=['RES', 'CH3'])
    topo, NULL = generate_topology(structure)
    assert not _check_independent_residues(topo)
Пример #8
0
def test_ring_count():
    # Two rings
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }
    rule = SMARTSGraph(name='test',
                       parser=PARSER,
                       smarts_string='[#6;R2]',
                       typemap=typemap)

    match_indices = list(rule.find_matches(top, typemap))
    for atom_idx in (3, 4):
        assert atom_idx in match_indices
    assert len(match_indices) == 2

    rule = SMARTSGraph(name='test',
                       parser=PARSER,
                       smarts_string='[#6;R1]',
                       typemap=typemap)
    match_indices = list(rule.find_matches(top, typemap))
    for atom_idx in (0, 1, 2, 5, 6, 7, 8, 9):
        assert atom_idx in match_indices
    assert len(match_indices) == 8

    # One ring
    ring = pmd.load_file(get_fn('ring.mol2'), structure=True)
    top, _ = generate_topology(ring)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    rule = SMARTSGraph(name='test',
                       parser=PARSER,
                       smarts_string='[#6;R1]',
                       typemap=typemap)
    match_indices = list(rule.find_matches(top, typemap))
    for atom_idx in range(6):
        assert atom_idx in match_indices
    assert len(match_indices) == 6
Пример #9
0
def test_independent_residues_atoms():
    """Test to see that _check_independent_residues works for single aotms."""
    argon = mb.Compound()
    argon.name = 'Ar'
    structure = argon.to_parmed()
    topo, NULL = generate_topology(structure)
    assert _check_independent_residues(topo)
Пример #10
0
def test_independent_residues_atoms():
    """Test to see that _check_independent_residues works for single aotms."""
    argon = mb.Compound()
    argon.name = 'Ar'
    structure = argon.to_parmed()
    topo, NULL = generate_topology(structure)
    assert _check_independent_residues(topo)
Пример #11
0
def test_uniqueness():
    mol2 = pmd.load_file(get_fn('uniqueness_test.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', False)
    _rule_match(top, '[#6]1[#6][#6][#6][#6]1', False)
    _rule_match(top, '[#6]1[#6][#6][#6]1', True)
Пример #12
0
def test_uniqueness():
    mol2 = pmd.load_file(get_fn('uniqueness_test.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    _rule_match(top, '[#6]1[#6][#6][#6][#6][#6]1', False)
    _rule_match(top, '[#6]1[#6][#6][#6][#6]1', False)
    _rule_match(top, '[#6]1[#6][#6][#6]1', True)
Пример #13
0
def test_cycle_finding_multiple():
    fullerene = pmd.load_file(get_fn('fullerene.pdb'), structure=True)
    top, _ = generate_topology(fullerene)

    _prepare_atoms(top, compute_cycles=True)
    cycle_lengths = [list(map(len, atom.cycles)) for atom in top.atoms()]
    expected = [5, 6, 6]
    assert all(sorted(lengths) == expected for lengths in cycle_lengths)
Пример #14
0
def test_cycle_finding_multiple():
    fullerene = pmd.load_file(get_fn('fullerene.pdb'), structure=True)
    top, _ = generate_topology(fullerene)

    _prepare_atoms(top, compute_cycles=True)
    cycle_lengths = [list(map(len, atom.cycles)) for atom in top.atoms()]
    expected = [5, 6, 6]
    assert all(sorted(lengths) == expected for lengths in cycle_lengths)
Пример #15
0
def test_uniqueness():
    mol2 = pmd.load_file(get_fn('uniqueness_test.mol2'), structure=True)
    top = generate_topology(mol2)

    atom1 = next(top.atoms())
    _rule_match(atom1, '[#6]1[#6][#6][#6][#6][#6]1', False)
    _rule_match(atom1, '[#6]1[#6][#6][#6][#6]1', False)
    _rule_match(atom1, '[#6]1[#6][#6][#6]1', True)
Пример #16
0
def test_uniqueness():
    mol2 = pmd.load_file(get_fn('uniqueness_test.mol2'), structure=True)
    top = generate_topology(mol2)

    atom1 = next(top.atoms())
    _rule_match(atom1, '[#6]1[#6][#6][#6][#6][#6]1', False)
    _rule_match(atom1, '[#6]1[#6][#6][#6][#6]1', False)
    _rule_match(atom1, '[#6]1[#6][#6][#6]1', True)
Пример #17
0
def test_fused_ring():
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    rule = SMARTSGraph(name='test', parser=PARSER,
                       smarts_string='[#6]12[#6][#6][#6][#6][#6]1[#6][#6][#6][#6]2')

    match_indices = list(rule.find_matches(top))
    assert 3 in match_indices
    assert 4 in match_indices
    assert len(match_indices) == 2
Пример #18
0
def test_fused_ring():
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top = generate_topology(fused)
    atoms = list(top.atoms())
    rule = Rule('test', parser=PARSER,
                smarts_string='[#6]12[#6][#6][#6][#6][#6]1[#6][#6][#6][#6]2')

    assert rule.matches(atoms[2]) is False
    for _ in range(10):  # Traversal order during matching is stochastic.
        assert rule.matches(atoms[3]) is True
        assert rule.matches(atoms[4]) is True
    assert rule.matches(atoms[5]) is False
Пример #19
0
def test_not():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top = generate_topology(mol2)
    atom1 = next(top.atoms())

    checks = {'[!O]': True,
              '[!#5]': True,
              '[!C]': False,
              '[!#6]': False,
              }
    for smart, result in checks.items():
        _rule_match(atom1, smart, result)
Пример #20
0
def test_fused_ring():
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    rule = SMARTSGraph(
        name='test',
        parser=PARSER,
        smarts_string='[#6]12[#6][#6][#6][#6][#6]1[#6][#6][#6][#6]2')

    match_indices = list(rule.find_matches(top))
    assert 3 in match_indices
    assert 4 in match_indices
    assert len(match_indices) == 2
Пример #21
0
def test_precedence():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    checks = {'[C,O;C]': 2,
              '[C&O;C]': 0,
              '[!C;O,C]': 0,
              '[!C&O,C]': 2,
              }

    for smart, result in checks.items():
        _rule_match_count(top, smart, result)
Пример #22
0
def test_not():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    checks = {'[!O]': 8,
              '[!#5]': 8,
              '[!C]': 6,
              '[!#6]': 6,
              '[!C&!H]': 0,
              '[!C;!H]': 0,
              }
    for smart, result in checks.items():
        _rule_match_count(top, smart, result)
Пример #23
0
def test_lazy_cycle_finding():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    rule = SMARTSGraph(smarts_string='[C]')
    list(rule.find_matches(top))
    assert not any([hasattr(a, 'cycles') for a in top.atoms()])

    ring_tokens = ['R1', 'r6']
    for token in ring_tokens:
        rule = SMARTSGraph(smarts_string='[C;{}]'.format(token))
        list(rule.find_matches(top))
        assert all([hasattr(a, 'cycles') for a in top.atoms()])
Пример #24
0
def test_lazy_cycle_finding():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    rule = SMARTSGraph(smarts_string='[C]')
    list(rule.find_matches(top))
    assert not any([hasattr(a, 'cycles') for a in top.atoms()])

    ring_tokens = ['R1', 'r6']
    for token in ring_tokens:
        rule = SMARTSGraph(smarts_string='[C;{}]'.format(token))
        list(rule.find_matches(top))
        assert all([hasattr(a, 'cycles') for a in top.atoms()])
Пример #25
0
def test_fused_ring():
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    atoms = list(top.atoms())
    rule = Rule('test',
                parser=PARSER,
                smarts_string='[#6]12[#6][#6][#6][#6][#6]1[#6][#6][#6][#6]2')

    assert rule.matches(atoms[2]) is False
    for _ in range(10):  # Traversal order during matching is stochastic.
        assert rule.matches(atoms[3]) is True
        assert rule.matches(atoms[4]) is True
    assert rule.matches(atoms[5]) is False
Пример #26
0
def test_not():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)
    atom1 = next(top.atoms())

    checks = {
        '[!O]': True,
        '[!#5]': True,
        '[!C]': False,
        '[!#6]': False,
    }
    for smart, result in checks.items():
        _rule_match(atom1, smart, result)
Пример #27
0
def test_precedence():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top = generate_topology(mol2)
    atom1 = next(top.atoms())

    checks = {'[C,H;C]': True,
              '[C&H;C]': False,
              '[!C;H,C]': False,
              '[!C&H,C]': True,
              }

    for smart, result in checks.items():
        _rule_match(atom1, smart, result)
Пример #28
0
def test_precedence():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    checks = {
        '[C,O;C]': 2,
        '[C&O;C]': 0,
        '[!C;O,C]': 0,
        '[!C&O,C]': 2,
    }

    for smart, result in checks.items():
        _rule_match_count(top, smart, result)
Пример #29
0
def test_precedence():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top = generate_topology(mol2)
    atom1 = next(top.atoms())

    checks = {
        '[C,H;C]': True,
        '[C&H;C]': False,
        '[!C;H,C]': False,
        '[!C&H,C]': True,
    }

    for smart, result in checks.items():
        _rule_match(atom1, smart, result)
Пример #30
0
def test_not():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)

    checks = {
        '[!O]': 8,
        '[!#5]': 8,
        '[!C]': 6,
        '[!#6]': 6,
        '[!C&!H]': 0,
        '[!C;!H]': 0,
    }
    for smart, result in checks.items():
        _rule_match_count(top, smart, result)
Пример #31
0
def test_uniqueness():
    mol2 = pmd.load_file(get_fn('uniqueness_test.mol2'), structure=True)
    top, _ = generate_topology(mol2)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    _rule_match(top, typemap, '[#6]1[#6][#6][#6][#6][#6]1', False)
    _rule_match(top, typemap, '[#6]1[#6][#6][#6][#6]1', False)
    _rule_match(top, typemap, '[#6]1[#6][#6][#6]1', True)
Пример #32
0
def test_residue_map():
    ethane = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    ethane *= 2
    oplsaa = Forcefield(name='oplsaa')
    topo, NULL = generate_topology(ethane)
    with_map = pmd.openmm.load_topology(
        topo, oplsaa.createSystem(topo, use_residue_map=True))
    without_map = pmd.openmm.load_topology(
        topo, oplsaa.createSystem(topo, use_residue_map=False))
    for atom_with, atom_without in zip(with_map.atoms, without_map.atoms):
        assert atom_with.type == atom_without.type
        b_with = atom_with.bond_partners
        b_without = atom_without.bond_partners
        assert [a0.type for a0 in b_with] == [a1.type for a1 in b_without]
        assert [a0.idx for a0 in b_with] == [a1.idx for a1 in b_without]
Пример #33
0
def test_residue_map():
    ethane = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    ethane *= 2
    oplsaa = Forcefield(name='oplsaa')
    topo, NULL = generate_topology(ethane)
    topo_with = oplsaa.run_atomtyping(topo, use_residue_map=True)
    topo_without = oplsaa.run_atomtyping(topo, use_residue_map=False)
    assert all([a.id for a in topo_with.atoms()][0])
    assert all([a.id for a in topo_without.atoms()][0])
    struct_with = pmd.openmm.load_topology(topo_with, oplsaa.createSystem(topo_with))
    struct_without = pmd.openmm.load_topology(topo_without, oplsaa.createSystem(topo_without))
    for atom_with, atom_without in zip(struct_with.atoms, struct_without.atoms):
        assert atom_with.type == atom_without.type
        b_with = atom_with.bond_partners
        b_without = atom_without.bond_partners
        assert [a0.type for a0 in b_with] == [a1.type for a1 in b_without]
        assert [a0.idx for a0 in b_with] == [a1.idx for a1 in b_without]
Пример #34
0
def test_cycle_finding_multiple():
    fullerene = pmd.load_file(get_fn('fullerene.pdb'), structure=True)
    top, _ = generate_topology(fullerene)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    _prepare_atoms(top, typemap, compute_cycles=True)
    #cycle_lengths = [list(map(len, atom.cycles)) for atom in top.atoms()]
    cycle_lengths = [
        list(map(len, typemap[atom.index]['cycles'])) for atom in top.atoms()
    ]
    expected = [5, 6, 6]
    assert all(sorted(lengths) == expected for lengths in cycle_lengths)
Пример #35
0
def test_residue_map():
    ethane = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    ethane *= 2
    oplsaa = Forcefield(name='oplsaa')
    topo, NULL = generate_topology(ethane)
    topo_with = oplsaa.run_atomtyping(topo, use_residue_map=True)
    topo_without = oplsaa.run_atomtyping(topo, use_residue_map=False)
    assert all([a.id for a in topo_with.atoms()][0])
    assert all([a.id for a in topo_without.atoms()][0])
    struct_with = pmd.openmm.load_topology(topo_with,
                                           oplsaa.createSystem(topo_with))
    struct_without = pmd.openmm.load_topology(
        topo_without, oplsaa.createSystem(topo_without))
    for atom_with, atom_without in zip(struct_with.atoms,
                                       struct_without.atoms):
        assert atom_with.type == atom_without.type
        b_with = atom_with.bond_partners
        b_without = atom_without.bond_partners
        assert [a0.type for a0 in b_with] == [a1.type for a1 in b_without]
        assert [a0.idx for a0 in b_with] == [a1.idx for a1 in b_without]
Пример #36
0
def test_precedence():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    checks = {
        '[C,O;C]': 2,
        '[C&O;C]': 0,
        '[!C;O,C]': 0,
        '[!C&O,C]': 2,
    }

    for smart, result in checks.items():
        _rule_match_count(top, typemap, smart, result)
Пример #37
0
def test_not():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    checks = {
        '[!O]': 8,
        '[!#5]': 8,
        '[!C]': 6,
        '[!#6]': 6,
        '[!C&!H]': 0,
        '[!C;!H]': 0,
    }
    for smart, result in checks.items():
        _rule_match_count(top, typemap, smart, result)
Пример #38
0
def test_fused_ring():
    fused = pmd.load_file(get_fn('fused.mol2'), structure=True)
    top, _ = generate_topology(fused)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    rule = SMARTSGraph(
        name='test',
        parser=PARSER,
        smarts_string='[#6]12[#6][#6][#6][#6][#6]1[#6][#6][#6][#6]2',
        typemap=typemap)

    match_indices = list(rule.find_matches(top, typemap))
    assert 3 in match_indices
    assert 4 in match_indices
    assert len(match_indices) == 2
Пример #39
0
def test_lazy_cycle_finding():
    mol2 = pmd.load_file(get_fn('ethane.mol2'), structure=True)
    top, _ = generate_topology(mol2)
    typemap = {
        atom.index: {
            'whitelist': set(),
            'blacklist': set(),
            'atomtype': None
        }
        for atom in top.atoms()
    }

    rule = SMARTSGraph(smarts_string='[C]', typemap=typemap)
    list(rule.find_matches(top, typemap))
    #assert not any([hasattr(a, 'cycles') for a in top.atoms()])
    assert not any(['cycles' in typemap[a.index] for a in top.atoms()])

    ring_tokens = ['R1', 'r6']
    for token in ring_tokens:
        rule = SMARTSGraph(smarts_string='[C;{}]'.format(token),
                           typemap=typemap)
        list(rule.find_matches(top, typemap))
        #assert all([hasattr(a, 'cycles') for a in top.atoms()])
        assert all(['cycles' in typemap[a.index] for a in top.atoms()])
Пример #40
0
ethane = oplsaa.apply(untyped_ethane)

print("Atoms:")
for atom in ethane.atoms:
    print('Atom {} is typed as {}'.format(atom, atom.type))

print("Bonds:")
for bond in ethane.bonds:
    print('{} '.format(bond))

print("Angles:")
for angle in ethane.angles:
    print('{} '.format(angle))

print("Dihedrals:")
for dihedral in ethane.dihedrals:
    print('{} '.format(dihedral))

# Save to GROMACS
ethane.save('ethane.gro')
ethane.save('ethane.top')

# Within the `Forcefield.apply` method, an intermediate OpenMM system is
# created. If you wish to use OpenMM, e.g. for use of potential forms not
# yet supported by ParmEd, you can simply stop the conversion process
# after the OpenMM System creation by directly invoking the internal
# method calls:
from foyer.forcefield import generate_topology
omm_topology = generate_topology(untyped_ethane)
omm_system = oplsaa.createSystem(topology=omm_topology)
Пример #41
0
for atom in ethane.atoms:
    print('Atom {} is typed as {}'.format(atom, atom.type))

print("Bonds:")
for bond in ethane.bonds:
    print('{} '.format(bond))

print("Angles:")
for angle in ethane.angles:
    print('{} '.format(angle))

print("Dihedrals:")
for dihedral in ethane.dihedrals:
    print('{} '.format(dihedral))

# Save to GROMACS
ethane.save('ethane.gro')
ethane.save('ethane.top')


# Within the `Forcefield.apply` method, an intermediate OpenMM system is
# created. If you wish to use OpenMM, e.g. for use of potential forms not
# yet supported by ParmEd, you can simply stop the conversion process
# after the OpenMM System creation by directly invoking the internal
# method calls:
from foyer.forcefield import generate_topology
omm_topology = generate_topology(untyped_ethane)
omm_system = oplsaa.createSystem(topology=omm_topology)


Пример #42
0
    ethane = oplsaa.apply(untyped_ethane, references_file='ethane.bib')

    print("Atoms:")
    for atom in ethane.atoms:
        print('Atom {} is typed as {}'.format(atom, atom.type))

    print("Bonds:")
    for bond in ethane.bonds:
        print('{} '.format(bond))

    print("Angles:")
    for angle in ethane.angles:
        print('{} '.format(angle))

    print("Dihedrals:")
    for dihedral in ethane.dihedrals:
        print('{} '.format(dihedral))

    # Save to GROMACS
    ethane.save('ethane.gro')
    ethane.save('ethane.top')

    # Within the `Forcefield.apply` method, an intermediate OpenMM system is
    # created. If you wish to use OpenMM, e.g. for use of potential forms not
    # yet supported by ParmEd, you can simply stop the conversion process
    # after the OpenMM System creation by directly invoking the internal
    # method calls:
    from foyer.forcefield import generate_topology
    omm_topology, positions = generate_topology(untyped_ethane)
    omm_system = oplsaa.createSystem(topology=omm_topology)