//Define new root apo's
Map<IAtom, Map<Integer, IBond>> apoBonds= new HashMap<IAtom, Map<Integer, IBond>>();
for (IAtom atom : molecule.atoms()) {
if (atom instanceof IPseudoAtom) {
IPseudoAtom pseudo = (IPseudoAtom)atom;
if (pseudo.getLabel()!=null && RGroupQuery.isValidRgroupQueryLabel(pseudo.getLabel())) {
chooseRootAttachmentBonds(pseudo,molecule,apoBonds);
}
}
}
rgrpQuery.setRootAttachmentPoints(apoBonds);
}
/* User action: certain atom+bond selection is to be a substituent. */
else if (type.equals("setSubstitute")) {
if (hub.getRGroupHandler() == null || hub.getRGroupHandler().getrGroupQuery()==null ||
hub.getRGroupHandler().getrGroupQuery().getRootStructure()==null) {
JOptionPane.showMessageDialog(jcpPanel, GT.get("Please define a root structure first."));
return;
}
IAtomContainer atc =selection.getConnectedAtomContainer();
if (!isProperSelection(atc)) {
JOptionPane.showMessageDialog(jcpPanel, GT.get("Please do not make a fragmented selection."));
return;
}
// Check - are there any R-groups -> collect them so that user input can be validated
Map<Integer,Integer> validRnumChoices=new HashMap<Integer,Integer>();
for (IAtom atom : hub.getRGroupHandler().getrGroupQuery().getRootStructure().atoms()) {
if (atom instanceof IPseudoAtom) {
IPseudoAtom pseudo = (IPseudoAtom)atom;
if (pseudo.getLabel()!=null && RGroupQuery.isValidRgroupQueryLabel(pseudo.getLabel())) {
int bondCnt=0;
int rNum=new Integer(pseudo.getLabel().substring(1));
for (IBond b : hub.getRGroupHandler().getrGroupQuery().getRootStructure().bonds())
if (b.contains(atom))
bondCnt++;
if ((!validRnumChoices.containsKey(rNum))||