// ############################## START FUNC ############################################ // This function calculates ring centra function calculate_ring_centra(saml, x, y, z, atom_sorts, d_b_atoms, t_b_atoms, d_conn) { var au=saml.split("#"); var tupp = new Array(0); // xp, yp, and zp will work as sums of all participating atoms x, y, z in each ring // The sums is then devided by the number of participating atoms and put in centra[n][x-z] var xp=0; var yp=0; var zp=0; var n=0; var m=0; var saml=""; var i=""; var opp=0; var size=0; var aromatic=""; var pi_electrons_counter=0; var aromatic_atoms = ""; for(n=0;n-1 || d_conn[i].indexOf("o")>-1)){ opp=parseInt(d_conn[i].substring(2,d_conn[i].length)); // A doublebonded carbon must not have its double bond connected to a neighbour outside the ring if(au[n].indexOf(" "+opp+" ")==-1) pi_electrons_counter=1.983742411; } } if((atom_sorts[i]==7 || atom_sorts[i]==8 || atom_sorts[i]==16) && !d_b_atoms.Check(i)) pi_electrons_counter=pi_electrons_counter+2; // ex: pyrrol if(atom_sorts[i]==8) pi_electrons_counter=pi_electrons_counter+2; // Just to destroy every possibility to get aromaticity out if(atom_sorts[i]==6 && (!d_b_atoms.Check(i) && !t_b_atoms.Check(i))) pi_electrons_counter=1.983742411; } xp=parseInt(xp/tupp.length*1000)/1000; yp=parseInt(yp/tupp.length*1000)/1000; zp=parseInt(zp/tupp.length*1000)/1000; aromatic=""; if((pi_electrons_counter-2)/4==parseInt((pi_electrons_counter-2)/4)) aromatic="aromatic_"; if(pi_electrons_counter/4==parseInt(pi_electrons_counter/4)) aromatic="anti-aromatic_"; // The row below is for cyclodecapentadene and similar molecules. To set the double bonds it is // necessary to measure the bond lengths and then this solution is probably better anyway. if(aromatic=="aromatic_" && (size==10 || size==9)) aromatic="conjugated_"; if(aromatic=="aromatic_") aromatic_atoms=aromatic_atoms+"#"+au[n]; if(size>13) size=big; saml=saml+" "+aromatic+size+"-ring "+xp+" "+yp+" "+zp+"#"; } saml=saml.substring(0, saml.length-1); if(aromatic_atoms!="") saml=saml+"?"+aromatic_atoms; return saml; } // ############################### end func ############################################