-
Notifications
You must be signed in to change notification settings - Fork 32
CreateASimpleMolecule
dstoeckel edited this page Mar 16, 2015
·
2 revisions
Create a molecule with two atoms and a connecting bond:
#include<BALL/KERNEL/molecule.h>
#include<BALL/KERNEL/atom.h>
#include<BALL/KERNEL/bond.h>
...
BALL::Molecule m;
BALL::Atom A;
BALL::Atom C;
// create a connecting bond
BALL::Bond* b = A.createBond(C);
// now insert all atoms into the molecule m
m.insert(A);
m.insert(C);
Note that it is not necessary to add the bond to the molecule! Note: there is a difference between class Atom and PDBAtom!
import sys
from BALL import *
m = Molecule()
A = Atom()
C = Atom()
# create elements (group, period, atomicNumber etc. are set automatically)
hydrogen = PTE["H"]
oxygen = PTE["O"]
A.setElement(hydrogen)
C.setElement(oxygen)
A.setPosition(Vector3(1.4, 0, 0))
C.setPosition(Vector3(0, 0, 0))
B = Atom(A)
B.setPosition(Vector3(0, 1.4, 0))
# create connecting bonds, constructing a water molecule
bond1 = A.createBond(C)
bond2 = B.createBond(C)
# now insert all atoms into the molecule m
m.insert(A)
m.insert(B)
m.insert(C)
print "Number of atoms in the molecule: ", m.countAtoms()
print "Group of hydrogen: ", hydrogen.getGroup(), ", ...and oxygen: ", oxygen.getGroup()
print "Period of atom A (hydrogen): ", A.getElement().getPeriod(), ", ... and atom C (oxygen): ", C.getElement().getPeriod()
print "Atomic number of A: ", A.getElement().getAtomicNumber(), ", ... and atom C: ", C.getElement().getAtomicNumber()
Note that it is not necessary to add the bond to the molecule!
Note that getGroup gives the number according to the group numbering including the subgroups!