First, the whole molecule should be built using the Core API methods, or imported. In this example, we import it from SMILES format. Then the SuperatomSgroup is constructed with the molecule in the argument of the its constructor.
Molecule mol = MolImporter.importMol("C1=CC=CC=C1C"); Cleaner.clean(mol, 2, null); // Create the Sgroups. SuperatomSgroup superSg = new SuperatomSgroup(mol);
The atoms that are supposed to be a part of an S-group should be added to it (that is, set the S-group as the parent of the MolAtom). In our example, we add the carbon atoms of the benzene ring to the S-group, they are the first six atoms of the molecule.
for (int i = 0; i < 6; i++) { mol.setSgroupParent(mol.getAtom(i), superSg, true); }In the argument of the
Molecule.setSgroupParent()
method,
MolAtom
represents the atom to be added to the
Superatom S-group superSg
. If the boolean is true, the
atom will be added to the S-group, otherwise it will be removed from there.
In order to set subscript of a Superatom S-group, use the
SuperatomSgroup.setSubscript(String)
method:
superSg.setSubscript("Ph");
MolAtom.setAttach(int a);method. The integer
int a
defines the type of the attachment point:
MolAtom.NONE
, MolAtom.Attach1
, MolAtom.Attach2
, MolAtom.BOTH
. Attachments points are put to atoms in the S-group that have bond which other end atom is outside the group. That kind of bond is called crossing bond. Currently only two attachment points are possible on each Superatom S-group:
MolAtom.ATTACH1
and
MolAtom.ATTACH2
on two different atoms MolAtom.BOTH
both attachment points are on the same atom:
MolAtom.BOTH
The method SuperatomSgroup.calculateAttachmentPoints();
calculates the attachment points for the atoms having crossing bonds.
superSg.calculateAttachmentPoints();
Sgroup.XSTATE_XC
where the
S-group remembers its previous contracted
state but the represented atoms were moved to the molecule graph
and the abbreviation (SgroupAtom) was removed from the molecule
graph. Set this state on all Sgroups by calling
Molecule.setGUIContracted(false)
or by calling
Sgroup.setGUIStateRecursively(false)
individually on Sgroup-s.
Example for a typical usage is a non-GUI related API
based calculation where we need the represented atoms in the
molecule graph instead of the abbreviation.
Sgroup.XSTATE_X
)
the represented atoms are present in the parent molecule.
In the case of contracted S-groups (called Sgroup.XSTATE_C
)
the abbreviation (SgroupAtom) is present in the parent
molecule. Set this state on all Sgroups by calling
Molecule.setGUIContracted(true)
or by calling
Sgroup.setGUIStateRecursively(true)
individually on Sgroup-s.
Molecule.isGUIContracted()
returns true and afterwards you call:
Molecule.setGUIContracted(false);
Molecule.setGUIContracted(true);
the second setGUIContracted
call will restore the state before
the first setGUIContracted
call!
Repeating unit S-groups are used to represent polymers and other repeating units.
In order to construct a repeating unit S-group object, use its constructor as
RepeatingUnitSgroup repeatingSg = new RepeatingUnitSgroup(Molecule mol, String connectivity, int type);
The parameter Molecule
object will be the parent of the S-group
repeatingSg
.
The String connectivity defines way the units connects to each other: "ht", for
head-to-tail; "hh", for head-to-head, and "eu" for either/undefined polymers.
The type of the S-group can be defined using the following constants:
Sgroup.ST_ANY
,Sgroup.ST_SRU
,Sgroup.ST_COPOLYMER
,Sgroup.ST_CROSSLINK
,Sgroup.ST_GRAFT
,Sgroup.ST_MODIFICATION
.Atoms and bonds can be added to a repeating unit S-group in a same way as to a Superatom S-group.
The bracket of this type of S-groups defines the repeating fragment of the polymer. Bonds that cross the brackets, called crossing bonds, define how the repeating units of the S-group connect.
The generateBracketCoord
method of the
CleanUtil
class generates brackets. As parameter the S-group
and the bracket type, square or round, should be added:
CleanUtil.generateBracketCoords(repeatingSg, MBracket.T_SQUARE);
The end groups of polymers are often unknown or unspecified which are represented by star atoms (*). Star atoms are defined with the
repeatingSg.addStarAtoms();method.
Full example of building of polystyrene can be found at the Code examples.
Previous chapter |
Next chapter |