/** * Method to check whether a given bond exists in the root and is attached * to an R-Group. * @param bond */ public boolean isRGroupRootBond(IBond bond) { if (rGroupQuery!=null && rGroupQuery.getRootStructure()!=null && rGroupQuery.getRootStructure().contains(bond)) { for(IAtom atom : bond.atoms()) { if (atom instanceof IPseudoAtom && RGroupQuery.isValidRgroupQueryLabel(((IPseudoAtom)atom).getLabel())) { return true; } } } return false; }
root.put(0,rGroupQuery.getRootStructure().hashCode()); rgrpHash.put(-1,root );
rgrpQ.getRootStructure().setProperty(CDKConstants.TITLE,RGroup.ROOT_LABEL); rgrpQ.setRootAttachmentPoints(redoRootAttachmentPoints);
this.existingBondDistr=_existingBondDistr; this.existingRgroupLists=_existingRgroupLists; this.redoRootStructure=rgrpHandler.getrGroupQuery().getRootStructure(); this.userSelection=(IAtomContainer)_userSelection; if (_existingRgroupLists!=null) {
/** * Verifies if a merge is allowed from the R-Group's point of view. * Merging between the root structure and r-group substitutes is not allowed, * because it does not makes sense (plus the root structure could get lost). * @param hub controller hub that is about to do a merge. */ public boolean isMergeAllowed(IChemModelRelay hub) { //System.out.println("^^^ isMergeAllowed(IChemModelRelay hub)"); if (rGroupQuery!=null) { for (Iterator<IAtom> it = hub.getRenderer().getRenderer2DModel().getMerge().keySet().iterator(); it.hasNext();) { IAtom mergedAtom = it.next(); IAtom mergedPartnerAtom = hub.getRenderer().getRenderer2DModel().getMerge().get(mergedAtom); IAtomContainer container1 = ChemModelManipulator.getRelevantAtomContainer(hub.getChemModel(), mergedAtom); IAtomContainer container2 = ChemModelManipulator.getRelevantAtomContainer(hub.getChemModel(), mergedPartnerAtom); if(container1!=container2) { List<IAtomContainer> substitutes = rGroupQuery.getSubstituents(); if ((container1==rGroupQuery.getRootStructure() && substitutes.contains(container2)) || (container2==rGroupQuery.getRootStructure() && substitutes.contains(container1))) { JOptionPane.showMessageDialog(jcpPanel.getRenderPanel(), GT.get("This operation is not allowed in the R-Group configuration."), GT.get("R-Group alert"), JOptionPane.INFORMATION_MESSAGE); return false; } } } } return true; }
/** * Creates a {@link org.openscience.cdk.interfaces.IAtomContainerSet} from a * provided {@link org.openscience.cdk.isomorphism.matchers.IRGroupQuery). * The root structure becomes the atom container as position zero, the * substitutes follow on position 1..n, ordered by R-group number. * * @param chemModel * @param RgroupQuery * @throws CDKException */ public IAtomContainerSet getMoleculeSet (IChemModel chemModel) throws CDKException { if (rGroupQuery==null || rGroupQuery.getRootStructure() == null || rGroupQuery.getRootStructure().getAtomCount()==0) throw new CDKException( "The R-group is empty"); IAtomContainerSet moleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class); moleculeSet.addAtomContainer(rGroupQuery.getRootStructure()); chemModel.setMoleculeSet(moleculeSet); for (int rgrpNum : sortRGroupNumbers()) { RGroupList rgrpList = rGroupQuery.getRGroupDefinitions().get(rgrpNum); for (RGroup rgrp : rgrpList.getRGroups()) { chemModel.getMoleculeSet().addAtomContainer(rgrp.getGroup()); } } return moleculeSet; }
rgrpQ.getRootStructure().setProperty(CDKConstants.TITLE, RGroup.ROOT_LABEL); for (Iterator<Integer> rnumItr= hub.getRGroupHandler().getrGroupQuery().getRGroupDefinitions().keySet().iterator(); rnumItr.hasNext();) { int rNum=rnumItr.next();
/** * Method to detect if removing atoms/bonds has unwanted results for * the R-group. * * @param atc * @param hub * @return */ public boolean checkRGroupOkayForDelete(IAtomContainer atc,IChemModelRelay hub ) { //Check if the root would still remain there (partly) after a delete.. if(rGroupQuery!=null) { boolean rootRemains=false; root: for(IAtom a : rGroupQuery.getRootStructure().atoms()) { if (!atc.contains(a)){ rootRemains=true; break root; } } if (!rootRemains) { int answer = JOptionPane.showConfirmDialog(jcpPanel.getRenderPanel(), GT.get("This operation would irreversibly remove the R-Group query. Continue?"), GT.get("R-Group alert"), JOptionPane.YES_NO_OPTION); if(answer == JOptionPane.NO_OPTION) return false; } } return true; }
IAtomContainer rootAtc = rGroupQuery.getRootStructure();
for (IAtom movedAtom : newAtc.atoms()) { if (rGroupQuery.getRootStructure().contains(movedAtom)) {
if (ac==rGroupQuery.getRootStructure()) {
if (rGroupQuery==null || rGroupQuery.getRootStructure() == null || rGroupQuery.getRootStructure().getAtomCount()==0) throw new CDKException( "The R-group is empty"); IAtomContainer rootStruct=rGroupQuery.getRootStructure(); double xLeft=(findBoundary(rootStruct,true,true,Double.POSITIVE_INFINITY)); double yBottom=(findBoundary(rootStruct,false,true,Double.POSITIVE_INFINITY))-MARGIN;
rGroupHandler=hub.getRGroupHandler(); rgrpQuery = hub.getRGroupHandler().getrGroupQuery(); if(rgrpQuery.getRootStructure()!=null) { existingRoot=rgrpQuery.getRootStructure(); rgrpQuery.getRootStructure().removeProperty(CDKConstants.TITLE); hub.getRGroupHandler().getrGroupQuery().getRootStructure()==null) { JOptionPane.showMessageDialog(jcpPanel, GT.get("Please define a root structure first.")); return; for (IAtom atom : hub.getRGroupHandler().getrGroupQuery().getRootStructure().atoms()) { if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom)atom; int bondCnt=0; int rNum=new Integer(pseudo.getLabel().substring(1)); for (IBond b : hub.getRGroupHandler().getrGroupQuery().getRootStructure().bonds()) if (b.contains(atom)) bondCnt++;