private List < Integer > tryDoubleBondCombinations ( IAtomContainer container , int dblBondsAdded , int bondOffSet , int doubleBondMax , List < IAtom > atomsInNeedOfFix ) { int offSet = bondOffSet ; List < Integer > dblBondPositions = null ; while ( offSet < container . getBondCount ( ) && dblBondPositions == null ) { IBond bond = container . getBond ( offSet ) ; if ( atomsInNeedOfFix . contains ( bond . getBegin ( ) ) && atomsInNeedOfFix . contains ( bond . getEnd ( ) ) ) { bond . setOrder ( IBond . Order . DOUBLE ) ; dblBondsAdded = dblBondsAdded + 1 ; if ( dblBondsAdded == doubleBondMax ) { boolean validDoubleBondConfig = true ; CHECK : for ( IAtom atom : container . atoms ( ) ) { if ( atom . getValency ( ) != atom . getImplicitHydrogenCount ( ) + getConnectivity ( atom , container ) ) { validDoubleBondConfig = false ; break CHECK ; } } if ( validDoubleBondConfig ) { dblBondPositions = new ArrayList < Integer > ( ) ; for ( int idx = 0 ; idx < container . getBondCount ( ) ; idx ++ ) { if ( container . getBond ( idx ) . getOrder ( ) . equals ( IBond . Order . DOUBLE ) ) dblBondPositions . add ( idx ) ; } return dblBondPositions ; } } else { dblBondPositions = tryDoubleBondCombinations ( container , dblBondsAdded , offSet + 1 , doubleBondMax , atomsInNeedOfFix ) ; } bond . setOrder ( IBond . Order . SINGLE ) ; dblBondsAdded = dblBondsAdded - 1 ; } offSet ++ ; } return dblBondPositions ; }
Tries double bond combinations for a certain input container of which the double bonds have been stripped around the mobile hydrogen positions . Recursively .