@@ -1182,31 +1182,41 @@ private void calcGroup056_57(int i) {
11821182 // carboxyl= HO-C(=O)-
11831183
11841184 if (!fragment [i ].equals ("SsOH" )) return ;
1185- List < IAtom > nbor = atomContainer .getConnectedAtomsList ( atomContainer . getAtom (i ) );
1185+ IAtom atm = atomContainer .getAtom (i );
11861186 int htype = 50 ; //H atom attached to a hetero atom
11871187 frags [htype ]++;
11881188
1189- IAtom ca0 = (IAtom ) nbor .get (0 );
1190- if (ca0 .getAtomicNumber () == 1 ) {
1191- ca0 = (IAtom ) nbor .get (1 );
1192- alogpfrag [atomContainer .indexOf (nbor .get (0 ))] = htype ;
1193- } else
1194- alogpfrag [atomContainer .indexOf (nbor .get (1 ))] = htype ;
1189+ IAtom ca0 = null ;
1190+ for (IBond bond : atm .bonds ()) {
1191+ IAtom nbor = bond .getOther (atm );
1192+ if (nbor .getAtomicNumber () == 6 )
1193+ ca0 = nbor ;
1194+ else if (nbor .getAtomicNumber () == 1 )
1195+ alogpfrag [nbor .getIndex ()] = htype ;
1196+ }
1197+
11951198
1199+ if (ca0 != null ) {
11961200 if (ca0 .isAromatic ()) { // phenol
11971201 frags [57 ]++;
11981202 alogpfrag [i ] = 57 ;
11991203 return ;
12001204 }
12011205
1202- List ca2 = atomContainer .getConnectedAtomsList (ca0 );
1203- for (int j = 0 ; j <= ca2 .size () - 1 ; j ++) {
1204- if (atomContainer .getBond ((IAtom ) ca2 .get (j ), ca0 ).getOrder () == IBond .Order .DOUBLE ) {
1206+ // Check for C=COH, and C(OH)=O
1207+ for (IBond bond : ca0 .bonds ()) {
1208+ IAtom nbor2 = bond .getOther (ca0 );
1209+ if (nbor2 == atm )
1210+ continue ;
1211+ if (bond .getOrder () == IBond .Order .DOUBLE &&
1212+ (nbor2 .getAtomicNumber () == 6 || nbor2 .getAtomicNumber () == 8 )) {
12051213 frags [57 ]++;
12061214 alogpfrag [i ] = 57 ;
12071215 return ;
12081216 }
12091217 }
1218+ }
1219+
12101220 frags [56 ]++;
12111221 alogpfrag [i ] = 56 ;
12121222 }
0 commit comments