get smallest set of smallest ring BONDS

User 568550d85a

16-09-2008 16:12:46

It would be nice to be able to get an int[][] containing the smallest set of smallest ring bond indices (not the atom indices). I don't know if it already exsits, please tell me if so. If not here is a proposal:





lorenz





Code:



import chemaxon.struc.Molecule;


import chemaxon.util.MolHandler;





public class SSSRB {





   public static void main(String[] args) throws Exception {


      int[][] sssrb = new SSSRB().getSSSRBonds(new MolHandler("C12CC=C1CCOC2CCC").getMolecule());


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


       for (int j = 0; j < sssrb[i].length; j++) {


          System.out.println("Ring "+i+" Bond "+sssrb[i][j]);


       }


    }


   }





   public int[][] getSSSRBonds(Molecule m) {


      int[][] sssr = m.getSSSR();


      int[][] btab = m.getBtab();


      int[][] sssrb = new int[sssr.length][0];


      //Loop through rings


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


         //bonds will contain bonds of ring i


         int[] bonds = new int[0];


         for (int j = 0; j < sssr[i].length; j++) {


            for (int k = j+1; k < sssr[i].length; k++) {


               //if atom j and k (of ring i) are connected then add bond to bonds


               int bond = btab[sssr[i][j]][sssr[i][k]];


               if(bond!=-1) {


                  bonds = addInt(bonds, bond);


               }


            }


         }


         sssrb[i] = bonds;


      }


      return sssrb;


   }


   


   private int[] addInt(int[] arr, int i) {


      int[] temp = arr;


      int size = temp.length;


      arr = new int[size+1];


      System.arraycopy(temp, 0, arr, 0, size);


      arr[size] = i;


      return arr;


   }


}





ChemAxon 25dcd765a3

18-09-2008 08:39:48

Hi,





We can create such function.


I'll write if it is ready.


(I guess for the next release - Marvin 5.1.2 - it is going to be ready.)

ChemAxon 25dcd765a3

29-09-2008 08:34:43

Hi,





The function is ready:


Code:
public final int[][] getSSSREdges()






Andras

User 568550d85a

29-09-2008 09:05:56

volfi wrote:
Hi,





The function is ready:


Code:
public final int[][] getSSSREdges()






Andras
thanks!