private void combineHydrogenPositions ( List < Integer > taken , List < List < Integer > > combinations , IAtomContainer skeleton , int totalMobHydrCount , List < Integer > mobHydrAttachPositions ) { if ( taken . size ( ) != totalMobHydrCount ) { for ( int i = 0 ; i < mobHydrAttachPositions . size ( ) ; i ++ ) { int pos = mobHydrAttachPositions . get ( i ) ; IAtom atom = findAtomByPosition ( skeleton , pos ) ; int conn = getConnectivity ( atom , skeleton ) ; int hCnt = 0 ; for ( int t : taken ) if ( t == pos ) hCnt ++ ; if ( atom . getValency ( ) - atom . getFormalCharge ( ) > ( hCnt + conn ) ) { taken . add ( pos ) ; combineHydrogenPositions ( taken , combinations , skeleton , totalMobHydrCount , mobHydrAttachPositions ) ; taken . remove ( taken . size ( ) - 1 ) ; } } } else { List < Integer > addList = new ArrayList < Integer > ( taken . size ( ) ) ; addList . addAll ( taken ) ; Collections . sort ( addList ) ; if ( ! combinations . contains ( addList ) ) { combinations . add ( addList ) ; } } }
Makes combinations recursively of all possible mobile Hydrogen positions .