@@ -680,51 +680,42 @@ private void calcGroup017_019_020_038_to_041(int i) {
680680 return ;
681681 }
682682
683- List ca = atomContainer .getConnectedAtomsList (ai );
683+ List < IAtom > ca = atomContainer .getConnectedAtomsList (ai );
684684
685685 int rCount = 0 ;
686686 int xCount = 0 ;
687687 boolean haveCdX = false ;
688688 int aromaticCount = 0 ;
689689
690- for (int j = 0 ; j <= ca .size () - 1 ; j ++) {
691- if (atomContainer .getBond (ai , ((IAtom ) ca .get (j ))).getOrder () == IBond .Order .SINGLE ) {
692- if (((IAtom ) ca .get (j )).getSymbol ().equals ("C" )) {
690+ for (IBond bond : ai .bonds ()) {
691+ IAtom nbor = bond .getOther (ai );
692+ if (bond .getOrder () == IBond .Order .SINGLE ) {
693+ if (nbor .getAtomicNumber () == 6 ) {
693694 rCount ++;
695+ if (nbor .isAromatic ())
696+ aromaticCount ++;
694697 }
695- else {
698+ else
696699 xCount ++;
697- }
698-
699- if (((IAtom ) ca .get (j )).getFlag (CDKConstants .ISAROMATIC )) {
700- aromaticCount ++;
701- }
702-
703700 }
704- else if (atomContainer . getBond ( ai , (( IAtom ) ca . get ( j ))) .getOrder () == IBond .Order .DOUBLE ) {
705- if (!(( IAtom ) ca . get ( j )). getSymbol (). equals ( "C" )) {
701+ else if (bond .getOrder () == IBond .Order .DOUBLE ) {
702+ if (isHetero ( nbor )) {
706703 haveCdX = true ;
707704 }
708705 }
709706 }
710707
711708 if (haveCdX ) {
712- if (aromaticCount >= 1 ) { // Ar-C(=X)-R
713- for (IBond bond : ai .bonds ()) {
714- if (bond .getOrder () != IBond .Order .SINGLE )
715- continue ;
716- IAtom nbor = bond .getOther (ai );
717- if (!nbor .isAromatic ()) {
718- if (isHetero (nbor )) {
719- frags [40 ]++;
720- alogpfrag [i ] = 40 ;
721- } else {
722- frags [39 ]++;
723- alogpfrag [i ] = 39 ;
724- }
725- }
709+ if (aromaticCount >= 1 ) {
710+ // Ar-C(=X)-R 39
711+ // Ar-C(=X)-X 40
712+ if (xCount == 1 ) {
713+ frags [40 ]++;
714+ alogpfrag [i ] = 40 ;
715+ } else {
716+ frags [39 ]++;
717+ alogpfrag [i ] = 39 ;
726718 }
727-
728719 }
729720 else if (aromaticCount == 0 ) {
730721 if (rCount == 1 && xCount == 1 ) {
@@ -739,9 +730,7 @@ else if (rCount == 0 && xCount == 2) {
739730 frags [38 ]++;
740731 alogpfrag [i ] = 38 ;
741732 }
742-
743733 }
744-
745734 }
746735 else {
747736 if (rCount == 2 && xCount == 0 ) {
0 commit comments