File: MolecularSystemAdapter.py

package info (click to toggle)
mgltools-pyautodock 1.5.7-3
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye, buster, sid
  • size: 45,148 kB
  • sloc: python: 4,540; sh: 78; makefile: 13
file content (83 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
# $Id: MolecularSystemAdapter.py,v 1.5 2010/05/28 19:00:04 annao Exp $
#

"""
usage:
    adapter = Adapter[str(entity_set.__class__)](entity_set)
"""


class MolecularSystemAdapter:
    """abstract base class
    """
    def __init__(self):
        pass

    def get_iterator(self):
        pass
# MolecularSystemAdapter



class AtomSetAdapter(MolecularSystemAdapter):
    def __init__(self, atom_set):
        from MolKit.molecule import AtomSet
        assert( isinstance(atom_set, AtomSet))
        self.atom_set = atom_set
        MolecularSystemAdapter.__init__(self)

    def get_iterator(self):
        return self.atom_set

# AtomSetAdapter



class ResidueSetAdapter(MolecularSystemAdapter):
    def __init__(self, residue_set):
        from MolKit.protein import ResidueSet
        assert( isinstance(residue_set, ResidueSet))
        self.residue_set = residue_set
        MolecularSystemAdapter.__init__(self)

    def get_iterator(self):
        return self.residue_set

# ResidueSetAdapter



class GridMapAdapter(MolecularSystemAdapter):
    def __init__(self, grid_map):
        from AutoGrid import GridMap
        assert( isinstance(grid_map, GridMap))
        self.grid_map = grid_map
        MolecularSystemAdapter.__init__(self)

    def get_iterator(self):
        return self.grid_map.get_entity_list()

# GridMapAdapter

from MolKit.molecule import AtomSet
from MolKit.protein import ResidueSet

Adapters = {
    # class string : Adapter class
    str(AtomSet):AtomSetAdapter,
    'AutoDockSuite.AutoDockPy.AutoGrid.GridMap' : GridMapAdapter,
    'AutoDockPy.AutoGrid.GridMap' : GridMapAdapter,
    'PyAutoDock.AutoGrid.GridMap' : GridMapAdapter,
    str(ResidueSet) : ResidueSetAdapter,
    }

## Adapters = {
##     # class string : Adapter class
##     'MolKit.molecule.AtomSet': AtomSetAdapter,
##     'AutoDockSuite.AutoDockPy.AutoGrid.GridMap' : GridMapAdapter,
##     'AutoDockPy.AutoGrid.GridMap' : GridMapAdapter,
##     'PyAutoDock.AutoGrid.GridMap' : GridMapAdapter,
##     'MolKit.protein.ResidueSet' : ResidueSetAdapter,
##     }