16
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
b'\\ No newline at end of file'
20
"""class to store info about an atom"""
21
def __init__(self, id=0, symbol="", pos=[0,0,0]):
27
" class to store info about a bond """
28
def __init__(self, id=0, atom_id_1=0, atom_id_2=0):
30
self.atom_id_1 = atom_id_1
31
self.atom_id_2 = atom_id_2
33
class Molecule(object):
34
""" class to store info about a molecule"""
35
def __init__(self, id=0, name="", atoms={}, bonds={}):
41
if __name__ == '__main__':
42
# code to test the atom, bond and molecule classes
44
# create a molecule and give it some data
45
m = Molecule(id=1, name="Water")
47
# add 3 atoms to the molecule
48
m.atoms[1] = Atom(id=1, symbol="O", pos=[1,2,3])
49
m.atoms[2] = Atom(id=2, symbol="H", pos=[4,2,3])
50
m.atoms[3] = Atom(id=3, symbol="H", pos=[1,5,6])
53
m.bonds[1] = Bond(id=1, atom_id_1=1, atom_id_2=2)
54
m.bonds[2] = Bond(id=2, atom_id_1=1, atom_id_2=3)
56
# retrive the molecule data
57
print "Molecule name is: %s" % m.name
59
for key in m.atoms.keys():
60
print "Atom #%s is %s" % (key, m.atoms[key].symbol)
62
for key in m.bonds.keys():
63
print "Bond #%s is bounded to atom %s and atom %s" % (key, m.bonds[key].atom_id_1, m.bonds[key].atom_id_2)
b'\\ No newline at end of file'