Make selection

User be40d3c52d

11-10-2004 09:37:36

hello,





I would like to know java code to select some part of the molecule and get the smiles of only the selected part.





can u please say me which method in marvin sketch make the selection of some part of the molecule.





ok then waitng for the reply


varsha

ChemAxon 7c2d26e5cf

11-10-2004 13:11:10

Code:



        MSketchPane sketchPane; // the sketcher


        int[] index; // array of the required atoms


        ...


        Molecule m = sketchPane.getMol();


        // select required atoms


        for(int i=0;i<index.length;i++) {


            if(m.getAtomCount() > index[i]) {


                MolAtom atom = m.getAtom(index[i]);


                atom.setSelected(true);


            }


        }


        // update molecule in the sketcher


        sketchPane.setMol(m);


        // get selection


        Molecule msel = sketchPane.getSelection();


        if(msel != null && !msel.isEmpty()) {


            System.err.println("smiles:"+msel.toFormat("smiles"));


        }